RNCryptorGeneratedVectorTests.swift 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. // Automatically Generated by GenVectorTests
  2. import XCTest
  3. class GeneratedVectorTests: XCTestCase {
  4. func test_v3_kdf_One_byte() {
  5. verify_v3_kdf([
  6. "title": "One byte",
  7. "version": "3",
  8. "password": "a",
  9. "salt_hex": "0102030405060708",
  10. "key_hex": "fc632b0c a6b23eff 9a9dc3e0 e585167f 5a328916 ed19f835 58be3ba9 828797cd"])
  11. }
  12. func test_v3_kdf_Short_password() {
  13. verify_v3_kdf([
  14. "title": "Short password",
  15. "version": "3",
  16. "password": "thepassword",
  17. "salt_hex": "0203040506070801",
  18. "key_hex": "0ea84f52 52310dc3 e3a7607c 33bfd1eb 580805fb 68293005 da21037c cf499626"])
  19. }
  20. func test_v3_kdf_Passphrase() {
  21. verify_v3_kdf([
  22. "title": "Passphrase",
  23. "version": "3",
  24. "password": "this is a bit longer password",
  25. "salt_hex": "0304050607080102",
  26. "key_hex": "71343acb 1e9675b0 16ac65dc fe5ddac2 e57ed9c3 5565fdbb 2dd6d2ce fe263d5b"])
  27. }
  28. func test_v3_kdf_Long_passphrase() {
  29. verify_v3_kdf([
  30. "title": "Long passphrase",
  31. "version": "3",
  32. "password": "$$$it was the epoch of belief, it was the epoch of incredulity; it was the season of Light, it was the season of Darkness; it was the spring of hope, it was the winter of despair; we had everything before us, we had nothing before us; we were all going directly to Heaven, we were all going the other way.",
  33. "salt_hex": "0405060708010203",
  34. "key_hex": "11b52c50 cbf45be6 a636a314 2b8c30b8 5a624481 4a7d43e3 7457f38d e46c6735"])
  35. }
  36. func test_v3_kdf_Multibyte() {
  37. verify_v3_kdf([
  38. "title": "Multibyte",
  39. "version": "3",
  40. "password": "中文密码",
  41. "salt_hex": "0506070801020304",
  42. "key_hex": "d2fc3237 d4a69668 ca83d969 c2cda1ac 6c368479 2b6644b1 a90b2052 007215dd"])
  43. }
  44. func test_v3_kdf_Mixed_language() {
  45. verify_v3_kdf([
  46. "title": "Mixed language",
  47. "version": "3",
  48. "password": "中文密码 with a little English, too.",
  49. "salt_hex": "0607080102030405",
  50. "key_hex": "46bda5f4 65982a47 40c728bc 14c5de5c c7fc4eea f0aa41bb 9b9e8495 452dafff"])
  51. }
  52. func test_v3_password_All_fields_empty_or_zero_with_one_byte_password_() {
  53. verify_v3_password([
  54. "title": "All fields empty or zero (with one-byte password)",
  55. "version": "3",
  56. "password": "a",
  57. "enc_salt_hex": "0000000000000000",
  58. "hmac_salt_hex": "0000000000000000",
  59. "iv_hex": "00000000000000000000000000000000",
  60. "plaintext_hex": "",
  61. "ciphertext_hex": "03010000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000b303 9be31cd7 ece5e754 f5c8da17 00366631 3ae8a89d dcf8e3cb 41fdc130 b2329dbe 07d6f4d3 2c34e050 c8bd7e93 3b12"])
  62. }
  63. func test_v3_password_One_byte() {
  64. verify_v3_password([
  65. "title": "One byte",
  66. "version": "3",
  67. "password": "thepassword",
  68. "enc_salt_hex": "0001020304050607",
  69. "hmac_salt_hex": "0102030405060708",
  70. "iv_hex": "02030405060708090a0b0c0d0e0f0001",
  71. "plaintext_hex": "01",
  72. "ciphertext_hex": "03010001 02030405 06070102 03040506 07080203 04050607 08090a0b 0c0d0e0f 0001a1f8 730e0bf4 80eb7b70 f690abf2 1e029514 164ad3c4 74a51b30 c7eaa1ca 545b7de3 de5b010a cbad0a9a 13857df6 96a8"])
  73. }
  74. func test_v3_password_Exactly_one_block() {
  75. verify_v3_password([
  76. "title": "Exactly one block",
  77. "version": "3",
  78. "password": "thepassword",
  79. "enc_salt_hex": "0102030405060700",
  80. "hmac_salt_hex": "0203040506070801",
  81. "iv_hex": "030405060708090a0b0c0d0e0f000102",
  82. "plaintext_hex": "0123456789abcdef",
  83. "ciphertext_hex": "03010102 03040506 07000203 04050607 08010304 05060708 090a0b0c 0d0e0f00 01020e43 7fe80930 9c03fd53 a475131e 9a1978b8 eaef576f 60adb8ce 2320849b a32d7429 00438ba8 97d22210 c76c35c8 49df"])
  84. }
  85. func test_v3_password_More_than_one_block() {
  86. verify_v3_password([
  87. "title": "More than one block",
  88. "version": "3",
  89. "password": "thepassword",
  90. "enc_salt_hex": "0203040506070001",
  91. "hmac_salt_hex": "0304050607080102",
  92. "iv_hex": "0405060708090a0b0c0d0e0f00010203",
  93. "plaintext_hex": "0123456789abcdef 01234567",
  94. "ciphertext_hex": "03010203 04050607 00010304 05060708 01020405 06070809 0a0b0c0d 0e0f0001 0203e01b bda5df2c a8adace3 8f6c588d 291e03f9 51b78d34 17bc2816 581dc6b7 67f1a2e5 7597512b 18e1638f 21235fa5 928c"])
  95. }
  96. func test_v3_password_Multibyte_password() {
  97. verify_v3_password([
  98. "title": "Multibyte password",
  99. "version": "3",
  100. "password": "中文密码",
  101. "enc_salt_hex": "0304050607000102",
  102. "hmac_salt_hex": "0405060708010203",
  103. "iv_hex": "05060708090a0b0c0d0e0f0001020304",
  104. "plaintext_hex": "23456789abcdef 0123456701",
  105. "ciphertext_hex": "03010304 05060700 01020405 06070801 02030506 0708090a 0b0c0d0e 0f000102 03048a9e 08bdec1c 4bfe13e8 1fb85f00 9ab3ddb9 1387e809 c4ad86d9 e8a60145 57716657 bd317d4b b6a76446 15b3de40 2341"])
  106. }
  107. func test_v3_password_Longer_text_and_password() {
  108. verify_v3_password([
  109. "title": "Longer text and password",
  110. "version": "3",
  111. "password": "It was the best of times, it was the worst of times; it was the age of wisdom, it was the age of foolishness;",
  112. "enc_salt_hex": "0405060700010203",
  113. "hmac_salt_hex": "0506070801020304",
  114. "iv_hex": "060708090a0b0c0d0e0f000102030405",
  115. "plaintext_hex": "69 74 20 77 61 73 20 74 68 65 20 65 70 6f 63 68 20 6f 66 20 62 65 6c 69 65 66 2c 20 69 74 20 77 61 73 20 74 68 65 20 65 70 6f 63 68 20 6f 66 20 69 6e 63 72 65 64 75 6c 69 74 79 3b 20 69 74 20 77 61 73 20 74 68 65 20 73 65 61 73 6f 6e 20 6f 66 20 4c 69 67 68 74 2c 20 69 74 20 77 61 73 20 74 68 65 20 73 65 61 73 6f 6e 20 6f 66 20 44 61 72 6b 6e 65 73 73 3b 20 69 74 20 77 61 73 20 74 68 65 20 73 70 72 69 6e 67 20 6f 66 20 68 6f 70 65 2c 20 69 74 20 77 61 73 20 74 68 65 20 77 69 6e 74 65 72 20 6f 66 20 64 65 73 70 61 69 72 3b 20 77 65 20 68 61 64 20 65 76 65 72 79 74 68 69 6e 67 20 62 65 66 6f 72 65 20 75 73 2c 20 77 65 20 68 61 64 20 6e 6f 74 68 69 6e 67 20 62 65 66 6f 72 65 20 75 73 3b 20 77 65 20 77 65 72 65 20 61 6c 6c 20 67 6f 69 6e 67 20 64 69 72 65 63 74 6c 79 20 74 6f 20 48 65 61 76 65 6e 2c 20 77 65 20 77 65 72 65 20 61 6c 6c 20 67 6f 69 6e 67 20 74 68 65 20 6f 74 68 65 72 20 77 61 79 2e 0a 0a",
  116. "ciphertext_hex": "03010405 06070001 02030506 07080102 03040607 08090a0b 0c0d0e0f 00010203 0405d564 c7a99da9 21a6e7c4 078a8264 1d954795 51283167 a2c81f31 ab80c9d7 d8beb770 111decd3 e3d29bbd f7ebbfc5 f10ac87e 7e55bfb5 a7f487bc d3983570 5e83b9c0 49c6d695 2be011f8 ddb1a14f c0c92573 8de017e6 2b1d621c cdb75f29 37d0a1a7 0e44d843 b9c61037 dee2998b 2bbd740b 910232ee a7196116 8838f699 5b996417 3b34c0bc d311a2c8 7e271630 928bae30 1a8f4703 ac2ae469 9f3c285a bf1c55ac 324b073a 958ae52e e8c3bd68 f919c09e b1cd2814 2a1996a9 e6cbff5f 4f4e1dba 07d29ff6 6860db98 95a48233 140ca249 419d6304 6448db1b 0f4252a6 e4edb947 fd0071d1 e52bc156 00622fa5 48a67739 63618150 797a8a80 e592446d f5926d0b fd32b544 b796f335 9567394f 77e7b171 b2f9bc5f 2caf7a0f ac0da7d0 4d6a8674 4d6e06d0 2fbe15d0 f580a1d5 bd16ad91 34800361 1358dcb4 ac999095 5f6cbbbf b185941d 4b4b71ce 7f9ba6ef c1270b78 08838b6c 7b7ef17e 8db919b3 4fac"])
  117. }
  118. func test_v3_key_All_fields_empty_or_zero() {
  119. verify_v3_key([
  120. "title": "All fields empty or zero",
  121. "version": "3",
  122. "enc_key_hex": "0000000000000000000000000000000000000000000000000000000000000000",
  123. "hmac_key_hex": "0000000000000000000000000000000000000000000000000000000000000000",
  124. "iv_hex": "00000000000000000000000000000000",
  125. "plaintext_hex": "",
  126. "ciphertext_hex": "03000000 00000000 00000000 00000000 00001f78 8fe6d86c 31754969 7fbf0c07 fa436384 ac0ef35b 860b2ddb 2aba2fff 816b1fb3 a9c180f7 b43650ae c0d2b5f8 8e33"])
  127. }
  128. func test_v3_key_One_byte() {
  129. verify_v3_key([
  130. "title": "One byte",
  131. "version": "3",
  132. "enc_key_hex": "000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f",
  133. "hmac_key_hex": "0102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f00",
  134. "iv_hex": "02030405060708090a0b0c0d0e0f0001",
  135. "plaintext_hex": "01",
  136. "ciphertext_hex": "03000203 04050607 08090a0b 0c0d0e0f 0001981b 22e7a644 8118d695 bd654f72 e9d6ed75 ec14ae2a a067eed2 a98a56e0 993dfe22 ab5887b3 f6e3cdd4 0767f519 5eb5"])
  137. }
  138. func test_v3_key_Exactly_one_block() {
  139. verify_v3_key([
  140. "title": "Exactly one block",
  141. "version": "3",
  142. "enc_key_hex": "0102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f00",
  143. "hmac_key_hex": "02030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f0001",
  144. "iv_hex": "030405060708090a0b0c0d0e0f000102",
  145. "plaintext_hex": "000102030405060708090a0b0c0d0e0f",
  146. "ciphertext_hex": "03000304 05060708 090a0b0c 0d0e0f00 0102d2b1 77d61878 1829f564 53f739a2 d4f729f9 2b1a9c6c 50837864 74e16a22 c60f92b0 73454f79 76cdda04 3e09b117 66de05ff e05bc1dc a9522ea6 6e64ad25 bbbc"])
  147. }
  148. func test_v3_key_More_than_one_block() {
  149. verify_v3_key([
  150. "title": "More than one block",
  151. "version": "3",
  152. "enc_key_hex": "02030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f0001",
  153. "hmac_key_hex": "030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f000102",
  154. "iv_hex": "0405060708090a0b0c0d0e0f00010203",
  155. "plaintext_hex": "000102030405060708090a0b0c0d0e0f 000102030405060708",
  156. "ciphertext_hex": "03000405 06070809 0a0b0c0d 0e0f0001 02034c9b 98b425f1 d732644c b311278d 858e3d18 2a0789b8 6af7f741 34b6a27e 9d938617 741c0fb8 aaf094b3 b5b26f50 5da7bf19 13f6c17e 70273977 ae51323b 6f09"])
  157. }
  158. //func test_v2_kdf_One_byte() {
  159. // verify_v2_kdf([
  160. // "title": "One byte",
  161. // "version": "2",
  162. // "password": "a",
  163. // "salt_hex": "0102030405060708",
  164. // "key_hex": "fc632b0c a6b23eff 9a9dc3e0 e585167f 5a328916 ed19f835 58be3ba9 828797cd"])
  165. //}
  166. //
  167. //
  168. //func test_v2_kdf_Short_password() {
  169. // verify_v2_kdf([
  170. // "title": "Short password",
  171. // "version": "2",
  172. // "password": "thepassword",
  173. // "salt_hex": "0203040506070801",
  174. // "key_hex": "0ea84f52 52310dc3 e3a7607c 33bfd1eb 580805fb 68293005 da21037c cf499626"])
  175. //}
  176. //
  177. //
  178. //func test_v2_kdf_Passphrase() {
  179. // verify_v2_kdf([
  180. // "title": "Passphrase",
  181. // "version": "2",
  182. // "password": "this is a bit longer password",
  183. // "salt_hex": "0304050607080102",
  184. // "key_hex": "71343acb 1e9675b0 16ac65dc fe5ddac2 e57ed9c3 5565fdbb 2dd6d2ce fe263d5b"])
  185. //}
  186. //
  187. //
  188. //func test_v2_kdf_Long_passphrase() {
  189. // verify_v2_kdf([
  190. // "title": "Long passphrase",
  191. // "version": "2",
  192. // "password": "$$$it was the epoch of belief, it was the epoch of incredulity; it was the season of Light, it was the season of Darkness; it was the spring of hope, it was the winter of despair; we had everything before us, we had nothing before us; we were all going directly to Heaven, we were all going the other way.",
  193. // "salt_hex": "0405060708010203",
  194. // "key_hex": "11b52c50 cbf45be6 a636a314 2b8c30b8 5a624481 4a7d43e3 7457f38d e46c6735"])
  195. //}
  196. //
  197. //
  198. //func test_v2_password_Multi_block() {
  199. // verify_v2_password([
  200. // "title": "Multi-block",
  201. // "version": "2",
  202. // "password": "password",
  203. // "enc_salt_hex": "9707 6dc6 61b6 e0ce",
  204. // "hmac_salt_hex": "9da3 bb43 d95b cd45",
  205. // "iv_hex": "ee39 6d39 e342 ffdb 679b 270d cd9c 557c",
  206. // "plaintext_hex": "546869732069732061206c6f6e676572207465737420766563746f722069 6e74656e64656420746f206265206c6f6e676572207468616e206f6e6520 626c6f636b2e",
  207. // "ciphertext_hex": "020197076dc661b6e0ce9da3bb43d95bcd45ee396d39e342ffdb679b270d cd9c557c37055fffcc1b663b1e6b8c5694dbb96d97a3ac0fa3f355db6668 c5a8a2a06f10056ce92384a618a35bf0fa9eb612b0b4fa72f749f76e2f72 8c16574dc2f15b7cec1786d291c2135f932ddc5a34d9eafd6b45f99491ac 23c34299af0be68a43e6e8113bb748fbc19bcad638ea79b07309"])
  208. //}
  209. //
  210. //
  211. //func test_v1_kdf_One_byte() {
  212. // verify_v1_kdf([
  213. // "title": "One byte",
  214. // "version": "1",
  215. // "password": "a",
  216. // "salt_hex": "0102030405060708",
  217. // "key_hex": "fc632b0c a6b23eff 9a9dc3e0 e585167f 5a328916 ed19f835 58be3ba9 828797cd"])
  218. //}
  219. //
  220. //
  221. //func test_v1_kdf_Short_password() {
  222. // verify_v1_kdf([
  223. // "title": "Short password",
  224. // "version": "1",
  225. // "password": "thepassword",
  226. // "salt_hex": "0203040506070801",
  227. // "key_hex": "0ea84f52 52310dc3 e3a7607c 33bfd1eb 580805fb 68293005 da21037c cf499626"])
  228. //}
  229. //
  230. //
  231. //func test_v1_kdf_Passphrase() {
  232. // verify_v1_kdf([
  233. // "title": "Passphrase",
  234. // "version": "1",
  235. // "password": "this is a bit longer password",
  236. // "salt_hex": "0304050607080102",
  237. // "key_hex": "71343acb 1e9675b0 16ac65dc fe5ddac2 e57ed9c3 5565fdbb 2dd6d2ce fe263d5b"])
  238. //}
  239. //
  240. //
  241. //func test_v1_kdf_Long_passphrase() {
  242. // verify_v1_kdf([
  243. // "title": "Long passphrase",
  244. // "version": "1",
  245. // "password": "$$$it was the epoch of belief, it was the epoch of incredulity; it was the season of Light, it was the season of Darkness; it was the spring of hope, it was the winter of despair; we had everything before us, we had nothing before us; we were all going directly to Heaven, we were all going the other way.",
  246. // "salt_hex": "0405060708010203",
  247. // "key_hex": "11b52c50 cbf45be6 a636a314 2b8c30b8 5a624481 4a7d43e3 7457f38d e46c6735"])
  248. //}
  249. //
  250. //
  251. //func test_v1_password_Multi_block() {
  252. // verify_v1_password([
  253. // "title": "Multi-block",
  254. // "version": "1",
  255. // "password": "password",
  256. // "enc_salt_hex": "9707 6dc6 61b6 e0ce",
  257. // "hmac_salt_hex": "9da3 bb43 d95b cd45",
  258. // "iv_hex": "ee39 6d39 e342 ffdb 679b 270d cd9c 557c",
  259. // "plaintext_hex": "546869732069732061206c6f6e676572207465737420766563746f722069 6e74656e64656420746f206265206c6f6e676572207468616e206f6e6520 626c6f636b2e",
  260. // "ciphertext_hex": "0101d5e9b0eeefa3336d7578c1f9babe4b5de9ecf9598c104ae1e080ec71 e0cabad22204d8d0dc5bf77203fa7e46465d09136cd4a194aadf2b5593d5 f9122aa13b27dc7afaca7ca1548e046a92298ee884c014b5b4a55503be28 852ba1a2750208fd5f0e410e7c1eb969c3990c621b3b73a65715de4d9ff5 6e159ee7625e852517b135dbccef0b9460350a04cd6e3d10e925"])
  261. //}
  262. //
  263. }