Skip to content

Commit ce6a069

Browse files
autodoc updates (#2157)
Co-authored-by: lestrrat <lestrrat@users.noreply.github.com>
1 parent 0af8770 commit ce6a069

3 files changed

Lines changed: 17 additions & 17 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ func Example() {
108108

109109
// Encrypt and Decrypt arbitrary payload with JWE!
110110
{
111-
encrypted, err := jwe.Encrypt(payloadLoremIpsum, jwe.WithKey(jwa.RSA_OAEP(), jwkRSAPublicKey))
111+
encrypted, err := jwe.Encrypt(payloadLoremIpsum, jwe.WithKey(jwa.RSA_OAEP_256(), jwkRSAPublicKey))
112112
if err != nil {
113113
fmt.Printf("failed to encrypt payload: %s\n", err)
114114
return
115115
}
116116

117-
decrypted, err := jwe.Decrypt(encrypted, jwe.WithKey(jwa.RSA_OAEP(), jwkRSAPrivateKey))
117+
decrypted, err := jwe.Decrypt(encrypted, jwe.WithKey(jwa.RSA_OAEP_256(), jwkRSAPrivateKey))
118118
if err != nil {
119119
fmt.Printf("failed to decrypt payload: %s\n", err)
120120
return

docs/01-jwt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,7 @@ func Example_jwt_serialize_jwe_jws() {
14461446
}
14471447

14481448
serialized, err := jwt.NewSerializer().
1449-
Encrypt(jwt.WithKey(jwa.RSA_OAEP(), enckey)).
1449+
Encrypt(jwt.WithKey(jwa.RSA_OAEP_256(), enckey)).
14501450
Sign(jwt.WithKey(jwa.HS256(), signkey)).
14511451
Serialize(tok)
14521452
if err != nil {

docs/03-jwe.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,13 @@ func Example_jwe_encrypt() {
146146
}
147147

148148
const payload = `Lorem ipsum`
149-
encrypted, err := jwe.Encrypt([]byte(payload), jwe.WithKey(jwa.RSA_OAEP(), pubkey))
149+
encrypted, err := jwe.Encrypt([]byte(payload), jwe.WithKey(jwa.RSA_OAEP_256(), pubkey))
150150
if err != nil {
151151
fmt.Printf("failed to encrypt payload: %s\n", err)
152152
return
153153
}
154154

155-
decrypted, err := jwe.Decrypt(encrypted, jwe.WithKey(jwa.RSA_OAEP(), privkey))
155+
decrypted, err := jwe.Decrypt(encrypted, jwe.WithKey(jwa.RSA_OAEP_256(), privkey))
156156
if err != nil {
157157
fmt.Printf("failed to decrypt payload: %s\n", err)
158158
return
@@ -207,14 +207,14 @@ func Example_jwe_encrypt_json() {
207207
encrypted, err := jwe.Encrypt(
208208
[]byte(payload),
209209
jwe.WithJSON(), // Toggle JSON serialization. Because there's only one key (recipient), this will produce Flattened JSON serialization
210-
jwe.WithKey(jwa.RSA_OAEP(), pubkey), // Public key for encryption
210+
jwe.WithKey(jwa.RSA_OAEP_256(), pubkey), // Public key for encryption
211211
)
212212
if err != nil {
213213
fmt.Printf("failed to encrypt payload: %s\n", err)
214214
return
215215
}
216216

217-
decrypted, err := jwe.Decrypt(encrypted, jwe.WithKey(jwa.RSA_OAEP(), privkey))
217+
decrypted, err := jwe.Decrypt(encrypted, jwe.WithKey(jwa.RSA_OAEP_256(), privkey))
218218
if err != nil {
219219
fmt.Printf("failed to decrypt payload: %s\n", err)
220220
return
@@ -251,7 +251,7 @@ func Example_jwe_encrypt_json_multi() {
251251

252252
options := []jwe.EncryptOption{jwe.WithJSON()}
253253
for _, key := range pubkeys {
254-
options = append(options, jwe.WithKey(jwa.RSA_OAEP(), key))
254+
options = append(options, jwe.WithKey(jwa.RSA_OAEP_256(), key))
255255
}
256256

257257
const payload = `Lorem ipsum`
@@ -262,7 +262,7 @@ func Example_jwe_encrypt_json_multi() {
262262
}
263263

264264
for _, key := range privkeys {
265-
decrypted, err := jwe.Decrypt(encrypted, jwe.WithKey(jwa.RSA_OAEP(), key))
265+
decrypted, err := jwe.Decrypt(encrypted, jwe.WithKey(jwa.RSA_OAEP_256(), key))
266266
if err != nil {
267267
fmt.Printf("failed to decrypt payload: %s\n", err)
268268
return
@@ -312,7 +312,7 @@ func Example_jwe_encrypt_with_headers() {
312312

313313
hdrs := jwe.NewHeaders()
314314
hdrs.Set(`x-example`, true)
315-
encrypted, err := jwe.Encrypt([]byte(payload), jwe.WithKey(jwa.RSA_OAEP(), privkey.PublicKey, jwe.WithPerRecipientHeaders(hdrs)))
315+
encrypted, err := jwe.Encrypt([]byte(payload), jwe.WithKey(jwa.RSA_OAEP_256(), privkey.PublicKey, jwe.WithPerRecipientHeaders(hdrs)))
316316
if err != nil {
317317
fmt.Printf("failed to encrypt payload: %s\n", err)
318318
return
@@ -337,7 +337,7 @@ func Example_jwe_encrypt_with_headers() {
337337
json.NewEncoder(os.Stdout).Encode(msg.ProtectedHeaders())
338338

339339
// OUTPUT:
340-
// {"alg":"RSA-OAEP","enc":"A256GCM","x-example":true}
340+
// {"alg":"RSA-OAEP-256","enc":"A256GCM","x-example":true}
341341
}
342342
```
343343
source: [examples/jwe_encrypt_with_headers_example_test.go](https://github.com/jwx-go/examples/blob/v4/jwe_encrypt_with_headers_example_test.go)
@@ -365,13 +365,13 @@ import (
365365

366366
func Example_jwe_verify_with_key() {
367367
const payload = "Lorem ipsum"
368-
encrypted, err := jwe.Encrypt([]byte(payload), jwe.WithKey(jwa.RSA_OAEP(), jwkRSAPublicKey))
368+
encrypted, err := jwe.Encrypt([]byte(payload), jwe.WithKey(jwa.RSA_OAEP_256(), jwkRSAPublicKey))
369369
if err != nil {
370370
fmt.Printf("failed to sign payload: %s\n", err)
371371
return
372372
}
373373

374-
decrypted, err := jwe.Decrypt(encrypted, jwe.WithKey(jwa.RSA_OAEP(), jwkRSAPrivateKey))
374+
decrypted, err := jwe.Decrypt(encrypted, jwe.WithKey(jwa.RSA_OAEP_256(), jwkRSAPrivateKey))
375375
if err != nil {
376376
fmt.Printf("failed to sign payload: %s\n", err)
377377
return
@@ -415,7 +415,7 @@ func Example_jwe_verify_with_jwk_set() {
415415
return
416416
}
417417
const payload = "Lorem ipsum"
418-
encrypted, err := jwe.Encrypt([]byte(payload), jwe.WithKey(jwa.RSA_OAEP(), privkey.PublicKey))
418+
encrypted, err := jwe.Encrypt([]byte(payload), jwe.WithKey(jwa.RSA_OAEP_256(), privkey.PublicKey))
419419
if err != nil {
420420
fmt.Printf("failed to sign payload: %s\n", err)
421421
return
@@ -430,7 +430,7 @@ func Example_jwe_verify_with_jwk_set() {
430430
set.AddKey(k2)
431431
// Add the real thing
432432
k3, _ := jwk.Import[jwk.Key](privkey)
433-
k3.Set(jwk.AlgorithmKey, jwa.RSA_OAEP())
433+
k3.Set(jwk.AlgorithmKey, jwa.RSA_OAEP_256())
434434
set.AddKey(k3)
435435

436436
// Up to this point, you probably will replace with a simple
@@ -686,7 +686,7 @@ func Example_jwe_filter_basic() {
686686
// and application-specific custom fields.
687687
protectedHeaders := jwe.NewHeaders()
688688
protectedHeaders.Set(jwe.AlgorithmKey, jwa.RSA_OAEP_256())
689-
protectedHeaders.Set(jwe.ContentEncryptionKey, jwa.A256GCM)
689+
protectedHeaders.Set(jwe.ContentEncryptionKey, jwa.A256GCM())
690690
protectedHeaders.Set(jwe.ContentTypeKey, "application/json")
691691
protectedHeaders.Set(jwe.KeyIDKey, "example-key-1")
692692
protectedHeaders.Set("custom-header", "custom-value")
@@ -777,7 +777,7 @@ func Example_jwe_filter_advanced() {
777777
// Create JWE headers with comprehensive metadata including security and service information
778778
protectedHeaders := jwe.NewHeaders()
779779
protectedHeaders.Set(jwe.AlgorithmKey, jwa.RSA_OAEP_256())
780-
protectedHeaders.Set(jwe.ContentEncryptionKey, jwa.A256GCM)
780+
protectedHeaders.Set(jwe.ContentEncryptionKey, jwa.A256GCM())
781781
protectedHeaders.Set(jwe.ContentTypeKey, "application/json")
782782
protectedHeaders.Set(jwe.KeyIDKey, "service-key-001")
783783

0 commit comments

Comments
 (0)