summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/rsa/rsa.h
diff options
context:
space:
mode:
authorjsing <>2019-10-31 13:56:29 +0000
committerjsing <>2019-10-31 13:56:29 +0000
commitf423c1be64ebf3368add6bb5bb8ccfd7353f5101 (patch)
treee3ca88f44b13c8e50b648e4fb2179ff06bfe6614 /src/lib/libcrypto/rsa/rsa.h
parentf098d438361a13d0852404f0d8bb32359469e033 (diff)
downloadopenbsd-f423c1be64ebf3368add6bb5bb8ccfd7353f5101.tar.gz
openbsd-f423c1be64ebf3368add6bb5bb8ccfd7353f5101.tar.bz2
openbsd-f423c1be64ebf3368add6bb5bb8ccfd7353f5101.zip
Add support for RSA-PSS.
From OpenSSL 1.1.1d. ok inoguchi@
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa.h')
-rw-r--r--src/lib/libcrypto/rsa/rsa.h64
1 files changed, 41 insertions, 23 deletions
diff --git a/src/lib/libcrypto/rsa/rsa.h b/src/lib/libcrypto/rsa/rsa.h
index d3f9bee3a5..48d6d64bd1 100644
--- a/src/lib/libcrypto/rsa/rsa.h
+++ b/src/lib/libcrypto/rsa/rsa.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa.h,v 1.44 2019/10/29 08:00:18 jsing Exp $ */ 1/* $OpenBSD: rsa.h,v 1.45 2019/10/31 13:56:29 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 *
@@ -201,46 +201,55 @@ struct rsa_st {
201 */ 201 */
202#define RSA_FLAG_NO_BLINDING 0x0080 202#define RSA_FLAG_NO_BLINDING 0x0080
203 203
204/* Salt length matches digest */
205#define RSA_PSS_SALTLEN_DIGEST -1
206/* Verify only: auto detect salt length */
207#define RSA_PSS_SALTLEN_AUTO -2
208/* Set salt length to maximum possible */
209#define RSA_PSS_SALTLEN_MAX -3
210
204#define EVP_PKEY_CTX_set_rsa_padding(ctx, pad) \ 211#define EVP_PKEY_CTX_set_rsa_padding(ctx, pad) \
205 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, EVP_PKEY_CTRL_RSA_PADDING, \ 212 RSA_pkey_ctx_ctrl(ctx, -1, EVP_PKEY_CTRL_RSA_PADDING, pad, NULL)
206 pad, NULL)
207 213
208#define EVP_PKEY_CTX_get_rsa_padding(ctx, ppad) \ 214#define EVP_PKEY_CTX_get_rsa_padding(ctx, ppad) \
209 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, \ 215 RSA_pkey_ctx_ctrl(ctx, -1, EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad)
210 EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad)
211 216
212#define EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, len) \ 217#define EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, len) \
213 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \ 218 RSA_pkey_ctx_ctrl(ctx, (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \
214 (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \ 219 EVP_PKEY_CTRL_RSA_PSS_SALTLEN, len, NULL)
215 EVP_PKEY_CTRL_RSA_PSS_SALTLEN, \ 220
216 len, NULL) 221#define EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen(ctx, len) \
222 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA_PSS, EVP_PKEY_OP_KEYGEN, \
223 EVP_PKEY_CTRL_RSA_PSS_SALTLEN, len, NULL)
217 224
218#define EVP_PKEY_CTX_get_rsa_pss_saltlen(ctx, plen) \ 225#define EVP_PKEY_CTX_get_rsa_pss_saltlen(ctx, plen) \
219 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \ 226 RSA_pkey_ctx_ctrl(ctx, (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \
220 (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \ 227 EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN, 0, plen)
221 EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN, \
222 0, plen)
223 228
224#define EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, bits) \ 229#define EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, bits) \
225 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_KEYGEN, \ 230 RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_KEYGEN, \
226 EVP_PKEY_CTRL_RSA_KEYGEN_BITS, bits, NULL) 231 EVP_PKEY_CTRL_RSA_KEYGEN_BITS, bits, NULL)
227 232
228#define EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, pubexp) \ 233#define EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, pubexp) \
229 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_KEYGEN, \ 234 RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_KEYGEN, \
230 EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP, 0, pubexp) 235 EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP, 0, pubexp)
231 236
232#define EVP_PKEY_CTX_set_rsa_mgf1_md(ctx, md) \ 237#define EVP_PKEY_CTX_set_rsa_mgf1_md(ctx, md) \
233 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_SIG, \ 238 RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \
234 EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)md) 239 EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)(md))
235 240
236#define EVP_PKEY_CTX_get_rsa_mgf1_md(ctx, pmd) \ 241#define EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(ctx, md) \
237 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_SIG, \ 242 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA_PSS, EVP_PKEY_OP_KEYGEN, \
238 EVP_PKEY_CTRL_GET_RSA_MGF1_MD, 0, (void *)pmd) 243 EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)(md))
239 244
240#define EVP_PKEY_CTX_set_rsa_oaep_md(ctx, md) \ 245#define EVP_PKEY_CTX_set_rsa_oaep_md(ctx, md) \
241 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \ 246 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \
242 EVP_PKEY_CTRL_RSA_OAEP_MD, 0, (void *)(md)) 247 EVP_PKEY_CTRL_RSA_OAEP_MD, 0, (void *)(md))
243 248
249#define EVP_PKEY_CTX_get_rsa_mgf1_md(ctx, pmd) \
250 RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \
251 EVP_PKEY_CTRL_GET_RSA_MGF1_MD, 0, (void *)(pmd))
252
244#define EVP_PKEY_CTX_get_rsa_oaep_md(ctx, pmd) \ 253#define EVP_PKEY_CTX_get_rsa_oaep_md(ctx, pmd) \
245 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \ 254 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \
246 EVP_PKEY_CTRL_GET_RSA_OAEP_MD, 0, (void *)(pmd)) 255 EVP_PKEY_CTRL_GET_RSA_OAEP_MD, 0, (void *)(pmd))
@@ -253,6 +262,10 @@ struct rsa_st {
253 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \ 262 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \
254 EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL, 0, (void *)(l)) 263 EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL, 0, (void *)(l))
255 264
265#define EVP_PKEY_CTX_set_rsa_pss_keygen_md(ctx, md) \
266 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA_PSS, \
267 EVP_PKEY_OP_KEYGEN, EVP_PKEY_CTRL_MD, 0, (void *)(md))
268
256#define EVP_PKEY_CTRL_RSA_PADDING (EVP_PKEY_ALG_CTRL + 1) 269#define EVP_PKEY_CTRL_RSA_PADDING (EVP_PKEY_ALG_CTRL + 1)
257#define EVP_PKEY_CTRL_RSA_PSS_SALTLEN (EVP_PKEY_ALG_CTRL + 2) 270#define EVP_PKEY_CTRL_RSA_PSS_SALTLEN (EVP_PKEY_ALG_CTRL + 2)
258 271
@@ -602,12 +615,14 @@ void ERR_load_RSA_strings(void);
602#define RSA_R_DATA_TOO_LARGE_FOR_MODULUS 132 615#define RSA_R_DATA_TOO_LARGE_FOR_MODULUS 132
603#define RSA_R_DATA_TOO_SMALL 111 616#define RSA_R_DATA_TOO_SMALL 111
604#define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122 617#define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122
618#define RSA_R_DIGEST_NOT_ALLOWED 145
605#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112 619#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112
606#define RSA_R_DMP1_NOT_CONGRUENT_TO_D 124 620#define RSA_R_DMP1_NOT_CONGRUENT_TO_D 124
607#define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125 621#define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125
608#define RSA_R_D_E_NOT_CONGRUENT_TO_1 123 622#define RSA_R_D_E_NOT_CONGRUENT_TO_1 123
609#define RSA_R_FIRST_OCTET_INVALID 133 623#define RSA_R_FIRST_OCTET_INVALID 133
610#define RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE 144 624#define RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE 144
625#define RSA_R_INVALID_DIGEST 157
611#define RSA_R_INVALID_DIGEST_LENGTH 143 626#define RSA_R_INVALID_DIGEST_LENGTH 143
612#define RSA_R_INVALID_HEADER 137 627#define RSA_R_INVALID_HEADER 137
613#define RSA_R_INVALID_KEYBITS 145 628#define RSA_R_INVALID_KEYBITS 145
@@ -624,6 +639,7 @@ void ERR_load_RSA_strings(void);
624#define RSA_R_KEY_SIZE_TOO_SMALL 120 639#define RSA_R_KEY_SIZE_TOO_SMALL 120
625#define RSA_R_LAST_OCTET_INVALID 134 640#define RSA_R_LAST_OCTET_INVALID 134
626#define RSA_R_MODULUS_TOO_LARGE 105 641#define RSA_R_MODULUS_TOO_LARGE 105
642#define RSA_R_MGF1_DIGEST_NOT_ALLOWED 152
627#define RSA_R_NON_FIPS_RSA_METHOD 157 643#define RSA_R_NON_FIPS_RSA_METHOD 157
628#define RSA_R_NO_PUBLIC_EXPONENT 140 644#define RSA_R_NO_PUBLIC_EXPONENT 140
629#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113 645#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113
@@ -632,6 +648,7 @@ void ERR_load_RSA_strings(void);
632#define RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE 158 648#define RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE 158
633#define RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 148 649#define RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 148
634#define RSA_R_PADDING_CHECK_FAILED 114 650#define RSA_R_PADDING_CHECK_FAILED 114
651#define RSA_R_PSS_SALTLEN_TOO_SMALL 164
635#define RSA_R_P_NOT_PRIME 128 652#define RSA_R_P_NOT_PRIME 128
636#define RSA_R_Q_NOT_PRIME 129 653#define RSA_R_Q_NOT_PRIME 129
637#define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 130 654#define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 130
@@ -640,6 +657,7 @@ void ERR_load_RSA_strings(void);
640#define RSA_R_SSLV3_ROLLBACK_ATTACK 115 657#define RSA_R_SSLV3_ROLLBACK_ATTACK 115
641#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116 658#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116
642#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117 659#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117
660#define RSA_R_UNKNOWN_DIGEST 166
643#define RSA_R_UNKNOWN_MASK_DIGEST 151 661#define RSA_R_UNKNOWN_MASK_DIGEST 151
644#define RSA_R_UNKNOWN_PADDING_TYPE 118 662#define RSA_R_UNKNOWN_PADDING_TYPE 118
645#define RSA_R_UNKNOWN_PSS_DIGEST 152 663#define RSA_R_UNKNOWN_PSS_DIGEST 152