mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-08-08 23:13:38 +08:00
add encrypt/decrypt to ec_key_method
This commit is contained in:
@@ -323,9 +323,50 @@ void EC_KEY_METHOD_get_verify(EC_KEY_METHOD *meth,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_SM2
|
#ifndef OPENSSL_NO_SM2
|
||||||
|
void EC_KEY_METHOD_set_encrypt(EC_KEY_METHOD *meth,
|
||||||
|
int (*encrypt)(int type,
|
||||||
|
const unsigned char *in,
|
||||||
|
size_t inlen,
|
||||||
|
unsigned char *out,
|
||||||
|
size_t *outlen,
|
||||||
|
EC_KEY *ec_key),
|
||||||
|
ECIES_CIPHERTEXT_VALUE *(*do_encrypt)(int type,
|
||||||
|
const unsigned char *in,
|
||||||
|
size_t inlen,
|
||||||
|
EC_KEY *ec_key))
|
||||||
|
{
|
||||||
|
meth->encrypt = encrypt;
|
||||||
|
meth->do_encrypt = do_encrypt;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EC_KEY_METHOD_get_decrypt(EC_KEY_METHOD *meth,
|
||||||
|
int (*decrypt)(int type,
|
||||||
|
const unsigned char *in,
|
||||||
|
size_t inlen,
|
||||||
|
unsigned char *out,
|
||||||
|
size_t *outlen,
|
||||||
|
EC_KEY *ec_key),
|
||||||
|
int (do_decrypt)(int type,
|
||||||
|
const ECIES_CIPHERTEXT_VALUE *in,
|
||||||
|
unsigned char *out,
|
||||||
|
size_t *outlen,
|
||||||
|
EC_KEY *ec_key))
|
||||||
|
{
|
||||||
|
meth->decrypt = decrypt;
|
||||||
|
meth->do_decrypt = do_decrypt;
|
||||||
|
}
|
||||||
|
|
||||||
void EC_KEY_METHOD_get_encrypt(EC_KEY_METHOD *meth,
|
void EC_KEY_METHOD_get_encrypt(EC_KEY_METHOD *meth,
|
||||||
int (**pencrypt)(int a),
|
int (**pencrypt)(int type,
|
||||||
int (**pdo_encrypt)(int a))
|
const unsigned char *in,
|
||||||
|
size_t inlen,
|
||||||
|
unsigned char *out,
|
||||||
|
size_t *outlen,
|
||||||
|
EC_KEY *ec_key),
|
||||||
|
ECIES_CIPHERTEXT_VALUE *(**pdo_encrypt)(int type,
|
||||||
|
const unsigned char *in,
|
||||||
|
size_t inlen,
|
||||||
|
EC_KEY *ec_key))
|
||||||
{
|
{
|
||||||
if (pencrypt != NULL)
|
if (pencrypt != NULL)
|
||||||
*pencrypt = meth->encrypt;
|
*pencrypt = meth->encrypt;
|
||||||
@@ -333,6 +374,22 @@ void EC_KEY_METHOD_get_encrypt(EC_KEY_METHOD *meth,
|
|||||||
*pdo_encrypt = meth->do_encrypt;
|
*pdo_encrypt = meth->do_encrypt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EC_KEY_METHOD_get_decrypt(EC_KEY_METHOD *meth,
|
||||||
|
int (**pdecrypt)(int type,
|
||||||
|
const unsigned char *in,
|
||||||
|
size_t inlen,
|
||||||
|
unsigned char *out,
|
||||||
|
size_t *outlen,
|
||||||
|
EC_KEY *ec_key),
|
||||||
|
int (*pdo_decrypt)(int type,
|
||||||
|
const ECIES_CIPHERTEXT_VALUE *in,
|
||||||
|
unsigned char *out,
|
||||||
|
size_t *outlen,
|
||||||
|
EC_KEY *ec_key))
|
||||||
|
{
|
||||||
|
if (pdecrypt != NULL)
|
||||||
|
*pdecrypt = meth->decrypt;
|
||||||
|
if (pdo_decrypt != NULL)
|
||||||
|
*pdo_decrypt = meth->do_decrypt;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1272,6 +1272,58 @@ void EC_KEY_METHOD_get_verify(EC_KEY_METHOD *meth,
|
|||||||
const ECDSA_SIG *sig,
|
const ECDSA_SIG *sig,
|
||||||
EC_KEY *eckey));
|
EC_KEY *eckey));
|
||||||
|
|
||||||
|
# ifndef OPENSSL_NO_SM2
|
||||||
|
void EC_KEY_METHOD_set_encrypt(EC_KEY_METHOD *meth,
|
||||||
|
int (*encrypt)(int type,
|
||||||
|
const unsigned char *in,
|
||||||
|
size_t inlen,
|
||||||
|
unsigned char *out,
|
||||||
|
size_t *outlen,
|
||||||
|
EC_KEY *ec_key),
|
||||||
|
ECIES_CIPHERTEXT_VALUE *(*do_encrypt)(int type,
|
||||||
|
const unsigned char *in,
|
||||||
|
size_t inlen,
|
||||||
|
EC_KEY *ec_key));
|
||||||
|
|
||||||
|
void EC_KEY_METHOD_get_decrypt(EC_KEY_METHOD *meth,
|
||||||
|
int (*decrypt)(int type,
|
||||||
|
const unsigned char *in,
|
||||||
|
size_t inlen,
|
||||||
|
unsigned char *out,
|
||||||
|
size_t *outlen,
|
||||||
|
EC_KEY *ec_key),
|
||||||
|
int (do_decrypt)(int type,
|
||||||
|
const ECIES_CIPHERTEXT_VALUE *in,
|
||||||
|
unsigned char *out,
|
||||||
|
size_t *outlen,
|
||||||
|
EC_KEY *ec_key));
|
||||||
|
|
||||||
|
void EC_KEY_METHOD_get_encrypt(EC_KEY_METHOD *meth,
|
||||||
|
int (**pencrypt)(int type,
|
||||||
|
const unsigned char *in,
|
||||||
|
size_t inlen,
|
||||||
|
unsigned char *out,
|
||||||
|
size_t *outlen,
|
||||||
|
EC_KEY *ec_key),
|
||||||
|
ECIES_CIPHERTEXT_VALUE *(**pdo_encrypt)(int type,
|
||||||
|
const unsigned char *in,
|
||||||
|
size_t inlen,
|
||||||
|
EC_KEY *ec_key));
|
||||||
|
|
||||||
|
void EC_KEY_METHOD_get_decrypt(EC_KEY_METHOD *meth,
|
||||||
|
int (**pdecrypt)(int type,
|
||||||
|
const unsigned char *in,
|
||||||
|
size_t inlen,
|
||||||
|
unsigned char *out,
|
||||||
|
size_t *outlen,
|
||||||
|
EC_KEY *ec_key),
|
||||||
|
int (*pdo_decrypt)(int type,
|
||||||
|
const ECIES_CIPHERTEXT_VALUE *in,
|
||||||
|
unsigned char *out,
|
||||||
|
size_t *outlen,
|
||||||
|
EC_KEY *ec_key));
|
||||||
|
# endif
|
||||||
|
|
||||||
# define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)
|
# define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)
|
||||||
|
|
||||||
# ifndef __cplusplus
|
# ifndef __cplusplus
|
||||||
|
|||||||
Reference in New Issue
Block a user