/[smecontribs]/rpms/openssl3/contribs10/0060-FIPS-KAT-signature-tests.patch
ViewVC logotype

Contents of /rpms/openssl3/contribs10/0060-FIPS-KAT-signature-tests.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Wed Jan 31 17:24:41 2024 UTC (9 months, 3 weeks ago) by jpp
Branch: MAIN
CVS Tags: openssl3-3_0_7-5_el7_sme_1, HEAD
Error occurred while calculating annotation data.
Initial import

1 diff -up openssl-3.0.1/crypto/ec/ec_backend.c.fips_kat_signature openssl-3.0.1/crypto/ec/ec_backend.c
2 --- openssl-3.0.1/crypto/ec/ec_backend.c.fips_kat_signature 2022-04-04 15:49:24.786455707 +0200
3 +++ openssl-3.0.1/crypto/ec/ec_backend.c 2022-04-04 16:06:13.250271963 +0200
4 @@ -393,6 +393,10 @@ int ossl_ec_key_fromdata(EC_KEY *ec, con
5 const OSSL_PARAM *param_priv_key = NULL, *param_pub_key = NULL;
6 BN_CTX *ctx = NULL;
7 BIGNUM *priv_key = NULL;
8 +#ifdef FIPS_MODULE
9 + const OSSL_PARAM *param_sign_kat_k = NULL;
10 + BIGNUM *sign_kat_k = NULL;
11 +#endif
12 unsigned char *pub_key = NULL;
13 size_t pub_key_len;
14 const EC_GROUP *ecg = NULL;
15 @@ -408,7 +412,10 @@ int ossl_ec_key_fromdata(EC_KEY *ec, con
16 if (include_private)
17 param_priv_key =
18 OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY);
19 -
20 +#ifdef FIPS_MODULE
21 + param_sign_kat_k =
22 + OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_REDHAT_SIGN_KAT_K);
23 +#endif
24 ctx = BN_CTX_new_ex(ossl_ec_key_get_libctx(ec));
25 if (ctx == NULL)
26 goto err;
27 @@ -481,6 +489,17 @@ int ossl_ec_key_fromdata(EC_KEY *ec, con
28 && !EC_KEY_set_public_key(ec, pub_point))
29 goto err;
30
31 +#ifdef FIPS_MODULE
32 + if (param_sign_kat_k) {
33 + if ((sign_kat_k = BN_secure_new()) == NULL)
34 + goto err;
35 + BN_set_flags(sign_kat_k, BN_FLG_CONSTTIME);
36 +
37 + if (!OSSL_PARAM_get_BN(param_sign_kat_k, &sign_kat_k))
38 + goto err;
39 + ec->sign_kat_k = sign_kat_k;
40 + }
41 +#endif
42 ok = 1;
43
44 err:
45 diff -up openssl-3.0.1/crypto/ec/ecdsa_ossl.c.fips_kat_signature openssl-3.0.1/crypto/ec/ecdsa_ossl.c
46 --- openssl-3.0.1/crypto/ec/ecdsa_ossl.c.fips_kat_signature 2022-04-04 17:01:35.725323127 +0200
47 +++ openssl-3.0.1/crypto/ec/ecdsa_ossl.c 2022-04-04 17:03:42.000427050 +0200
48 @@ -20,6 +20,10 @@
49 #include "crypto/bn.h"
50 #include "ec_local.h"
51
52 +#ifdef FIPS_MODULE
53 +extern int REDHAT_FIPS_signature_st;
54 +#endif
55 +
56 int ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
57 BIGNUM **rp)
58 {
59 @@ -126,6 +130,11 @@ static int ecdsa_sign_setup(EC_KEY *ecke
60 goto err;
61
62 do {
63 +#ifdef FIPS_MODULE
64 + if (REDHAT_FIPS_signature_st && eckey->sign_kat_k != NULL) {
65 + BN_copy(k, eckey->sign_kat_k);
66 + } else {
67 +#endif
68 /* get random k */
69 do {
70 if (dgst != NULL) {
71 @@ -141,7 +150,9 @@ static int ecdsa_sign_setup(EC_KEY *ecke
72 }
73 }
74 } while (BN_is_zero(k));
75 -
76 +#ifdef FIPS_MODULE
77 + }
78 +#endif
79 /* compute r the x-coordinate of generator * k */
80 if (!EC_POINT_mul(group, tmp_point, k, NULL, NULL, ctx)) {
81 ERR_raise(ERR_LIB_EC, ERR_R_EC_LIB);
82 diff -up openssl-3.0.1/crypto/ec/ec_key.c.fips_kat_signature openssl-3.0.1/crypto/ec/ec_key.c
83 --- openssl-3.0.1/crypto/ec/ec_key.c.fips_kat_signature 2022-04-04 13:48:52.231172299 +0200
84 +++ openssl-3.0.1/crypto/ec/ec_key.c 2022-04-04 14:00:35.077368605 +0200
85 @@ -97,6 +97,9 @@ void EC_KEY_free(EC_KEY *r)
86 EC_GROUP_free(r->group);
87 EC_POINT_free(r->pub_key);
88 BN_clear_free(r->priv_key);
89 +#ifdef FIPS_MODULE
90 + BN_clear_free(r->sign_kat_k);
91 +#endif
92 OPENSSL_free(r->propq);
93
94 OPENSSL_clear_free((void *)r, sizeof(EC_KEY));
95 diff -up openssl-3.0.1/crypto/ec/ec_local.h.fips_kat_signature openssl-3.0.1/crypto/ec/ec_local.h
96 --- openssl-3.0.1/crypto/ec/ec_local.h.fips_kat_signature 2022-04-04 13:46:57.576161867 +0200
97 +++ openssl-3.0.1/crypto/ec/ec_local.h 2022-04-04 13:48:07.827780835 +0200
98 @@ -298,6 +298,9 @@ struct ec_key_st {
99 #ifndef FIPS_MODULE
100 CRYPTO_EX_DATA ex_data;
101 #endif
102 +#ifdef FIPS_MODULE
103 + BIGNUM *sign_kat_k;
104 +#endif
105 CRYPTO_RWLOCK *lock;
106 OSSL_LIB_CTX *libctx;
107 char *propq;
108 diff -up openssl-3.0.1/include/openssl/core_names.h.fips_kat_signature openssl-3.0.1/include/openssl/core_names.h
109 --- openssl-3.0.1/include/openssl/core_names.h.fips_kat_signature 2022-04-04 14:06:15.717370014 +0200
110 +++ openssl-3.0.1/include/openssl/core_names.h 2022-04-04 14:07:35.376071229 +0200
111 @@ -293,6 +293,7 @@ extern "C" {
112 #define OSSL_PKEY_PARAM_DIST_ID "distid"
113 #define OSSL_PKEY_PARAM_PUB_KEY "pub"
114 #define OSSL_PKEY_PARAM_PRIV_KEY "priv"
115 +#define OSSL_PKEY_PARAM_REDHAT_SIGN_KAT_K "rh_sign_kat_k"
116
117 /* Diffie-Hellman/DSA Parameters */
118 #define OSSL_PKEY_PARAM_FFC_P "p"
119 diff -up openssl-3.0.1/providers/implementations/keymgmt/ec_kmgmt.c.fips_kat_signature openssl-3.0.1/providers/implementations/keymgmt/ec_kmgmt.c
120 --- openssl-3.0.1/providers/implementations/keymgmt/ec_kmgmt.c.fips_kat_signature 2022-04-04 14:21:03.043180906 +0200
121 +++ openssl-3.0.1/providers/implementations/keymgmt/ec_kmgmt.c 2022-04-04 14:38:33.949406645 +0200
122 @@ -530,7 +530,8 @@ end:
123 # define EC_IMEXPORTABLE_PUBLIC_KEY \
124 OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PUB_KEY, NULL, 0)
125 # define EC_IMEXPORTABLE_PRIVATE_KEY \
126 - OSSL_PARAM_BN(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0)
127 + OSSL_PARAM_BN(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0), \
128 + OSSL_PARAM_BN(OSSL_PKEY_PARAM_REDHAT_SIGN_KAT_K, NULL, 0)
129 # define EC_IMEXPORTABLE_OTHER_PARAMETERS \
130 OSSL_PARAM_int(OSSL_PKEY_PARAM_USE_COFACTOR_ECDH, NULL), \
131 OSSL_PARAM_int(OSSL_PKEY_PARAM_EC_INCLUDE_PUBLIC, NULL)
132 diff -up openssl-3.0.1/providers/fips/self_test_kats.c.kat openssl-3.0.1/providers/fips/self_test_kats.c
133 --- openssl-3.0.1/providers/fips/self_test_kats.c.kat 2022-05-10 15:10:32.502185265 +0200
134 +++ openssl-3.0.1/providers/fips/self_test_kats.c 2022-05-10 15:13:21.465653720 +0200
135 @@ -17,6 +17,8 @@
136 #include "self_test.h"
137 #include "self_test_data.inc"
138
139 +int REDHAT_FIPS_signature_st = 0;
140 +
141 static int self_test_digest(const ST_KAT_DIGEST *t, OSSL_SELF_TEST *st,
142 OSSL_LIB_CTX *libctx)
143 {
144 @@ -446,6 +448,7 @@ static int self_test_sign(const ST_KAT_S
145 EVP_PKEY *pkey = NULL;
146 unsigned char sig[256];
147 BN_CTX *bnctx = NULL;
148 + BIGNUM *K = NULL;
149 size_t siglen = sizeof(sig);
150 static const unsigned char dgst[] = {
151 0x7f, 0x83, 0xb1, 0x65, 0x7f, 0xf1, 0xfc, 0x53, 0xb9, 0x2d, 0xc1, 0x81,
152 @@ -462,6 +465,9 @@ static int self_test_sign(const ST_KAT_S
153 bnctx = BN_CTX_new_ex(libctx);
154 if (bnctx == NULL)
155 goto err;
156 + K = BN_CTX_get(bnctx);
157 + if (K == NULL || BN_bin2bn(dgst, sizeof(dgst), K) == NULL)
158 + goto err;
159
160 bld = OSSL_PARAM_BLD_new();
161 if (bld == NULL)
162 @@ -469,6 +475,9 @@ static int self_test_sign(const ST_KAT_S
163
164 if (!add_params(bld, t->key, bnctx))
165 goto err;
166 + /* set K for ECDSA KAT tests */
167 + if (!OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_REDHAT_SIGN_KAT_K, K))
168 + goto err;
169 params = OSSL_PARAM_BLD_to_param(bld);
170
171 /* Create a EVP_PKEY_CTX to load the DSA key into */
172 @@ -689,11 +698,13 @@ static int self_test_kas(OSSL_SELF_TEST
173 static int self_test_signatures(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx)
174 {
175 int i, ret = 1;
176 + REDHAT_FIPS_signature_st = 1;
177
178 for (i = 0; i < (int)OSSL_NELEM(st_kat_sign_tests); ++i) {
179 if (!self_test_sign(&st_kat_sign_tests[i], st, libctx))
180 ret = 0;
181 }
182 + REDHAT_FIPS_signature_st = 0;
183 return ret;
184 }
185
186 diff -up openssl-3.0.1/providers/fips/self_test_data.inc.kat openssl-3.0.1/providers/fips/self_test_data.inc
187 --- openssl-3.0.1/providers/fips/self_test_data.inc.kat 2022-05-16 17:37:34.962807400 +0200
188 +++ openssl-3.0.1/providers/fips/self_test_data.inc 2022-05-16 17:48:10.709376779 +0200
189 @@ -1399,7 +1399,151 @@ static const ST_KAT_PARAM ecdsa_prime_ke
190 ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_PRIV_KEY, ecd_prime_priv),
191 ST_KAT_PARAM_END()
192 };
193 +static const unsigned char ec224r1_kat_sig[] = {
194 +0x30, 0x3c, 0x02, 0x1c, 0x2f, 0x24, 0x30, 0x96, 0x3b, 0x39, 0xe0, 0xab, 0xe2, 0x5a, 0x6f, 0xe0,
195 +0x40, 0x7e, 0x19, 0x30, 0x6e, 0x6a, 0xfd, 0x7a, 0x2b, 0x5d, 0xaa, 0xc2, 0x34, 0x6c, 0xc8, 0xce,
196 +0x02, 0x1c, 0x47, 0xe1, 0xac, 0xfd, 0xb4, 0xb8, 0x2b, 0x8c, 0x49, 0xb6, 0x36, 0xcd, 0xdd, 0x22,
197 +0x2a, 0x2d, 0x29, 0x64, 0x70, 0x61, 0xc3, 0x3e, 0x18, 0x51, 0xec, 0xf2, 0xad, 0x3c
198 +};
199
200 +static const char ecd_prime_curve_name384[] = "secp384r1";
201 +/*
202 +priv:
203 + 58:12:2b:94:be:29:23:13:83:f5:c4:20:e8:22:34:
204 + 54:73:49:91:10:05:e9:10:e9:d7:2d:72:9c:5e:6a:
205 + ba:8f:6d:d6:e4:a7:eb:e0:ae:e3:d4:c9:aa:33:87:
206 + 4c:91:87
207 +pub:
208 + 04:d1:86:8b:f5:c4:a2:f7:a5:92:e6:85:2a:d2:92:
209 + 81:97:0a:8d:fa:09:3f:84:6c:17:43:03:43:49:23:
210 + 77:c4:31:f4:0a:a4:de:87:ac:5c:c0:d1:bc:e4:43:
211 + 7f:8d:44:e1:3b:5f:bc:27:c8:79:0f:d0:31:9f:a7:
212 + 6d:de:fb:f7:da:19:40:fd:aa:83:dc:69:ce:a6:f3:
213 + 4d:65:20:1c:66:82:80:03:f7:7b:2e:f3:b3:7c:1f:
214 + 11:f2:a3:bf:e8:0e:88
215 +*/
216 +static const unsigned char ecd_prime_priv384[] = {
217 + 0x58, 0x12, 0x2b, 0x94, 0xbe, 0x29, 0x23, 0x13, 0x83, 0xf5, 0xc4, 0x20, 0xe8, 0x22, 0x34,
218 + 0x54, 0x73, 0x49, 0x91, 0x10, 0x05, 0xe9, 0x10, 0xe9, 0xd7, 0x2d, 0x72, 0x9c, 0x5e, 0x6a,
219 + 0xba, 0x8f, 0x6d, 0xd6, 0xe4, 0xa7, 0xeb, 0xe0, 0xae, 0xe3, 0xd4, 0xc9, 0xaa, 0x33, 0x87,
220 + 0x4c, 0x91, 0x87
221 +};
222 +static const unsigned char ecd_prime_pub384[] = {
223 + 0x04, 0xd1, 0x86, 0x8b, 0xf5, 0xc4, 0xa2, 0xf7, 0xa5, 0x92, 0xe6, 0x85, 0x2a, 0xd2, 0x92,
224 + 0x81, 0x97, 0x0a, 0x8d, 0xfa, 0x09, 0x3f, 0x84, 0x6c, 0x17, 0x43, 0x03, 0x43, 0x49, 0x23,
225 + 0x77, 0xc4, 0x31, 0xf4, 0x0a, 0xa4, 0xde, 0x87, 0xac, 0x5c, 0xc0, 0xd1, 0xbc, 0xe4, 0x43,
226 + 0x7f, 0x8d, 0x44, 0xe1, 0x3b, 0x5f, 0xbc, 0x27, 0xc8, 0x79, 0x0f, 0xd0, 0x31, 0x9f, 0xa7,
227 + 0x6d, 0xde, 0xfb, 0xf7, 0xda, 0x19, 0x40, 0xfd, 0xaa, 0x83, 0xdc, 0x69, 0xce, 0xa6, 0xf3,
228 + 0x4d, 0x65, 0x20, 0x1c, 0x66, 0x82, 0x80, 0x03, 0xf7, 0x7b, 0x2e, 0xf3, 0xb3, 0x7c, 0x1f,
229 + 0x11, 0xf2, 0xa3, 0xbf, 0xe8, 0x0e, 0x88
230 +};
231 +static const ST_KAT_PARAM ecdsa_prime_key384[] = {
232 + ST_KAT_PARAM_UTF8STRING(OSSL_PKEY_PARAM_GROUP_NAME, ecd_prime_curve_name384),
233 + ST_KAT_PARAM_OCTET(OSSL_PKEY_PARAM_PUB_KEY, ecd_prime_pub384),
234 + ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_PRIV_KEY, ecd_prime_priv384),
235 + ST_KAT_PARAM_END()
236 +};
237 +static const unsigned char ec384r1_kat_sig[] = {
238 +0x30, 0x65, 0x02, 0x30, 0x1a, 0xd5, 0x57, 0x1b, 0x28, 0x0f, 0xf1, 0x68, 0x66, 0x68, 0x8a, 0x98,
239 +0xe3, 0x9c, 0xce, 0x7f, 0xa7, 0x68, 0xdc, 0x84, 0x5a, 0x65, 0xdc, 0x2b, 0x5d, 0x7e, 0xf3, 0x9b,
240 +0xa0, 0x40, 0xe8, 0x7a, 0x02, 0xc7, 0x82, 0xe0, 0x0c, 0x81, 0xa5, 0xda, 0x55, 0x27, 0xbf, 0x79,
241 +0xee, 0x72, 0xc2, 0x14, 0x02, 0x31, 0x00, 0xd1, 0x9d, 0x67, 0xda, 0x5a, 0xd2, 0x58, 0x68, 0xe7,
242 +0x71, 0x08, 0xb2, 0xa4, 0xe4, 0xe8, 0x74, 0xb4, 0x0a, 0x3d, 0x76, 0x49, 0x31, 0x17, 0x6e, 0x33,
243 +0x16, 0xf0, 0x00, 0x1f, 0x3c, 0x1f, 0xf9, 0x7c, 0xdb, 0x93, 0x49, 0x9c, 0x7d, 0xb3, 0xd3, 0x30,
244 +0x98, 0x81, 0x6f, 0xb0, 0xc9, 0x30, 0x2f
245 +};
246 +static const char ecd_prime_curve_name521[] = "secp521r1";
247 +/*
248 +priv:
249 + 00:44:0f:96:31:a9:87:f2:5f:be:a0:bc:ef:0c:ae:
250 + 58:cc:5f:f8:44:9e:89:86:7e:bf:db:ce:cb:0e:20:
251 + 10:4a:11:ec:0b:51:1d:e4:91:ca:c6:40:fb:c6:69:
252 + ad:68:33:9e:c8:f5:c4:c6:a5:93:a8:4d:a9:a9:a2:
253 + af:fe:6d:cb:c2:3b
254 +pub:
255 + 04:01:5f:58:a9:40:0c:ee:9b:ed:4a:f4:7a:3c:a3:
256 + 89:c2:f3:7e:2c:f4:b5:53:80:ae:33:7d:36:d1:b5:
257 + 18:bd:ef:a9:48:00:ea:88:ee:00:5c:ca:07:08:b5:
258 + 67:4a:c3:2b:10:c6:07:b0:c2:45:37:b7:1d:e3:6c:
259 + e1:bf:2c:44:18:4a:aa:01:af:75:40:6a:e3:f5:b2:
260 + 7f:d1:9d:1b:8b:29:1f:91:4d:db:93:bf:bd:8c:b7:
261 + 6a:8d:4b:2c:36:2a:6b:ab:54:9d:7b:31:99:a4:de:
262 + c9:10:c4:f4:a3:f4:6d:94:97:62:16:a5:34:65:1f:
263 + 42:cd:8b:9e:e6:db:14:5d:a9:8d:19:95:8d
264 +*/
265 +static const unsigned char ecd_prime_priv521[] = {
266 + 0x00, 0x44, 0x0f, 0x96, 0x31, 0xa9, 0x87, 0xf2, 0x5f, 0xbe, 0xa0, 0xbc, 0xef, 0x0c, 0xae,
267 + 0x58, 0xcc, 0x5f, 0xf8, 0x44, 0x9e, 0x89, 0x86, 0x7e, 0xbf, 0xdb, 0xce, 0xcb, 0x0e, 0x20,
268 + 0x10, 0x4a, 0x11, 0xec, 0x0b, 0x51, 0x1d, 0xe4, 0x91, 0xca, 0xc6, 0x40, 0xfb, 0xc6, 0x69,
269 + 0xad, 0x68, 0x33, 0x9e, 0xc8, 0xf5, 0xc4, 0xc6, 0xa5, 0x93, 0xa8, 0x4d, 0xa9, 0xa9, 0xa2,
270 + 0xaf, 0xfe, 0x6d, 0xcb, 0xc2, 0x3b
271 +};
272 +static const unsigned char ecd_prime_pub521[] = {
273 + 0x04, 0x01, 0x5f, 0x58, 0xa9, 0x40, 0x0c, 0xee, 0x9b, 0xed, 0x4a, 0xf4, 0x7a, 0x3c, 0xa3,
274 + 0x89, 0xc2, 0xf3, 0x7e, 0x2c, 0xf4, 0xb5, 0x53, 0x80, 0xae, 0x33, 0x7d, 0x36, 0xd1, 0xb5,
275 + 0x18, 0xbd, 0xef, 0xa9, 0x48, 0x00, 0xea, 0x88, 0xee, 0x00, 0x5c, 0xca, 0x07, 0x08, 0xb5,
276 + 0x67, 0x4a, 0xc3, 0x2b, 0x10, 0xc6, 0x07, 0xb0, 0xc2, 0x45, 0x37, 0xb7, 0x1d, 0xe3, 0x6c,
277 + 0xe1, 0xbf, 0x2c, 0x44, 0x18, 0x4a, 0xaa, 0x01, 0xaf, 0x75, 0x40, 0x6a, 0xe3, 0xf5, 0xb2,
278 + 0x7f, 0xd1, 0x9d, 0x1b, 0x8b, 0x29, 0x1f, 0x91, 0x4d, 0xdb, 0x93, 0xbf, 0xbd, 0x8c, 0xb7,
279 + 0x6a, 0x8d, 0x4b, 0x2c, 0x36, 0x2a, 0x6b, 0xab, 0x54, 0x9d, 0x7b, 0x31, 0x99, 0xa4, 0xde,
280 + 0xc9, 0x10, 0xc4, 0xf4, 0xa3, 0xf4, 0x6d, 0x94, 0x97, 0x62, 0x16, 0xa5, 0x34, 0x65, 0x1f,
281 + 0x42, 0xcd, 0x8b, 0x9e, 0xe6, 0xdb, 0x14, 0x5d, 0xa9, 0x8d, 0x19, 0x95, 0x8d
282 +};
283 +static const ST_KAT_PARAM ecdsa_prime_key521[] = {
284 + ST_KAT_PARAM_UTF8STRING(OSSL_PKEY_PARAM_GROUP_NAME, ecd_prime_curve_name521),
285 + ST_KAT_PARAM_OCTET(OSSL_PKEY_PARAM_PUB_KEY, ecd_prime_pub521),
286 + ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_PRIV_KEY, ecd_prime_priv521),
287 + ST_KAT_PARAM_END()
288 +};
289 +static const unsigned char ec521r1_kat_sig[] = {
290 +0x30, 0x81, 0x88, 0x02, 0x42, 0x00, 0xdf, 0x64, 0x9c, 0xc8, 0x5b, 0xdd, 0x0b, 0x7f, 0x69, 0x7e,
291 +0xdb, 0x83, 0x58, 0x67, 0x63, 0x43, 0xb7, 0xfa, 0x40, 0x29, 0xde, 0xb9, 0xde, 0xe9, 0x96, 0x65,
292 +0xe6, 0x8e, 0xf4, 0xeb, 0xd0, 0xe9, 0x6a, 0xd3, 0x27, 0x6c, 0x4d, 0x60, 0x47, 0x9c, 0x62, 0xb8,
293 +0x6c, 0xc1, 0x36, 0x19, 0x65, 0xff, 0xab, 0xcf, 0x24, 0xa3, 0xde, 0xd1, 0x4b, 0x1b, 0xdd, 0x89,
294 +0xcf, 0xf8, 0x72, 0x7b, 0x92, 0xbc, 0x02, 0x02, 0x42, 0x01, 0xf8, 0x07, 0x77, 0xb8, 0xcb, 0xa2,
295 +0xe2, 0x1f, 0x53, 0x9a, 0x7c, 0x16, 0xb5, 0x8e, 0xad, 0xe3, 0xc3, 0xac, 0xb7, 0xb2, 0x51, 0x8f,
296 +0xf9, 0x09, 0x65, 0x43, 0xf8, 0xd8, 0x3c, 0xe3, 0x5c, 0x4a, 0x5e, 0x3d, 0x6f, 0xb7, 0xbb, 0x5a,
297 +0x92, 0x69, 0xec, 0x71, 0xa2, 0x35, 0xe5, 0x29, 0x17, 0xaf, 0xc9, 0x69, 0xa7, 0xaa, 0x94, 0xf9,
298 +0xf9, 0x50, 0x87, 0x7b, 0x5d, 0x87, 0xe3, 0xd6, 0x3f, 0xb6, 0x6e
299 +};
300 +static const char ecd_prime_curve_name256[] = "prime256v1";
301 +/*
302 +priv:
303 + 84:88:11:3f:a9:c9:9e:23:72:8b:40:cb:a2:b1:88:
304 + 01:1e:92:48:af:13:2d:9b:33:8e:6d:43:40:30:c7:
305 + 30:fa
306 +pub:
307 + 04:22:58:b6:f9:01:3b:8c:a6:9b:9f:ae:75:fc:73:
308 + cf:1b:f0:81:dc:55:a3:cc:5d:81:46:85:06:32:34:
309 + 99:0d:c5:7e:a1:95:bb:21:73:33:40:4b:35:17:f6:
310 + 8e:26:61:46:94:2c:4c:ac:9b:20:f8:08:72:25:74:
311 + 98:66:c4:63:a6
312 +*/
313 +static const unsigned char ecd_prime_priv256[] = {
314 + 0x84, 0x88, 0x11, 0x3f, 0xa9, 0xc9, 0x9e, 0x23, 0x72, 0x8b, 0x40, 0xcb, 0xa2, 0xb1, 0x88,
315 + 0x01, 0x1e, 0x92, 0x48, 0xaf, 0x13, 0x2d, 0x9b, 0x33, 0x8e, 0x6d, 0x43, 0x40, 0x30, 0xc7,
316 + 0x30, 0xfa
317 +};
318 +static const unsigned char ecd_prime_pub256[] = {
319 + 0x04, 0x22, 0x58, 0xb6, 0xf9, 0x01, 0x3b, 0x8c, 0xa6, 0x9b, 0x9f, 0xae, 0x75, 0xfc, 0x73,
320 + 0xcf, 0x1b, 0xf0, 0x81, 0xdc, 0x55, 0xa3, 0xcc, 0x5d, 0x81, 0x46, 0x85, 0x06, 0x32, 0x34,
321 + 0x99, 0x0d, 0xc5, 0x7e, 0xa1, 0x95, 0xbb, 0x21, 0x73, 0x33, 0x40, 0x4b, 0x35, 0x17, 0xf6,
322 + 0x8e, 0x26, 0x61, 0x46, 0x94, 0x2c, 0x4c, 0xac, 0x9b, 0x20, 0xf8, 0x08, 0x72, 0x25, 0x74,
323 + 0x98, 0x66, 0xc4, 0x63, 0xa6
324 +};
325 +static const ST_KAT_PARAM ecdsa_prime_key256[] = {
326 + ST_KAT_PARAM_UTF8STRING(OSSL_PKEY_PARAM_GROUP_NAME, ecd_prime_curve_name256),
327 + ST_KAT_PARAM_OCTET(OSSL_PKEY_PARAM_PUB_KEY, ecd_prime_pub256),
328 + ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_PRIV_KEY, ecd_prime_priv256),
329 + ST_KAT_PARAM_END()
330 +};
331 +static const unsigned char ec256v1_kat_sig[] = {
332 +0x30, 0x46, 0x02, 0x21, 0x00, 0xc9, 0x11, 0x27, 0x06, 0x51, 0x2b, 0x50, 0x8c, 0x6b, 0xc0, 0xa6,
333 +0x85, 0xaa, 0xf4, 0x66, 0x0d, 0xe4, 0x54, 0x0a, 0x10, 0xb6, 0x9f, 0x87, 0xfc, 0xa2, 0xbc, 0x8f,
334 +0x3c, 0x58, 0xb4, 0xe9, 0x41, 0x02, 0x21, 0x00, 0xc9, 0x72, 0x94, 0xa9, 0xdd, 0x52, 0xca, 0x21,
335 +0x82, 0x66, 0x7a, 0x68, 0xcb, 0x1e, 0x3b, 0x12, 0x71, 0x4d, 0x56, 0xb5, 0xb7, 0xdd, 0xca, 0x2b,
336 +0x18, 0xa3, 0xa7, 0x08, 0x0d, 0xfa, 0x9c, 0x66
337 +};
338 # ifndef OPENSSL_NO_EC2M
339 static const char ecd_bin_curve_name[] = "sect233r1";
340 static const unsigned char ecd_bin_priv[] = {
341 @@ -1571,8 +1715,42 @@ static const ST_KAT_SIGN st_kat_sign_tes
342 ecdsa_prime_key,
343 /*
344 * The ECDSA signature changes each time due to it using a random k.
345 - * So there is no expected KAT for this case.
346 + * We provide this value in our build
347 + */
348 + ITM(ec224r1_kat_sig)
349 + },
350 + {
351 + OSSL_SELF_TEST_DESC_SIGN_ECDSA,
352 + "EC",
353 + "SHA-256",
354 + ecdsa_prime_key384,
355 + /*
356 + * The ECDSA signature changes each time due to it using a random k.
357 + * We provide this value in our build
358 + */
359 + ITM(ec384r1_kat_sig)
360 + },
361 + {
362 + OSSL_SELF_TEST_DESC_SIGN_ECDSA,
363 + "EC",
364 + "SHA-256",
365 + ecdsa_prime_key521,
366 + /*
367 + * The ECDSA signature changes each time due to it using a random k.
368 + * We provide this value in our build
369 + */
370 + ITM(ec521r1_kat_sig)
371 + },
372 + {
373 + OSSL_SELF_TEST_DESC_SIGN_ECDSA,
374 + "EC",
375 + "SHA-256",
376 + ecdsa_prime_key256,
377 + /*
378 + * The ECDSA signature changes each time due to it using a random k.
379 + * We provide this value in our build
380 */
381 + ITM(ec256v1_kat_sig)
382 },
383 # ifndef OPENSSL_NO_EC2M
384 {
385 diff -up openssl-3.0.1/crypto/ec/ecp_s390x_nistp.c.fipskat openssl-3.0.1/crypto/ec/ecp_s390x_nistp.c
386 --- openssl-3.0.1/crypto/ec/ecp_s390x_nistp.c.fipskat 2022-05-30 14:48:53.180999124 +0200
387 +++ openssl-3.0.1/crypto/ec/ecp_s390x_nistp.c 2022-05-30 14:58:52.841286228 +0200
388 @@ -44,6 +44,10 @@
389 #define S390X_OFF_RN(n) (4 * n)
390 #define S390X_OFF_Y(n) (4 * n)
391
392 +#ifdef FIPS_MODULE
393 +extern int REDHAT_FIPS_signature_st;
394 +#endif
395 +
396 static int ec_GFp_s390x_nistp_mul(const EC_GROUP *group, EC_POINT *r,
397 const BIGNUM *scalar,
398 size_t num, const EC_POINT *points[],
399 @@ -183,11 +187,21 @@ static ECDSA_SIG *ecdsa_s390x_nistp_sign
400 * because kdsa instruction constructs an in-range, invertible nonce
401 * internally implementing counter-measures for RNG weakness.
402 */
403 +#ifdef FIPS_MODULE
404 + if (REDHAT_FIPS_signature_st && eckey->sign_kat_k != NULL) {
405 + BN_bn2binpad(eckey->sign_kat_k, param + S390X_OFF_RN(len), len);
406 + /* Turns KDSA internal nonce-generation off. */
407 + fc |= S390X_KDSA_D;
408 + } else {
409 +#endif
410 if (RAND_priv_bytes_ex(eckey->libctx, param + S390X_OFF_RN(len),
411 (size_t)len, 0) != 1) {
412 ERR_raise(ERR_LIB_EC, EC_R_RANDOM_NUMBER_GENERATION_FAILED);
413 goto ret;
414 }
415 +#ifdef FIPS_MODULE
416 + }
417 +#endif
418 } else {
419 /* Reconstruct k = (k^-1)^-1. */
420 if (ossl_ec_group_do_inverse_ord(group, k, kinv, NULL) == 0

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed