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/x25519.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 / x25519.om` 115 lines ยท 2574 bytes Raw Blame History 1 note omtls test driver x25519: ot_x25_mul / ot_x25_base on tests/vectors/x25519/rfc7748.txt (X R K U O: the output 2 note must be O and, when R is 1, all zero by ot_ct_zero32; B K O; I N O: N iterations from k = u = 9, RFC 7748 5.2) 3 note and Wycheproof x25519 (X R K U O, R 1 for the ZeroSharedSecret cases). The rfc7748.txt "L" lines check the 4 note length refusals of an API with run-time lengths; this API takes sized 32-byte arrays, so a wrong length cannot 5 note be passed (compile-time error 7) and those lines are not counted. Usage: x25519 FILE... 6 text ot_syx_area "x25519" 7 text ot_syx_x "X" 8 text ot_syx_b "B" 9 text ot_syx_i "I" 10 fn ot_syx_xr b view uchar * st edit ulong 10 to bool 11 k = new uchar 32 0 12 u = new uchar 32 0 13 e = new uchar 32 0 14 o = new uchar 32 0 15 r = ot_sy_ndec b st 16 kl = ot_sy_nhex b st k 17 ul = ot_sy_nhex b st u 18 el = ot_sy_nhex b st e 19 if or ne kl 32 or ne ul 32 ne el 32 20 ret false 21 end 22 ot_x25_mul o k u 23 z = ot_ct_zero32 o 24 if ne z eq r 1 25 ret false 26 end 27 ret ot_ct_eq32 o e 28 end 29 fn ot_syx_br b view uchar * st edit ulong 10 to bool 30 k = new uchar 32 0 31 e = new uchar 32 0 32 o = new uchar 32 0 33 kl = ot_sy_nhex b st k 34 el = ot_sy_nhex b st e 35 if or ne kl 32 ne el 32 36 ret false 37 end 38 ot_x25_base o k 39 ret ot_ct_eq32 o e 40 end 41 note RFC 7748 5.2: k = u = 9; repeat N times: (k, u) = (X25519(k, u), k). 42 fn ot_syx_it b view uchar * st edit ulong 10 to bool 43 k = new uchar 32 0 44 u = new uchar 32 0 45 o = new uchar 32 0 46 e = new uchar 32 0 47 n = ot_sy_ndec b st 48 el = ot_sy_nhex b st e 49 if ne el 32 50 ret false 51 end 52 put k 0 9 53 put u 0 9 54 j = ulong 0 55 while lt j n bound `9223372036854775807` 56 ot_x25_mul o k u 57 for i ulong 32 unroll 58 put u i get k i 59 put k i get o i 60 end 61 j = add j 1 62 end 63 ret ot_ct_eq32 k e 64 end 65 fn ot_syx_line b view uchar * st edit ulong 10 to bool 66 if ot_sy_is b st ot_syx_x 67 ret ot_syx_xr b st 68 end 69 if ot_sy_is b st ot_syx_b 70 ret ot_syx_br b st 71 end 72 if ot_sy_is b st ot_syx_i 73 ret ot_syx_it b st 74 end 75 put st 9 1 76 ret true 77 end 78 fn ot_syx_file fd int b edit uchar * r edit ulong 4 to void 79 st = new ulong 10 0 80 while ot_sy_line fd b st bound `9223372036854775807` 81 n = ot_sy_tok b st 82 if gt n 0 83 if ne get b get st 6 35 84 put st 9 0 85 ok = ot_syx_line b st 86 if eq get st 9 0 87 ot_sy_res r ok ot_syx_area st 88 end 89 end 90 end 91 end 92 if eq get st 2 2 93 put r 1 add get r 1 1 94 end 95 end 96 fn main to int 97 b = new uchar `1048576` 0 98 pth = new uchar 4096 0 99 r = new ulong 4 0 100 st = new ulong 10 0 101 na = argcnt 102 i = ulong 1 103 while lt i ulong na bound 4096 104 fd = ot_sy_open i pth 105 if lt fd 0 106 put r 1 add get r 1 1 107 ot_sy_bad ot_syx_area i st 108 else 109 ot_syx_file fd b r 110 cl = fclose fd 111 end 112 i = add i 1 113 end 114 ret ot_sy_done ot_syx_area get r 0 get r 1 115 end