poly1305_internal_test.c 56 KB

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