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/om/tls/test/acvp/mlkemacvp.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 / om / tls / test / acvp / mlkemacvp.om` 130 lines ยท 2515 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note mlkemacvp.om: ACVP ML-KEM (FIPS 203) response engine for om/tls/mlkem.om (ML-KEM-768). The program 3 note is acvpio.om || mlkemacvp.om || acvpmain.om, composed after sha3.om and mlkem.om (run.sh does 4 note this). Records on stdin, as in acvp.om (hex, "-" = empty, ID echoed first): 5 note Q ID D Z mlkem_keygen (ML-KEM.KeyGen_internal) -> ID RC EK DK 6 note P ID EK M mlkem_encaps (ML-KEM.Encaps_internal, 7.2 checks) -> ID RC C K 7 note U ID DK C mlkem_decaps (ML-KEM.Decaps_internal, 7.3 checks) -> ID RC K 8 note Y ID DK decapsulation key check: mlkem_decaps on DK and an all-zero 1088-byte ciphertext; 9 note its 7.3 input checks (lengths, H(ek) == h) run before any decapsulation -> ID RC 10 note Z ID EK encapsulation key check: mlkem_encaps on EK and an all-zero m; its 7.2 input 11 note checks (length, modulus) run first -> ID RC 12 note RC is the library's return code (0 ok, 1 modulus check failed, 2 bad length, 3 hash check failed). 13 14 note copy a[o..o+32) into d 15 fn mkcp a view uchar * o ulong d edit uchar 32 to void 16 for i ulong 32 17 put d i get a add o i 18 end 19 end 20 21 fn recq a edit uchar * b edit uchar * to void 22 d = new uchar 32 0 23 z = new uchar 32 0 24 drid 25 dl = drhex a 26 zl = drhex part a 32 32 27 dreor 28 if ne dl 32 29 drbad 30 end 31 if ne zl 32 32 drbad 33 end 34 if isbad 35 ret 36 end 37 mkcp a 0 d 38 mkcp a 32 z 39 rc = mlkem_keygen d z part a 0 1184 part b 0 2400 40 ofld rc 41 ohex part a 0 1184 42 ohex part b 0 2400 43 end 44 45 fn recp a edit uchar * b edit uchar * to void 46 m = new uchar 32 0 47 ss = new uchar 32 0 48 drid 49 el = drhex a 50 ml = drhex b 51 dreor 52 if ne ml 32 53 drbad 54 end 55 if isbad 56 ret 57 end 58 mkcp b 0 m 59 rc = mlkem_encaps part a 0 el m part b 0 1088 ss 60 ofld rc 61 ohex part b 0 1088 62 ohex ss 63 end 64 65 fn recu a edit uchar * b edit uchar * to void 66 ss = new uchar 32 0 67 drid 68 dl = drhex a 69 cl = drhex b 70 dreor 71 if isbad 72 ret 73 end 74 rc = mlkem_decaps part a 0 dl part b 0 cl ss 75 ofld rc 76 ohex ss 77 end 78 79 fn recy a edit uchar * to void 80 ct = new uchar 1088 0 81 ss = new uchar 32 0 82 drid 83 dl = drhex a 84 dreor 85 if isbad 86 ret 87 end 88 rc = mlkem_decaps part a 0 dl ct ss 89 ofld rc 90 end 91 92 fn recz a edit uchar * to void 93 m = new uchar 32 0 94 ct = new uchar 1088 0 95 ss = new uchar 32 0 96 drid 97 el = drhex a 98 dreor 99 if isbad 100 ret 101 end 102 rc = mlkem_encaps part a 0 el m ct ss 103 ofld rc 104 end 105 106 fn drrec a edit uchar * b edit uchar * c edit uchar * to void 107 op = drpeek 108 dradv 109 if eq op 81 110 recq a b 111 ret 112 end 113 if eq op 80 114 recp a b 115 ret 116 end 117 if eq op 85 118 recu a b 119 ret 120 end 121 if eq op 89 122 recy a 123 ret 124 end 125 if eq op 90 126 recz a 127 ret 128 end 129 drbad 130 end