2
0

evppkey_ecdsa.txt 7.8 KB

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