@@ -24,7 +24,7 @@ I can continue maintaining it and adding new features carefree. You may also don
24
24
## JWK (JSON Web Key)
25
25
26
26
<!-- TOC JWK START -->
27
- - [ Class: < ; JWK.Key> ; and < ; JWK.RSAKey> ; &vert ; < ; JWK.ECKey> ; &vert ; < ; JWK.OctKey> ; ] ( #class-jwkkey-and-jwkrsakey--jwkeckey--jwkoctkey )
27
+ - [ Class: < ; JWK.Key> ; and < ; JWK.RSAKey> ; &vert ; < ; JWK.ECKey> ; &vert ; < ; JWK.OKPKey & gt ; & vert ; & lt ; JWK. OctKey> ; ] ( #class-jwkkey-and-jwkrsakey--jwkeckey--jwkokpkey --jwkoctkey )
28
28
- [ key.kty] ( #keykty )
29
29
- [ key.alg] ( #keyalg )
30
30
- [ key.use] ( #keyuse )
@@ -58,28 +58,30 @@ const { JWK } = require('@panva/jose')
58
58
59
59
---
60
60
61
- #### Class: ` <JWK.Key> ` and ` <JWK.RSAKey> ` &vert ; ` <JWK.ECKey> ` &vert ; ` <JWK.OctKey> `
61
+ #### Class: ` <JWK.Key> ` and ` <JWK.RSAKey> ` &vert ; ` <JWK.ECKey> ` &vert ; ` <JWK.OKPKey> ` & vert ; ` <JWK. OctKey>`
62
62
63
- ` <JWK.RSAKey> ` , ` <JWK.ECKey> ` and ` <JWK.OctKey> ` represent a key usable for JWS and JWE operations.
63
+ ` <JWK.RSAKey> ` , ` <JWK.ECKey> ` , ` <JWK.OKPKey> ` and ` <JWK.OctKey> ` represent a key usable for JWS and JWE operations.
64
64
The ` JWK.importKey() ` method is used to retrieve a key representation of an existing key or secret.
65
65
` JWK.generate() ` method is used to generate a new random key.
66
66
67
- ` <JWK.RSAKey> ` , ` <JWK.ECKey> ` and ` <JWK.OctKey> ` inherit methods from ` <JWK.Key> ` and in addition
67
+ ` <JWK.RSAKey> ` , ` <JWK.ECKey> ` , ` <JWK.OKPKey> ` and ` <JWK.OctKey> ` inherit methods from ` <JWK.Key> ` and in addition
68
68
to the properties documented below have the respective key component properties exported as
69
69
` <string> ` in their format defined by the specifications.
70
70
71
71
- ` e, n ` for Public RSA Keys
72
72
- ` e, n, d, p, q, dp, dq, qi ` for Private RSA Keys
73
73
- ` crv, x, y ` for Public EC Keys
74
74
- ` crv, x, y, n ` for Private EC Keys
75
+ - ` crv, x ` for Public OKP Keys
76
+ - ` crv, x, n ` for Private OKP Keys
75
77
- ` k ` for Symmetric keys
76
78
77
79
---
78
80
79
81
#### ` key.kty `
80
82
81
- Returns the key's JWK Key Type Parameter. 'EC', 'RSA' or 'oct' for the respective supported key
82
- types.
83
+ Returns the key's JWK Key Type Parameter. 'EC', 'RSA', 'OKP' or 'oct' for the respective supported
84
+ key types.
83
85
84
86
- ` <string> `
85
87
@@ -262,7 +264,7 @@ Private keys may also be passphrase protected.
262
264
[ RFC7638] [ spec-thumbprint ]
263
265
- ` use ` : ` <string> ` option indicates whether the key is to be used for encrypting & decrypting
264
266
data or signing & verifying data. Must be 'sig' or 'enc'.
265
- - Returns: ` <JWK.RSAKey> ` &vert ; ` <JWK.ECKey> `
267
+ - Returns: ` <JWK.RSAKey> ` &vert ; ` <JWK.ECKey> ` & vert ; ` <JWK.OKPKey> `
266
268
267
269
See the underlying Node.js API for details on importing private and public keys in the different
268
270
formats
@@ -321,11 +323,11 @@ const key = importKey(Buffer.from('8yHym6h5CG5FylbzrCn8fhxEbp3kOaTsgLaawaaJ'))
321
323
322
324
#### ` JWK.importKey(jwk) ` JWK-formatted key import
323
325
324
- Imports a JWK formatted key. This supports JWK formatted EC, RSA and oct keys. Asymmetrical keys
325
- may be both private and public.
326
+ Imports a JWK formatted key. This supports JWK formatted RSA, EC, OKP and oct keys. Asymmetrical
327
+ keys may be both private and public.
326
328
327
329
- ` jwk ` : ` <Object> `
328
- - ` kty ` : ` <string> ` Key type. Must be 'RSA', 'EC' or 'oct'.
330
+ - ` kty ` : ` <string> ` Key type. Must be 'RSA', 'EC', 'OKP' or 'oct'.
329
331
- ` alg ` : ` <string> ` option identifies the algorithm intended for use with the key.
330
332
- ` use ` : ` <string> ` option indicates whether the key is to be used for encrypting & decrypting
331
333
data or signing & verifying data. Must be 'sig' or 'enc'.
@@ -335,8 +337,10 @@ may be both private and public.
335
337
- ` e ` , ` n ` , ` d ` , ` p ` , ` q ` , ` dp ` , ` dq ` , ` qi ` properties as ` <string> ` for RSA private keys
336
338
- ` crv ` , ` x ` , ` y ` properties as ` <string> ` for EC public keys
337
339
- ` crv ` , ` x ` , ` y ` , ` d ` properties as ` <string> ` for EC private keys
340
+ - ` crv ` , ` x ` , properties as ` <string> ` for OKP public keys
341
+ - ` crv ` , ` x ` , ` d ` properties as ` <string> ` for OKP private keys
338
342
- ` k ` properties as ` <string> ` for secret oct keys
339
- - Returns: ` <JWK.RSAKey> ` &vert ; ` <JWK.ECKey> ` &vert ; ` <JWK.OctKey> `
343
+ - Returns: ` <JWK.RSAKey> ` &vert ; ` <JWK.ECKey> ` &vert ; ` <JWK.OKPKey> ` & vert ; ` <JWK. OctKey>`
340
344
341
345
<details >
342
346
<summary ><em ><strong >Example</strong ></em > (Click to expand)</summary >
@@ -366,10 +370,11 @@ const key = importKey(jwk)
366
370
367
371
#### ` JWK.generate(kty[, crvOrSize[, options[, private]]]) ` generating new keys
368
372
369
- Securely generates a new RSA, EC or oct key.
373
+ Securely generates a new RSA, EC, OKP or oct key.
370
374
371
- - ` kty ` : ` <string> ` Key type. Must be 'RSA', 'EC' or 'oct'.
372
- - ` crvOrSize ` : ` <number> ` &vert ; ` <string> ` key's bit size or in case of EC keys the curve
375
+ - ` kty ` : ` <string> ` Key type. Must be 'RSA', 'EC', 'OKP' or 'oct'.
376
+ - ` crvOrSize ` : ` <number> ` &vert ; ` <string> ` key's bit size or in case of OKP and EC keys the curve
377
+ ** Default:** 2048 for RSA, 'P-256' for EC, 'Ed25519' for OKP and 256 for oct.
373
378
- ` options ` : ` <Object> `
374
379
- ` alg ` : ` <string> ` option identifies the algorithm intended for use with the key.
375
380
- ` kid ` : ` <string> ` Key ID Parameter. When not provided is computed using the method defined in
@@ -378,7 +383,7 @@ Securely generates a new RSA, EC or oct key.
378
383
data or signing & verifying data. Must be 'sig' or 'enc'.
379
384
- ` private ` : ` <boolean> ` ** Default** 'true'. Is the resulting key private or public (when
380
385
asymmetrical)
381
- - Returns: ` Promise<JWK.RSAKey> ` &vert ; ` Promise<JWK.ECKey> ` &vert ; ` Promise<JWK.OctKey> `
386
+ - Returns: ` Promise<JWK.RSAKey> ` &vert ; ` Promise<JWK.ECKey> ` &vert ; ` Promise<JWK.OKPKey> ` & vert ; ` Promise<JWK. OctKey>`
382
387
383
388
<details >
384
389
<summary ><em ><strong >Example</strong ></em > (Click to expand)</summary >
@@ -406,9 +411,9 @@ const { JWK: { generate } } = require('@panva/jose')
406
411
407
412
Synchronous version of ` JWK.generate() `
408
413
409
- - ` kty ` : ` <string> ` Key type. Must be 'RSA', 'EC' or 'oct'.
410
- - ` crvOrSize ` : ` <number> ` &vert ; ` <string> ` key's bit size or in case of EC keys the curve. ** Default: **
411
- 2048 for RSA, 'P-256' for EC and 256 for oct.
414
+ - ` kty ` : ` <string> ` Key type. Must be 'RSA', 'EC', 'OKP' or 'oct'.
415
+ - ` crvOrSize ` : ` <number> ` &vert ; ` <string> ` key's bit size or in case of OKP and EC keys the curve.
416
+ ** Default: ** 2048 for RSA, 'P-256' for EC, 'Ed25519' for OKP and 256 for oct.
412
417
- ` options ` : ` <Object> `
413
418
- ` alg ` : ` <string> ` option identifies the algorithm intended for use with the key.
414
419
- ` use ` : ` <string> ` option indicates whether the key is to be used for encrypting & decrypting
@@ -417,7 +422,7 @@ Synchronous version of `JWK.generate()`
417
422
[ RFC7638] [ spec-thumbprint ]
418
423
- ` private ` : ` <boolean> ` ** Default** 'true'. Is the resulting key private or public (when
419
424
asymmetrical)
420
- - Returns: ` <JWK.RSAKey> ` &vert ; ` <JWK.ECKey> ` &vert ; ` <JWK.OctKey> `
425
+ - Returns: ` <JWK.RSAKey> ` &vert ; ` <JWK.ECKey> ` &vert ; ` <JWK.OKPKey> ` & vert ; ` <JWK. OctKey>`
421
426
422
427
<details >
423
428
<summary ><em ><strong >Example</strong ></em > (Click to expand)</summary >
@@ -527,23 +532,23 @@ parameters is returned.
527
532
- ` kid ` : ` <string> ` Key ID to filter for.
528
533
- ` operation ` : ` <string> ` Further specify the operation a given alg must be valid for. Must be one
529
534
of 'encrypt', 'decrypt', 'sign', 'verify', 'wrapKey', 'unwrapKey'
530
- - Returns: ` <JWK.RSAKey> ` &vert ; ` <JWK.ECKey> ` &vert ; ` <JWK.OctKey> ` &vert ; ` <undefined> `
535
+ - Returns: ` <JWK.RSAKey> ` &vert ; ` <JWK.ECKey> ` &vert ; ` <JWK.OKPKey> ` & vert ; ` <JWK. OctKey>` &vert ; ` <undefined> `
531
536
532
537
---
533
538
534
539
#### ` keystore.add(key) `
535
540
536
541
Adds a key instance to the store unless it is already included.
537
542
538
- - ` key ` : ` <JWK.RSAKey> ` &vert ; ` <JWK.ECKey> ` &vert ; ` <JWK.OctKey> `
543
+ - ` key ` : ` <JWK.RSAKey> ` &vert ; ` <JWK.ECKey> ` &vert ; ` <JWK.OKPKey> ` & vert ; ` <JWK. OctKey>`
539
544
540
545
---
541
546
542
547
#### ` keystore.remove(key) `
543
548
544
549
Ensures a key is removed from a store.
545
550
546
- - ` key ` : ` <JWK.RSAKey> ` &vert ; ` <JWK.ECKey> ` &vert ; ` <JWK.OctKey> `
551
+ - ` key ` : ` <JWK.RSAKey> ` &vert ; ` <JWK.ECKey> ` &vert ; ` <JWK.OKPKey> ` & vert ; ` <JWK. OctKey>`
547
552
548
553
---
549
554
0 commit comments