summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/evp')
-rw-r--r--src/lib/libcrypto/evp/evp.h15
-rw-r--r--src/lib/libcrypto/evp/evp_locl.h4
-rw-r--r--src/lib/libcrypto/evp/pmeth_gn.c24
-rw-r--r--src/lib/libcrypto/evp/pmeth_lib.c8
4 files changed, 47 insertions, 4 deletions
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h
index aa5b35f67c..e122a6b329 100644
--- a/src/lib/libcrypto/evp/evp.h
+++ b/src/lib/libcrypto/evp/evp.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp.h,v 1.92 2022/01/09 15:15:25 tb Exp $ */ 1/* $OpenBSD: evp.h,v 1.93 2022/01/10 11:52:43 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -1087,6 +1087,11 @@ void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,
1087void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth, 1087void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
1088 int (*pkey_ctrl)(EVP_PKEY *pkey, int op, long arg1, void *arg2)); 1088 int (*pkey_ctrl)(EVP_PKEY *pkey, int op, long arg1, void *arg2));
1089 1089
1090#if defined(LIBRESSL_CRYPTO_INTERNAL) || defined(LIBRESSL_NEXT_API)
1091void EVP_PKEY_asn1_set_check(EVP_PKEY_ASN1_METHOD *ameth,
1092 int (*pkey_check)(const EVP_PKEY *pk));
1093#endif
1094
1090#define EVP_PKEY_OP_UNDEFINED 0 1095#define EVP_PKEY_OP_UNDEFINED 0
1091#define EVP_PKEY_OP_PARAMGEN (1<<1) 1096#define EVP_PKEY_OP_PARAMGEN (1<<1)
1092#define EVP_PKEY_OP_KEYGEN (1<<2) 1097#define EVP_PKEY_OP_KEYGEN (1<<2)
@@ -1213,6 +1218,9 @@ int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx);
1213int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey); 1218int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
1214int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx); 1219int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx);
1215int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey); 1220int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
1221#if defined(LIBRESSL_CRYPTO_INTERNAL) || defined(LIBRESSL_NEXT_API)
1222int EVP_PKEY_check(EVP_PKEY_CTX *ctx);
1223#endif
1216 1224
1217void EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb); 1225void EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb);
1218EVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx); 1226EVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx);
@@ -1279,6 +1287,11 @@ void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,
1279 int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2), 1287 int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2),
1280 int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value)); 1288 int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value));
1281 1289
1290#if defined(LIBRESSL_CRYPTO_INTERNAL) || defined(LIBRESSL_NEXT_API)
1291void EVP_PKEY_meth_set_check(EVP_PKEY_METHOD *pmeth,
1292 int (*check)(EVP_PKEY *pkey));
1293#endif
1294
1282/* Authenticated Encryption with Additional Data. 1295/* Authenticated Encryption with Additional Data.
1283 * 1296 *
1284 * AEAD couples confidentiality and integrity in a single primtive. AEAD 1297 * AEAD couples confidentiality and integrity in a single primtive. AEAD
diff --git a/src/lib/libcrypto/evp/evp_locl.h b/src/lib/libcrypto/evp/evp_locl.h
index 5eef0b244f..3ff8e8ad99 100644
--- a/src/lib/libcrypto/evp/evp_locl.h
+++ b/src/lib/libcrypto/evp/evp_locl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_locl.h,v 1.18 2022/01/09 15:15:25 tb Exp $ */ 1/* $OpenBSD: evp_locl.h,v 1.19 2022/01/10 11:52:43 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -347,6 +347,8 @@ struct evp_pkey_method_st {
347 347
348 int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2); 348 int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2);
349 int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value); 349 int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value);
350
351 int (*check)(EVP_PKEY *pkey);
350} /* EVP_PKEY_METHOD */; 352} /* EVP_PKEY_METHOD */;
351 353
352void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx); 354void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx);
diff --git a/src/lib/libcrypto/evp/pmeth_gn.c b/src/lib/libcrypto/evp/pmeth_gn.c
index 066291b800..a8a4cc97db 100644
--- a/src/lib/libcrypto/evp/pmeth_gn.c
+++ b/src/lib/libcrypto/evp/pmeth_gn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pmeth_gn.c,v 1.8 2021/12/04 16:08:32 tb Exp $ */ 1/* $OpenBSD: pmeth_gn.c,v 1.9 2022/01/10 11:52:43 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -64,6 +64,7 @@
64#include <openssl/evp.h> 64#include <openssl/evp.h>
65#include <openssl/objects.h> 65#include <openssl/objects.h>
66 66
67#include "asn1_locl.h"
67#include "bn_lcl.h" 68#include "bn_lcl.h"
68#include "evp_locl.h" 69#include "evp_locl.h"
69 70
@@ -222,3 +223,24 @@ merr:
222 EVP_PKEY_CTX_free(mac_ctx); 223 EVP_PKEY_CTX_free(mac_ctx);
223 return mac_key; 224 return mac_key;
224} 225}
226
227int
228EVP_PKEY_check(EVP_PKEY_CTX *ctx)
229{
230 EVP_PKEY *pkey;
231
232 if ((pkey = ctx->pkey) == NULL) {
233 EVPerror(EVP_R_NO_KEY_SET);
234 return 0;
235 }
236
237 if (ctx->pmeth->check != NULL)
238 return ctx->pmeth->check(pkey);
239
240 if (pkey->ameth == NULL || pkey->ameth->pkey_check == NULL) {
241 EVPerror(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
242 return -2;
243 }
244
245 return pkey->ameth->pkey_check(pkey);
246}
diff --git a/src/lib/libcrypto/evp/pmeth_lib.c b/src/lib/libcrypto/evp/pmeth_lib.c
index 33924dbd66..92328dd246 100644
--- a/src/lib/libcrypto/evp/pmeth_lib.c
+++ b/src/lib/libcrypto/evp/pmeth_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pmeth_lib.c,v 1.18 2021/12/03 14:19:57 tb Exp $ */ 1/* $OpenBSD: pmeth_lib.c,v 1.19 2022/01/10 11:52:43 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -582,3 +582,9 @@ EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,
582 pmeth->ctrl = ctrl; 582 pmeth->ctrl = ctrl;
583 pmeth->ctrl_str = ctrl_str; 583 pmeth->ctrl_str = ctrl_str;
584} 584}
585
586void
587EVP_PKEY_meth_set_check(EVP_PKEY_METHOD *pmeth, int (*check)(EVP_PKEY *pkey))
588{
589 pmeth->check = check;
590}