gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit1eb6f1a11eb6f1a1Missions AP56, BS1mre1eb6f1a1/plugins/crypto/README.md

2.7 KB

  1. # hl:crypto — Web Push primitives (ticket #173)
  2. Beside passwords/hashing/base64 (see `server.hl`), hl:crypto carries what RFC 8030 / 8291 /
  3. 8292 need, in Zig `std.crypto` (no OpenSSL) with a node:crypto twin in `server.js`.
  4. Everything takes and returns `Bytes`; calls that can be handed bad input answer `null`
  5. (or `false`) instead of throwing.
  6. | call | in | out |
  7. |---|---|---|
  8. | `base64urlEncode(data)` | String (its UTF-8) or Bytes | String, URL-safe alphabet, **no padding** |
  9. | `base64urlDecode(text)` | String | Bytes, or `null` (not base64url; `+` `/` refused; padded or unpadded accepted) |
  10. | `p256Generate()` | – | `{ privateKey: Bytes 32, publicKey: Bytes 65 }` (uncompressed `04‖X‖Y`); for ES256 **and** ECDH |
  11. | `p256PublicKey(privateKey)` | Bytes 32 | Bytes 65, or `null` (invalid scalar) |
  12. | `es256Sign(privateKey, message)` | Bytes 32, Bytes | Bytes 64 = raw `r‖s` (JWS, not DER); hedged (fresh noise per signature) |
  13. | `es256Verify(publicKey, message, signature)` | Bytes 65, Bytes, Bytes 64 | Boolean (`false` for any malformed input) |
  14. | `ecdhSharedSecret(privateKey, peerPublicKey)` | Bytes 32, Bytes 65 | Bytes 32 (the X coordinate), or `null` (peer not on the curve) |
  15. | `hkdfExtract(salt, ikm)` | Bytes, Bytes | Bytes 32 (PRK); empty salt allowed |
  16. | `hkdfExpand(prk, info, length)` | Bytes 32, Bytes, Number 1..8160 | Bytes `length` |
  17. | `hkdf(salt, ikm, info, length)` | as above | extract then expand |
  18. | `aes128gcmEncrypt(key, nonce, plaintext, aad)` | Bytes 16, Bytes 12, Bytes, Bytes or `null` | Bytes = ciphertext ‖ 16-byte tag (`plaintext.length + 16`) |
  19. | `aes128gcmDecrypt(key, nonce, data, aad)` | Bytes 16, Bytes 12, Bytes (ct‖tag), Bytes or `null` | Bytes plaintext, or `null` when the tag fails / input shorter than 16 |
  20. Wrong-size key, nonce, private key or PRK is a located error (programmer mistake); a wrong
  21. *peer* value is `null`/`false` (remote data).
  22. Known-answer tests: `plugins/build.sh test` (RFC 5869 A.1–A.3, McGrew-Viega GCM cases 1, 2, 4,
  23. node:crypto P-256 key / ECDH secret / ES256 signature), `tests/pass/plugins/038_*` (the same
  24. through the language, plus both engines) and `tests/pass/plugins/037_crypto_rfc8291.hl`
  25. (RFC 8291 §5/Appendix A end to end, composed only from these calls).
  26. `timingSafeEqual(a, b)` compares Strings (their UTF-8 bytes), Bytes, or one of each.
  27. It returns a Boolean; equal byte sequences, including empty inputs, return true.
  28. Equal-length inputs are compared without depending on where they differ; unequal
  29. byte lengths return false immediately (length is public). Other input types return
  30. false. Native calls reuse `constantTimeEql`; Node calls `node:crypto` timingSafeEqual.
  31. The plugin has no browser half, so this call is not offered in the browser.
  32. Regression: `tests/pass/plugins/062_crypto_timing_safe_equal.hl`.

Branches

Latest commits

  • 1eb6f1a1Missions AP56, BS1mre
  • 4871f8adLog: AP52 live on day52, browser gate greenmre
  • d9bf2988Merge ap52: day52, tracker#58 server argument, #51 modal close rule, #56 keyed season rowsmre
  • c4a60ef2Log: RT52 retest passed, AP52 startedmre
  • 83760a55Browser gate: search results belong to the address form of the typed text (tracker#52 navigate replace)mre
  • 6e951d91AP52: show-page rows are keyed records; closing a season is one upsert and removes (tracker#56, hybriel#331)mre
  • 3bb4ccddAP52: modal close button refers to its nested rule with Style.buttonModalX (tracker#51, hybriel#333)mre
  • ba16933fAP52: login callback and title route are static handlers taking the server as third argument (tracker#58, hybriel#332)mre
  • 85153900AP52: re-vendor Hybriel set day52 (source 77cfca31, bin 0a8ed496)mre
  • 7c051eddLog: hybriel#338 answermre
  • d049b8b8Log: HM50 live, #52 donemre
  • 6d05fa37Log: HM50 Part A mergedmre
  • 1c7dab74HM50: the shell reads the framework's online state, netProbe removed (tracker#55)mre
  • e8b91697HM50: search address follows the text via navigate(path, replace = true) (tracker#52)mre
  • 6fe1896cHM50: re-vendor Hybriel set day50 (source 0ae38232, bin d3ef9d16)mre
  • 2f391aa9Log: HM50 startedmre
  • 4b59c03dHM50 mission: doc pathmre
  • ed526d67HM50 missionmre
  • 2f986ca3Log: RT50 passmre
  • 1c4715a4RT50 mission: day50 repro retestmre