You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ec942b9
Browse filesBrowse the repository at this point in the historyBrowse files
feat: add NewJWSSignerFromJWK for private JWK signing
Infer alg from a private jwk.Key (same rules as verify), export raw
private material, and construct a foreign JWS signer. Closes#24.
Co-authored-by: Cursor <cursoragent@cursor.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,7 +53,7 @@ fields.go / digest.go ← Component field abstraction + Content-Digest head
53
53
54
54
### JWX dual-version support
55
55
56
-
Optional foreign JWS uses `lestrrat-go/jwx/v4` via `NewJWSSigner` / `NewJWSVerifier` (infer) / `NewJWSVerifierWithAlg` (including ML-DSA with `crypto/mldsa` on Go 1.27+). Requires Go 1.27+.
56
+
Optional foreign JWS uses `lestrrat-go/jwx/v4` via `NewJWSSigner` / `NewJWSSignerFromJWK` / `NewJWSVerifier` (infer) / `NewJWSVerifierWithAlg` (including ML-DSA with `crypto/mldsa` on Go 1.27+). Requires Go 1.27+.
Copy file name to clipboardExpand all lines: README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,21 +31,21 @@ in the [API reference](https://pkg.go.dev/github.com/yaronf/httpsign).
31
31
32
32
**v0.6.0** (shipped) raised the Go floor to **1.27+** and cut foreign JWS over to **jwx v4** + ML-DSA. See [internal-docs/RELEASE-v0.6.0.md](internal-docs/RELEASE-v0.6.0.md).
33
33
34
-
**v0.6.1** breaks foreign-JWS **verify** again: prefer `NewJWSVerifier(allowed, key, …)` (infer alg); use `NewJWSVerifierWithAlg` when needed; pass a `JWSAlgAllowlist` (`nil` skips policy). `NewJWSSigner` defaults to / requires `SignAlg(false)`.
34
+
**v0.6.1** breaks foreign-JWS **verify** again: prefer `NewJWSVerifier(allowed, key, …)` (infer alg); use `NewJWSVerifierWithAlg` when needed; pass a `JWSAlgAllowlist` (`nil` skips policy). `NewJWSSigner` defaults to / requires `SignAlg(false)`; use `NewJWSSignerFromJWK` when the private key is a JWK.
Pass a non-nil allowlist when `keyid` can select among keys. `SetAllowedAlgs` still only filters Signature-Input `alg`, not JWS `jwa`.
43
43
44
44
Full notes: [internal-docs/RELEASE-v0.6.1.md](internal-docs/RELEASE-v0.6.1.md).
45
45
46
46
### Foreign JWS and ML-DSA
47
47
48
-
Optional algorithms beyond the native set use [`lestrrat-go/jwx/v4`](https://github.com/lestrrat-go/jwx) (≥ v4.5.0) via `NewJWSSigner` / `NewJWSVerifier`.
48
+
Optional algorithms beyond the native set use [`lestrrat-go/jwx/v4`](https://github.com/lestrrat-go/jwx) (≥ v4.5.0) via `NewJWSSigner` / `NewJWSSignerFromJWK` / `NewJWSVerifier`.
49
49
50
50
**ML-DSA (FIPS 204)** works through the same path with `crypto/mldsa` keys. Prefer inferring the alg from the public key:
**Migration:** `NewJWSVerifier(alg, key, cfg, fields)` → `NewJWSVerifierWithAlg(allowed, alg, key, cfg, fields)`, or preferably `NewJWSVerifier(allowed, key, …)` when the key type is inferrable.
3. Existing **`validateJWSKeyAlg`**; default “unsupported” → fall through to **`jws.VerifierFor(alg)`** (jwx).
95
96
4. Reject raw `jwk.Key` here — use preferred `NewJWSVerifier` (or convert).
96
97
97
-
**`NewJWSSigner`:** hardening + passthrough; **no** allowlist; force `SignAlg(false)`.
98
+
**`NewJWSSigner`:** hardening + passthrough; **no** allowlist; force `SignAlg(false)`. Reject raw `jwk.Key` — use `NewJWSSignerFromJWK`.
99
+
100
+
**`NewJWSSignerFromJWK`:** require a **private** JWK (symmetric `oct` OK); resolve alg with the same table / EdDSA↔Ed25519 rules as verify; export raw **private** material; then `NewJWSSigner`.
98
101
99
102
Do **not** put the JWS allowlist on `VerifyConfig`.
Copy file name to clipboardExpand all lines: internal-docs/RELEASE-v0.6.1.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@ Copy the **Summary** section below into the GitHub release when tagging `v0.6.1`
11
11
### Highlights
12
12
13
13
-**Preferred verify API:**`NewJWSVerifier(allowed, key, …)` infers the JWS algorithm from `jwk.Key`, `*ecdsa.PublicKey`, or `*mldsa.PublicKey`.
14
+
-**`NewJWSSignerFromJWK`:** infer alg from a **private**`jwk.Key` and sign (symmetric with preferred verify for JWK-stored keys).
14
15
-**Escape hatch:**`NewJWSVerifierWithAlg(allowed, alg, key, …)` when alg cannot be inferred (raw RSA/HMAC) or the store already chose alg. Today’s `NewJWSVerifier(alg, key, …)` migrates here.
15
16
-**`JWSAlgAllowlist`:** both verify constructors take an allowlist (`nil` skips policy for tests/lazy use). Prefer a non-nil allowlist when `keyid` can select among keys.
16
17
-**`NewJWSSigner`:** nil config defaults to `SignAlg(false)`; configs with `SignAlg(true)` are rejected.
@@ -24,7 +25,7 @@ Copy the **Summary** section below into the GitHub release when tagging `v0.6.1`
24
25
|---------|--------|
25
26
|**Native only**| No API changes. |
26
27
|**`NewJWSVerifier(alg, key, …)`**| Prefer `NewJWSVerifier(allowed, key, …)` when the key is inferrable; else `NewJWSVerifierWithAlg(allowed, alg, key, …)`. |
27
-
|**`NewJWSSigner`**| Omit config or keep `SignAlg(false)`; `SignAlg(true)` now errors. |
28
+
|**`NewJWSSigner`**| Omit config or keep `SignAlg(false)`; `SignAlg(true)` now errors. Prefer `NewJWSSignerFromJWK` when the private key is a JWK. |
0 commit comments