Remove unused EVP_PKEY_METHOD hooks.
foo_init hooks are never implemented. Even upstream never uses them. The flags member is also never used. We also don't expose paramgen, so remove it. Change-Id: I51d9439316c5163520ab7168693c457f33e59417 Reviewed-on: https://boringssl-review.googlesource.com/6846 Reviewed-by: Adam Langley <alangley@gmail.com>
This commit is contained in:
parent
9bf1b1b440
commit
8ac35f0274
@ -229,15 +229,6 @@ int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx) {
|
||||
}
|
||||
|
||||
ctx->operation = EVP_PKEY_OP_SIGN;
|
||||
if (!ctx->pmeth->sign_init) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!ctx->pmeth->sign_init(ctx)) {
|
||||
ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -260,14 +251,6 @@ int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx) {
|
||||
return 0;
|
||||
}
|
||||
ctx->operation = EVP_PKEY_OP_VERIFY;
|
||||
if (!ctx->pmeth->verify_init) {
|
||||
return 1;
|
||||
}
|
||||
if (!ctx->pmeth->verify_init(ctx)) {
|
||||
ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -290,13 +273,6 @@ int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx) {
|
||||
return 0;
|
||||
}
|
||||
ctx->operation = EVP_PKEY_OP_ENCRYPT;
|
||||
if (!ctx->pmeth->encrypt_init) {
|
||||
return 1;
|
||||
}
|
||||
if (!ctx->pmeth->encrypt_init(ctx)) {
|
||||
ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -319,13 +295,6 @@ int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx) {
|
||||
return 0;
|
||||
}
|
||||
ctx->operation = EVP_PKEY_OP_DECRYPT;
|
||||
if (!ctx->pmeth->decrypt_init) {
|
||||
return 1;
|
||||
}
|
||||
if (!ctx->pmeth->decrypt_init(ctx)) {
|
||||
ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -348,13 +317,6 @@ int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx) {
|
||||
return 0;
|
||||
}
|
||||
ctx->operation = EVP_PKEY_OP_VERIFYRECOVER;
|
||||
if (!ctx->pmeth->verify_recover_init) {
|
||||
return 1;
|
||||
}
|
||||
if (!ctx->pmeth->verify_recover_init(ctx)) {
|
||||
ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -377,13 +339,6 @@ int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx) {
|
||||
return 0;
|
||||
}
|
||||
ctx->operation = EVP_PKEY_OP_DERIVE;
|
||||
if (!ctx->pmeth->derive_init) {
|
||||
return 1;
|
||||
}
|
||||
if (!ctx->pmeth->derive_init(ctx)) {
|
||||
ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -465,13 +420,6 @@ int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx) {
|
||||
return 0;
|
||||
}
|
||||
ctx->operation = EVP_PKEY_OP_KEYGEN;
|
||||
if (!ctx->pmeth->keygen_init) {
|
||||
return 1;
|
||||
}
|
||||
if (!ctx->pmeth->keygen_init(ctx)) {
|
||||
ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -144,10 +144,7 @@ struct evp_pkey_asn1_method_st {
|
||||
} /* EVP_PKEY_ASN1_METHOD */;
|
||||
|
||||
|
||||
typedef int EVP_PKEY_gen_cb(EVP_PKEY_CTX *ctx);
|
||||
|
||||
#define EVP_PKEY_OP_UNDEFINED 0
|
||||
#define EVP_PKEY_OP_PARAMGEN (1 << 1)
|
||||
#define EVP_PKEY_OP_KEYGEN (1 << 2)
|
||||
#define EVP_PKEY_OP_SIGN (1 << 3)
|
||||
#define EVP_PKEY_OP_VERIFY (1 << 4)
|
||||
@ -156,7 +153,7 @@ typedef int EVP_PKEY_gen_cb(EVP_PKEY_CTX *ctx);
|
||||
#define EVP_PKEY_OP_DECRYPT (1 << 7)
|
||||
#define EVP_PKEY_OP_DERIVE (1 << 8)
|
||||
|
||||
#define EVP_PKEY_OP_TYPE_SIG \
|
||||
#define EVP_PKEY_OP_TYPE_SIG \
|
||||
(EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYRECOVER)
|
||||
|
||||
#define EVP_PKEY_OP_TYPE_CRYPT (EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT)
|
||||
@ -164,7 +161,7 @@ typedef int EVP_PKEY_gen_cb(EVP_PKEY_CTX *ctx);
|
||||
#define EVP_PKEY_OP_TYPE_NOGEN \
|
||||
(EVP_PKEY_OP_SIG | EVP_PKEY_OP_CRYPT | EVP_PKEY_OP_DERIVE)
|
||||
|
||||
#define EVP_PKEY_OP_TYPE_GEN (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN)
|
||||
#define EVP_PKEY_OP_TYPE_GEN EVP_PKEY_OP_KEYGEN
|
||||
|
||||
/* EVP_PKEY_CTX_ctrl performs |cmd| on |ctx|. The |keytype| and |optype|
|
||||
* arguments can be -1 to specify that any type and operation are acceptable,
|
||||
@ -229,39 +226,28 @@ struct evp_pkey_ctx_st {
|
||||
|
||||
struct evp_pkey_method_st {
|
||||
int pkey_id;
|
||||
int flags;
|
||||
|
||||
int (*init)(EVP_PKEY_CTX *ctx);
|
||||
int (*copy)(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src);
|
||||
void (*cleanup)(EVP_PKEY_CTX *ctx);
|
||||
|
||||
int (*paramgen_init)(EVP_PKEY_CTX *ctx);
|
||||
int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
|
||||
|
||||
int (*keygen_init)(EVP_PKEY_CTX *ctx);
|
||||
int (*keygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
|
||||
|
||||
int (*sign_init)(EVP_PKEY_CTX *ctx);
|
||||
int (*sign)(EVP_PKEY_CTX *ctx, uint8_t *sig, size_t *siglen,
|
||||
const uint8_t *tbs, size_t tbslen);
|
||||
|
||||
int (*verify_init)(EVP_PKEY_CTX *ctx);
|
||||
int (*verify)(EVP_PKEY_CTX *ctx, const uint8_t *sig, size_t siglen,
|
||||
const uint8_t *tbs, size_t tbslen);
|
||||
|
||||
int (*verify_recover_init)(EVP_PKEY_CTX *ctx);
|
||||
int (*verify_recover)(EVP_PKEY_CTX *ctx, uint8_t *out, size_t *out_len,
|
||||
const uint8_t *sig, size_t sig_len);
|
||||
|
||||
int (*encrypt_init)(EVP_PKEY_CTX *ctx);
|
||||
int (*encrypt)(EVP_PKEY_CTX *ctx, uint8_t *out, size_t *outlen,
|
||||
const uint8_t *in, size_t inlen);
|
||||
|
||||
int (*decrypt_init)(EVP_PKEY_CTX *ctx);
|
||||
int (*decrypt)(EVP_PKEY_CTX *ctx, uint8_t *out, size_t *outlen,
|
||||
const uint8_t *in, size_t inlen);
|
||||
|
||||
int (*derive_init)(EVP_PKEY_CTX *ctx);
|
||||
int (*derive)(EVP_PKEY_CTX *ctx, uint8_t *key, size_t *keylen);
|
||||
|
||||
int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2);
|
||||
|
@ -225,28 +225,6 @@ static int pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) {
|
||||
}
|
||||
}
|
||||
|
||||
static int pkey_ec_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) {
|
||||
EC_KEY *ec = NULL;
|
||||
EC_PKEY_CTX *dctx = ctx->data;
|
||||
int ret = 0;
|
||||
|
||||
if (dctx->gen_group == NULL) {
|
||||
OPENSSL_PUT_ERROR(EVP, EVP_R_NO_PARAMETERS_SET);
|
||||
return 0;
|
||||
}
|
||||
ec = EC_KEY_new();
|
||||
if (!ec) {
|
||||
return 0;
|
||||
}
|
||||
ret = EC_KEY_set_group(ec, dctx->gen_group);
|
||||
if (ret) {
|
||||
EVP_PKEY_assign_EC_KEY(pkey, ec);
|
||||
} else {
|
||||
EC_KEY_free(ec);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int pkey_ec_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) {
|
||||
EC_KEY *ec = NULL;
|
||||
EC_PKEY_CTX *dctx = ctx->data;
|
||||
@ -274,25 +252,15 @@ static int pkey_ec_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) {
|
||||
|
||||
const EVP_PKEY_METHOD ec_pkey_meth = {
|
||||
EVP_PKEY_EC,
|
||||
0 /* flags */,
|
||||
pkey_ec_init,
|
||||
pkey_ec_copy,
|
||||
pkey_ec_cleanup,
|
||||
0 /* paramgen_init */,
|
||||
pkey_ec_paramgen,
|
||||
0 /* keygen_init */,
|
||||
pkey_ec_keygen,
|
||||
0 /* sign_init */,
|
||||
pkey_ec_sign,
|
||||
0 /* verify_init */,
|
||||
pkey_ec_verify,
|
||||
0 /* verify_recover_init */,
|
||||
0 /* verify_recover */,
|
||||
0 /* encrypt_init */,
|
||||
0 /* encrypt */,
|
||||
0 /* decrypt_init */,
|
||||
0 /* decrypt */,
|
||||
0 /* derive_init */,
|
||||
pkey_ec_derive,
|
||||
pkey_ec_ctrl,
|
||||
};
|
||||
|
@ -579,25 +579,15 @@ static int pkey_rsa_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) {
|
||||
|
||||
const EVP_PKEY_METHOD rsa_pkey_meth = {
|
||||
EVP_PKEY_RSA,
|
||||
0 /* flags */,
|
||||
pkey_rsa_init,
|
||||
pkey_rsa_copy,
|
||||
pkey_rsa_cleanup,
|
||||
0 /* paramgen_init */,
|
||||
0 /* paramgen */,
|
||||
0 /* keygen_init */,
|
||||
pkey_rsa_keygen,
|
||||
0 /* sign_init */,
|
||||
pkey_rsa_sign,
|
||||
0 /* verify_init */,
|
||||
pkey_rsa_verify,
|
||||
0 /* verify_recover_init */,
|
||||
pkey_rsa_verify_recover,
|
||||
0 /* encrypt_init */,
|
||||
pkey_rsa_encrypt,
|
||||
0 /* decrypt_init */,
|
||||
pkey_rsa_decrypt,
|
||||
0 /* derive_init */,
|
||||
0 /* derive */,
|
||||
pkey_rsa_ctrl,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user