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/aienux/blob/main/native/omega/allen/tls-p384.om # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. 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 `aienux / native / omega / allen / tls-p384.om` 471 lines ยท 10324 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note Modified 2026-10-25: public verification subset of aien-dev/spark-rsi-mv om/p256/p256.om (P256 arithmetic adapted to P384). 3 note Source commit `bba3877510daeb8a0e070a781a689bcf1952b6f6`, SHA256 4 note `92da68007af091ccfbe01aa845be779502130e02bf57e9550332d669905db958`. 5 note Adapted to P384, names prefixed cp3/C3, digest supplied by caller; signing, HMAC, nonce and private-key APIs removed. 6 note Public ECDSA inputs only. 32-bit-limb Montgomery arithmetic and complete a=-3 point addition. 7 note Renes-Costello-Batina 2015 algorithm 4; SEC2 v2 section 2.5.1 parameters. 8 note Byte buffer: key3072 (97 bytes), raw signature3200 (96), prehash3296 (48). 9 note No secret-key or constant-time compiler claim. Apache license in CERT-APACHE-LICENSE. 10 11 const C3MP ulong 0 12 const C3MN ulong 72 13 const C3ONE1 ulong 144 14 const C3BM ulong 156 15 const C3GX ulong 180 16 const C3W1 ulong 240 17 const C3W2 ulong 252 18 const C3XX ulong 264 19 const C3YY ulong 276 20 const C3ZZ ulong 288 21 const C3XY ulong 300 22 const C3YZ ulong 312 23 const C3XZ ulong 324 24 const C3U ulong 336 25 const C3V ulong 348 26 const C3YM ulong 360 27 const C3YP ulong 372 28 const C3BX3 ulong 384 29 const C3XX3 ulong 396 30 const C3ZZ3 ulong 408 31 const C3RX ulong 420 32 const C3ACC ulong 456 33 const C3TMP ulong 492 34 const C3BASE ulong 528 35 const C3ZI ulong 564 36 const C3Z ulong 792 37 const C3R ulong 804 38 const C3S ulong 816 39 const C3U1 ulong 828 40 const C3U2 ulong 840 41 const C3T1 ulong 864 42 const C3T2 ulong 876 43 const C3T3 ulong 888 44 const C3X ulong 912 45 const C3Y ulong 924 46 const C3Q ulong 960 47 const C3P1 ulong 996 48 const C3P2 ulong 1032 49 const C3BPUB ulong 3072 50 const C3BSIG ulong 3200 51 const C3BDIG ulong 3296 52 53 fn cp3cpy w edit ulong 1536 o ulong a ulong to void 54 for i ulong 12 55 put w add o i get w add a i 56 end 57 end 58 59 fn cp3pcpy w edit ulong 1536 o ulong a ulong to void 60 for i ulong 36 61 put w add o i get w add a i 62 end 63 end 64 65 fn cp3set w edit ulong 1536 o ulong v ulong to void 66 put w o v 67 for i ulong 11 68 put w add o add i 1 0 69 end 70 end 71 72 fn cp3red w edit ulong 1536 o ulong t view ulong 14 m ulong to void 73 u = new ulong 12 0 74 bw = ulong 0 75 x = ulong 0 76 for i ulong 12 77 x = sub sub get t i get w add m i bw 78 put u i and x `4294967295` 79 bw = shr x 63 80 end 81 sel = or get t 12 xor bw 1 82 mk = sub 0 sel 83 for j ulong 12 84 y = and get u j mk 85 put w add o j or y and get t j not mk 86 end 87 end 88 89 fn cp3mrow t edit ulong 14 w edit ulong 1536 a ulong bi ulong to void 90 c = ulong 0 91 x = ulong 0 92 for j ulong 12 93 x = add add get t j mul get w add a j bi c 94 put t j and x `4294967295` 95 c = shr x 32 96 end 97 x = add get t 12 c 98 put t 12 and x `4294967295` 99 put t 13 shr x 32 100 end 101 102 fn cp3mred t edit ulong 14 w edit ulong 1536 m ulong to void 103 q = and mul get t 0 get w add m 12 `4294967295` 104 x = add get t 0 mul q get w m 105 c = shr x 32 106 j1 = ulong 0 107 for k ulong 11 108 j1 = add k 1 109 x = add add get t j1 mul q get w add m j1 c 110 put t k and x `4294967295` 111 c = shr x 32 112 end 113 x = add get t 12 c 114 put t 11 and x `4294967295` 115 put t 12 add get t 13 shr x 32 116 end 117 118 fn cp3mul w edit ulong 1536 o ulong a ulong b ulong m ulong to void 119 t = new ulong 14 0 120 for i ulong 12 121 cp3mrow t w a get w add b i 122 cp3mred t w m 123 end 124 cp3red w o t m 125 end 126 127 fn cp3add w edit ulong 1536 o ulong a ulong b ulong m ulong to void 128 t = new ulong 14 0 129 c = ulong 0 130 x = ulong 0 131 for i ulong 12 132 x = add add get w add a i get w add b i c 133 put t i and x `4294967295` 134 c = shr x 32 135 end 136 put t 12 c 137 cp3red w o t m 138 end 139 140 fn cp3sub w edit ulong 1536 o ulong a ulong b ulong m ulong to void 141 t = new ulong 12 0 142 bw = ulong 0 143 x = ulong 0 144 for i ulong 12 145 x = sub sub get w add a i get w add b i bw 146 put t i and x `4294967295` 147 bw = shr x 63 148 end 149 mk = sub 0 bw 150 c = ulong 0 151 for j ulong 12 152 x = add add get t j and get w add m j mk c 153 put w add o j and x `4294967295` 154 c = shr x 32 155 end 156 end 157 158 fn cp3modr w edit ulong 1536 o ulong m ulong to void 159 t = new ulong 14 0 160 for i ulong 12 161 put t i get w add o i 162 end 163 cp3red w o t m 164 end 165 166 fn cp3lt w edit ulong 1536 a ulong m ulong to bool 167 bw = ulong 0 168 x = ulong 0 169 for i ulong 12 170 x = sub sub get w add a i get w add m i bw 171 bw = shr x 63 172 end 173 ret eq bw 1 174 end 175 176 fn cp3isz w edit ulong 1536 a ulong to bool 177 v = ulong 0 178 for i ulong 12 179 v = or v get w add a i 180 end 181 ret eq v 0 182 end 183 184 fn cp3eqv w edit ulong 1536 a ulong b ulong to bool 185 v = ulong 0 186 for i ulong 12 187 v = or v xor get w add a i get w add b i 188 end 189 ret eq v 0 190 end 191 192 fn cp3rng w edit ulong 1536 a ulong to bool 193 ret and not cp3isz w a cp3lt w a C3MN 194 end 195 196 fn cp3pow w edit ulong 1536 o ulong a ulong e ulong m ulong to void 197 cp3cpy w C3W2 a 198 cp3cpy w C3W1 add m 36 199 i = ulong 0 200 bit = ulong 0 201 for j ulong 384 202 i = sub 383 j 203 cp3mul w C3W1 C3W1 C3W1 m 204 bit = and shr get w add e shr i 5 and i 31 1 205 if eq bit 1 206 cp3mul w C3W1 C3W1 C3W2 m 207 end 208 end 209 cp3cpy w o C3W1 210 end 211 212 fn cp3inv w edit ulong 1536 o ulong a ulong m ulong to void 213 cp3pow w o a add m 48 m 214 end 215 216 fn cp3tom w edit ulong 1536 o ulong a ulong m ulong to void 217 cp3mul w o a add m 24 m 218 end 219 220 fn cp3frm w edit ulong 1536 o ulong a ulong m ulong to void 221 cp3mul w o a C3ONE1 m 222 end 223 224 fn cp3mod w edit ulong 1536 m ulong to void 225 m0 = get w m 226 x = m0 227 for i ulong 5 228 x = mul x sub 2 mul m0 x 229 end 230 put w add m 12 and sub 0 x `4294967295` 231 cp3set w add m 24 1 232 for j ulong 768 233 cp3add w add m 24 add m 24 add m 24 m 234 end 235 cp3mul w add m 36 C3ONE1 add m 24 m 236 cp3cpy w add m 48 m 237 put w add m 48 sub get w add m 48 2 238 end 239 240 fn cp3init w edit ulong 1536 to void 241 for i ulong 1536 242 put w i 0 243 end 244 put w 0 `4294967295` 245 put w 1 0 246 put w 2 0 247 put w 3 `4294967295` 248 put w 4 `4294967294` 249 put w 5 `4294967295` 250 put w 6 `4294967295` 251 put w 7 `4294967295` 252 put w 8 `4294967295` 253 put w 9 `4294967295` 254 put w 10 `4294967295` 255 put w 11 `4294967295` 256 put w 72 `3435473267` 257 put w 73 `3974895978` 258 put w 74 `1219536762` 259 put w 75 `1478102450` 260 put w 76 `4097256927` 261 put w 77 `3345173889` 262 put w 78 `4294967295` 263 put w 79 `4294967295` 264 put w 80 `4294967295` 265 put w 81 `4294967295` 266 put w 82 `4294967295` 267 put w 83 `4294967295` 268 put w C3ONE1 1 269 cp3mod w C3MP 270 cp3mod w C3MN 271 put w 864 `3555470063` 272 put w 865 `713410797` 273 put w 866 `2318324125` 274 put w 867 `3327539597` 275 put w 868 `1343457114` 276 put w 869 `51644559` 277 put w 870 `4269883666` 278 put w 871 `404593774` 279 put w 872 `3824692505` 280 put w 873 `2559444331` 281 put w 874 `3795773412` 282 put w 875 `3006345127` 283 cp3tom w C3BM C3T1 C3MP 284 put w 864 `1920338615` 285 put w 865 `978607672` 286 put w 866 `3210029420` 287 put w 867 `1426256477` 288 put w 868 `2186553912` 289 put w 869 `1509376480` 290 put w 870 `2343017368` 291 put w 871 `1847409506` 292 put w 872 `4079005044` 293 put w 873 `2394015518` 294 put w 874 `3196781879` 295 put w 875 `2861025826` 296 cp3tom w C3GX C3T1 C3MP 297 put w 864 `2431258207` 298 put w 865 `2051218812` 299 put w 866 `494829981` 300 put w 867 `174109134` 301 put w 868 `3052452032` 302 put w 869 `3923390739` 303 put w 870 `681186428` 304 put w 871 `4176747965` 305 put w 872 `2459098153` 306 put w 873 `1570674879` 307 put w 874 `2519084143` 308 put w 875 `907533898` 309 cp3tom w add C3GX 12 C3T1 C3MP 310 cp3cpy w add C3GX 24 add C3MP 36 311 cp3set w C3T1 0 312 end 313 314 fn cp3padd w edit ulong 1536 o ulong a ulong q ulong to void 315 cp3mul w C3XX a q C3MP 316 cp3mul w C3YY add a 12 add q 12 C3MP 317 cp3mul w C3ZZ add a 24 add q 24 C3MP 318 cp3add w C3U a add a 12 C3MP 319 cp3add w C3V q add q 12 C3MP 320 cp3mul w C3XY C3U C3V C3MP 321 cp3add w C3U C3XX C3YY C3MP 322 cp3sub w C3XY C3XY C3U C3MP 323 cp3add w C3U add a 12 add a 24 C3MP 324 cp3add w C3V add q 12 add q 24 C3MP 325 cp3mul w C3YZ C3U C3V C3MP 326 cp3add w C3U C3YY C3ZZ C3MP 327 cp3sub w C3YZ C3YZ C3U C3MP 328 cp3add w C3U a add a 24 C3MP 329 cp3add w C3V q add q 24 C3MP 330 cp3mul w C3XZ C3U C3V C3MP 331 cp3add w C3U C3XX C3ZZ C3MP 332 cp3sub w C3XZ C3XZ C3U C3MP 333 note bzz3 = 3 (xz - b zz); ym = yy - bzz3; yp = yy + bzz3 334 cp3mul w C3U C3BM C3ZZ C3MP 335 cp3sub w C3U C3XZ C3U C3MP 336 cp3add w C3V C3U C3U C3MP 337 cp3add w C3U C3V C3U C3MP 338 cp3sub w C3YM C3YY C3U C3MP 339 cp3add w C3YP C3YY C3U C3MP 340 note zz3 = 3 zz; bxz3 = 3 (b xz - (zz3 + xx)); xx3 = 3 xx - zz3 341 cp3add w C3ZZ3 C3ZZ C3ZZ C3MP 342 cp3add w C3ZZ3 C3ZZ3 C3ZZ C3MP 343 cp3mul w C3U C3BM C3XZ C3MP 344 cp3add w C3V C3ZZ3 C3XX C3MP 345 cp3sub w C3U C3U C3V C3MP 346 cp3add w C3V C3U C3U C3MP 347 cp3add w C3BX3 C3V C3U C3MP 348 cp3add w C3V C3XX C3XX C3MP 349 cp3add w C3V C3V C3XX C3MP 350 cp3sub w C3XX3 C3V C3ZZ3 C3MP 351 note X3 = yp xy - yz bxz3; Y3 = yp ym + xx3 bxz3; Z3 = ym yz + xy xx3 352 cp3mul w C3U C3YP C3XY C3MP 353 cp3mul w C3V C3YZ C3BX3 C3MP 354 cp3sub w C3RX C3U C3V C3MP 355 cp3mul w C3U C3YP C3YM C3MP 356 cp3mul w C3V C3XX3 C3BX3 C3MP 357 cp3add w add C3RX 12 C3U C3V C3MP 358 cp3mul w C3U C3YM C3YZ C3MP 359 cp3mul w C3V C3XY C3XX3 C3MP 360 cp3add w add C3RX 24 C3U C3V C3MP 361 cp3pcpy w o C3RX 362 end 363 364 fn cp3psel w edit ulong 1536 bit ulong to void 365 mk = sub 0 bit 366 nm = not mk 367 for c ulong 36 368 y = and get w add C3TMP c mk 369 put w add C3ACC c or y and get w add C3ACC c nm 370 end 371 end 372 373 fn cp3smul w edit ulong 1536 o ulong k ulong p ulong to void 374 cp3pcpy w C3BASE p 375 cp3set w C3ACC 0 376 cp3cpy w add C3ACC 12 add C3MP 36 377 cp3set w add C3ACC 24 0 378 i = ulong 0 379 for j ulong 384 380 i = sub 383 j 381 cp3padd w C3ACC C3ACC C3ACC 382 cp3padd w C3TMP C3ACC C3BASE 383 cp3psel w and shr get w add k shr i 5 and i 31 1 384 end 385 cp3pcpy w o C3ACC 386 end 387 388 fn cp3aff w edit ulong 1536 x ulong y ulong p ulong to void 389 cp3inv w C3ZI add p 24 C3MP 390 cp3mul w x p C3ZI C3MP 391 cp3frm w x x C3MP 392 cp3mul w y add p 12 C3ZI C3MP 393 cp3frm w y y C3MP 394 end 395 396 fn cp3ld w edit ulong 1536 o ulong b edit uchar 4096 off ulong to void 397 q = ulong 0 398 v = ulong 0 399 for i ulong 12 400 q = add off sub 44 mul i 4 401 v = ulong get b q 402 v = or shl v 8 ulong get b add q 1 403 v = or shl v 8 ulong get b add q 2 404 v = or shl v 8 ulong get b add q 3 405 put w add o i v 406 end 407 end 408 409 fn cp3oncv w edit ulong 1536 to bool 410 if not cp3lt w C3X C3MP 411 ret false 412 end 413 if not cp3lt w C3Y C3MP 414 ret false 415 end 416 cp3tom w C3T1 C3X C3MP 417 cp3tom w C3T2 C3Y C3MP 418 cp3mul w C3T3 C3T2 C3T2 C3MP 419 cp3mul w C3T2 C3T1 C3T1 C3MP 420 cp3mul w C3T2 C3T2 C3T1 C3MP 421 cp3sub w C3T2 C3T2 C3T1 C3MP 422 cp3sub w C3T2 C3T2 C3T1 C3MP 423 cp3sub w C3T2 C3T2 C3T1 C3MP 424 cp3add w C3T2 C3T2 C3BM C3MP 425 ret cp3eqv w C3T2 C3T3 426 end 427 428 fn cp3vrfy w edit ulong 1536 b edit uchar 4096 to ulong 429 if ne get b C3BPUB 4 430 ret 0 431 end 432 cp3ld w C3X b add C3BPUB 1 433 cp3ld w C3Y b add C3BPUB 49 434 if not cp3oncv w 435 ret 0 436 end 437 cp3ld w C3R b C3BSIG 438 cp3ld w C3S b add C3BSIG 48 439 if not cp3rng w C3R 440 ret 0 441 end 442 if not cp3rng w C3S 443 ret 0 444 end 445 cp3ld w C3Z b C3BDIG 446 cp3modr w C3Z C3MN 447 cp3tom w C3T1 C3S C3MN 448 cp3inv w C3T1 C3T1 C3MN 449 cp3tom w C3T2 C3Z C3MN 450 cp3mul w C3U1 C3T2 C3T1 C3MN 451 cp3frm w C3U1 C3U1 C3MN 452 cp3tom w C3T2 C3R C3MN 453 cp3mul w C3U2 C3T2 C3T1 C3MN 454 cp3frm w C3U2 C3U2 C3MN 455 cp3tom w C3Q C3X C3MP 456 cp3tom w add C3Q 12 C3Y C3MP 457 cp3cpy w add C3Q 24 add C3MP 36 458 cp3smul w C3P1 C3U1 C3GX 459 cp3smul w C3P2 C3U2 C3Q 460 cp3padd w C3P1 C3P1 C3P2 461 if cp3isz w add C3P1 24 462 ret 0 463 end 464 cp3aff w C3X C3Y C3P1 465 cp3modr w C3X C3MN 466 if cp3eqv w C3X C3R 467 ret 1 468 end 469 ret 0 470 end 471