poly1305_internal_test.c 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639
  1. /*
  2. * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (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. /* Internal tests for the poly1305 module */
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include "testutil.h"
  13. #include "internal/poly1305.h"
  14. #include "../crypto/poly1305/poly1305_local.h"
  15. #include "e_os.h"
  16. typedef struct {
  17. size_t size;
  18. const unsigned char data[1024];
  19. } SIZED_DATA;
  20. typedef struct {
  21. SIZED_DATA input;
  22. SIZED_DATA key;
  23. SIZED_DATA expected;
  24. } TESTDATA;
  25. /**********************************************************************
  26. *
  27. * Test of poly1305 internal functions
  28. *
  29. ***/
  30. static void benchmark_poly1305()
  31. {
  32. # ifdef OPENSSL_CPUID_OBJ
  33. POLY1305 poly1305;
  34. unsigned char key[32];
  35. unsigned char buf[8192];
  36. unsigned long long stopwatch;
  37. unsigned long long OPENSSL_rdtsc();
  38. unsigned int i;
  39. memset (buf,0x55,sizeof(buf));
  40. memset (key,0xAA,sizeof(key));
  41. Poly1305_Init(&poly1305, key);
  42. for (i=0;i<100000;i++)
  43. Poly1305_Update(&poly1305,buf,sizeof(buf));
  44. stopwatch = OPENSSL_rdtsc();
  45. for (i=0;i<10000;i++)
  46. Poly1305_Update(&poly1305,buf,sizeof(buf));
  47. stopwatch = OPENSSL_rdtsc() - stopwatch;
  48. printf("%g\n",stopwatch/(double)(i*sizeof(buf)));
  49. stopwatch = OPENSSL_rdtsc();
  50. for (i=0;i<10000;i++) {
  51. Poly1305_Init(&poly1305, key);
  52. Poly1305_Update(&poly1305,buf,16);
  53. Poly1305_Final(&poly1305,buf);
  54. }
  55. stopwatch = OPENSSL_rdtsc() - stopwatch;
  56. printf("%g\n",stopwatch/(double)(i));
  57. # else
  58. fprintf(stderr,
  59. "Benchmarking of poly1305 isn't available on this platform\n");
  60. # endif
  61. }
  62. static TESTDATA tests[] = {
  63. /*
  64. * RFC7539
  65. */
  66. {
  67. {
  68. 34,
  69. {
  70. 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x67, 0x72,
  71. 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x46, 0x6f,
  72. 0x72, 0x75, 0x6d, 0x20, 0x52, 0x65, 0x73, 0x65,
  73. 0x61, 0x72, 0x63, 0x68, 0x20, 0x47, 0x72, 0x6f,
  74. 0x75, 0x70
  75. }
  76. },
  77. {
  78. 32,
  79. {
  80. 0x85, 0xd6, 0xbe, 0x78, 0x57, 0x55, 0x6d, 0x33,
  81. 0x7f, 0x44, 0x52, 0xfe, 0x42, 0xd5, 0x06, 0xa8,
  82. 0x01, 0x03, 0x80, 0x8a, 0xfb, 0x0d, 0xb2, 0xfd,
  83. 0x4a, 0xbf, 0xf6, 0xaf, 0x41, 0x49, 0xf5, 0x1b
  84. }
  85. },
  86. {
  87. 16,
  88. {
  89. 0xa8, 0x06, 0x1d, 0xc1, 0x30, 0x51, 0x36, 0xc6,
  90. 0xc2, 0x2b, 0x8b, 0xaf, 0x0c, 0x01, 0x27, 0xa9
  91. }
  92. }
  93. },
  94. /*
  95. * test vectors from "The Poly1305-AES message-authentication code"
  96. */
  97. {
  98. {
  99. 2,
  100. {
  101. 0xf3, 0xf6
  102. }
  103. },
  104. {
  105. 32,
  106. {
  107. 0x85, 0x1f, 0xc4, 0x0c, 0x34, 0x67, 0xac, 0x0b,
  108. 0xe0, 0x5c, 0xc2, 0x04, 0x04, 0xf3, 0xf7, 0x00,
  109. 0x58, 0x0b, 0x3b, 0x0f, 0x94, 0x47, 0xbb, 0x1e,
  110. 0x69, 0xd0, 0x95, 0xb5, 0x92, 0x8b, 0x6d, 0xbc
  111. }
  112. },
  113. {
  114. 16,
  115. {
  116. 0xf4, 0xc6, 0x33, 0xc3, 0x04, 0x4f, 0xc1, 0x45,
  117. 0xf8, 0x4f, 0x33, 0x5c, 0xb8, 0x19, 0x53, 0xde
  118. }
  119. }
  120. },
  121. {
  122. {
  123. 0,
  124. {
  125. 0
  126. }
  127. },
  128. {
  129. 32,
  130. {
  131. 0xa0, 0xf3, 0x08, 0x00, 0x00, 0xf4, 0x64, 0x00,
  132. 0xd0, 0xc7, 0xe9, 0x07, 0x6c, 0x83, 0x44, 0x03,
  133. 0xdd, 0x3f, 0xab, 0x22, 0x51, 0xf1, 0x1a, 0xc7,
  134. 0x59, 0xf0, 0x88, 0x71, 0x29, 0xcc, 0x2e, 0xe7
  135. }
  136. },
  137. {
  138. 16,
  139. {
  140. 0xdd, 0x3f, 0xab, 0x22, 0x51, 0xf1, 0x1a, 0xc7,
  141. 0x59, 0xf0, 0x88, 0x71, 0x29, 0xcc, 0x2e, 0xe7
  142. }
  143. }
  144. },
  145. {
  146. {
  147. 32,
  148. {
  149. 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
  150. 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
  151. 0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
  152. 0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36
  153. }
  154. },
  155. {
  156. 32,
  157. {
  158. 0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
  159. 0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
  160. 0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
  161. 0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef
  162. }
  163. },
  164. {
  165. 16,
  166. {
  167. 0x0e, 0xe1, 0xc1, 0x6b, 0xb7, 0x3f, 0x0f, 0x4f,
  168. 0xd1, 0x98, 0x81, 0x75, 0x3c, 0x01, 0xcd, 0xbe
  169. }
  170. }
  171. },
  172. {
  173. {
  174. 63,
  175. {
  176. 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
  177. 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
  178. 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
  179. 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
  180. 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
  181. 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
  182. 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
  183. 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9
  184. }
  185. },
  186. {
  187. 32,
  188. {
  189. 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
  190. 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
  191. 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
  192. 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
  193. }
  194. },
  195. {
  196. 16,
  197. {
  198. 0x51, 0x54, 0xad, 0x0d, 0x2c, 0xb2, 0x6e, 0x01,
  199. 0x27, 0x4f, 0xc5, 0x11, 0x48, 0x49, 0x1f, 0x1b
  200. }
  201. },
  202. },
  203. /*
  204. * self-generated vectors exercise "significant" lengths, such that
  205. * are handled by different code paths
  206. */
  207. {
  208. {
  209. 64,
  210. {
  211. 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
  212. 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
  213. 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
  214. 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
  215. 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
  216. 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
  217. 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
  218. 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf
  219. }
  220. },
  221. {
  222. 32,
  223. {
  224. 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
  225. 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
  226. 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
  227. 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
  228. }
  229. },
  230. {
  231. 16,
  232. {
  233. 0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
  234. 0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66
  235. }
  236. },
  237. },
  238. {
  239. {
  240. 48,
  241. {
  242. 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
  243. 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
  244. 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
  245. 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
  246. 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
  247. 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67
  248. }
  249. },
  250. {
  251. 32,
  252. {
  253. 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
  254. 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
  255. 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
  256. 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
  257. }
  258. },
  259. {
  260. 16,
  261. {
  262. 0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
  263. 0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61
  264. }
  265. },
  266. },
  267. {
  268. {
  269. 96,
  270. {
  271. 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
  272. 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
  273. 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
  274. 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
  275. 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
  276. 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
  277. 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
  278. 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
  279. 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
  280. 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
  281. 0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
  282. 0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36
  283. }
  284. },
  285. {
  286. 32,
  287. {
  288. 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
  289. 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
  290. 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
  291. 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
  292. }
  293. },
  294. {
  295. 16,
  296. {
  297. 0xbb, 0xb6, 0x13, 0xb2, 0xb6, 0xd7, 0x53, 0xba,
  298. 0x07, 0x39, 0x5b, 0x91, 0x6a, 0xae, 0xce, 0x15
  299. }
  300. },
  301. },
  302. {
  303. {
  304. 112,
  305. {
  306. 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
  307. 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
  308. 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
  309. 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
  310. 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
  311. 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
  312. 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
  313. 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
  314. 0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
  315. 0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
  316. 0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
  317. 0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
  318. 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
  319. 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24
  320. }
  321. },
  322. {
  323. 32,
  324. {
  325. 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
  326. 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
  327. 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
  328. 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
  329. }
  330. },
  331. {
  332. 16,
  333. {
  334. 0xc7, 0x94, 0xd7, 0x05, 0x7d, 0x17, 0x78, 0xc4,
  335. 0xbb, 0xee, 0x0a, 0x39, 0xb3, 0xd9, 0x73, 0x42
  336. }
  337. },
  338. },
  339. {
  340. {
  341. 128,
  342. {
  343. 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
  344. 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
  345. 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
  346. 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
  347. 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
  348. 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
  349. 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
  350. 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
  351. 0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
  352. 0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
  353. 0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
  354. 0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
  355. 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
  356. 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
  357. 0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
  358. 0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36
  359. }
  360. },
  361. {
  362. 32,
  363. {
  364. 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
  365. 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
  366. 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
  367. 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
  368. }
  369. },
  370. {
  371. 16,
  372. {
  373. 0xff, 0xbc, 0xb9, 0xb3, 0x71, 0x42, 0x31, 0x52,
  374. 0xd7, 0xfc, 0xa5, 0xad, 0x04, 0x2f, 0xba, 0xa9
  375. }
  376. },
  377. },
  378. {
  379. {
  380. 144,
  381. {
  382. 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
  383. 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
  384. 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
  385. 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
  386. 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
  387. 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
  388. 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
  389. 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
  390. 0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
  391. 0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
  392. 0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
  393. 0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
  394. 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
  395. 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
  396. 0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
  397. 0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
  398. 0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
  399. 0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66
  400. }
  401. },
  402. {
  403. 32,
  404. {
  405. 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
  406. 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
  407. 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
  408. 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
  409. }
  410. },
  411. {
  412. 16,
  413. {
  414. 0x06, 0x9e, 0xd6, 0xb8, 0xef, 0x0f, 0x20, 0x7b,
  415. 0x3e, 0x24, 0x3b, 0xb1, 0x01, 0x9f, 0xe6, 0x32
  416. }
  417. },
  418. },
  419. {
  420. {
  421. 160,
  422. {
  423. 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
  424. 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
  425. 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
  426. 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
  427. 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
  428. 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
  429. 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
  430. 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
  431. 0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
  432. 0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
  433. 0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
  434. 0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
  435. 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
  436. 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
  437. 0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
  438. 0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
  439. 0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
  440. 0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66,
  441. 0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
  442. 0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61
  443. }
  444. },
  445. {
  446. 32,
  447. {
  448. 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
  449. 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
  450. 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
  451. 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
  452. }
  453. },
  454. {
  455. 16,
  456. {
  457. 0xcc, 0xa3, 0x39, 0xd9, 0xa4, 0x5f, 0xa2, 0x36,
  458. 0x8c, 0x2c, 0x68, 0xb3, 0xa4, 0x17, 0x91, 0x33
  459. }
  460. },
  461. },
  462. {
  463. {
  464. 288,
  465. {
  466. 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
  467. 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
  468. 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
  469. 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
  470. 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
  471. 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
  472. 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
  473. 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
  474. 0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
  475. 0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
  476. 0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
  477. 0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
  478. 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
  479. 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
  480. 0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
  481. 0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
  482. 0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
  483. 0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66,
  484. 0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
  485. 0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61,
  486. 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
  487. 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
  488. 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
  489. 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
  490. 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
  491. 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
  492. 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
  493. 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
  494. 0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
  495. 0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
  496. 0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
  497. 0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
  498. 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
  499. 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
  500. 0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
  501. 0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36
  502. }
  503. },
  504. {
  505. 32,
  506. {
  507. 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
  508. 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
  509. 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
  510. 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
  511. }
  512. },
  513. {
  514. 16,
  515. {
  516. 0x53, 0xf6, 0xe8, 0x28, 0xa2, 0xf0, 0xfe, 0x0e,
  517. 0xe8, 0x15, 0xbf, 0x0b, 0xd5, 0x84, 0x1a, 0x34
  518. }
  519. },
  520. },
  521. {
  522. {
  523. 320,
  524. {
  525. 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
  526. 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
  527. 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
  528. 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
  529. 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
  530. 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
  531. 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
  532. 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
  533. 0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
  534. 0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
  535. 0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
  536. 0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
  537. 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
  538. 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
  539. 0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
  540. 0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
  541. 0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
  542. 0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66,
  543. 0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
  544. 0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61,
  545. 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
  546. 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
  547. 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
  548. 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
  549. 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
  550. 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
  551. 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
  552. 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
  553. 0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
  554. 0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
  555. 0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
  556. 0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
  557. 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
  558. 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
  559. 0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
  560. 0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
  561. 0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
  562. 0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66,
  563. 0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
  564. 0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61
  565. }
  566. },
  567. {
  568. 32,
  569. {
  570. 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
  571. 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
  572. 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
  573. 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
  574. }
  575. },
  576. {
  577. 16,
  578. {
  579. 0xb8, 0x46, 0xd4, 0x4e, 0x9b, 0xbd, 0x53, 0xce,
  580. 0xdf, 0xfb, 0xfb, 0xb6, 0xb7, 0xfa, 0x49, 0x33
  581. }
  582. },
  583. },
  584. /*
  585. * 4th power of the key spills to 131th bit in SIMD key setup
  586. */
  587. {
  588. {
  589. 256,
  590. {
  591. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  592. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  593. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  594. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  595. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  596. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  597. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  598. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  599. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  600. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  601. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  602. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  603. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  604. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  605. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  606. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  607. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  608. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  609. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  610. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  611. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  612. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  613. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  614. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  615. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  616. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  617. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  618. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  619. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  620. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  621. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  622. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
  623. }
  624. },
  625. {
  626. 32,
  627. {
  628. 0xad, 0x62, 0x81, 0x07, 0xe8, 0x35, 0x1d, 0x0f,
  629. 0x2c, 0x23, 0x1a, 0x05, 0xdc, 0x4a, 0x41, 0x06,
  630. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  631. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  632. }
  633. },
  634. {
  635. 16,
  636. {
  637. 0x07, 0x14, 0x5a, 0x4c, 0x02, 0xfe, 0x5f, 0xa3,
  638. 0x20, 0x36, 0xde, 0x68, 0xfa, 0xbe, 0x90, 0x66
  639. }
  640. },
  641. },
  642. /*
  643. * poly1305_ieee754.c failed this in final stage
  644. */
  645. {
  646. {
  647. 252,
  648. {
  649. 0x84, 0x23, 0x64, 0xe1, 0x56, 0x33, 0x6c, 0x09,
  650. 0x98, 0xb9, 0x33, 0xa6, 0x23, 0x77, 0x26, 0x18,
  651. 0x0d, 0x9e, 0x3f, 0xdc, 0xbd, 0xe4, 0xcd, 0x5d,
  652. 0x17, 0x08, 0x0f, 0xc3, 0xbe, 0xb4, 0x96, 0x14,
  653. 0xd7, 0x12, 0x2c, 0x03, 0x74, 0x63, 0xff, 0x10,
  654. 0x4d, 0x73, 0xf1, 0x9c, 0x12, 0x70, 0x46, 0x28,
  655. 0xd4, 0x17, 0xc4, 0xc5, 0x4a, 0x3f, 0xe3, 0x0d,
  656. 0x3c, 0x3d, 0x77, 0x14, 0x38, 0x2d, 0x43, 0xb0,
  657. 0x38, 0x2a, 0x50, 0xa5, 0xde, 0xe5, 0x4b, 0xe8,
  658. 0x44, 0xb0, 0x76, 0xe8, 0xdf, 0x88, 0x20, 0x1a,
  659. 0x1c, 0xd4, 0x3b, 0x90, 0xeb, 0x21, 0x64, 0x3f,
  660. 0xa9, 0x6f, 0x39, 0xb5, 0x18, 0xaa, 0x83, 0x40,
  661. 0xc9, 0x42, 0xff, 0x3c, 0x31, 0xba, 0xf7, 0xc9,
  662. 0xbd, 0xbf, 0x0f, 0x31, 0xae, 0x3f, 0xa0, 0x96,
  663. 0xbf, 0x8c, 0x63, 0x03, 0x06, 0x09, 0x82, 0x9f,
  664. 0xe7, 0x2e, 0x17, 0x98, 0x24, 0x89, 0x0b, 0xc8,
  665. 0xe0, 0x8c, 0x31, 0x5c, 0x1c, 0xce, 0x2a, 0x83,
  666. 0x14, 0x4d, 0xbb, 0xff, 0x09, 0xf7, 0x4e, 0x3e,
  667. 0xfc, 0x77, 0x0b, 0x54, 0xd0, 0x98, 0x4a, 0x8f,
  668. 0x19, 0xb1, 0x47, 0x19, 0xe6, 0x36, 0x35, 0x64,
  669. 0x1d, 0x6b, 0x1e, 0xed, 0xf6, 0x3e, 0xfb, 0xf0,
  670. 0x80, 0xe1, 0x78, 0x3d, 0x32, 0x44, 0x54, 0x12,
  671. 0x11, 0x4c, 0x20, 0xde, 0x0b, 0x83, 0x7a, 0x0d,
  672. 0xfa, 0x33, 0xd6, 0xb8, 0x28, 0x25, 0xff, 0xf4,
  673. 0x4c, 0x9a, 0x70, 0xea, 0x54, 0xce, 0x47, 0xf0,
  674. 0x7d, 0xf6, 0x98, 0xe6, 0xb0, 0x33, 0x23, 0xb5,
  675. 0x30, 0x79, 0x36, 0x4a, 0x5f, 0xc3, 0xe9, 0xdd,
  676. 0x03, 0x43, 0x92, 0xbd, 0xde, 0x86, 0xdc, 0xcd,
  677. 0xda, 0x94, 0x32, 0x1c, 0x5e, 0x44, 0x06, 0x04,
  678. 0x89, 0x33, 0x6c, 0xb6, 0x5b, 0xf3, 0x98, 0x9c,
  679. 0x36, 0xf7, 0x28, 0x2c, 0x2f, 0x5d, 0x2b, 0x88,
  680. 0x2c, 0x17, 0x1e, 0x74
  681. }
  682. },
  683. {
  684. 32,
  685. {
  686. 0x95, 0xd5, 0xc0, 0x05, 0x50, 0x3e, 0x51, 0x0d,
  687. 0x8c, 0xd0, 0xaa, 0x07, 0x2c, 0x4a, 0x4d, 0x06,
  688. 0x6e, 0xab, 0xc5, 0x2d, 0x11, 0x65, 0x3d, 0xf4,
  689. 0x7f, 0xbf, 0x63, 0xab, 0x19, 0x8b, 0xcc, 0x26
  690. }
  691. },
  692. {
  693. 16,
  694. {
  695. 0xf2, 0x48, 0x31, 0x2e, 0x57, 0x8d, 0x9d, 0x58,
  696. 0xf8, 0xb7, 0xbb, 0x4d, 0x19, 0x10, 0x54, 0x31
  697. }
  698. },
  699. },
  700. /*
  701. * AVX2 in poly1305-x86.pl failed this with 176+32 split
  702. */
  703. {
  704. {
  705. 208,
  706. {
  707. 0x24, 0x8a, 0xc3, 0x10, 0x85, 0xb6, 0xc2, 0xad,
  708. 0xaa, 0xa3, 0x82, 0x59, 0xa0, 0xd7, 0x19, 0x2c,
  709. 0x5c, 0x35, 0xd1, 0xbb, 0x4e, 0xf3, 0x9a, 0xd9,
  710. 0x4c, 0x38, 0xd1, 0xc8, 0x24, 0x79, 0xe2, 0xdd,
  711. 0x21, 0x59, 0xa0, 0x77, 0x02, 0x4b, 0x05, 0x89,
  712. 0xbc, 0x8a, 0x20, 0x10, 0x1b, 0x50, 0x6f, 0x0a,
  713. 0x1a, 0xd0, 0xbb, 0xab, 0x76, 0xe8, 0x3a, 0x83,
  714. 0xf1, 0xb9, 0x4b, 0xe6, 0xbe, 0xae, 0x74, 0xe8,
  715. 0x74, 0xca, 0xb6, 0x92, 0xc5, 0x96, 0x3a, 0x75,
  716. 0x43, 0x6b, 0x77, 0x61, 0x21, 0xec, 0x9f, 0x62,
  717. 0x39, 0x9a, 0x3e, 0x66, 0xb2, 0xd2, 0x27, 0x07,
  718. 0xda, 0xe8, 0x19, 0x33, 0xb6, 0x27, 0x7f, 0x3c,
  719. 0x85, 0x16, 0xbc, 0xbe, 0x26, 0xdb, 0xbd, 0x86,
  720. 0xf3, 0x73, 0x10, 0x3d, 0x7c, 0xf4, 0xca, 0xd1,
  721. 0x88, 0x8c, 0x95, 0x21, 0x18, 0xfb, 0xfb, 0xd0,
  722. 0xd7, 0xb4, 0xbe, 0xdc, 0x4a, 0xe4, 0x93, 0x6a,
  723. 0xff, 0x91, 0x15, 0x7e, 0x7a, 0xa4, 0x7c, 0x54,
  724. 0x44, 0x2e, 0xa7, 0x8d, 0x6a, 0xc2, 0x51, 0xd3,
  725. 0x24, 0xa0, 0xfb, 0xe4, 0x9d, 0x89, 0xcc, 0x35,
  726. 0x21, 0xb6, 0x6d, 0x16, 0xe9, 0xc6, 0x6a, 0x37,
  727. 0x09, 0x89, 0x4e, 0x4e, 0xb0, 0xa4, 0xee, 0xdc,
  728. 0x4a, 0xe1, 0x94, 0x68, 0xe6, 0x6b, 0x81, 0xf2,
  729. 0x71, 0x35, 0x1b, 0x1d, 0x92, 0x1e, 0xa5, 0x51,
  730. 0x04, 0x7a, 0xbc, 0xc6, 0xb8, 0x7a, 0x90, 0x1f,
  731. 0xde, 0x7d, 0xb7, 0x9f, 0xa1, 0x81, 0x8c, 0x11,
  732. 0x33, 0x6d, 0xbc, 0x07, 0x24, 0x4a, 0x40, 0xeb
  733. }
  734. },
  735. {
  736. 32,
  737. {
  738. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  739. 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
  740. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  741. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  742. }
  743. },
  744. {
  745. 16,
  746. {
  747. 0xbc, 0x93, 0x9b, 0xc5, 0x28, 0x14, 0x80, 0xfa,
  748. 0x99, 0xc6, 0xd6, 0x8c, 0x25, 0x8e, 0xc4, 0x2f
  749. }
  750. },
  751. },
  752. /*
  753. * test vectors from Google
  754. */
  755. {
  756. {
  757. 0,
  758. {
  759. 0x00,
  760. }
  761. },
  762. {
  763. 32,
  764. {
  765. 0xc8, 0xaf, 0xaa, 0xc3, 0x31, 0xee, 0x37, 0x2c,
  766. 0xd6, 0x08, 0x2d, 0xe1, 0x34, 0x94, 0x3b, 0x17,
  767. 0x47, 0x10, 0x13, 0x0e, 0x9f, 0x6f, 0xea, 0x8d,
  768. 0x72, 0x29, 0x38, 0x50, 0xa6, 0x67, 0xd8, 0x6c
  769. }
  770. },
  771. {
  772. 16,
  773. {
  774. 0x47, 0x10, 0x13, 0x0e, 0x9f, 0x6f, 0xea, 0x8d,
  775. 0x72, 0x29, 0x38, 0x50, 0xa6, 0x67, 0xd8, 0x6c
  776. }
  777. },
  778. },
  779. {
  780. {
  781. 12,
  782. {
  783. 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f,
  784. 0x72, 0x6c, 0x64, 0x21
  785. }
  786. },
  787. {
  788. 32,
  789. {
  790. 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
  791. 0x33, 0x32, 0x2d, 0x62, 0x79, 0x74, 0x65, 0x20,
  792. 0x6b, 0x65, 0x79, 0x20, 0x66, 0x6f, 0x72, 0x20,
  793. 0x50, 0x6f, 0x6c, 0x79, 0x31, 0x33, 0x30, 0x35
  794. }
  795. },
  796. {
  797. 16,
  798. {
  799. 0xa6, 0xf7, 0x45, 0x00, 0x8f, 0x81, 0xc9, 0x16,
  800. 0xa2, 0x0d, 0xcc, 0x74, 0xee, 0xf2, 0xb2, 0xf0
  801. }
  802. },
  803. },
  804. {
  805. {
  806. 32,
  807. {
  808. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  809. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  810. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  811. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  812. }
  813. },
  814. {
  815. 32,
  816. {
  817. 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
  818. 0x33, 0x32, 0x2d, 0x62, 0x79, 0x74, 0x65, 0x20,
  819. 0x6b, 0x65, 0x79, 0x20, 0x66, 0x6f, 0x72, 0x20,
  820. 0x50, 0x6f, 0x6c, 0x79, 0x31, 0x33, 0x30, 0x35
  821. }
  822. },
  823. {
  824. 16,
  825. {
  826. 0x49, 0xec, 0x78, 0x09, 0x0e, 0x48, 0x1e, 0xc6,
  827. 0xc2, 0x6b, 0x33, 0xb9, 0x1c, 0xcc, 0x03, 0x07
  828. }
  829. },
  830. },
  831. {
  832. {
  833. 128,
  834. {
  835. 0x89, 0xda, 0xb8, 0x0b, 0x77, 0x17, 0xc1, 0xdb,
  836. 0x5d, 0xb4, 0x37, 0x86, 0x0a, 0x3f, 0x70, 0x21,
  837. 0x8e, 0x93, 0xe1, 0xb8, 0xf4, 0x61, 0xfb, 0x67,
  838. 0x7f, 0x16, 0xf3, 0x5f, 0x6f, 0x87, 0xe2, 0xa9,
  839. 0x1c, 0x99, 0xbc, 0x3a, 0x47, 0xac, 0xe4, 0x76,
  840. 0x40, 0xcc, 0x95, 0xc3, 0x45, 0xbe, 0x5e, 0xcc,
  841. 0xa5, 0xa3, 0x52, 0x3c, 0x35, 0xcc, 0x01, 0x89,
  842. 0x3a, 0xf0, 0xb6, 0x4a, 0x62, 0x03, 0x34, 0x27,
  843. 0x03, 0x72, 0xec, 0x12, 0x48, 0x2d, 0x1b, 0x1e,
  844. 0x36, 0x35, 0x61, 0x69, 0x8a, 0x57, 0x8b, 0x35,
  845. 0x98, 0x03, 0x49, 0x5b, 0xb4, 0xe2, 0xef, 0x19,
  846. 0x30, 0xb1, 0x7a, 0x51, 0x90, 0xb5, 0x80, 0xf1,
  847. 0x41, 0x30, 0x0d, 0xf3, 0x0a, 0xdb, 0xec, 0xa2,
  848. 0x8f, 0x64, 0x27, 0xa8, 0xbc, 0x1a, 0x99, 0x9f,
  849. 0xd5, 0x1c, 0x55, 0x4a, 0x01, 0x7d, 0x09, 0x5d,
  850. 0x8c, 0x3e, 0x31, 0x27, 0xda, 0xf9, 0xf5, 0x95
  851. }
  852. },
  853. {
  854. 32,
  855. {
  856. 0x2d, 0x77, 0x3b, 0xe3, 0x7a, 0xdb, 0x1e, 0x4d,
  857. 0x68, 0x3b, 0xf0, 0x07, 0x5e, 0x79, 0xc4, 0xee,
  858. 0x03, 0x79, 0x18, 0x53, 0x5a, 0x7f, 0x99, 0xcc,
  859. 0xb7, 0x04, 0x0f, 0xb5, 0xf5, 0xf4, 0x3a, 0xea
  860. }
  861. },
  862. {
  863. 16,
  864. {
  865. 0xc8, 0x5d, 0x15, 0xed, 0x44, 0xc3, 0x78, 0xd6,
  866. 0xb0, 0x0e, 0x23, 0x06, 0x4c, 0x7b, 0xcd, 0x51
  867. }
  868. },
  869. },
  870. {
  871. {
  872. 528,
  873. {
  874. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b,
  875. 0x17, 0x03, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00,
  876. 0x06, 0xdb, 0x1f, 0x1f, 0x36, 0x8d, 0x69, 0x6a,
  877. 0x81, 0x0a, 0x34, 0x9c, 0x0c, 0x71, 0x4c, 0x9a,
  878. 0x5e, 0x78, 0x50, 0xc2, 0x40, 0x7d, 0x72, 0x1a,
  879. 0xcd, 0xed, 0x95, 0xe0, 0x18, 0xd7, 0xa8, 0x52,
  880. 0x66, 0xa6, 0xe1, 0x28, 0x9c, 0xdb, 0x4a, 0xeb,
  881. 0x18, 0xda, 0x5a, 0xc8, 0xa2, 0xb0, 0x02, 0x6d,
  882. 0x24, 0xa5, 0x9a, 0xd4, 0x85, 0x22, 0x7f, 0x3e,
  883. 0xae, 0xdb, 0xb2, 0xe7, 0xe3, 0x5e, 0x1c, 0x66,
  884. 0xcd, 0x60, 0xf9, 0xab, 0xf7, 0x16, 0xdc, 0xc9,
  885. 0xac, 0x42, 0x68, 0x2d, 0xd7, 0xda, 0xb2, 0x87,
  886. 0xa7, 0x02, 0x4c, 0x4e, 0xef, 0xc3, 0x21, 0xcc,
  887. 0x05, 0x74, 0xe1, 0x67, 0x93, 0xe3, 0x7c, 0xec,
  888. 0x03, 0xc5, 0xbd, 0xa4, 0x2b, 0x54, 0xc1, 0x14,
  889. 0xa8, 0x0b, 0x57, 0xaf, 0x26, 0x41, 0x6c, 0x7b,
  890. 0xe7, 0x42, 0x00, 0x5e, 0x20, 0x85, 0x5c, 0x73,
  891. 0xe2, 0x1d, 0xc8, 0xe2, 0xed, 0xc9, 0xd4, 0x35,
  892. 0xcb, 0x6f, 0x60, 0x59, 0x28, 0x00, 0x11, 0xc2,
  893. 0x70, 0xb7, 0x15, 0x70, 0x05, 0x1c, 0x1c, 0x9b,
  894. 0x30, 0x52, 0x12, 0x66, 0x20, 0xbc, 0x1e, 0x27,
  895. 0x30, 0xfa, 0x06, 0x6c, 0x7a, 0x50, 0x9d, 0x53,
  896. 0xc6, 0x0e, 0x5a, 0xe1, 0xb4, 0x0a, 0xa6, 0xe3,
  897. 0x9e, 0x49, 0x66, 0x92, 0x28, 0xc9, 0x0e, 0xec,
  898. 0xb4, 0xa5, 0x0d, 0xb3, 0x2a, 0x50, 0xbc, 0x49,
  899. 0xe9, 0x0b, 0x4f, 0x4b, 0x35, 0x9a, 0x1d, 0xfd,
  900. 0x11, 0x74, 0x9c, 0xd3, 0x86, 0x7f, 0xcf, 0x2f,
  901. 0xb7, 0xbb, 0x6c, 0xd4, 0x73, 0x8f, 0x6a, 0x4a,
  902. 0xd6, 0xf7, 0xca, 0x50, 0x58, 0xf7, 0x61, 0x88,
  903. 0x45, 0xaf, 0x9f, 0x02, 0x0f, 0x6c, 0x3b, 0x96,
  904. 0x7b, 0x8f, 0x4c, 0xd4, 0xa9, 0x1e, 0x28, 0x13,
  905. 0xb5, 0x07, 0xae, 0x66, 0xf2, 0xd3, 0x5c, 0x18,
  906. 0x28, 0x4f, 0x72, 0x92, 0x18, 0x60, 0x62, 0xe1,
  907. 0x0f, 0xd5, 0x51, 0x0d, 0x18, 0x77, 0x53, 0x51,
  908. 0xef, 0x33, 0x4e, 0x76, 0x34, 0xab, 0x47, 0x43,
  909. 0xf5, 0xb6, 0x8f, 0x49, 0xad, 0xca, 0xb3, 0x84,
  910. 0xd3, 0xfd, 0x75, 0xf7, 0x39, 0x0f, 0x40, 0x06,
  911. 0xef, 0x2a, 0x29, 0x5c, 0x8c, 0x7a, 0x07, 0x6a,
  912. 0xd5, 0x45, 0x46, 0xcd, 0x25, 0xd2, 0x10, 0x7f,
  913. 0xbe, 0x14, 0x36, 0xc8, 0x40, 0x92, 0x4a, 0xae,
  914. 0xbe, 0x5b, 0x37, 0x08, 0x93, 0xcd, 0x63, 0xd1,
  915. 0x32, 0x5b, 0x86, 0x16, 0xfc, 0x48, 0x10, 0x88,
  916. 0x6b, 0xc1, 0x52, 0xc5, 0x32, 0x21, 0xb6, 0xdf,
  917. 0x37, 0x31, 0x19, 0x39, 0x32, 0x55, 0xee, 0x72,
  918. 0xbc, 0xaa, 0x88, 0x01, 0x74, 0xf1, 0x71, 0x7f,
  919. 0x91, 0x84, 0xfa, 0x91, 0x64, 0x6f, 0x17, 0xa2,
  920. 0x4a, 0xc5, 0x5d, 0x16, 0xbf, 0xdd, 0xca, 0x95,
  921. 0x81, 0xa9, 0x2e, 0xda, 0x47, 0x92, 0x01, 0xf0,
  922. 0xed, 0xbf, 0x63, 0x36, 0x00, 0xd6, 0x06, 0x6d,
  923. 0x1a, 0xb3, 0x6d, 0x5d, 0x24, 0x15, 0xd7, 0x13,
  924. 0x51, 0xbb, 0xcd, 0x60, 0x8a, 0x25, 0x10, 0x8d,
  925. 0x25, 0x64, 0x19, 0x92, 0xc1, 0xf2, 0x6c, 0x53,
  926. 0x1c, 0xf9, 0xf9, 0x02, 0x03, 0xbc, 0x4c, 0xc1,
  927. 0x9f, 0x59, 0x27, 0xd8, 0x34, 0xb0, 0xa4, 0x71,
  928. 0x16, 0xd3, 0x88, 0x4b, 0xbb, 0x16, 0x4b, 0x8e,
  929. 0xc8, 0x83, 0xd1, 0xac, 0x83, 0x2e, 0x56, 0xb3,
  930. 0x91, 0x8a, 0x98, 0x60, 0x1a, 0x08, 0xd1, 0x71,
  931. 0x88, 0x15, 0x41, 0xd5, 0x94, 0xdb, 0x39, 0x9c,
  932. 0x6a, 0xe6, 0x15, 0x12, 0x21, 0x74, 0x5a, 0xec,
  933. 0x81, 0x4c, 0x45, 0xb0, 0xb0, 0x5b, 0x56, 0x54,
  934. 0x36, 0xfd, 0x6f, 0x13, 0x7a, 0xa1, 0x0a, 0x0c,
  935. 0x0b, 0x64, 0x37, 0x61, 0xdb, 0xd6, 0xf9, 0xa9,
  936. 0xdc, 0xb9, 0x9b, 0x1a, 0x6e, 0x69, 0x08, 0x54,
  937. 0xce, 0x07, 0x69, 0xcd, 0xe3, 0x97, 0x61, 0xd8,
  938. 0x2f, 0xcd, 0xec, 0x15, 0xf0, 0xd9, 0x2d, 0x7d,
  939. 0x8e, 0x94, 0xad, 0xe8, 0xeb, 0x83, 0xfb, 0xe0
  940. }
  941. },
  942. {
  943. 32,
  944. {
  945. 0x99, 0xe5, 0x82, 0x2d, 0xd4, 0x17, 0x3c, 0x99,
  946. 0x5e, 0x3d, 0xae, 0x0d, 0xde, 0xfb, 0x97, 0x74,
  947. 0x3f, 0xde, 0x3b, 0x08, 0x01, 0x34, 0xb3, 0x9f,
  948. 0x76, 0xe9, 0xbf, 0x8d, 0x0e, 0x88, 0xd5, 0x46
  949. }
  950. },
  951. {
  952. 16,
  953. {
  954. 0x26, 0x37, 0x40, 0x8f, 0xe1, 0x30, 0x86, 0xea,
  955. 0x73, 0xf9, 0x71, 0xe3, 0x42, 0x5e, 0x28, 0x20
  956. }
  957. },
  958. },
  959. /*
  960. * test vectors from Hanno Böck
  961. */
  962. {
  963. {
  964. 257,
  965. {
  966. 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
  967. 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
  968. 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
  969. 0xcc, 0x80, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
  970. 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
  971. 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
  972. 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
  973. 0xcc, 0xcc, 0xcc, 0xcc, 0xce, 0xcc, 0xcc, 0xcc,
  974. 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
  975. 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xc5,
  976. 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
  977. 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
  978. 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xe3, 0xcc, 0xcc,
  979. 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
  980. 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
  981. 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
  982. 0xcc, 0xcc, 0xcc, 0xcc, 0xac, 0xcc, 0xcc, 0xcc,
  983. 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xe6,
  984. 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x00, 0x00, 0x00,
  985. 0xaf, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
  986. 0xcc, 0xcc, 0xff, 0xff, 0xff, 0xf5, 0x00, 0x00,
  987. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  988. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  989. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  990. 0x00, 0xff, 0xff, 0xff, 0xe7, 0x00, 0x00, 0x00,
  991. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  992. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  993. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  994. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  995. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  996. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  997. 0x00, 0x00, 0x71, 0x92, 0x05, 0xa8, 0x52, 0x1d,
  998. 0xfc
  999. }
  1000. },
  1001. {
  1002. 32,
  1003. {
  1004. 0x7f, 0x1b, 0x02, 0x64, 0x00, 0x00, 0x00, 0x00,
  1005. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1006. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1007. 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc
  1008. }
  1009. },
  1010. {
  1011. 16,
  1012. {
  1013. 0x85, 0x59, 0xb8, 0x76, 0xec, 0xee, 0xd6, 0x6e,
  1014. 0xb3, 0x77, 0x98, 0xc0, 0x45, 0x7b, 0xaf, 0xf9
  1015. }
  1016. },
  1017. },
  1018. {
  1019. {
  1020. 39,
  1021. {
  1022. 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
  1023. 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
  1024. 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
  1025. 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00,
  1026. 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x64
  1027. }
  1028. },
  1029. {
  1030. 32,
  1031. {
  1032. 0xe0, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00,
  1033. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1034. 0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
  1035. 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa
  1036. }
  1037. },
  1038. {
  1039. 16,
  1040. {
  1041. 0x00, 0xbd, 0x12, 0x58, 0x97, 0x8e, 0x20, 0x54,
  1042. 0x44, 0xc9, 0xaa, 0xaa, 0x82, 0x00, 0x6f, 0xed
  1043. }
  1044. },
  1045. },
  1046. {
  1047. {
  1048. 2,
  1049. {
  1050. 0x02, 0xfc
  1051. }
  1052. },
  1053. {
  1054. 32,
  1055. {
  1056. 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
  1057. 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
  1058. 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
  1059. 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c
  1060. }
  1061. },
  1062. {
  1063. 16,
  1064. {
  1065. 0x06, 0x12, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
  1066. 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c
  1067. }
  1068. },
  1069. },
  1070. {
  1071. {
  1072. 415,
  1073. {
  1074. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1075. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1076. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1077. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1078. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7a, 0x7b,
  1079. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1080. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1081. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1082. 0x7b, 0x7b, 0x5c, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1083. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1084. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1085. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1086. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1087. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1088. 0x7b, 0x7b, 0x7b, 0x7b, 0x6e, 0x7b, 0x00, 0x7b,
  1089. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1090. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1091. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1092. 0x7b, 0x7b, 0x7b, 0x7a, 0x7b, 0x7b, 0x7b, 0x7b,
  1093. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1094. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1095. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x5c,
  1096. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1097. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1098. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1099. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1100. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1101. 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
  1102. 0x7b, 0x6e, 0x7b, 0x00, 0x13, 0x00, 0x00, 0x00,
  1103. 0x00, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1104. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1105. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1106. 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1107. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1108. 0x00, 0x00, 0x00, 0x20, 0x00, 0xef, 0xff, 0x00,
  1109. 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1110. 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
  1111. 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x64, 0x00,
  1112. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1113. 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00,
  1114. 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1115. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1116. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2,
  1117. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1118. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1119. 0x00, 0x00, 0x20, 0x00, 0xef, 0xff, 0x00, 0x09,
  1120. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1121. 0x00, 0x7a, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
  1122. 0x00, 0x09, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00,
  1123. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1124. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1125. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc
  1126. }
  1127. },
  1128. {
  1129. 32,
  1130. {
  1131. 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1132. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1133. 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00,
  1134. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, 0x7b
  1135. }
  1136. },
  1137. {
  1138. 16,
  1139. {
  1140. 0x33, 0x20, 0x5b, 0xbf, 0x9e, 0x9f, 0x8f, 0x72,
  1141. 0x12, 0xab, 0x9e, 0x2a, 0xb9, 0xb7, 0xe4, 0xa5
  1142. }
  1143. },
  1144. },
  1145. {
  1146. {
  1147. 118,
  1148. {
  1149. 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
  1150. 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
  1151. 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
  1152. 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
  1153. 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
  1154. 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
  1155. 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
  1156. 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
  1157. 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
  1158. 0x77, 0x77, 0x77, 0x77, 0xff, 0xff, 0xff, 0xe9,
  1159. 0xe9, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac,
  1160. 0xac, 0xac, 0xac, 0xac, 0x00, 0x00, 0xac, 0xac,
  1161. 0xec, 0x01, 0x00, 0xac, 0xac, 0xac, 0x2c, 0xac,
  1162. 0xa2, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac,
  1163. 0xac, 0xac, 0xac, 0xac, 0x64, 0xf2
  1164. }
  1165. },
  1166. {
  1167. 32,
  1168. {
  1169. 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x7f,
  1170. 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
  1171. 0x00, 0x00, 0xcf, 0x77, 0x77, 0x77, 0x77, 0x77,
  1172. 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77
  1173. }
  1174. },
  1175. {
  1176. 16,
  1177. {
  1178. 0x02, 0xee, 0x7c, 0x8c, 0x54, 0x6d, 0xde, 0xb1,
  1179. 0xa4, 0x67, 0xe4, 0xc3, 0x98, 0x11, 0x58, 0xb9
  1180. }
  1181. },
  1182. },
  1183. /*
  1184. * test vectors from Andrew Moon
  1185. */
  1186. { /* nacl */
  1187. {
  1188. 131,
  1189. {
  1190. 0x8e, 0x99, 0x3b, 0x9f, 0x48, 0x68, 0x12, 0x73,
  1191. 0xc2, 0x96, 0x50, 0xba, 0x32, 0xfc, 0x76, 0xce,
  1192. 0x48, 0x33, 0x2e, 0xa7, 0x16, 0x4d, 0x96, 0xa4,
  1193. 0x47, 0x6f, 0xb8, 0xc5, 0x31, 0xa1, 0x18, 0x6a,
  1194. 0xc0, 0xdf, 0xc1, 0x7c, 0x98, 0xdc, 0xe8, 0x7b,
  1195. 0x4d, 0xa7, 0xf0, 0x11, 0xec, 0x48, 0xc9, 0x72,
  1196. 0x71, 0xd2, 0xc2, 0x0f, 0x9b, 0x92, 0x8f, 0xe2,
  1197. 0x27, 0x0d, 0x6f, 0xb8, 0x63, 0xd5, 0x17, 0x38,
  1198. 0xb4, 0x8e, 0xee, 0xe3, 0x14, 0xa7, 0xcc, 0x8a,
  1199. 0xb9, 0x32, 0x16, 0x45, 0x48, 0xe5, 0x26, 0xae,
  1200. 0x90, 0x22, 0x43, 0x68, 0x51, 0x7a, 0xcf, 0xea,
  1201. 0xbd, 0x6b, 0xb3, 0x73, 0x2b, 0xc0, 0xe9, 0xda,
  1202. 0x99, 0x83, 0x2b, 0x61, 0xca, 0x01, 0xb6, 0xde,
  1203. 0x56, 0x24, 0x4a, 0x9e, 0x88, 0xd5, 0xf9, 0xb3,
  1204. 0x79, 0x73, 0xf6, 0x22, 0xa4, 0x3d, 0x14, 0xa6,
  1205. 0x59, 0x9b, 0x1f, 0x65, 0x4c, 0xb4, 0x5a, 0x74,
  1206. 0xe3, 0x55, 0xa5
  1207. }
  1208. },
  1209. {
  1210. 32,
  1211. {
  1212. 0xee, 0xa6, 0xa7, 0x25, 0x1c, 0x1e, 0x72, 0x91,
  1213. 0x6d, 0x11, 0xc2, 0xcb, 0x21, 0x4d, 0x3c, 0x25,
  1214. 0x25, 0x39, 0x12, 0x1d, 0x8e, 0x23, 0x4e, 0x65,
  1215. 0x2d, 0x65, 0x1f, 0xa4, 0xc8, 0xcf, 0xf8, 0x80
  1216. }
  1217. },
  1218. {
  1219. 16,
  1220. {
  1221. 0xf3, 0xff, 0xc7, 0x70, 0x3f, 0x94, 0x00, 0xe5,
  1222. 0x2a, 0x7d, 0xfb, 0x4b, 0x3d, 0x33, 0x05, 0xd9
  1223. }
  1224. },
  1225. },
  1226. { /* wrap 2^130-5 */
  1227. {
  1228. 16,
  1229. {
  1230. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1231. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
  1232. }
  1233. },
  1234. {
  1235. 32,
  1236. {
  1237. 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1238. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1239. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1240. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  1241. }
  1242. },
  1243. {
  1244. 16,
  1245. {
  1246. 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1247. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  1248. }
  1249. },
  1250. },
  1251. { /* wrap 2^128 */
  1252. {
  1253. 16,
  1254. {
  1255. 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1256. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  1257. }
  1258. },
  1259. {
  1260. 32,
  1261. {
  1262. 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1263. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1264. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1265. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
  1266. }
  1267. },
  1268. {
  1269. 16,
  1270. {
  1271. 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1272. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  1273. }
  1274. },
  1275. },
  1276. { /* limb carry */
  1277. {
  1278. 48,
  1279. {
  1280. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1281. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1282. 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1283. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1284. 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1285. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  1286. }
  1287. },
  1288. {
  1289. 32,
  1290. {
  1291. 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1292. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1293. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1294. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  1295. }
  1296. },
  1297. {
  1298. 16,
  1299. {
  1300. 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1301. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  1302. }
  1303. },
  1304. },
  1305. { /* 2^130-5 */
  1306. {
  1307. 48,
  1308. {
  1309. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1310. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1311. 0xfb, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
  1312. 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
  1313. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  1314. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01
  1315. }
  1316. },
  1317. {
  1318. 32,
  1319. {
  1320. 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1321. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1322. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1323. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  1324. }
  1325. },
  1326. {
  1327. 16,
  1328. {
  1329. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1330. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  1331. }
  1332. },
  1333. },
  1334. { /* 2^130-6 */
  1335. {
  1336. 16,
  1337. {
  1338. 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1339. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
  1340. }
  1341. },
  1342. {
  1343. 32,
  1344. {
  1345. 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1346. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1347. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1348. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  1349. }
  1350. },
  1351. {
  1352. 16,
  1353. {
  1354. 0xfa, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1355. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
  1356. }
  1357. },
  1358. },
  1359. { /* 5*H+L reduction intermediate */
  1360. {
  1361. 64,
  1362. {
  1363. 0xe3, 0x35, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0xb9,
  1364. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1365. 0x33, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0x79, 0xcd,
  1366. 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1367. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1368. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1369. 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1370. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  1371. }
  1372. },
  1373. {
  1374. 32,
  1375. {
  1376. 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1377. 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1378. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1379. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  1380. }
  1381. },
  1382. {
  1383. 16,
  1384. {
  1385. 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1386. 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  1387. }
  1388. },
  1389. },
  1390. { /* 5*H+L reduction final */
  1391. {
  1392. 48,
  1393. {
  1394. 0xe3, 0x35, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0xb9,
  1395. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1396. 0x33, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0x79, 0xcd,
  1397. 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1398. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1399. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  1400. }
  1401. },
  1402. {
  1403. 32,
  1404. {
  1405. 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1406. 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1407. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1408. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  1409. }
  1410. },
  1411. {
  1412. 16,
  1413. {
  1414. 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1415. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  1416. }
  1417. }
  1418. }
  1419. };
  1420. static int test_poly1305(int idx)
  1421. {
  1422. POLY1305 poly1305;
  1423. const TESTDATA test = tests[idx];
  1424. const unsigned char *in = test.input.data;
  1425. size_t inlen = test.input.size;
  1426. const unsigned char *key = test.key.data;
  1427. const unsigned char *expected = test.expected.data;
  1428. size_t expectedlen = test.expected.size;
  1429. unsigned char out[16];
  1430. if (!TEST_size_t_eq(expectedlen, sizeof(out)))
  1431. return 0;
  1432. Poly1305_Init(&poly1305, key);
  1433. Poly1305_Update(&poly1305, in, inlen);
  1434. Poly1305_Final(&poly1305, out);
  1435. if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
  1436. TEST_info("Poly1305 test #%d failed.", idx);
  1437. return 0;
  1438. }
  1439. if (inlen > 16) {
  1440. Poly1305_Init(&poly1305, key);
  1441. Poly1305_Update(&poly1305, in, 1);
  1442. Poly1305_Update(&poly1305, in+1, inlen-1);
  1443. Poly1305_Final(&poly1305, out);
  1444. if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
  1445. TEST_info("Poly1305 test #%d/1+(N-1) failed.", idx);
  1446. return 0;
  1447. }
  1448. }
  1449. if (inlen > 32) {
  1450. size_t half = inlen / 2;
  1451. Poly1305_Init(&poly1305, key);
  1452. Poly1305_Update(&poly1305, in, half);
  1453. Poly1305_Update(&poly1305, in+half, inlen-half);
  1454. Poly1305_Final(&poly1305, out);
  1455. if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
  1456. TEST_info("Poly1305 test #%d/2 failed.", idx);
  1457. return 0;
  1458. }
  1459. for (half = 16; half < inlen; half += 16) {
  1460. Poly1305_Init(&poly1305, key);
  1461. Poly1305_Update(&poly1305, in, half);
  1462. Poly1305_Update(&poly1305, in+half, inlen-half);
  1463. Poly1305_Final(&poly1305, out);
  1464. if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
  1465. TEST_info("Poly1305 test #%d/%zu+%zu failed.",
  1466. idx, half, inlen-half);
  1467. return 0;
  1468. }
  1469. }
  1470. }
  1471. return 1;
  1472. }
  1473. int test_main(int argc, char **argv)
  1474. {
  1475. int result = 0;
  1476. int iter_argv;
  1477. int benchmark = 0;
  1478. for (iter_argv = 1; iter_argv < argc; iter_argv++) {
  1479. if (strcmp(argv[iter_argv], "-b") == 0)
  1480. benchmark = 1;
  1481. else if (strcmp(argv[iter_argv], "-h") == 0)
  1482. goto help;
  1483. }
  1484. ADD_ALL_TESTS(test_poly1305, OSSL_NELEM(tests));
  1485. result = run_tests(argv[0]);
  1486. if (benchmark)
  1487. benchmark_poly1305();
  1488. return result;
  1489. help:
  1490. printf("-h\tThis help\n");
  1491. printf("-b\tBenchmark in addition to the tests\n");
  1492. return 0;
  1493. }