-/* $OpenBSD: pmeth_lib.c,v 1.36 2024/01/04 20:15:01 tb Exp $ */
+/* $OpenBSD: pmeth_lib.c,v 1.37 2024/01/13 12:46:59 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
#define N_PKEY_METHODS (sizeof(pkey_methods) / sizeof(pkey_methods[0]))
-const EVP_PKEY_METHOD *
-EVP_PKEY_meth_find(int type)
+static const EVP_PKEY_METHOD *
+evp_pkey_method_find(int nid)
{
size_t i;
for (i = 0; i < N_PKEY_METHODS; i++) {
const EVP_PKEY_METHOD *pmeth = pkey_methods[i];
- if (pmeth->pkey_id == type)
+ if (pmeth->pkey_id == nid)
return pmeth;
}
}
static EVP_PKEY_CTX *
-evp_pkey_ctx_new(EVP_PKEY *pkey, int id)
+evp_pkey_ctx_new(EVP_PKEY *pkey, int nid)
{
EVP_PKEY_CTX *pkey_ctx = NULL;
const EVP_PKEY_METHOD *pmeth;
- if (id == -1) {
+ if (nid == -1) {
if (pkey == NULL || pkey->ameth == NULL)
return NULL;
- id = pkey->ameth->pkey_id;
+ nid = pkey->ameth->pkey_id;
}
- if ((pmeth = EVP_PKEY_meth_find(id)) == NULL) {
+ if ((pmeth = evp_pkey_method_find(nid)) == NULL) {
EVPerror(EVP_R_UNSUPPORTED_ALGORITHM);
goto err;
}
return NULL;
}
-EVP_PKEY_METHOD*
-EVP_PKEY_meth_new(int id, int flags)
-{
- EVP_PKEY_METHOD *pmeth;
-
- if ((pmeth = calloc(1, sizeof(EVP_PKEY_METHOD))) == NULL)
- return NULL;
-
- pmeth->pkey_id = id;
- pmeth->flags = flags | EVP_PKEY_FLAG_DYNAMIC;
-
- return pmeth;
-}
-
-void
-EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags, const EVP_PKEY_METHOD *meth)
-{
- if (ppkey_id)
- *ppkey_id = meth->pkey_id;
- if (pflags)
- *pflags = meth->flags;
-}
-
-void
-EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src)
-{
- EVP_PKEY_METHOD preserve;
-
- preserve.pkey_id = dst->pkey_id;
- preserve.flags = dst->flags;
-
- *dst = *src;
-
- dst->pkey_id = preserve.pkey_id;
- dst->flags = preserve.flags;
-}
-
-void
-EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth)
-{
- if (pmeth && (pmeth->flags & EVP_PKEY_FLAG_DYNAMIC))
- free(pmeth);
-}
-
EVP_PKEY_CTX *
EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *engine)
{
}
EVP_PKEY_CTX *
-EVP_PKEY_CTX_new_id(int id, ENGINE *engine)
+EVP_PKEY_CTX_new_id(int nid, ENGINE *engine)
{
- return evp_pkey_ctx_new(NULL, id);
+ return evp_pkey_ctx_new(NULL, nid);
}
EVP_PKEY_CTX *
return NULL;
}
-int
-EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth)
-{
- EVPerror(ERR_R_DISABLED);
- return 0;
-}
-
void
EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx)
{
return ctx->app_data;
}
+/*
+ * Remove all the functions below in the next major bump
+ */
+
+const EVP_PKEY_METHOD *
+EVP_PKEY_meth_find(int type)
+{
+ EVPerror(ERR_R_DISABLED);
+ return NULL;
+}
+
+EVP_PKEY_METHOD*
+EVP_PKEY_meth_new(int id, int flags)
+{
+ EVPerror(ERR_R_DISABLED);
+ return NULL;
+}
+
+void
+EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags, const EVP_PKEY_METHOD *meth)
+{
+}
+
+void
+EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src)
+{
+}
+
+void
+EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth)
+{
+}
+
+int
+EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth)
+{
+ EVPerror(ERR_R_DISABLED);
+ return 0;
+}
+
void
EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,
int (*init)(EVP_PKEY_CTX *ctx))
{
- pmeth->init = init;
}
void
EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,
int (*copy)(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src))
{
- pmeth->copy = copy;
}
void
EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,
void (*cleanup)(EVP_PKEY_CTX *ctx))
{
- pmeth->cleanup = cleanup;
}
void
int (*paramgen_init)(EVP_PKEY_CTX *ctx),
int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey))
{
- pmeth->paramgen_init = paramgen_init;
- pmeth->paramgen = paramgen;
}
void
int (*keygen_init)(EVP_PKEY_CTX *ctx),
int (*keygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey))
{
- pmeth->keygen_init = keygen_init;
- pmeth->keygen = keygen;
}
void
int (*sign)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
const unsigned char *tbs, size_t tbslen))
{
- pmeth->sign_init = sign_init;
- pmeth->sign = sign;
}
void
int (*verify)(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen,
const unsigned char *tbs, size_t tbslen))
{
- pmeth->verify_init = verify_init;
- pmeth->verify = verify;
}
void
unsigned char *sig, size_t *siglen,
const unsigned char *tbs, size_t tbslen))
{
- pmeth->verify_recover_init = verify_recover_init;
- pmeth->verify_recover = verify_recover;
}
void
int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
EVP_MD_CTX *mctx))
{
- pmeth->signctx_init = signctx_init;
- pmeth->signctx = signctx;
}
void
int (*verifyctx)(EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen,
EVP_MD_CTX *mctx))
{
- pmeth->verifyctx_init = verifyctx_init;
- pmeth->verifyctx = verifyctx;
}
void
int (*encryptfn)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
const unsigned char *in, size_t inlen))
{
- pmeth->encrypt_init = encrypt_init;
- pmeth->encrypt = encryptfn;
}
void
int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
const unsigned char *in, size_t inlen))
{
- pmeth->decrypt_init = decrypt_init;
- pmeth->decrypt = decrypt;
}
void
int (*derive_init)(EVP_PKEY_CTX *ctx),
int (*derive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen))
{
- pmeth->derive_init = derive_init;
- pmeth->derive = derive;
}
void
int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2),
int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value))
{
- pmeth->ctrl = ctrl;
- pmeth->ctrl_str = ctrl_str;
}
void
EVP_PKEY_meth_set_check(EVP_PKEY_METHOD *pmeth, int (*check)(EVP_PKEY *pkey))
{
- pmeth->check = check;
}
void
EVP_PKEY_meth_set_public_check(EVP_PKEY_METHOD *pmeth,
int (*public_check)(EVP_PKEY *pkey))
{
- pmeth->public_check = public_check;
}
void
EVP_PKEY_meth_set_param_check(EVP_PKEY_METHOD *pmeth,
int (*param_check)(EVP_PKEY *pkey))
{
- pmeth->param_check = param_check;
}