Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omtls/blob/main/tests/drv/aeadchk.om # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omtls / tests / drv / aeadchk.om` 97 lines ยท 2766 bytes Raw Blame History 1 note omtls AEAD test helper (both AEADs): seal and open known answers plus derived negative checks. 2 note Buffers: aad, pt, ct (ciphertext || tag) in sized 65536-byte arrays; f (ulong 8): 0 aad length, 1 pt length, 3 note 2 ct length (with the tag), 3 1 when the case is expected valid, 4 1 for the derived checks too. 4 note A valid case: seal(pt) == ct, open(ct) is true and gives pt; with derived checks also each of 16 one-bit tag 5 note flips, an AAD flip, a ciphertext flip, a 15-byte tag (buffer one byte short), a 15-byte buffer: open false 6 note with the buffer zeroed. An invalid case: open is false and the buffer is all zero. 7 fn ot_sye_z b view uchar * to bool 8 acc = ulong 0 9 for i ulong len b 10 acc = or acc ulong get b i 11 end 12 ret eq acc 0 13 end 14 fn ot_sye_cp a view uchar * b edit uchar * n ulong to void 15 for i ulong n 16 put b i get a i 17 end 18 end 19 fn ot_sye_open alg ulong kn view uchar 44 aad view uchar 65536 buf edit uchar 65552 n ulong an ulong to bool 20 ret ot_ae_open alg kn view part aad 0 an part buf 0 n 21 end 22 fn ot_sye_seal alg ulong kn view uchar 44 aad view uchar 65536 buf edit uchar 65552 n ulong an ulong to void 23 ot_ae_seal alg kn view part aad 0 an part buf 0 n 24 end 25 note open(buf[0..n]) must refuse and leave buf[0..n] zero. 26 fn ot_sye_no alg ulong kn view uchar 44 aad view uchar 65536 buf edit uchar 65552 n ulong an ulong to bool 27 if ot_sye_open alg kn aad buf n an 28 ret false 29 end 30 ret ot_sye_z view part buf 0 n 31 end 32 fn ot_sye_run alg ulong kn view uchar 44 aad edit uchar 65536 pt view uchar 65536 ct view uchar 65536 f view ulong 8 to bool 33 buf = new uchar 65552 0 34 cn = get f 2 35 if or lt cn 16 gt cn 65552 36 ret and eq get f 3 0 lt cn 16 37 end 38 ot_sye_cp ct buf cn 39 if eq get f 3 0 40 ret ot_sye_no alg kn aad buf cn get f 0 41 end 42 if ne add get f 1 16 cn 43 ret false 44 end 45 if not ot_sye_open alg kn aad buf cn get f 0 46 ret false 47 end 48 if not ot_sy_eq buf pt get f 1 49 ret false 50 end 51 ot_sye_cp pt buf get f 1 52 ot_sye_seal alg kn aad buf cn get f 0 53 if not ot_sy_eq buf ct cn 54 ret false 55 end 56 if eq get f 4 0 57 ret true 58 end 59 ret ot_sye_neg alg kn aad ct f 60 end 61 fn ot_sye_neg alg ulong kn view uchar 44 aad edit uchar 65536 ct view uchar 65536 f view ulong 8 to bool 62 buf = new uchar 65552 0 63 an = get f 0 64 cn = get f 2 65 for j ulong 16 66 ot_sye_cp ct buf cn 67 q = add sub cn 16 j 68 bit = shl uchar 1 uchar and j 7 69 v = xor get buf q bit 70 put buf q v 71 if not ot_sye_no alg kn aad buf cn an 72 ret false 73 end 74 end 75 if gt an 0 76 put aad 0 xor get aad 0 1 77 ot_sye_cp ct buf cn 78 ok = ot_sye_no alg kn aad buf cn an 79 put aad 0 xor get aad 0 1 80 if not ok 81 ret false 82 end 83 end 84 if gt cn 16 85 ot_sye_cp ct buf cn 86 put buf 0 xor get buf 0 128 87 if not ot_sye_no alg kn aad buf cn an 88 ret false 89 end 90 end 91 ot_sye_cp ct buf cn 92 if not ot_sye_no alg kn aad buf sub cn 1 an 93 ret false 94 end 95 ot_sye_cp ct buf 15 96 ret ot_sye_no alg kn aad buf 15 an 97 end