diff options
Diffstat (limited to 'src/lib/libcrypto/rsa')
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_asn1.c | 186 |
1 files changed, 161 insertions, 25 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_asn1.c b/src/lib/libcrypto/rsa/rsa_asn1.c index 525c9455bd..27afdece00 100644 --- a/src/lib/libcrypto/rsa/rsa_asn1.c +++ b/src/lib/libcrypto/rsa/rsa_asn1.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: rsa_asn1.c,v 1.11 2015/02/10 05:12:23 jsing Exp $ */ | 1 | /* $OpenBSD: rsa_asn1.c,v 1.12 2015/02/14 15:06:55 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 2000. | 3 | * project 2000. |
| 4 | */ | 4 | */ |
| @@ -80,30 +80,166 @@ rsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | |||
| 80 | return 1; | 80 | return 1; |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | ASN1_SEQUENCE_cb(RSAPrivateKey, rsa_cb) = { | 83 | static const ASN1_AUX RSAPrivateKey_aux = { |
| 84 | ASN1_SIMPLE(RSA, version, LONG), | 84 | .app_data = NULL, |
| 85 | ASN1_SIMPLE(RSA, n, BIGNUM), | 85 | .flags = 0, |
| 86 | ASN1_SIMPLE(RSA, e, BIGNUM), | 86 | .ref_offset = 0, |
| 87 | ASN1_SIMPLE(RSA, d, BIGNUM), | 87 | .ref_lock = 0, |
| 88 | ASN1_SIMPLE(RSA, p, BIGNUM), | 88 | .asn1_cb = rsa_cb, |
| 89 | ASN1_SIMPLE(RSA, q, BIGNUM), | 89 | .enc_offset = 0, |
| 90 | ASN1_SIMPLE(RSA, dmp1, BIGNUM), | 90 | }; |
| 91 | ASN1_SIMPLE(RSA, dmq1, BIGNUM), | 91 | static const ASN1_TEMPLATE RSAPrivateKey_seq_tt[] = { |
| 92 | ASN1_SIMPLE(RSA, iqmp, BIGNUM) | 92 | { |
| 93 | } ASN1_SEQUENCE_END_cb(RSA, RSAPrivateKey) | 93 | .flags = 0, |
| 94 | 94 | .tag = 0, | |
| 95 | 95 | .offset = offsetof(RSA, version), | |
| 96 | ASN1_SEQUENCE_cb(RSAPublicKey, rsa_cb) = { | 96 | .field_name = "version", |
| 97 | ASN1_SIMPLE(RSA, n, BIGNUM), | 97 | .item = &LONG_it, |
| 98 | ASN1_SIMPLE(RSA, e, BIGNUM), | 98 | }, |
| 99 | } ASN1_SEQUENCE_END_cb(RSA, RSAPublicKey) | 99 | { |
| 100 | 100 | .flags = 0, | |
| 101 | ASN1_SEQUENCE(RSA_PSS_PARAMS) = { | 101 | .tag = 0, |
| 102 | ASN1_EXP_OPT(RSA_PSS_PARAMS, hashAlgorithm, X509_ALGOR, 0), | 102 | .offset = offsetof(RSA, n), |
| 103 | ASN1_EXP_OPT(RSA_PSS_PARAMS, maskGenAlgorithm, X509_ALGOR, 1), | 103 | .field_name = "n", |
| 104 | ASN1_EXP_OPT(RSA_PSS_PARAMS, saltLength, ASN1_INTEGER, 2), | 104 | .item = &BIGNUM_it, |
| 105 | ASN1_EXP_OPT(RSA_PSS_PARAMS, trailerField, ASN1_INTEGER, 3) | 105 | }, |
| 106 | } ASN1_SEQUENCE_END(RSA_PSS_PARAMS) | 106 | { |
| 107 | .flags = 0, | ||
| 108 | .tag = 0, | ||
| 109 | .offset = offsetof(RSA, e), | ||
| 110 | .field_name = "e", | ||
| 111 | .item = &BIGNUM_it, | ||
| 112 | }, | ||
| 113 | { | ||
| 114 | .flags = 0, | ||
| 115 | .tag = 0, | ||
| 116 | .offset = offsetof(RSA, d), | ||
| 117 | .field_name = "d", | ||
| 118 | .item = &BIGNUM_it, | ||
| 119 | }, | ||
| 120 | { | ||
| 121 | .flags = 0, | ||
| 122 | .tag = 0, | ||
| 123 | .offset = offsetof(RSA, p), | ||
| 124 | .field_name = "p", | ||
| 125 | .item = &BIGNUM_it, | ||
| 126 | }, | ||
| 127 | { | ||
| 128 | .flags = 0, | ||
| 129 | .tag = 0, | ||
| 130 | .offset = offsetof(RSA, q), | ||
| 131 | .field_name = "q", | ||
| 132 | .item = &BIGNUM_it, | ||
| 133 | }, | ||
| 134 | { | ||
| 135 | .flags = 0, | ||
| 136 | .tag = 0, | ||
| 137 | .offset = offsetof(RSA, dmp1), | ||
| 138 | .field_name = "dmp1", | ||
| 139 | .item = &BIGNUM_it, | ||
| 140 | }, | ||
| 141 | { | ||
| 142 | .flags = 0, | ||
| 143 | .tag = 0, | ||
| 144 | .offset = offsetof(RSA, dmq1), | ||
| 145 | .field_name = "dmq1", | ||
| 146 | .item = &BIGNUM_it, | ||
| 147 | }, | ||
| 148 | { | ||
| 149 | .flags = 0, | ||
| 150 | .tag = 0, | ||
| 151 | .offset = offsetof(RSA, iqmp), | ||
| 152 | .field_name = "iqmp", | ||
| 153 | .item = &BIGNUM_it, | ||
| 154 | }, | ||
| 155 | }; | ||
| 156 | |||
| 157 | const ASN1_ITEM RSAPrivateKey_it = { | ||
| 158 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 159 | .utype = V_ASN1_SEQUENCE, | ||
| 160 | .templates = RSAPrivateKey_seq_tt, | ||
| 161 | .tcount = sizeof(RSAPrivateKey_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 162 | .funcs = &RSAPrivateKey_aux, | ||
| 163 | .size = sizeof(RSA), | ||
| 164 | .sname = "RSA", | ||
| 165 | }; | ||
| 166 | |||
| 167 | |||
| 168 | static const ASN1_AUX RSAPublicKey_aux = { | ||
| 169 | .app_data = NULL, | ||
| 170 | .flags = 0, | ||
| 171 | .ref_offset = 0, | ||
| 172 | .ref_lock = 0, | ||
| 173 | .asn1_cb = rsa_cb, | ||
| 174 | .enc_offset = 0, | ||
| 175 | }; | ||
| 176 | static const ASN1_TEMPLATE RSAPublicKey_seq_tt[] = { | ||
| 177 | { | ||
| 178 | .flags = 0, | ||
| 179 | .tag = 0, | ||
| 180 | .offset = offsetof(RSA, n), | ||
| 181 | .field_name = "n", | ||
| 182 | .item = &BIGNUM_it, | ||
| 183 | }, | ||
| 184 | { | ||
| 185 | .flags = 0, | ||
| 186 | .tag = 0, | ||
| 187 | .offset = offsetof(RSA, e), | ||
| 188 | .field_name = "e", | ||
| 189 | .item = &BIGNUM_it, | ||
| 190 | }, | ||
| 191 | }; | ||
| 192 | |||
| 193 | const ASN1_ITEM RSAPublicKey_it = { | ||
| 194 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 195 | .utype = V_ASN1_SEQUENCE, | ||
| 196 | .templates = RSAPublicKey_seq_tt, | ||
| 197 | .tcount = sizeof(RSAPublicKey_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 198 | .funcs = &RSAPublicKey_aux, | ||
| 199 | .size = sizeof(RSA), | ||
| 200 | .sname = "RSA", | ||
| 201 | }; | ||
| 202 | |||
| 203 | static const ASN1_TEMPLATE RSA_PSS_PARAMS_seq_tt[] = { | ||
| 204 | { | ||
| 205 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL, | ||
| 206 | .tag = 0, | ||
| 207 | .offset = offsetof(RSA_PSS_PARAMS, hashAlgorithm), | ||
| 208 | .field_name = "hashAlgorithm", | ||
| 209 | .item = &X509_ALGOR_it, | ||
| 210 | }, | ||
| 211 | { | ||
| 212 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL, | ||
| 213 | .tag = 1, | ||
| 214 | .offset = offsetof(RSA_PSS_PARAMS, maskGenAlgorithm), | ||
| 215 | .field_name = "maskGenAlgorithm", | ||
| 216 | .item = &X509_ALGOR_it, | ||
| 217 | }, | ||
| 218 | { | ||
| 219 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL, | ||
| 220 | .tag = 2, | ||
| 221 | .offset = offsetof(RSA_PSS_PARAMS, saltLength), | ||
| 222 | .field_name = "saltLength", | ||
| 223 | .item = &ASN1_INTEGER_it, | ||
| 224 | }, | ||
| 225 | { | ||
| 226 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL, | ||
| 227 | .tag = 3, | ||
| 228 | .offset = offsetof(RSA_PSS_PARAMS, trailerField), | ||
| 229 | .field_name = "trailerField", | ||
| 230 | .item = &ASN1_INTEGER_it, | ||
| 231 | }, | ||
| 232 | }; | ||
| 233 | |||
| 234 | const ASN1_ITEM RSA_PSS_PARAMS_it = { | ||
| 235 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 236 | .utype = V_ASN1_SEQUENCE, | ||
| 237 | .templates = RSA_PSS_PARAMS_seq_tt, | ||
| 238 | .tcount = sizeof(RSA_PSS_PARAMS_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 239 | .funcs = NULL, | ||
| 240 | .size = sizeof(RSA_PSS_PARAMS), | ||
| 241 | .sname = "RSA_PSS_PARAMS", | ||
| 242 | }; | ||
| 107 | 243 | ||
| 108 | 244 | ||
| 109 | RSA_PSS_PARAMS * | 245 | RSA_PSS_PARAMS * |
