Add 'fips-securitychecks' option and plumb this into the actual fips checks
[openssl.git] / test / recipes / 30-test_evp_data / evppkey_ecdsa.txt
1 #
2 # Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved.
3 #
4 # Licensed under the Apache License 2.0 (the "License").  You may not use
5 # this file except in compliance with the License.  You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
8
9 # Tests start with one of these keywords
10 #       Cipher Decrypt Derive Digest Encoding KDF MAC PBE
11 #       PrivPubKeyPair Sign Verify VerifyRecover
12 # and continue until a blank line. Lines starting with a pound sign are ignored.
13 # The keyword Availablein must appear before the test name if needed.
14
15 # Public key algorithm tests
16
17 # Private keys used for PKEY operations.
18
19 # EC P-256 key
20
21 PrivateKey=P-256
22 -----BEGIN PRIVATE KEY-----
23 MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgiocvtiiTxNH/xbnw
24 +RdYBp+DUuCPoFpJ+NuSbLVyhyWhRANCAAQsFQ9CnOcPIWwlLPXgYs4fY5zV0WXH
25 +JQkBywnGX14szuSDpXNtmTpkNzwz+oNlOKo5q+dDlgFbmUxBJJbn+bJ
26 -----END PRIVATE KEY-----
27
28 # EC public key for above
29
30 PublicKey=P-256-PUBLIC
31 -----BEGIN PUBLIC KEY-----
32 MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAELBUPQpznDyFsJSz14GLOH2Oc1dFl
33 x/iUJAcsJxl9eLM7kg6VzbZk6ZDc8M/qDZTiqOavnQ5YBW5lMQSSW5/myQ==
34 -----END PUBLIC KEY-----
35
36 PrivPubKeyPair = P-256:P-256-PUBLIC
37
38 Title = ECDSA tests
39
40 Verify = P-256
41 Ctrl = digest:SHA1
42 Input = "0123456789ABCDEF1234"
43 Output = 3045022100b1d1cb1a577035bccdd5a86c6148c2cc7c633cd42b7234139b593076d041e15202201898cdd52b41ca502098184b409cf83a21bc945006746e3b7cea52234e043ec8
44
45 # Digest too long
46 Verify = P-256
47 Ctrl = digest:SHA1
48 Input = "0123456789ABCDEF12345"
49 Output = 3045022100b1d1cb1a577035bccdd5a86c6148c2cc7c633cd42b7234139b593076d041e15202201898cdd52b41ca502098184b409cf83a21bc945006746e3b7cea52234e043ec8
50 Result = VERIFY_ERROR
51
52 # Digest too short
53 Verify = P-256
54 Ctrl = digest:SHA1
55 Input = "0123456789ABCDEF123"
56 Output = 3045022100b1d1cb1a577035bccdd5a86c6148c2cc7c633cd42b7234139b593076d041e15202201898cdd52b41ca502098184b409cf83a21bc945006746e3b7cea52234e043ec8
57 Result = VERIFY_ERROR
58
59 # Digest invalid
60 Verify = P-256
61 Ctrl = digest:SHA1
62 Input = "0123456789ABCDEF1235"
63 Output = 3045022100b1d1cb1a577035bccdd5a86c6148c2cc7c633cd42b7234139b593076d041e15202201898cdd52b41ca502098184b409cf83a21bc945006746e3b7cea52234e043ec8
64 Result = VERIFY_ERROR
65
66 # Invalid signature
67 Verify = P-256
68 Ctrl = digest:SHA1
69 Input = "0123456789ABCDEF1234"
70 Output = 3045022100b1d1cb1a577035bccdd5a86c6148c2cc7c633cd42b7234139b593076d041e15202201898cdd52b41ca502098184b409cf83a21bc945006746e3b7cea52234e043ec7
71 Result = VERIFY_ERROR
72
73 # Garbage after signature
74 Availablein = default
75 Verify = P-256
76 Ctrl = digest:SHA1
77 Input = "0123456789ABCDEF1234"
78 Output = 3045022100b1d1cb1a577035bccdd5a86c6148c2cc7c633cd42b7234139b593076d041e15202201898cdd52b41ca502098184b409cf83a21bc945006746e3b7cea52234e043ec800
79 Result = VERIFY_ERROR
80
81 # BER signature
82 Verify = P-256
83 Ctrl = digest:SHA1
84 Input = "0123456789ABCDEF1234"
85 Output = 3080022100b1d1cb1a577035bccdd5a86c6148c2cc7c633cd42b7234139b593076d041e15202201898cdd52b41ca502098184b409cf83a21bc945006746e3b7cea52234e043ec80000
86 Result = VERIFY_ERROR
87
88 Verify = P-256-PUBLIC
89 Ctrl = digest:SHA1
90 Input = "0123456789ABCDEF1234"
91 Output = 3045022100b1d1cb1a577035bccdd5a86c6148c2cc7c633cd42b7234139b593076d041e15202201898cdd52b41ca502098184b409cf83a21bc945006746e3b7cea52234e043ec8
92
93 Title = DigestSign and DigestVerify
94
95 DigestVerify = SHA256
96 Key = P-256-PUBLIC
97 Input = "Hello World"
98 Output = 3046022100e7515177ec3817b77a4a94066ab3070817b7aa9d44a8a09f040da250116e8972022100ba59b0f631258e59a9026be5d84f60685f4cf22b9165a0c2736d5c21c8ec1862
99
100 # Invalid digest
101 DigestVerify = MD5
102 Key = P-256-PUBLIC
103 Result = DIGESTVERIFYINIT_ERROR
104
105 # Oneshot tests
106 OneShotDigestVerify = SHA256
107 Key = P-256-PUBLIC
108 Input = "Hello World"
109 Output = 3046022100e7515177ec3817b77a4a94066ab3070817b7aa9d44a8a09f040da250116e8972022100ba59b0f631258e59a9026be5d84f60685f4cf22b9165a0c2736d5c21c8ec1862
110
111 PrivateKey = P-256_NAMED_CURVE_EXPLICIT
112 -----BEGIN PRIVATE KEY-----
113 MIIBeQIBADCCAQMGByqGSM49AgEwgfcCAQEwLAYHKoZIzj0BAQIhAP////8AAAAB
114 AAAAAAAAAAAAAAAA////////////////MFsEIP////8AAAABAAAAAAAAAAAAAAAA
115 ///////////////8BCBaxjXYqjqT57PrvVV2mIa8ZR0GsMxTsPY7zjw+J9JgSwMV
116 AMSdNgiG5wSTamZ44ROdJreBn36QBEEEaxfR8uEsQkf4vOblY6RA8ncDfYEt6zOg
117 9KE5RdiYwpZP40Li/hp/m47n60p8D54WK84zV2sxXs7LtkBoN79R9QIhAP////8A
118 AAAA//////////+85vqtpxeehPO5ysL8YyVRAgEBBG0wawIBAQQgiUTxtr5vLVjj
119 0BOXUa/4r82DJ30QoupYS/wlilW4gWehRANCAATM0n3q2UaDyaQ7OxzJM3B6prhW
120 3ev1gTwRBduzqqlwd54AUSgI+pjttW8zrWNitO8H1sf59MPWOESKxNtZ1+Nl
121 -----END PRIVATE KEY-----
122
123 PrivateKey = EC_EXPLICIT
124 -----BEGIN PRIVATE KEY-----
125 MIIBeQIBADCCAQMGByqGSM49AgEwgfcCAQEwLAYHKoZIzj0BAQIhAP////8AAAAB
126 AAAAAAAAAAAAAAAA////////////////MFsEIP////8AAAABAAAAAAAAAAAAAAAA
127 ///////////////8BCBaxjXYqjqT57PrvVV2mIa8ZR0GsMxTsPY7zjw+J9JgSwMV
128 AMSdNgiG5wSTamZ44ROdJreBn36QBEEE5JcIvn36opqjEm/k59Al40rBAxWM2TPG
129 l0L13Je51zHpfXQ9Z2o7IQicMXP4wSfJ0qCgg2bgydqoxlYrlLGuVQIhAP////8A
130 AAAA//////////+85vqtpxeehPO5ysL8YyVRAgEBBG0wawIBAQQgec92jwduadCk
131 OjoNRI+YT5Be5TkzZXzYCyTLkMOikDmhRANCAATtECEhQbLEaiUj/Wu0qjcr81lL
132 46dx5zYgArz/iaSNJ3W80oO+F7v04jlQ7wxQzg96R0bwKiMeq5CcW9ZFt6xg
133 -----END PRIVATE KEY-----
134
135 PrivateKey = B-163
136 -----BEGIN PRIVATE KEY-----
137 MGMCAQAwEAYHKoZIzj0CAQYFK4EEAA8ETDBKAgEBBBUDnQW0mLiHVha/jqFznX/K
138 DnVlDgChLgMsAAQB1qZ00fPIct+QN8skv1XIHtBNp3EGLytJV0tsAUTYtGhtrzRj
139 e3GzYyg=
140 -----END PRIVATE KEY-----
141
142 PrivateKey = secp256k1
143 -----BEGIN PRIVATE KEY-----
144 MIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQgsLpFV9joHc0bisyV53XL
145 mrG6/Gu6ZaHoXtKP/VFX44ehRANCAARLYWGgp5nP4N8guypLSbYGCVN6ZPCnWW4x
146 srYkcpdbxr4neRT3zC62keCKgPbJf5SIHkJ2Tcaw6hVSrBOUFtix
147 -----END PRIVATE KEY-----
148
149 Title = FIPS tests
150
151 # Test that a nist curve with < 112 bits is allowed in fips mode for verifying
152 DigestVerify = SHA256
153 Key = B-163
154 Input = "Hello World"
155 Output = 302e0215027bb891747468b4b59ca2a2bf8f42d29d08866cf5021502cc311b25e9a2168e42240b07a6071070f687eb3b
156
157 # Test that a nist curve with SHA3 is allowed in fips mode
158 # The sign will get a mismatch error since the output signature changes on each run 
159 DigestSign = SHA3-512
160 Key = P-256
161 Input = "Hello World"
162 Result = SIGNATURE_MISMATCH
163
164 # Test that a explicit curve that is a named curve is allowed in fips mode
165 DigestVerify = SHA256
166 Key = P-256_NAMED_CURVE_EXPLICIT
167 Input = "Hello World"
168 Output = 30450220796fcf472882ed5779226dcd0217b9d2b9acfe4fa2fb0109c8ee63c63adc1033022100e306c69f7e31b9a5d54eb12ba813cddf4de4af933e4f6cea38a0817d9d831d91
169
170 Title = FIPS Negative tests (using different curves and digests)
171
172 # Test that a explicit curve is not allowed in fips mode
173 Availablein = fips
174 DigestVerify = SHA256
175 Securitycheck = 1
176 Key = EC_EXPLICIT
177 Input = "Hello World"
178 Result = DIGESTVERIFYINIT_ERROR
179
180 # Test that a curve with < 112 bits is not allowed in fips mode for signing
181 Availablein = fips
182 DigestSign = SHA3-512
183 Securitycheck = 1
184 Key = B-163
185 Input = "Hello World"
186 Result = DIGESTSIGNINIT_ERROR
187
188 # Test that a non nist curve is not allowed in fips mode
189 Availablein = fips
190 DigestSign = SHA3-512
191 Securitycheck = 1
192 Key = secp256k1
193 Input = "Hello World"
194 Result = DIGESTSIGNINIT_ERROR