needs tests/harness num/poly1305 lib/func \ tests made against poly1305-donna : readallclose<< ( dst "name" -- len ) -1 word openpath r! read r> close ; 0 value MSG_LEN testbegin \test initialization create KEY 32 allot [: bi 1+ | KEY + c! :] 32 timesi KEY newPoly1305 const POLY create expected map< , $00030201 $01c18101 $00a08080 $0030302c $00000f0e POLY polyr expected 5 []= #true create expected map< , $14131211 $18171615 $1c1b1a19 $201f1e1d POLY polypad expected 4 []= #true \test single block create MSG ,"This is a long enough message to test." MSG 16 POLY blocks create expected map< , $01bed2ae $020c4a9a $021e86c8 $012ae179 $03a146ba POLY polyh expected 5 []= #true \test multiple blocks KEY POLY Poly1305$ MSG 38 POLY blocks create expected map< , $039d89d7 $010befab $018df0e2 $00b2d428 $009b1d2b POLY polyh expected 5 []= #true \test finish create expected map< c, $e8 $9b $b0 $c3 $d3 $45 $3b $26 $f8 $32 $25 $d1 $49 $49 $3c $bb POLY finish expected 16 c[]= #true \test single update create expected map< c, $98 $f7 $fa $71 $04 $34 $96 $70 $c6 $69 $e4 $2c $98 $7c $70 $e9 KEY POLY Poly1305$ MSG 38 POLY update POLY finish expected 16 c[]= #true \test multiple updates KEY POLY Poly1305$ MSG 13 POLY update MSG 13 + 15 POLY update MSG 28 + 10 POLY update POLY finish expected 16 c[]= #true \test verify \ differents by a single bit create data1 map< c, $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $a $b $c $d $e $f create data2 map< c, $0 $1 $2 $3 $4 $5 $6 $8 $8 $9 $a $b $c $d $e $f data1 data1 verify #true data1 data2 verify not #true data2 data1 verify not #true data2 data2 verify #true \test donna self-test create DONNA_MAC map< c, $dd $b9 $da $7d $dd $5e $52 $79 $27 $30 $ed $5c $da $5f $90 $a4 create DONNA_KEY 32 allot [: bi 221 + | DONNA_KEY + c! :] 32 timesi create DONNA_MSG 73 allot [: bi 121 + | DONNA_MSG + c! :] 73 timesi DONNA_KEY POLY Poly1305$ DONNA_MSG 73 POLY update POLY finish DONNA_MAC 16 c[]= #true \test donna NaCL batch create NACL_KEY map< c, $ee $a6 $a7 $25 $1c $1e $72 $91 $6d $11 $c2 $cb $21 $4d $3c $25 \ $25 $39 $12 $1d $8e $23 $4e $65 $2d $65 $1f $a4 $c8 $cf $f8 $80 create NACL_MSG 200 allot NACL_MSG readallclose<< data/tests/poly1305/msg1.bin to MSG_LEN create NACL_MAC map< c, $f3 $ff $c7 $70 $3f $94 $00 $e5 $2a $7d $fb $4b $3d $33 $05 $d9 NACL_KEY POLY Poly1305$ NACL_MSG MSG_LEN POLY update POLY finish NACL_MAC 16 c[]= #true \test donna NaCL incremental NACL_KEY POLY Poly1305$ NACL_MSG 000 + 32 POLY update NACL_MSG 032 + 64 POLY update NACL_MSG 096 + 16 POLY update NACL_MSG 112 + 08 POLY update NACL_MSG 120 + 04 POLY update NACL_MSG 124 + 02 POLY update NACL_MSG 126 + 01 POLY update NACL_MSG 127 + 01 POLY update NACL_MSG 128 + 01 POLY update NACL_MSG 129 + 01 POLY update NACL_MSG 130 + 01 POLY update POLY finish NACL_MAC 16 c[]= #true \test donna wrap create WRAP_KEY map< c, $02 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 \ $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 create WRAP_MSG map< c, $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff create WRAP_MAC map< c, $03 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 WRAP_KEY POLY Poly1305$ WRAP_MSG 16 POLY update POLY finish WRAP_MAC 16 c[]= #true \ tests below come from RFC 8439 create MSG 400 allot 0 value MSG_LEN \test text1 create KEY map< c, $36 $e5 $f6 $b5 $c5 $e0 $60 $70 $f0 $ef $ca $96 $22 $7a $86 $3e \ $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 MSG readallclose<< data/tests/chacha/plain2.txt to MSG_LEN create MAC map< c, $f3 $47 $7e $7c $d9 $54 $17 $af $89 $a6 $b8 $79 $4c $31 $0c $f0 KEY POLY Poly1305$ MSG MSG_LEN POLY update POLY finish MAC 16 c[]= #true \test text1 r=0 create KEY map< c, $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 \ $36 $e5 $f6 $b5 $c5 $e0 $60 $70 $f0 $ef $ca $96 $22 $7a $86 $3e create MAC map< c, $36 $e5 $f6 $b5 $c5 $e0 $60 $70 $f0 $ef $ca $96 $22 $7a $86 $3e KEY POLY Poly1305$ MSG MSG_LEN POLY update POLY finish MAC 16 c[]= #true \test text2 create KEY map< c, $1c $92 $40 $a5 $eb $55 $d3 $8a $f3 $33 $88 $86 $04 $f6 $b5 $f0 \ $47 $39 $17 $c1 $40 $2b $80 $09 $9d $ca $5c $bc $20 $70 $75 $c0 MSG readallclose<< data/tests/poly1305/msg2.txt to MSG_LEN create MAC map< c, $45 $41 $66 $9a $7e $aa $ee $61 $e7 $08 $dc $7c $bc $c5 $eb $62 KEY POLY Poly1305$ MSG MSG_LEN POLY update POLY finish MAC 16 c[]= #true \test carry from lower data limbs create KEY map< c, $01 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 \ $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 create MSG map< c, $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff \ $f0 $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff \ $11 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 create MAC map< c, $05 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 KEY POLY Poly1305$ MSG 48 POLY update POLY finish MAC 16 c[]= #true \test final result is exactly 2^130-5 create MSG map< c, $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff \ $fb $fe $fe $fe $fe $fe $fe $fe $fe $fe $fe $fe $fe $fe $fe $fe \ $01 $01 $01 $01 $01 $01 $01 $01 $01 $01 $01 $01 $01 $01 $01 $01 create MAC map< c, $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 KEY POLY Poly1305$ MSG 48 POLY update POLY finish MAC 16 c[]= #true \test final result is exactly 2^130-6 create KEY map< c, $02 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 \ $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 create MSG map< c, $fd $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff create MAC map< c, $fa $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff $ff KEY POLY Poly1305$ MSG 16 POLY update POLY finish MAC 16 c[]= #true \test reduction produces 131-bit intermediate result create KEY map< c, $01 $00 $00 $00 $00 $00 $00 $00 $04 $00 $00 $00 $00 $00 $00 $00 \ $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 create MSG map< c, $e3 $35 $94 $d7 $50 $5e $43 $b9 $00 $00 $00 $00 $00 $00 $00 $00 \ $33 $94 $d7 $50 $5e $43 $79 $cd $01 $00 $00 $00 $00 $00 $00 $00 \ $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 \ $01 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 create MAC map< c, $14 $00 $00 $00 $00 $00 $00 $00 $55 $00 $00 $00 $00 $00 $00 $00 KEY POLY Poly1305$ MSG 64 POLY update POLY finish MAC 16 c[]= #true \test reduction produces 131-bit final result create MAC map< c, $13 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 KEY POLY Poly1305$ MSG 48 POLY update POLY finish MAC 16 c[]= #true testend