evpciph_aes_cts.txt 15 KB

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