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/omega-mv/blob/main/aienux/allen/tests/tls-crypto-poly.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / aienux / allen / tests / tls-crypto-poly.om` 133 lines ยท 2419 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-or-later 2 note RFC8439 section2.5.2 and Appendix A.3 vectors1,5,6,7,8,9,10,11. 3 note https://www.rfc-editor.org/rfc/rfc8439 ; attribution/license in tls-crypto-fixture.om. 4 note Internal primitive entry points are used to isolate reduction and final-pad carry bugs. 5 text Vpk "`85d6be7857556d337f4452fe42d506a80103808afb0db2fd4abff6af4149f51b`" 6 text Vpm "Cryptographic Forum Research Group" 7 text Vpt "`a8061dc1305136c6c22b8baf0c0127a9`" 8 text Vred "`e33594d7505e43b900000000000000003394d7505e4379cd0100000000000000`" 9 10 fn tvpoly n ulong to void 11 tcminit 12 p = ulong 0 13 while lt p n bound 4 14 m = sub n p 15 if gt m 16 16 m = 16 17 end 18 for i ulong m 19 put Tcmblk i get Tcbuf add p i 20 end 21 tcmblock m 22 p = add p m 23 end 24 tcmfinish 25 end 26 27 fn tvsmall first uchar to void 28 tvcheck eq get Tcmtag 0 first 40 29 for i ulong 15 30 tvcheck eq get Tcmtag add i 1 0 41 31 end 32 tccwipe 33 tvscrub 34 end 35 36 fn tvreduce last bool to void 37 tcwipe 38 put Tcmkey 0 1 39 put Tcmkey 8 4 40 for i ulong 32 41 p = mul i 2 42 put Tcbuf i tvbyte get Vred p get Vred add p 1 43 end 44 if last 45 put Tcbuf 48 1 46 tvpoly 64 47 tvcheck eq get Tcmtag 0 20 50 48 tvcheck eq get Tcmtag 8 85 51 49 for i ulong 16 50 if and ne i 0 ne i 8 51 tvcheck eq get Tcmtag i 0 52 52 end 53 end 54 else 55 tvpoly 48 56 tvsmall 19 57 end 58 end 59 60 fn main to int 61 tcwipe 62 for i ulong 32 63 p = mul i 2 64 put Tcmkey i tvbyte get Vpk p get Vpk add p 1 65 end 66 for i ulong len Vpm 67 put Tcbuf i get Vpm i 68 end 69 tvpoly len Vpm 70 for i ulong 16 71 p = mul i 2 72 v = tvbyte get Vpt p get Vpt add p 1 73 tvcheck eq get Tcmtag i v 1 74 end 75 tcwipe 76 tvpoly 64 77 tvsmall 0 78 note Appendix A.3 vector5: final 130-bit partial reduction. 79 tcwipe 80 put Tcmkey 0 2 81 for i ulong 16 82 put Tcbuf i 255 83 end 84 tvpoly 16 85 tvsmall 3 86 note Vector6: addition of pad overflows modulo2^128. 87 tcwipe 88 put Tcmkey 0 2 89 for i ulong 16 90 put Tcmkey add i 16 255 91 end 92 put Tcbuf 0 2 93 tvpoly 16 94 tvsmall 3 95 note Vector7: all-ones limbs with a carry. 96 tcwipe 97 put Tcmkey 0 1 98 for i ulong 32 99 put Tcbuf i 255 100 end 101 put Tcbuf 16 240 102 put Tcbuf 32 17 103 tvpoly 48 104 tvsmall 5 105 note Vector8: accumulator exactly p must encode0. 106 tcwipe 107 put Tcmkey 0 1 108 for i ulong 16 109 put Tcbuf i 255 110 put Tcbuf add i 16 254 111 put Tcbuf add i 32 1 112 end 113 put Tcbuf 16 251 114 tvpoly 48 115 tvsmall 0 116 note Vector9: accumulator exactly p-1 must not reduce to0. 117 tcwipe 118 put Tcmkey 0 2 119 for i ulong 16 120 put Tcbuf i 255 121 end 122 put Tcbuf 0 253 123 tvpoly 16 124 tvcheck eq get Tcmtag 0 250 60 125 for i ulong 15 126 tvcheck eq get Tcmtag add i 1 255 61 127 end 128 tvreduce true 129 tvreduce false 130 tcwipe 131 tvscrub 132 ret 0 133 end