mirror of
https://github.com/QuasarApp/openssl.git
synced 2025-05-08 23:49:39 +00:00
EC_KEY_METHOD keygen support.
Add keygen to EC_KEY_METHOD. Redirect EC_KEY_generate_key through method and set the current EC key generation function as the default. Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
parent
d2fa70d82b
commit
5a6a1029d2
@ -300,6 +300,7 @@ static ERR_STRING_DATA EC_str_reasons[] = {
|
|||||||
{ERR_REASON(EC_R_NOT_INITIALIZED), "not initialized"},
|
{ERR_REASON(EC_R_NOT_INITIALIZED), "not initialized"},
|
||||||
{ERR_REASON(EC_R_NO_FIELD_MOD), "no field mod"},
|
{ERR_REASON(EC_R_NO_FIELD_MOD), "no field mod"},
|
||||||
{ERR_REASON(EC_R_NO_PARAMETERS_SET), "no parameters set"},
|
{ERR_REASON(EC_R_NO_PARAMETERS_SET), "no parameters set"},
|
||||||
|
{ERR_REASON(EC_R_OPERATION_NOT_SUPPORTED), "operation not supported"},
|
||||||
{ERR_REASON(EC_R_PASSED_NULL_PARAMETER), "passed null parameter"},
|
{ERR_REASON(EC_R_PASSED_NULL_PARAMETER), "passed null parameter"},
|
||||||
{ERR_REASON(EC_R_PEER_KEY_ERROR), "peer key error"},
|
{ERR_REASON(EC_R_PEER_KEY_ERROR), "peer key error"},
|
||||||
{ERR_REASON(EC_R_PKPARAMETERS2GROUP_FAILURE),
|
{ERR_REASON(EC_R_PKPARAMETERS2GROUP_FAILURE),
|
||||||
|
@ -203,15 +203,22 @@ int EC_KEY_up_ref(EC_KEY *r)
|
|||||||
|
|
||||||
int EC_KEY_generate_key(EC_KEY *eckey)
|
int EC_KEY_generate_key(EC_KEY *eckey)
|
||||||
{
|
{
|
||||||
int ok = 0;
|
|
||||||
BN_CTX *ctx = NULL;
|
|
||||||
BIGNUM *priv_key = NULL, *order = NULL;
|
|
||||||
EC_POINT *pub_key = NULL;
|
|
||||||
|
|
||||||
if (!eckey || !eckey->group) {
|
if (!eckey || !eckey->group) {
|
||||||
ECerr(EC_F_EC_KEY_GENERATE_KEY, ERR_R_PASSED_NULL_PARAMETER);
|
ECerr(EC_F_EC_KEY_GENERATE_KEY, ERR_R_PASSED_NULL_PARAMETER);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (eckey->meth->keygen)
|
||||||
|
return eckey->meth->keygen(eckey);
|
||||||
|
ECerr(EC_F_EC_KEY_GENERATE_KEY, EC_R_OPERATION_NOT_SUPPORTED);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ossl_ec_key_gen(EC_KEY *eckey)
|
||||||
|
{
|
||||||
|
int ok = 0;
|
||||||
|
BN_CTX *ctx = NULL;
|
||||||
|
BIGNUM *priv_key = NULL, *order = NULL;
|
||||||
|
EC_POINT *pub_key = NULL;
|
||||||
|
|
||||||
if ((order = BN_new()) == NULL)
|
if ((order = BN_new()) == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -60,7 +60,8 @@
|
|||||||
|
|
||||||
static const EC_KEY_METHOD openssl_ec_key_method = {
|
static const EC_KEY_METHOD openssl_ec_key_method = {
|
||||||
"OpenSSL EC_KEY method",
|
"OpenSSL EC_KEY method",
|
||||||
0
|
0,
|
||||||
|
ossl_ec_key_gen
|
||||||
};
|
};
|
||||||
|
|
||||||
const EC_KEY_METHOD *default_ec_key_meth = &openssl_ec_key_method;
|
const EC_KEY_METHOD *default_ec_key_meth = &openssl_ec_key_method;
|
||||||
|
@ -560,6 +560,9 @@ const EC_METHOD *EC_GFp_nistz256_method(void);
|
|||||||
struct ec_key_method_st {
|
struct ec_key_method_st {
|
||||||
const char *name;
|
const char *name;
|
||||||
int32_t flags;
|
int32_t flags;
|
||||||
|
int (*keygen)(EC_KEY *key);
|
||||||
} /* EC_KEY_METHOD */ ;
|
} /* EC_KEY_METHOD */ ;
|
||||||
|
|
||||||
#define EC_KEY_METHOD_DYNAMIC 1
|
#define EC_KEY_METHOD_DYNAMIC 1
|
||||||
|
|
||||||
|
int ossl_ec_key_gen(EC_KEY *eckey);
|
||||||
|
@ -1266,6 +1266,7 @@ void ERR_load_EC_strings(void);
|
|||||||
# define EC_R_NOT_INITIALIZED 111
|
# define EC_R_NOT_INITIALIZED 111
|
||||||
# define EC_R_NO_FIELD_MOD 133
|
# define EC_R_NO_FIELD_MOD 133
|
||||||
# define EC_R_NO_PARAMETERS_SET 139
|
# define EC_R_NO_PARAMETERS_SET 139
|
||||||
|
# define EC_R_OPERATION_NOT_SUPPORTED 152
|
||||||
# define EC_R_PASSED_NULL_PARAMETER 134
|
# define EC_R_PASSED_NULL_PARAMETER 134
|
||||||
# define EC_R_PEER_KEY_ERROR 149
|
# define EC_R_PEER_KEY_ERROR 149
|
||||||
# define EC_R_PKPARAMETERS2GROUP_FAILURE 127
|
# define EC_R_PKPARAMETERS2GROUP_FAILURE 127
|
||||||
|
Loading…
x
Reference in New Issue
Block a user