summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2019-09-09 18:06:26 +0000
committerjsing <>2019-09-09 18:06:26 +0000
commit8c18a9af07ae60481c97eb03c3ed72a1d0bb44b5 (patch)
treea865a7b163451c6d2c4ef5b36642f1deb36a91b9
parent04c7d3e8b6cca3886df6a6a1bba0d0e29951da8c (diff)
downloadopenbsd-8c18a9af07ae60481c97eb03c3ed72a1d0bb44b5.tar.gz
openbsd-8c18a9af07ae60481c97eb03c3ed72a1d0bb44b5.tar.bz2
openbsd-8c18a9af07ae60481c97eb03c3ed72a1d0bb44b5.zip
Provide EVP_PKEY_CTX_get_signature_md() macro and implement the
EVP_PKEY_CTRL_GET_MD control for DSA, EC and RSA. This is used by the upcoming RSA CMS code. ok inoguchi@ tb@
-rw-r--r--src/lib/libcrypto/dsa/dsa_pmeth.c6
-rw-r--r--src/lib/libcrypto/ec/ec_pmeth.c6
-rw-r--r--src/lib/libcrypto/evp/evp.h14
-rw-r--r--src/lib/libcrypto/rsa/rsa_pmeth.c6
4 files changed, 25 insertions, 7 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_pmeth.c b/src/lib/libcrypto/dsa/dsa_pmeth.c
index 780b070a72..dd0da348b6 100644
--- a/src/lib/libcrypto/dsa/dsa_pmeth.c
+++ b/src/lib/libcrypto/dsa/dsa_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_pmeth.c,v 1.11 2017/01/29 17:49:22 beck Exp $ */ 1/* $OpenBSD: dsa_pmeth.c,v 1.12 2019/09/09 18:06:25 jsing 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 */
@@ -214,6 +214,10 @@ pkey_dsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
214 dctx->md = p2; 214 dctx->md = p2;
215 return 1; 215 return 1;
216 216
217 case EVP_PKEY_CTRL_GET_MD:
218 *(const EVP_MD **)p2 = dctx->md;
219 return 1;
220
217 case EVP_PKEY_CTRL_DIGESTINIT: 221 case EVP_PKEY_CTRL_DIGESTINIT:
218 case EVP_PKEY_CTRL_PKCS7_SIGN: 222 case EVP_PKEY_CTRL_PKCS7_SIGN:
219 case EVP_PKEY_CTRL_CMS_SIGN: 223 case EVP_PKEY_CTRL_CMS_SIGN:
diff --git a/src/lib/libcrypto/ec/ec_pmeth.c b/src/lib/libcrypto/ec/ec_pmeth.c
index 08050df292..c57d26ae29 100644
--- a/src/lib/libcrypto/ec/ec_pmeth.c
+++ b/src/lib/libcrypto/ec/ec_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_pmeth.c,v 1.11 2019/09/06 17:59:25 jsing Exp $ */ 1/* $OpenBSD: ec_pmeth.c,v 1.12 2019/09/09 18:06:25 jsing 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 */
@@ -392,6 +392,10 @@ pkey_ec_ctrl(EVP_PKEY_CTX * ctx, int type, int p1, void *p2)
392 dctx->md = p2; 392 dctx->md = p2;
393 return 1; 393 return 1;
394 394
395 case EVP_PKEY_CTRL_GET_MD:
396 *(const EVP_MD **)p2 = dctx->md;
397 return 1;
398
395 case EVP_PKEY_CTRL_PEER_KEY: 399 case EVP_PKEY_CTRL_PEER_KEY:
396 /* Default behaviour is OK */ 400 /* Default behaviour is OK */
397 case EVP_PKEY_CTRL_DIGESTINIT: 401 case EVP_PKEY_CTRL_DIGESTINIT:
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h
index 3b3d6a07ea..b49fc61380 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.76 2019/08/11 14:11:28 jsing Exp $ */ 1/* $OpenBSD: evp.h,v 1.77 2019/09/09 18:06:25 jsing 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 *
@@ -1085,9 +1085,13 @@ void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
1085#define EVP_PKEY_OP_TYPE_GEN \ 1085#define EVP_PKEY_OP_TYPE_GEN \
1086 (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN) 1086 (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN)
1087 1087
1088#define EVP_PKEY_CTX_set_signature_md(ctx, md) \ 1088#define EVP_PKEY_CTX_set_signature_md(ctx, md) \
1089 EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG, \ 1089 EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG, \
1090 EVP_PKEY_CTRL_MD, 0, (void *)md) 1090 EVP_PKEY_CTRL_MD, 0, (void *)md)
1091
1092#define EVP_PKEY_CTX_get_signature_md(ctx, pmd) \
1093 EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG, \
1094 EVP_PKEY_CTRL_GET_MD, 0, (void *)(pmd))
1091 1095
1092#define EVP_PKEY_CTRL_MD 1 1096#define EVP_PKEY_CTRL_MD 1
1093#define EVP_PKEY_CTRL_PEER_KEY 2 1097#define EVP_PKEY_CTRL_PEER_KEY 2
@@ -1110,6 +1114,8 @@ void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
1110 1114
1111#define EVP_PKEY_CTRL_CIPHER 12 1115#define EVP_PKEY_CTRL_CIPHER 12
1112 1116
1117#define EVP_PKEY_CTRL_GET_MD 13
1118
1113#define EVP_PKEY_ALG_CTRL 0x1000 1119#define EVP_PKEY_ALG_CTRL 0x1000
1114 1120
1115 1121
diff --git a/src/lib/libcrypto/rsa/rsa_pmeth.c b/src/lib/libcrypto/rsa/rsa_pmeth.c
index ea6401b3da..d0cc50cd9f 100644
--- a/src/lib/libcrypto/rsa/rsa_pmeth.c
+++ b/src/lib/libcrypto/rsa/rsa_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_pmeth.c,v 1.21 2018/09/05 00:55:33 djm Exp $ */ 1/* $OpenBSD: rsa_pmeth.c,v 1.22 2019/09/09 18:06:26 jsing 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 */
@@ -423,6 +423,10 @@ bad_pad:
423 rctx->md = p2; 423 rctx->md = p2;
424 return 1; 424 return 1;
425 425
426 case EVP_PKEY_CTRL_GET_MD:
427 *(const EVP_MD **)p2 = rctx->md;
428 return 1;
429
426 case EVP_PKEY_CTRL_RSA_MGF1_MD: 430 case EVP_PKEY_CTRL_RSA_MGF1_MD:
427 case EVP_PKEY_CTRL_GET_RSA_MGF1_MD: 431 case EVP_PKEY_CTRL_GET_RSA_MGF1_MD:
428 if (rctx->pad_mode != RSA_PKCS1_PSS_PADDING) { 432 if (rctx->pad_mode != RSA_PKCS1_PSS_PADDING) {