evpciph_aes_cts.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. #
  2. # Copyright 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. # Original test vectors were taken from https://www.ietf.org/rfc/rfc3962.txt for CS3
  9. # These have an IV of all zeros, for a 128 bit AES key.
  10. Title = AES CBC Test vectors
  11. #------------------------------------------------------
  12. # AES_CBC results for aligned block lengths. (Result should be the same as 32 byte CTS1 & CTS2)
  13. # 32 bytes input
  14. Cipher = AES-128-CBC
  15. Key = 636869636b656e207465726979616b69
  16. IV = 00000000000000000000000000000000
  17. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043
  18. Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a8
  19. # 48 bytes input
  20. Cipher = AES-128-CBC
  21. Key = 636869636b656e207465726979616b69
  22. IV = 00000000000000000000000000000000
  23. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20
  24. Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a89dad8bbb96c4cdc03bc103e1a194bbd8
  25. # 64 bytes input
  26. Cipher = AES-128-CBC
  27. Key = 636869636b656e207465726979616b69
  28. IV = 00000000000000000000000000000000
  29. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e
  30. Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a89dad8bbb96c4cdc03bc103e1a194bbd84807efe836ee89a526730dbc2f7bc840
  31. Title = AES CBC CTS1 Test vectors
  32. #------------------------------------------------------
  33. # Manually edited using the same inputs to also produce CS1 ciphertext
  34. # where aligned blocks are the same as CBC mode, and partial lengths
  35. # have the last 2 blocks swapped compared to CS3.
  36. # 17 bytes Input((Default is CS1 if CTSMode is not specified)
  37. Cipher = AES-128-CBC-CTS
  38. Key = 636869636b656e207465726979616b69
  39. IV = 00000000000000000000000000000000
  40. Plaintext = 4920776f756c64206c696b652074686520
  41. Ciphertext = 97c6353568f2bf8cb4d8a580362da7ff7f
  42. # 31 bytes input
  43. Cipher = AES-128-CBC-CTS
  44. CTSMode = CS1
  45. Key = 636869636b656e207465726979616b69
  46. IV = 00000000000000000000000000000000
  47. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320
  48. Ciphertext = 97687268d6ecccc0c07b25e25ecfe5fc00783e0efdb2c1d445d4c8eff7ed22
  49. # 32 bytes input
  50. Cipher = AES-128-CBC-CTS
  51. CTSMode = CS1
  52. Key = 636869636b656e207465726979616b69
  53. IV = 00000000000000000000000000000000
  54. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043
  55. Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a8
  56. # 47 bytes input
  57. Cipher = AES-128-CBC-CTS
  58. Key = 636869636b656e207465726979616b69
  59. IV = 00000000000000000000000000000000
  60. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c
  61. Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5b3fffd940c16a18c1b5549d2f838029e
  62. # 64 bytes input (CS1 is equivalent to CBC when the last block in full)
  63. Cipher = AES-128-CBC-CTS
  64. CTSMode = CS1
  65. Key = 636869636b656e207465726979616b69
  66. IV = 00000000000000000000000000000000
  67. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e
  68. Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a89dad8bbb96c4cdc03bc103e1a194bbd84807efe836ee89a526730dbc2f7bc840
  69. #-------------------------------------------------------------------------------
  70. # Generated test values using an IV.
  71. # 47 bytes input
  72. Cipher = AES-128-CBC-CTS
  73. CTSMode = CS1
  74. Key = 636869636b656e207465726979616b69
  75. IV =000102030405060708090A0B0C0D0E0F
  76. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c
  77. Ciphertext = 5432a630742dee7beb70f9f1400ee6a0b557cfb581949a4bdf3bb67dedd472426da5c54a9990f5ae0b7825f51f0060
  78. # 127 bytes
  79. Cipher = AES-128-CBC-CTS
  80. CTSMode = CS1
  81. Key = 636869636b656e207465726979616b69
  82. IV = 000102030405060708090A0B0C0D0E0F
  83. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f7570
  84. Ciphertext = 5432a630742dee7beb70f9f1400ee6a0b557cfb581949a4bdf3bb67dedd472b9fc50e4e7dacf9e3d94b6cc031f9997a22d2fea7e6ef4aba2b717b0fa3f150e5e86e46b9e51c6ea5091a92aa791ce826b2e4fbaaf0e0314939625434b9530ce56f299891a48d26bdc287f54b230340d652a4721bf0f082ede80b6399800a92f
  85. # 129 bytes
  86. Cipher = AES-128-CBC-CTS
  87. CTSMode = CS1
  88. Key = 636869636b656e207465726979616b69
  89. IV = 000102030405060708090A0B0C0D0E0F
  90. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e49
  91. Ciphertext = 5432a630742dee7beb70f9f1400ee6a0b557cfb581949a4bdf3bb67dedd472b9fc50e4e7dacf9e3d94b6cc031f9997a22d2fea7e6ef4aba2b717b0fa3f150e5e86e46b9e51c6ea5091a92aa791ce826b2e4fbaaf0e0314939625434b9530ce56f299891a48d26bdc287f54b230340d14fde9fd1098b9b1db788b5868a8d009eeef
  92. # 17 Bytes
  93. Cipher = AES-192-CBC-CTS
  94. CTSMode = CS1
  95. Key = 636869636b656e207465726979616b69636869636b656e20
  96. IV = 000102030405060708090A0B0C0D0E0F
  97. Plaintext = 4920776f756c64206c696b652074686520
  98. Ciphertext = e9de1b402de8f79f947cc6b5880588d9b6
  99. # 31 Bytes
  100. Cipher = AES-192-CBC-CTS
  101. CTSMode = CS1
  102. Key = 636869636b656e207465726979616b69636869636b656e20
  103. IV = 000102030405060708090A0B0C0D0E0F
  104. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320
  105. Ciphertext = e9de17d6248fb492bdea1fb2e09c8edea2b610546f3b1e1d231821e283e153
  106. # 32 Bytes
  107. Cipher = AES-192-CBC-CTS
  108. CTSMode = CS1
  109. Key = 636869636b656e207465726979616b69636869636b656e20
  110. IV = 000102030405060708090A0B0C0D0E0F
  111. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043
  112. Ciphertext = e9de17d6248fb492bdea1fb2e09c8e8e31d005cc9fea948fed1ba6308dad9dd1
  113. #------------------------------------------------------------------------------
  114. # Failure test
  115. # 15 bytes should fail for CS1
  116. Cipher = AES-128-CBC-CTS
  117. CTSMode = CS1
  118. Key = 636869636b656e207465726979616b69
  119. IV = 00000000000000000000000000000000
  120. Plaintext = 0102030405060708090A0B0C0D0E0F
  121. Result = CIPHERUPDATE_ERROR
  122. # Original test vectors were taken from https://www.ietf.org/rfc/rfc3962.txt for CS3
  123. # These have an IV of all zeros, for a 128 bit AES key.
  124. Title = AES CBC CTS2 Test vectors
  125. #------------------------------------------------------
  126. # Manually edited using the same inputs to also produce CS2 ciphertext
  127. # where aligned blocks are the same as CBC mode, and partial lengths
  128. # are the same as CS3.
  129. # 17 bytes Input (For partial blocks the output should match CS3)
  130. Cipher = AES-128-CBC-CTS
  131. CTSMode = CS2
  132. Key = 636869636b656e207465726979616b69
  133. IV = 00000000000000000000000000000000
  134. Plaintext = 4920776f756c64206c696b652074686520
  135. Ciphertext = c6353568f2bf8cb4d8a580362da7ff7f97
  136. # 31 bytes input (For partial blocks the output should match CS3)
  137. Cipher = AES-128-CBC-CTS
  138. CTSMode = CS2
  139. Key = 636869636b656e207465726979616b69
  140. IV = 00000000000000000000000000000000
  141. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320
  142. Ciphertext = fc00783e0efdb2c1d445d4c8eff7ed2297687268d6ecccc0c07b25e25ecfe5
  143. # 32 bytes input (Aligned blocks should match normal CBC mode)
  144. Cipher = AES-128-CBC-CTS
  145. CTSMode = CS2
  146. Key = 636869636b656e207465726979616b69
  147. IV = 00000000000000000000000000000000
  148. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043
  149. Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a8
  150. # 47 bytes input
  151. Cipher = AES-128-CBC-CTS
  152. CTSMode = CS2
  153. Key = 636869636b656e207465726979616b69
  154. IV = 00000000000000000000000000000000
  155. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c
  156. Ciphertext = 97687268d6ecccc0c07b25e25ecfe584b3fffd940c16a18c1b5549d2f838029e39312523a78662d5be7fcbcc98ebf5
  157. # 64 bytes input (CS2 is equivalent to CBC when the last block in full)
  158. Cipher = AES-128-CBC-CTS
  159. CTSMode = CS2
  160. Key = 636869636b656e207465726979616b69
  161. IV = 00000000000000000000000000000000
  162. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e
  163. Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a89dad8bbb96c4cdc03bc103e1a194bbd84807efe836ee89a526730dbc2f7bc840
  164. # Generated test values using an IV.
  165. # 17 Bytes
  166. Cipher = AES-192-CBC-CTS
  167. CTSMode = CS2
  168. Key = 636869636b656e207465726979616b69636869636b656e20
  169. IV = 000102030405060708090A0B0C0D0E0F
  170. Plaintext = 4920776f756c64206c696b652074686520
  171. Ciphertext = de1b402de8f79f947cc6b5880588d9b6e9
  172. # 31 Bytes
  173. Cipher = AES-192-CBC-CTS
  174. CTSMode = CS2
  175. Key = 636869636b656e207465726979616b69636869636b656e20
  176. IV = 000102030405060708090A0B0C0D0E0F
  177. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320
  178. Ciphertext = dea2b610546f3b1e1d231821e283e153e9de17d6248fb492bdea1fb2e09c8e
  179. # 32 Bytes
  180. Cipher = AES-192-CBC-CTS
  181. CTSMode = CS2
  182. Key = 636869636b656e207465726979616b69636869636b656e20
  183. IV = 000102030405060708090A0B0C0D0E0F
  184. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043
  185. Ciphertext = e9de17d6248fb492bdea1fb2e09c8e8e31d005cc9fea948fed1ba6308dad9dd1
  186. # Failure test - 15 bytes should fail for CS2
  187. Cipher = AES-128-CBC-CTS
  188. CTSMode = CS2
  189. Key = 636869636b656e207465726979616b69
  190. IV = 00000000000000000000000000000000
  191. Plaintext = 0102030405060708090A0B0C0D0E0F
  192. Result = CIPHERUPDATE_ERROR
  193. Title = AES CBC CTS3 Test vectors
  194. # 17 bytes Input
  195. Cipher = AES-128-CBC-CTS
  196. CTSMode = CS3
  197. Key = 636869636b656e207465726979616b69
  198. IV = 00000000000000000000000000000000
  199. Plaintext = 4920776f756c64206c696b652074686520
  200. Ciphertext = c6353568f2bf8cb4d8a580362da7ff7f97
  201. # 31 bytes input
  202. Cipher = AES-128-CBC-CTS
  203. CTSMode = CS3
  204. Key = 636869636b656e207465726979616b69
  205. IV = 00000000000000000000000000000000
  206. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320
  207. Ciphertext = fc00783e0efdb2c1d445d4c8eff7ed2297687268d6ecccc0c07b25e25ecfe5
  208. # 32 bytes input (CS3 always swaps the last 2 byte blocks - so it is not equivalent to CBC for a full block)
  209. Cipher = AES-128-CBC-CTS
  210. CTSMode = CS3
  211. Key = 636869636b656e207465726979616b69
  212. IV = 00000000000000000000000000000000
  213. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043
  214. Ciphertext = 39312523a78662d5be7fcbcc98ebf5a897687268d6ecccc0c07b25e25ecfe584
  215. # 47 bytes input
  216. Cipher = AES-128-CBC-CTS
  217. CTSMode = CS3
  218. Key = 636869636b656e207465726979616b69
  219. IV = 00000000000000000000000000000000
  220. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c
  221. Ciphertext = 97687268d6ecccc0c07b25e25ecfe584b3fffd940c16a18c1b5549d2f838029e39312523a78662d5be7fcbcc98ebf5
  222. # 48 bytes input
  223. Cipher = AES-128-CBC-CTS
  224. CTSMode = CS3
  225. Key = 636869636b656e207465726979616b69
  226. IV = 00000000000000000000000000000000
  227. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20
  228. Ciphertext = 97687268d6ecccc0c07b25e25ecfe5849dad8bbb96c4cdc03bc103e1a194bbd839312523a78662d5be7fcbcc98ebf5a8
  229. # 64 bytes input (CS3 always swaps the last 2 byte blocks - so it is not equivalent to CBC for a full block)
  230. Cipher = AES-128-CBC-CTS
  231. CTSMode = CS3
  232. Key = 636869636b656e207465726979616b69
  233. IV = 00000000000000000000000000000000
  234. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e
  235. Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a84807efe836ee89a526730dbc2f7bc8409dad8bbb96c4cdc03bc103e1a194bbd8
  236. # Generated test values using an IV.
  237. # 47 bytes input
  238. Cipher = AES-128-CBC-CTS
  239. CTSMode = CS3
  240. Key = 636869636b656e207465726979616b69
  241. IV = 000102030405060708090A0B0C0D0E0F
  242. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c
  243. Ciphertext = 5432a630742dee7beb70f9f1400ee6a0426da5c54a9990f5ae0b7825f51f0060b557cfb581949a4bdf3bb67dedd472
  244. # 17 Bytes
  245. Cipher = AES-192-CBC-CTS
  246. CTSMode = CS3
  247. Key = 636869636b656e207465726979616b69636869636b656e20
  248. IV =000102030405060708090A0B0C0D0E0F
  249. Plaintext = 4920776f756c64206c696b652074686520
  250. Ciphertext = de1b402de8f79f947cc6b5880588d9b6e9
  251. # 31 Bytes
  252. Cipher = AES-192-CBC-CTS
  253. CTSMode = CS3
  254. Key = 636869636b656e207465726979616b69636869636b656e20
  255. IV = 000102030405060708090A0B0C0D0E0F
  256. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320
  257. Ciphertext = dea2b610546f3b1e1d231821e283e153e9de17d6248fb492bdea1fb2e09c8e
  258. # 32 Bytes
  259. Cipher = AES-192-CBC-CTS
  260. CTSMode = CS3
  261. Key = 636869636b656e207465726979616b69636869636b656e20
  262. IV = 000102030405060708090A0B0C0D0E0F
  263. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043
  264. Ciphertext = 31d005cc9fea948fed1ba6308dad9dd1e9de17d6248fb492bdea1fb2e09c8e8e
  265. # 17 Bytes
  266. Cipher = AES-256-CBC-CTS
  267. CTSMode = CS3
  268. Key = 636869636b656e207465726979616b69636869636b656e207465726979616b69
  269. IV = 000102030405060708090A0B0C0D0E0F
  270. Plaintext = 4920776f756c64206c696b652074686520
  271. Ciphertext = 6b5f5abc21c4d04156c73850da3bba29e9
  272. # 31 Bytes
  273. Cipher = AES-256-CBC-CTS
  274. CTSMode = CS3
  275. Key = 636869636b656e207465726979616b69636869636b656e207465726979616b69
  276. IV = 000102030405060708090A0B0C0D0E0F
  277. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320
  278. Ciphertext = f22553af78ee4f468f02fbe6f0f2168ee954e79fae9310dc75b6070e1d6253
  279. # 32 Bytes
  280. Cipher = AES-256-CBC-CTS
  281. CTSMode = CS3
  282. Key = 636869636b656e207465726979616b69636869636b656e207465726979616b69
  283. IV = 000102030405060708090A0B0C0D0E0F
  284. Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043
  285. Ciphertext = 2c0463982174df10baa9d8f782c5a5b3e954e79fae9310dc75b6070e1d625346
  286. # Failure tests
  287. # 15 bytes should fail for CS3
  288. Cipher = AES-128-CBC-CTS
  289. CTSMode = CS3
  290. Key = 636869636b656e207465726979616b69
  291. IV = 00000000000000000000000000000000
  292. Plaintext = 0102030405060708090A0B0C0D0E0F
  293. Result = CIPHERUPDATE_ERROR
  294. # 16 bytes should fail for CS3 (since it always needs 2 blocks).
  295. Cipher = AES-128-CBC-CTS
  296. CTSMode = CS3
  297. Key = 636869636b656e207465726979616b69
  298. IV = 00000000000000000000000000000000
  299. Plaintext = 0102030405060708090A0B0C0D0E0F00
  300. Result = CIPHERUPDATE_ERROR