update ec and sm2 kmeth

This commit is contained in:
Zhi Guan
2017-02-23 17:27:07 +08:00
parent 43ed716af9
commit 9ae79dee03
7 changed files with 211 additions and 91 deletions

View File

@@ -12,7 +12,9 @@
#include <openssl/engine.h>
#include <openssl/err.h>
#include "ec_lcl.h"
#ifndef OPENSSL_NO_SM2
# include "../ecies/ecies_lcl.h"
#endif
static const EC_KEY_METHOD openssl_ec_key_method = {
"OpenSSL EC_KEY method",
@@ -26,10 +28,10 @@ static const EC_KEY_METHOD openssl_ec_key_method = {
ossl_ecdsa_verify,
ossl_ecdsa_verify_sig,
#ifndef OPENSSL_NO_SM2
ossl_ecies_encrypt,
ossl_ecies_do_encrypt,
ossl_ecies_decrypt,
ossl_ecies_do_decrypt,
gmssl_ecies_encrypt,
gmssl_ecies_do_encrypt,
gmssl_ecies_decrypt,
gmssl_ecies_do_decrypt,
#endif
};
@@ -53,6 +55,18 @@ void EC_KEY_set_default_method(const EC_KEY_METHOD *meth)
default_ec_key_meth = meth;
}
#ifndef OPENSSL_NO_SM2
void EC_KEY_set_default_secg_method(void)
{
default_ec_key_meth = EC_KEY_OpenSSL();
}
void EC_KEY_set_default_sm_method(void)
{
default_ec_key_meth = EC_KEY_GmSSL();
}
#endif
const EC_KEY_METHOD *EC_KEY_get_method(const EC_KEY *key)
{
return key->meth;

View File

@@ -624,14 +624,3 @@ int X25519(uint8_t out_shared_key[32], const uint8_t private_key[32],
const uint8_t peer_public_value[32]);
void X25519_public_from_private(uint8_t out_public_value[32],
const uint8_t private_key[32]);
#ifndef OPENSSL_NO_SM2
int ossl_ecies_encrypt(int type, const unsigned char *in, size_t inlen,
unsigned char *out, size_t *outlen, EC_KEY *ec_key);
ECIES_CIPHERTEXT_VALUE *ossl_ecies_do_encrypt(int type, const unsigned char *in,
size_t inlen, EC_KEY *ec_key);
int ossl_ecies_decrypt(int type, const unsigned char *in, size_t inlen,
unsigned char *out, size_t *outlen, EC_KEY *ec_key);
int ossl_ecies_do_decrypt(int type, const ECIES_CIPHERTEXT_VALUE *in,
unsigned char *out, size_t *outlen, EC_KEY *ec_key);
#endif