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
omega-mv / protocol / uor-gpu / uor-gpu-gate.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note protocol/uor-gpu/uor-gpu-gate.om: Pure seeded OM-2 self-verifying host gate for |
| 3 | note hologram:gpu/omega-om2@1 (UOR-GPU-1). Zero CUDApp, zero C/Python/shell. |
| 4 | note Run from the omega-mv repository root with pinned seed/out/omc. |
| 5 | note Exercises: |
| 6 | note - RFC 8032 Ed25519 signing and verification vectors |
| 7 | note - Single-source SM121 compilation directly from om/gpu/bw_vecadd.om + om/gpu/bw_qmd.om |
| 8 | note via SHA-256-verified seed/out/omc (512B SASS cross-checked against OMEGA_BW_VECADD_EXPECTED_SHA256 |
| 9 | note + full 384B QMD v05.00 descriptor = 896B) |
| 10 | note - Single-source SPIR-V 1.0 OpenCL Kernel compilation directly from gpu/spirv/emit.om |
| 11 | note - Real P3 kernel VM replay executing the actual SM121 SASS+QMD v5 and SPIR-V binary bytes |
| 12 | note over both in-bounds (0..7) and out-of-bounds (8..11) threads/work-items |
| 13 | note - Local trust anchors, authority-signed capability grants, and 33 negative controls |
| 14 | note (including QMD v5 SKEDCHECK05 mutants, SM121 SASS arithmetic/OOB/illegal-op mutants, |
| 15 | note real SPIR-V emit.om `vadd cl mutant` OpFSub mutant, and unpinned omc refusal). |
| 16 | note The seeds below are derived from public tags: TEST ONLY, never a production key. |
| 17 | note Compose after si/directives/om2.om, om/tls/sha2.om, protocol/uor-gpu/b3_uor.om, |
| 18 | note protocol/omnet/om/sha512/sha512.om, protocol/omnet/om/ed25519/ed25519.om, |
| 19 | note protocol/uor-gpu/canonical.om, protocol/uor-gpu/payload_vm.om, protocol/uor-gpu/verify.om, |
| 20 | note protocol/uor-gpu/gate.om, protocol/uor-gpu/emit_kernels.om, protocol/uor-gpu/ed_sign.om. |
| 21 | |
| 22 | text ug_pass_msg "UOR_GPU_GATE_PASS\n" |
| 23 | text ug_fail_msg "UOR_GPU_GATE_FAIL\n" |
| 24 | note RFC 8032 section 7.1 TEST 1 (empty message) and TEST 2 (one byte 0x72) |
| 25 | text ug_ed1_seed "9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60" |
| 26 | text ug_ed1_pk "d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a" |
| 27 | text ug_ed1_sg "e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b" |
| 28 | text ug_ed2_seed "4ccd089b28ff96da9db6c346ec114e0f5b8a319f35aba624da8cf6ed4fb8a6fb" |
| 29 | text ug_ed2_pk "3d4017c3e843895a92b70aa74d1b7ebc9c982ccf2ec4968cc0cd55f12af4660c" |
| 30 | text ug_ed2_sg "92a009a9f0d4cab8720e820b5f642540a2b27b5416503f8fb3762223ebdb69da085ac1e43e15996e458f3613d0f11d8c387b2eaeb4302aeeb00d291612bb0c00" |
| 31 | text ug_tag_signer "uor-gpu-gate:test-signer:v1" |
| 32 | text ug_tag_auth "uor-gpu-gate:test-authority:v1" |
| 33 | text ug_tag_rogue "uor-gpu-gate:test-rogue:v1" |
| 34 | text ug_bad_omc "protocol/uor-gpu/README.md" |
| 35 | |
| 36 | fn ug_ed_vec seedhex view uchar 64 pkhex view uchar 64 sghex view uchar 128 m view uchar 65536 n ulong to ulong |
| 37 | sd = new uchar 32 0 |
| 38 | pk = new uchar 32 0 |
| 39 | pk2 = new uchar 32 0 |
| 40 | sg = new uchar 64 0 |
| 41 | sg2 = new uchar 64 0 |
| 42 | ug_parse_hex32 seedhex sd |
| 43 | ug_parse_hex32 pkhex pk |
| 44 | ug_parse_hex64 sghex sg |
| 45 | ues_pubkey sd pk2 |
| 46 | if eq uor_eq32 pk 0 pk2 0 0 |
| 47 | ret 0 |
| 48 | end |
| 49 | ues_sign sd m n sg2 |
| 50 | diff = ulong 0 |
| 51 | for i ulong 64 |
| 52 | diff = or diff ulong xor get sg i get sg2 i |
| 53 | end |
| 54 | if ne diff 0 |
| 55 | ret 0 |
| 56 | end |
| 57 | if eq edverify pk m n sg2 0 0 |
| 58 | ret 0 |
| 59 | end |
| 60 | put sg2 0 xor get sg2 0 uchar 1 |
| 61 | if ne edverify pk m n sg2 0 0 |
| 62 | ret 0 |
| 63 | end |
| 64 | ret 1 |
| 65 | end |
| 66 | |
| 67 | fn ug_selftest_ed to ulong |
| 68 | m = new uchar 65536 0 |
| 69 | if eq ug_ed_vec ug_ed1_seed ug_ed1_pk ug_ed1_sg m 0 0 |
| 70 | ret 0 |
| 71 | end |
| 72 | put m 0 uchar 0x72 |
| 73 | ret ug_ed_vec ug_ed2_seed ug_ed2_pk ug_ed2_sg m 1 |
| 74 | end |
| 75 | |
| 76 | fn ug_seeds sk edit uchar 96 to void |
| 77 | t = new uchar 32 0 |
| 78 | a = sha2_digest 256 ug_tag_signer t |
| 79 | for i ulong 32 |
| 80 | put sk i get t i |
| 81 | end |
| 82 | b = sha2_digest 256 ug_tag_auth t |
| 83 | for i ulong 32 |
| 84 | put sk add 32 i get t i |
| 85 | end |
| 86 | c = sha2_digest 256 ug_tag_rogue t |
| 87 | for i ulong 32 |
| 88 | put sk add 64 i get t i |
| 89 | end |
| 90 | if or ne a 32 or ne b 32 ne c 32 |
| 91 | trap 8 |
| 92 | end |
| 93 | end |
| 94 | |
| 95 | fn ug_seed_at sk view uchar 96 off ulong dst edit uchar 32 to void |
| 96 | for i ulong 32 |
| 97 | put dst i get sk add off i |
| 98 | end |
| 99 | end |
| 100 | |
| 101 | fn ug_make_anchors anc edit uchar 136 sk view uchar 96 to void |
| 102 | sd = new uchar 32 0 |
| 103 | spk = new uchar 32 0 |
| 104 | apk = new uchar 32 0 |
| 105 | ug_seed_at sk 0 sd |
| 106 | ues_pubkey sd spk |
| 107 | ug_seed_at sk 32 sd |
| 108 | ues_pubkey sd apk |
| 109 | ug_build_anchors anc apk spk |
| 110 | end |
| 111 | |
| 112 | fn ug_make_bundle hdr edit uchar 384 pay view uchar * sdig view uchar 32 seed view uchar 32 isa ulong to ulong |
| 113 | rc = ug_fill_p3_hdr_real hdr isa pay sdig |
| 114 | if ne rc UOR_VERDICT_PASS |
| 115 | ret rc |
| 116 | end |
| 117 | uor_hdr_seal hdr pay |
| 118 | ues_sign_hdr hdr seed |
| 119 | ret UOR_VERDICT_PASS |
| 120 | end |
| 121 | |
| 122 | fn ug_make_grant g edit uchar 168 seed view uchar 32 to void |
| 123 | for i ulong 168 |
| 124 | put g i uchar 0 |
| 125 | end |
| 126 | uor_put_u64 g 0 1 |
| 127 | uor_put_u64 g 8 42 |
| 128 | uor_put_u64 g 16 1 |
| 129 | uor_put_u64 g 24 1000 |
| 130 | uor_put_u64 g 32 7 |
| 131 | uor_put_u64 g 40 0x4152425247423130 |
| 132 | uor_put_u64 g 48 4 |
| 133 | uor_put_u64 g 128 42 |
| 134 | uor_put_u64 g 136 1 |
| 135 | uor_put_u64 g 144 100 |
| 136 | uor_put_u64 g 152 7 |
| 137 | uor_put_u64 g 160 0x4152425247423130 |
| 138 | ues_sign_grant g seed |
| 139 | end |
| 140 | |
| 141 | note Positive: exact OMEGA_BW_VECADD_EXPECTED_SHA256 match, deterministic build, P0/P2/P3, |
| 142 | note real SM121 SASS+QMD v5 replay, and authority-signed grant admission. |
| 143 | fn ug_check_positive hdr view uchar 384 pay view uchar * sdig view uchar 32 anc view uchar 136 sk view uchar 96 to ulong |
| 144 | h2 = new uchar 384 0 |
| 145 | sd = new uchar 32 0 |
| 146 | g = new uchar 168 0 |
| 147 | sass_dig = new uchar 32 0 |
| 148 | sass_exp = new uchar 32 0 |
| 149 | d = sha2_digest 256 part pay 0 UOR_SM121_CODE_BYTES sass_dig |
| 150 | if ne d 32 |
| 151 | ret 2 |
| 152 | end |
| 153 | ug_parse_hex32 ug_vecadd_sass_hex sass_exp |
| 154 | if eq uor_eq32 sass_dig 0 sass_exp 0 0 |
| 155 | ret 2 |
| 156 | end |
| 157 | ug_seed_at sk 0 sd |
| 158 | if ne ug_make_bundle h2 pay sdig sd UOR_GPU_ISA_SM121 UOR_VERDICT_PASS |
| 159 | ret 2 |
| 160 | end |
| 161 | for i ulong 384 |
| 162 | if ne get hdr i get h2 i |
| 163 | ret 2 |
| 164 | end |
| 165 | end |
| 166 | if ne uor_verify_policy hdr pay anc UOR_LVL_P0 UOR_VERDICT_PASS |
| 167 | ret 3 |
| 168 | end |
| 169 | if ne uor_verify_policy hdr pay anc UOR_LVL_P2 UOR_VERDICT_PASS |
| 170 | ret 4 |
| 171 | end |
| 172 | if ne uor_verify_policy hdr pay anc UOR_LVL_P3 UOR_VERDICT_PASS |
| 173 | ret 5 |
| 174 | end |
| 175 | if ne uor_verify_replay_real hdr pay UOR_VERDICT_PASS |
| 176 | ret 6 |
| 177 | end |
| 178 | ug_seed_at sk 32 sd |
| 179 | ug_make_grant g sd |
| 180 | if ne uor_gpu_admit hdr pay anc g UOR_VERDICT_PASS |
| 181 | ret 8 |
| 182 | end |
| 183 | ret 0 |
| 184 | end |
| 185 | |
| 186 | note Compile real SPIR-V 1.0 OpenCL vadd from gpu/spirv/emit.om, run P3 policy + real SPIR-V VM replay, |
| 187 | note then compile the real `vadd cl mutant` (OpFSub), seal+sign it, and verify real replay catches it! |
| 188 | fn ug_check_spirv anc view uchar * sk view uchar 96 to ulong |
| 189 | h = new uchar 384 0 |
| 190 | pay = new uchar 65536 0 |
| 191 | plen = new ulong 1 0 |
| 192 | sdig = new uchar 32 0 |
| 193 | sd = new uchar 32 0 |
| 194 | ug_seed_at sk 0 sd |
| 195 | if eq ug_compile_spirv ug_default_omc 0 pay plen sdig 0 |
| 196 | ret 7 |
| 197 | end |
| 198 | n = get plen 0 |
| 199 | if ne ug_make_bundle h part pay 0 n sdig sd UOR_GPU_ISA_SPIRV UOR_VERDICT_PASS |
| 200 | ret 7 |
| 201 | end |
| 202 | if ne uor_verify_policy h part pay 0 n anc UOR_LVL_P3 UOR_VERDICT_PASS |
| 203 | ret 7 |
| 204 | end |
| 205 | if ne uor_verify_replay_real h part pay 0 n UOR_VERDICT_PASS |
| 206 | ret 9 |
| 207 | end |
| 208 | note Negative control: corrupt SPIR-V magic (resealed + re-signed) -> UOR_ERR_BAD_SPIRV |
| 209 | put pay 0 uchar 0 |
| 210 | uor_hdr_seal h part pay 0 n |
| 211 | ues_sign_hdr h sd |
| 212 | if ne uor_verify_policy h part pay 0 n anc UOR_LVL_P2 UOR_ERR_BAD_SPIRV |
| 213 | ret 57 |
| 214 | end |
| 215 | note Negative control: compile real `gpu/spirv/emit.om vadd cl mutant` (OpFSub instead of OpFAdd), |
| 216 | note seal + sign with trusted key -> P2 passes, real SPIR-V VM replay MUST refuse (UOR_ERR_REPLAY_MISMATCH)! |
| 217 | if eq ug_compile_spirv ug_default_omc 1 pay plen sdig 0 |
| 218 | ret 58 |
| 219 | end |
| 220 | n = get plen 0 |
| 221 | if ne ug_make_bundle h part pay 0 n sdig sd UOR_GPU_ISA_SPIRV UOR_VERDICT_PASS |
| 222 | ret 58 |
| 223 | end |
| 224 | if ne uor_verify_policy h part pay 0 n anc UOR_LVL_P2 UOR_VERDICT_PASS |
| 225 | ret 58 |
| 226 | end |
| 227 | if ne uor_verify_replay_real h part pay 0 n UOR_ERR_REPLAY_MISMATCH |
| 228 | ret 59 |
| 229 | end |
| 230 | ret 0 |
| 231 | end |
| 232 | |
| 233 | note Integrity and pin refusals. |
| 234 | fn ug_neg_integrity hdr view uchar 384 pay view uchar * anc view uchar * to ulong |
| 235 | thdr = new uchar 384 0 |
| 236 | tpay = new uchar 896 0 |
| 237 | ac = new uchar 136 0 |
| 238 | for i ulong 384 |
| 239 | put thdr i get hdr i |
| 240 | end |
| 241 | for i ulong UOR_SM121_PAYLOAD_BYTES |
| 242 | put tpay i get pay i |
| 243 | end |
| 244 | for i ulong 136 |
| 245 | put ac i get anc i |
| 246 | end |
| 247 | note 1-byte payload tamper |
| 248 | put tpay 17 xor get tpay 17 uchar 1 |
| 249 | if ne uor_verify_policy thdr tpay ac UOR_LVL_P2 UOR_ERR_PAYLOAD_TAMPER |
| 250 | ret 11 |
| 251 | end |
| 252 | put tpay 17 get pay 17 |
| 253 | note 1-byte math contract tamper |
| 254 | put thdr 16 uchar 2 |
| 255 | if ne uor_verify_policy thdr tpay ac UOR_LVL_P2 UOR_ERR_UOR_ID_TAMPER |
| 256 | ret 12 |
| 257 | end |
| 258 | put thdr 16 get hdr 16 |
| 259 | note 1-byte .holo seal tamper |
| 260 | put thdr 256 xor get thdr 256 uchar 1 |
| 261 | if ne uor_verify_policy thdr tpay ac UOR_LVL_P2 UOR_ERR_HOLO_TAMPER |
| 262 | ret 13 |
| 263 | end |
| 264 | put thdr 256 get hdr 256 |
| 265 | note missing Lean 4 proof digest (resealed) |
| 266 | for i ulong 32 |
| 267 | put thdr add 128 i uchar 0 |
| 268 | end |
| 269 | uor_hdr_seal thdr tpay |
| 270 | if ne uor_verify_policy thdr tpay ac UOR_LVL_P2 UOR_ERR_NO_LEAN_PROOF |
| 271 | ret 14 |
| 272 | end |
| 273 | note non-zero but unpinned Lean 4 proof digest (resealed) |
| 274 | for i ulong 32 |
| 275 | put thdr add 128 i get hdr add 128 i |
| 276 | end |
| 277 | put thdr 130 xor get thdr 130 uchar 1 |
| 278 | uor_hdr_seal thdr tpay |
| 279 | if ne uor_verify_policy thdr tpay ac UOR_LVL_P2 UOR_ERR_LEAN_UNPINNED |
| 280 | ret 15 |
| 281 | end |
| 282 | note omc pin differs from the verifier's anchor |
| 283 | put ac 8 xor get ac 8 uchar 0xff |
| 284 | if ne uor_verify_policy hdr pay ac UOR_LVL_P2 UOR_ERR_OMC_PIN |
| 285 | ret 16 |
| 286 | end |
| 287 | note unpinned omc binary refused by compiler pin check |
| 288 | if ne ug_check_omc_pin ug_bad_omc len ug_bad_omc 0 |
| 289 | ret 17 |
| 290 | end |
| 291 | ret 0 |
| 292 | end |
| 293 | |
| 294 | note Signature and level refusals ("Nothing raises a level except signing"). |
| 295 | fn ug_neg_sig hdr view uchar 384 pay view uchar * anc view uchar * sk view uchar 96 to ulong |
| 296 | thdr = new uchar 384 0 |
| 297 | rs = new uchar 32 0 |
| 298 | for i ulong 384 |
| 299 | put thdr i get hdr i |
| 300 | end |
| 301 | note forged 1-bit signature |
| 302 | put thdr 320 xor get thdr 320 uchar 1 |
| 303 | if ne uor_verify_policy thdr pay anc UOR_LVL_P2 UOR_ERR_BAD_SIG |
| 304 | ret 21 |
| 305 | end |
| 306 | put thdr 320 get hdr 320 |
| 307 | note valid signature by a key the verifier does not trust |
| 308 | ug_seed_at sk 64 rs |
| 309 | ues_sign_hdr thdr rs |
| 310 | if ne uor_verify_policy thdr pay anc UOR_LVL_P0 UOR_ERR_UNTRUSTED_SIGNER |
| 311 | ret 22 |
| 312 | end |
| 313 | note unsigned bundle at P2 |
| 314 | for i ulong 32 |
| 315 | put thdr add 288 i uchar 0 |
| 316 | end |
| 317 | if ne uor_verify_policy thdr pay anc UOR_LVL_P2 UOR_ERR_BAD_SIG |
| 318 | ret 23 |
| 319 | end |
| 320 | note unsigned bundle whose header claims P3, checked at P0 |
| 321 | for i ulong 64 |
| 322 | put thdr add 320 i uchar 0 |
| 323 | end |
| 324 | if ne uor_verify_policy thdr pay anc UOR_LVL_P0 UOR_ERR_UNSIGNED_LEVEL |
| 325 | ret 24 |
| 326 | end |
| 327 | note unsigned P0 claim with smuggled signature bytes |
| 328 | uor_put_u32 thdr 20 UOR_LVL_P0 |
| 329 | uor_hdr_seal thdr pay |
| 330 | put thdr 350 uchar 1 |
| 331 | if ne uor_verify_policy thdr pay anc UOR_LVL_P0 UOR_ERR_BAD_SIG |
| 332 | ret 25 |
| 333 | end |
| 334 | note clean unsigned P0 claim passes P0 only |
| 335 | put thdr 350 uchar 0 |
| 336 | if ne uor_verify_policy thdr pay anc UOR_LVL_P0 UOR_VERDICT_PASS |
| 337 | ret 26 |
| 338 | end |
| 339 | if ne uor_verify_policy thdr pay anc UOR_LVL_P1 UOR_ERR_LEVEL_LOW |
| 340 | ret 27 |
| 341 | end |
| 342 | note replay digest mismatch (corrupted hdr.replay_sha256) |
| 343 | for i ulong 384 |
| 344 | put thdr i get hdr i |
| 345 | end |
| 346 | put thdr 160 xor get thdr 160 uchar 1 |
| 347 | if ne uor_verify_replay_real thdr pay UOR_ERR_REPLAY_MISMATCH |
| 348 | ret 28 |
| 349 | end |
| 350 | ret 0 |
| 351 | end |
| 352 | |
| 353 | note F5 negative controls: QMD v5 SKEDCHECK05 mutants and real SM121 SASS execution mutants |
| 354 | note (each resealed and re-signed with the trusted signer key so only QMD/replay catches them!). |
| 355 | fn ug_neg_sm121_f5 hdr view uchar 384 pay view uchar * anc view uchar * sk view uchar 96 to ulong |
| 356 | thdr = new uchar 384 0 |
| 357 | tpay = new uchar 896 0 |
| 358 | sd = new uchar 32 0 |
| 359 | ug_seed_at sk 0 sd |
| 360 | for i ulong 384 |
| 361 | put thdr i get hdr i |
| 362 | end |
| 363 | for i ulong UOR_SM121_PAYLOAD_BYTES |
| 364 | put tpay i get pay i |
| 365 | end |
| 366 | note 1. QMD v5 version mutant: word 14 version 5 -> 4 |
| 367 | sv = uvm_qmd_w tpay 14 |
| 368 | uor_put_u32 tpay 568 xor sv 0x00100000 |
| 369 | uor_hdr_seal thdr tpay |
| 370 | ues_sign_hdr thdr sd |
| 371 | if ne uor_verify_policy thdr tpay anc UOR_LVL_P2 UOR_ERR_BAD_QMD |
| 372 | ret 51 |
| 373 | end |
| 374 | uor_put_u32 tpay 568 sv |
| 375 | note 2. QMD v5 SKEDCHECK05 mutant: word 37 != 0 |
| 376 | uor_put_u32 tpay 660 1 |
| 377 | uor_hdr_seal thdr tpay |
| 378 | ues_sign_hdr thdr sd |
| 379 | if ne uor_verify_policy thdr tpay anc UOR_LVL_P2 UOR_ERR_BAD_QMD |
| 380 | ret 52 |
| 381 | end |
| 382 | uor_put_u32 tpay 660 0 |
| 383 | note 3. QMD v5 launch geometry mismatch: threads_x (word 34) != hdr.block_x |
| 384 | sv = uvm_qmd_w tpay 34 |
| 385 | uor_put_u32 tpay 648 or and sv 0xffff0000 128 |
| 386 | uor_hdr_seal thdr tpay |
| 387 | ues_sign_hdr thdr sd |
| 388 | if ne uor_verify_policy thdr tpay anc UOR_LVL_P2 UOR_ERR_BAD_QMD |
| 389 | ret 53 |
| 390 | end |
| 391 | uor_put_u32 tpay 648 sv |
| 392 | note 4. SM121 SASS arithmetic mutant: IADD3 R9, R2, R5 -> IADD3 R9, R2, R2 (w1 5 -> 2) |
| 393 | note Resealed and re-signed with trusted key: P2 passes, real SASS VM replay MUST refuse! |
| 394 | uor_put_u32 tpay 276 2 |
| 395 | uor_hdr_seal thdr tpay |
| 396 | ues_sign_hdr thdr sd |
| 397 | if ne uor_verify_policy thdr tpay anc UOR_LVL_P2 UOR_VERDICT_PASS |
| 398 | ret 54 |
| 399 | end |
| 400 | if ne uor_verify_replay_real thdr tpay UOR_ERR_REPLAY_MISMATCH |
| 401 | ret 54 |
| 402 | end |
| 403 | uor_put_u32 tpay 276 5 |
| 404 | note 5. SM121 SASS OOB guard mutant: replace `@P0 EXIT` (insn 7) with `NOP` (0x00007918) |
| 405 | note Resealed and re-signed: OOB threads 8..11 fall through and fault on OOB LDG/STG! |
| 406 | sv = uor_get_u32 tpay 112 |
| 407 | uor_put_u32 tpay 112 0x00007918 |
| 408 | uor_hdr_seal thdr tpay |
| 409 | ues_sign_hdr thdr sd |
| 410 | if ne uor_verify_replay_real thdr tpay UOR_ERR_REPLAY_FAULT |
| 411 | ret 55 |
| 412 | end |
| 413 | uor_put_u32 tpay 112 sv |
| 414 | note 6. SM121 SASS illegal opcode mutant: insn 17 opcode -> 0xfff |
| 415 | sv = uor_get_u32 tpay 272 |
| 416 | uor_put_u32 tpay 272 or and sv 0xfffff000 0xfff |
| 417 | uor_hdr_seal thdr tpay |
| 418 | ues_sign_hdr thdr sd |
| 419 | if ne uor_verify_replay_real thdr tpay UOR_ERR_REPLAY_FAULT |
| 420 | ret 56 |
| 421 | end |
| 422 | ret 0 |
| 423 | end |
| 424 | |
| 425 | note Capability grant refusals; each altered record is re-signed by the authority unless noted. |
| 426 | fn ug_neg_grant hdr view uchar 384 pay view uchar * anc view uchar * sk view uchar 96 to ulong |
| 427 | g = new uchar 168 0 |
| 428 | asd = new uchar 32 0 |
| 429 | ssd = new uchar 32 0 |
| 430 | ac = new uchar 136 0 |
| 431 | ug_seed_at sk 32 asd |
| 432 | ug_seed_at sk 0 ssd |
| 433 | ug_make_grant g asd |
| 434 | uor_put_u64 g 0 2 |
| 435 | ues_sign_grant g asd |
| 436 | if ne uor_gpu_admit hdr pay anc g UOR_ERR_CAP_DENIED |
| 437 | ret 31 |
| 438 | end |
| 439 | ug_make_grant g asd |
| 440 | uor_put_u64 g 40 0xdeadbeef |
| 441 | ues_sign_grant g asd |
| 442 | if ne uor_gpu_admit hdr pay anc g UOR_ERR_CAP_DENIED |
| 443 | ret 32 |
| 444 | end |
| 445 | ug_make_grant g asd |
| 446 | uor_put_u64 g 24 50 |
| 447 | ues_sign_grant g asd |
| 448 | if ne uor_gpu_admit hdr pay anc g UOR_ERR_CAP_DENIED |
| 449 | ret 33 |
| 450 | end |
| 451 | ug_make_grant g asd |
| 452 | uor_put_u64 g 8 0 |
| 453 | uor_put_u64 g 128 0 |
| 454 | ues_sign_grant g asd |
| 455 | if ne uor_gpu_admit hdr pay anc g UOR_ERR_CAP_DENIED |
| 456 | ret 34 |
| 457 | end |
| 458 | ug_make_grant g asd |
| 459 | uor_put_u64 g 24 0 |
| 460 | ues_sign_grant g asd |
| 461 | if ne uor_gpu_admit hdr pay anc g UOR_ERR_CAP_DENIED |
| 462 | ret 35 |
| 463 | end |
| 464 | ug_make_grant g asd |
| 465 | uor_put_u64 g 48 1 |
| 466 | ues_sign_grant g asd |
| 467 | if ne uor_gpu_admit hdr pay anc g UOR_ERR_CAP_DENIED |
| 468 | ret 36 |
| 469 | end |
| 470 | ug_make_grant g asd |
| 471 | uor_put_u64 g 24 0xffffffff |
| 472 | if ne uor_gpu_admit hdr pay anc g UOR_ERR_BAD_GRANT |
| 473 | ret 37 |
| 474 | end |
| 475 | ug_make_grant g ssd |
| 476 | if ne uor_gpu_admit hdr pay anc g UOR_ERR_BAD_GRANT |
| 477 | ret 38 |
| 478 | end |
| 479 | ug_make_grant g asd |
| 480 | for i ulong 136 |
| 481 | put ac i get anc i |
| 482 | end |
| 483 | for i ulong 32 |
| 484 | put ac add UOR_ANCH_AUTH i uchar 0 |
| 485 | end |
| 486 | if ne uor_gpu_admit hdr pay ac g UOR_ERR_BAD_GRANT |
| 487 | ret 39 |
| 488 | end |
| 489 | ret 0 |
| 490 | end |
| 491 | |
| 492 | note Malformed local trust anchors. |
| 493 | fn ug_neg_anchors hdr view uchar 384 pay view uchar * anc view uchar * to ulong |
| 494 | ac = new uchar 136 0 |
| 495 | for i ulong 136 |
| 496 | put ac i get anc i |
| 497 | end |
| 498 | put ac 0 uchar 88 |
| 499 | if ne uor_verify_policy hdr pay ac UOR_LVL_P2 UOR_ERR_BAD_ANCHORS |
| 500 | ret 41 |
| 501 | end |
| 502 | put ac 0 get anc 0 |
| 503 | for i ulong 32 |
| 504 | put ac add UOR_ANCH_AUTH i get anc add UOR_ANCH_KEYS i |
| 505 | end |
| 506 | if ne uor_verify_policy hdr pay ac UOR_LVL_P2 UOR_ERR_BAD_ANCHORS |
| 507 | ret 42 |
| 508 | end |
| 509 | for i ulong 32 |
| 510 | put ac add UOR_ANCH_AUTH i get anc add UOR_ANCH_AUTH i |
| 511 | put ac add UOR_ANCH_KEYS i uchar 0 |
| 512 | end |
| 513 | if ne uor_verify_policy hdr pay ac UOR_LVL_P2 UOR_ERR_BAD_ANCHORS |
| 514 | ret 43 |
| 515 | end |
| 516 | for i ulong 32 |
| 517 | put ac add UOR_ANCH_KEYS i get anc add UOR_ANCH_KEYS i |
| 518 | end |
| 519 | if ne uor_verify_policy hdr pay part ac 0 104 UOR_LVL_P2 UOR_ERR_BAD_ANCHORS |
| 520 | ret 44 |
| 521 | end |
| 522 | if ne uor_verify_policy hdr pay part ac 0 135 UOR_LVL_P2 UOR_ERR_BAD_ANCHORS |
| 523 | ret 45 |
| 524 | end |
| 525 | for i ulong 32 |
| 526 | put ac add UOR_ANCH_LEAN i uchar 0 |
| 527 | end |
| 528 | if ne uor_verify_policy hdr pay ac UOR_LVL_P2 UOR_ERR_BAD_ANCHORS |
| 529 | ret 46 |
| 530 | end |
| 531 | ret 0 |
| 532 | end |
| 533 | |
| 534 | fn ug_fail rc ulong to int |
| 535 | uor_write_all 2 ug_fail_msg len ug_fail_msg |
| 536 | ret int rc |
| 537 | end |
| 538 | |
| 539 | fn main to int |
| 540 | sk = new uchar 96 0 |
| 541 | anc = new uchar 136 0 |
| 542 | sm_raw = new uchar 65536 0 |
| 543 | sm_len = new ulong 1 0 |
| 544 | sdig = new uchar 32 0 |
| 545 | hdr1 = new uchar 384 0 |
| 546 | sd = new uchar 32 0 |
| 547 | if eq ug_selftest_ed 0 |
| 548 | ret ug_fail 1 |
| 549 | end |
| 550 | ug_seeds sk |
| 551 | ug_make_anchors anc sk |
| 552 | if eq ug_compile_sm121 ug_default_omc sm_raw sm_len sdig 0 |
| 553 | ret ug_fail 50 |
| 554 | end |
| 555 | if ne get sm_len 0 UOR_SM121_PAYLOAD_BYTES |
| 556 | ret ug_fail 50 |
| 557 | end |
| 558 | ug_seed_at sk 0 sd |
| 559 | if ne ug_make_bundle hdr1 part sm_raw 0 UOR_SM121_PAYLOAD_BYTES sdig sd UOR_GPU_ISA_SM121 UOR_VERDICT_PASS |
| 560 | ret ug_fail 50 |
| 561 | end |
| 562 | rc = ug_check_positive hdr1 part sm_raw 0 UOR_SM121_PAYLOAD_BYTES sdig anc sk |
| 563 | if ne rc 0 |
| 564 | ret ug_fail rc |
| 565 | end |
| 566 | rc = ug_check_spirv anc sk |
| 567 | if ne rc 0 |
| 568 | ret ug_fail rc |
| 569 | end |
| 570 | rc = ug_neg_integrity hdr1 part sm_raw 0 UOR_SM121_PAYLOAD_BYTES anc |
| 571 | if ne rc 0 |
| 572 | ret ug_fail rc |
| 573 | end |
| 574 | rc = ug_neg_sig hdr1 part sm_raw 0 UOR_SM121_PAYLOAD_BYTES anc sk |
| 575 | if ne rc 0 |
| 576 | ret ug_fail rc |
| 577 | end |
| 578 | rc = ug_neg_sm121_f5 hdr1 part sm_raw 0 UOR_SM121_PAYLOAD_BYTES anc sk |
| 579 | if ne rc 0 |
| 580 | ret ug_fail rc |
| 581 | end |
| 582 | rc = ug_neg_grant hdr1 part sm_raw 0 UOR_SM121_PAYLOAD_BYTES anc sk |
| 583 | if ne rc 0 |
| 584 | ret ug_fail rc |
| 585 | end |
| 586 | rc = ug_neg_anchors hdr1 part sm_raw 0 UOR_SM121_PAYLOAD_BYTES anc |
| 587 | if ne rc 0 |
| 588 | ret ug_fail rc |
| 589 | end |
| 590 | uor_emit_verdict hdr1 UOR_VERDICT_PASS UOR_LVL_P3 |
| 591 | uor_write_all 1 ug_pass_msg len ug_pass_msg |
| 592 | ret 0 |
| 593 | end |