omtls
omtls: a TLS 1.3 client (RFC 8446) written fresh in seeded Omega, for mailhand. Not audited by a cryptographer. Free (Apache-2.0).
Brought by drakestapleton
| 1 | note omtls Poly1305 driver layer (RFC 8439 2.5): blocks of d into the state st (see src/ct/p1.om). |
| 2 | note aead true: a short last block is zero-padded and still gets the 2^128 bit (RFC 8439 2.8 pad16); |
| 3 | note aead false: it gets 0x01 then zeros and no 2^128 bit (2.5.1). |
| 4 | fn ot_p1_upd st edit ulong 24 d view uchar * aead bool to void |
| 5 | b = new uchar 16 0 |
| 6 | n = len d |
| 7 | p = ulong 0 |
| 8 | while ge sub n p 16 bound 9223372036854775807 |
| 9 | for i ulong 16 unroll |
| 10 | put b i get d add p i |
| 11 | end |
| 12 | ot_p1_blk st b 1 |
| 13 | p = add p 16 |
| 14 | end |
| 15 | r = sub n p |
| 16 | if gt r 0 |
| 17 | for i ulong 16 unroll |
| 18 | put b i 0 |
| 19 | end |
| 20 | for i ulong r |
| 21 | put b i get d add p i |
| 22 | end |
| 23 | if aead |
| 24 | ot_p1_blk st b 1 |
| 25 | else |
| 26 | put b r 1 |
| 27 | ot_p1_blk st b 0 |
| 28 | end |
| 29 | end |
| 30 | for i ulong 16 unroll |
| 31 | put b i 0 |
| 32 | end |
| 33 | end |
| 34 | note One-shot Poly1305 tag of msg under the one-time key. |
| 35 | fn ot_p1_mac key view uchar 32 msg view uchar * tag edit uchar 16 to void |
| 36 | st = new ulong 24 0 |
| 37 | ot_p1_key st key |
| 38 | ot_p1_upd st msg false |
| 39 | ot_p1_tag st tag |
| 40 | for i ulong 24 unroll |
| 41 | put st i 0 |
| 42 | end |
| 43 | end |