gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmain10f8a8c8Merge branch 'code-order' into mainJukeboxmain/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

  • 10f8a8c8Merge branch 'code-order' into mainJukebox
  • 204fc828Merge branch 'day72' into mainJukebox
  • 95f5faae|||PR jukebox#7 Drop needless let declarationsmre
  • 33072bb5|||PR Record day72 gates and Chrome proofmre
  • 95f2cd73|||PR Use typed parent methods for screen playback and local server facesmre
  • 6422a020Sync media-player at 51c3818mre
  • b582ba1cVendor complete Hybriel day72 plugin setmre
  • 02dccbc9Merge branch 'records-1119' into mainJukebox
  • a39e1c23|||PR Records: missions 013-015, reconnect fix livemre
  • fc7db075Merge branch 'reconnect-retry' into mainJukebox
  • ac6f4c6fL2: plain declaration for a in pickedNextmre
  • 2f335086Review round 2: only an explicit queue pick drops pend (not the automatic advance); jb23 records every source changemre
  • 3eb6695fReview fixes: action generation, queue pick clears pend, Previous/Next retry the decided request, typed handlersmre
  • 7a53c0c2|||PR A tap lost to a dead socket plays after reconnect (mission 015)mre
  • 1f0cd77bMerge branch 'records-day41' into mainJukebox
  • 67be229f|||PR Records: day41 live (PR #4), mission 012, statusmre
  • 0bb027daconductor: caramboleyo is the user, not owner/creatorApollo
  • 04f5d9d5Merge branch 'day41' into mainJukebox
  • 8ed6da45|||PR README: media-player pin df9e7dfmre
  • d5d45fc3|||PR media-player df9e7df (repeat-one fix), sync pin and SOURCEmre