@@ -7,7 +7,7 @@ const { oaepHashSupported } = require('../../lib/help/node_support')
77const { generateSync } = require ( '../../lib/jwk/generate' )
88const RSAKey = require ( '../../lib/jwk/key/rsa' )
99
10- test ( ` RSA key .algorithms invalid operation` , t => {
10+ test ( ' RSA key .algorithms invalid operation' , t => {
1111 const key = new RSAKey ( createPrivateKey ( fixtures . PEM . RSA . private ) )
1212 t . throws ( ( ) => key . algorithms ( 'foo' ) , { instanceOf : TypeError , message : 'invalid key operation' } )
1313} )
@@ -17,20 +17,20 @@ test(`RSA key .algorithms invalid operation`, t => {
1717 const keyObject = createPrivateKey ( fixtures . PEM . RSA . private )
1818 const key = new RSAKey ( keyObject )
1919
20- test ( ` RSA Private key (with alg)` , hasProperty , new RSAKey ( keyObject , { alg : 'RS256' } ) , 'alg' , 'RS256' )
21- test ( ` RSA Private key (with kid)` , hasProperty , new RSAKey ( keyObject , { kid : 'foobar' } ) , 'kid' , 'foobar' )
22- test ( ` RSA Private key (with use)` , hasProperty , new RSAKey ( keyObject , { use : 'sig' } ) , 'use' , 'sig' )
23- test ( ` RSA Private key` , hasNoProperties , key , 'k' , 'x' , 'y' )
24- test ( ` RSA Private key` , hasProperties , key , 'e' , 'n' , 'p' , 'q' , 'dp' , 'dq' , 'qi' , 'd' )
25- test ( ` RSA Private key` , hasProperty , key , 'alg' , undefined )
26- test ( ` RSA Private key` , hasProperty , key , 'kid' , 'Bj1ccHv-y_ZoejJKWhAhBHLpnGSlawNAQUAMEQBd5L8' )
27- test ( ` RSA Private key` , hasProperty , key , 'kty' , 'RSA' )
28- test ( ` RSA Private key` , hasProperty , key , 'length' , 2048 )
29- test ( ` RSA Private key` , hasProperty , key , 'private' , true )
30- test ( ` RSA Private key` , hasProperty , key , 'public' , false )
31- test ( ` RSA Private key` , hasProperty , key , 'secret' , false )
32- test ( ` RSA Private key` , hasProperty , key , 'type' , 'private' )
33- test ( ` RSA Private key` , hasProperty , key , 'use' , undefined )
20+ test ( ' RSA Private key (with alg)' , hasProperty , new RSAKey ( keyObject , { alg : 'RS256' } ) , 'alg' , 'RS256' )
21+ test ( ' RSA Private key (with kid)' , hasProperty , new RSAKey ( keyObject , { kid : 'foobar' } ) , 'kid' , 'foobar' )
22+ test ( ' RSA Private key (with use)' , hasProperty , new RSAKey ( keyObject , { use : 'sig' } ) , 'use' , 'sig' )
23+ test ( ' RSA Private key' , hasNoProperties , key , 'k' , 'x' , 'y' )
24+ test ( ' RSA Private key' , hasProperties , key , 'e' , 'n' , 'p' , 'q' , 'dp' , 'dq' , 'qi' , 'd' )
25+ test ( ' RSA Private key' , hasProperty , key , 'alg' , undefined )
26+ test ( ' RSA Private key' , hasProperty , key , 'kid' , 'Bj1ccHv-y_ZoejJKWhAhBHLpnGSlawNAQUAMEQBd5L8' )
27+ test ( ' RSA Private key' , hasProperty , key , 'kty' , 'RSA' )
28+ test ( ' RSA Private key' , hasProperty , key , 'length' , 2048 )
29+ test ( ' RSA Private key' , hasProperty , key , 'private' , true )
30+ test ( ' RSA Private key' , hasProperty , key , 'public' , false )
31+ test ( ' RSA Private key' , hasProperty , key , 'secret' , false )
32+ test ( ' RSA Private key' , hasProperty , key , 'type' , 'private' )
33+ test ( ' RSA Private key' , hasProperty , key , 'use' , undefined )
3434
3535 if ( oaepHashSupported ) {
3636 test ( 'RSA Private key algorithms (no operation)' , t => {
@@ -53,54 +53,54 @@ test(`RSA key .algorithms invalid operation`, t => {
5353 t . deepEqual ( [ ...result ] , [ 'RS256' ] )
5454 } )
5555
56- test ( ` RSA Private key supports sign alg (no use)` , t => {
56+ test ( ' RSA Private key supports sign alg (no use)' , t => {
5757 const result = key . algorithms ( 'sign' )
5858 t . is ( result . constructor , Set )
5959 t . deepEqual ( [ ...result ] , [ 'PS256' , 'RS256' , 'PS384' , 'RS384' , 'PS512' , 'RS512' ] )
6060 } )
6161
62- test ( ` RSA Private key supports verify alg (no use)` , t => {
62+ test ( ' RSA Private key supports verify alg (no use)' , t => {
6363 const result = key . algorithms ( 'verify' )
6464 t . is ( result . constructor , Set )
6565 t . deepEqual ( [ ...result ] , [ 'PS256' , 'RS256' , 'PS384' , 'RS384' , 'PS512' , 'RS512' ] )
6666 } )
6767
68- test ( ` RSA Private key supports sign alg when \ `use\ ` is "sig")` , t => {
68+ test ( ' RSA Private key supports sign alg when `use` is "sig")' , t => {
6969 const sigKey = new RSAKey ( keyObject , { use : 'sig' } )
7070 const result = sigKey . algorithms ( 'sign' )
7171 t . is ( result . constructor , Set )
7272 t . deepEqual ( [ ...result ] , [ 'PS256' , 'RS256' , 'PS384' , 'RS384' , 'PS512' , 'RS512' ] )
7373 } )
7474
75- test ( ` RSA Private key supports verify alg when \ `use\ ` is "sig")` , t => {
75+ test ( ' RSA Private key supports verify alg when `use` is "sig")' , t => {
7676 const sigKey = new RSAKey ( keyObject , { use : 'sig' } )
7777 const result = sigKey . algorithms ( 'verify' )
7878 t . is ( result . constructor , Set )
7979 t . deepEqual ( [ ...result ] , [ 'PS256' , 'RS256' , 'PS384' , 'RS384' , 'PS512' , 'RS512' ] )
8080 } )
8181
82- test ( ` RSA Private key supports single sign alg when \ `alg\ ` is set)` , t => {
82+ test ( ' RSA Private key supports single sign alg when `alg` is set)' , t => {
8383 const sigKey = new RSAKey ( keyObject , { alg : 'RS256' } )
8484 const result = sigKey . algorithms ( 'sign' )
8585 t . is ( result . constructor , Set )
8686 t . deepEqual ( [ ...result ] , [ 'RS256' ] )
8787 } )
8888
89- test ( ` RSA Private key supports single verify alg when \ `alg\ ` is set)` , t => {
89+ test ( ' RSA Private key supports single verify alg when `alg` is set)' , t => {
9090 const sigKey = new RSAKey ( keyObject , { alg : 'RS256' } )
9191 const result = sigKey . algorithms ( 'verify' )
9292 t . is ( result . constructor , Set )
9393 t . deepEqual ( [ ...result ] , [ 'RS256' ] )
9494 } )
9595
96- test ( ` RSA Private key no sign support when \ `use\ ` is "enc"` , t => {
96+ test ( ' RSA Private key no sign support when `use` is "enc"' , t => {
9797 const encKey = new RSAKey ( keyObject , { use : 'enc' } )
9898 const result = encKey . algorithms ( 'sign' )
9999 t . is ( result . constructor , Set )
100100 t . deepEqual ( [ ...result ] , [ ] )
101101 } )
102102
103- test ( ` RSA Private key no verify support when \ `use\ ` is "enc"` , t => {
103+ test ( ' RSA Private key no verify support when `use` is "enc"' , t => {
104104 const encKey = new RSAKey ( keyObject , { use : 'enc' } )
105105 const result = encKey . algorithms ( 'verify' )
106106 t . is ( result . constructor , Set )
@@ -173,20 +173,20 @@ test(`RSA key .algorithms invalid operation`, t => {
173173 const keyObject = createPublicKey ( fixtures . PEM . RSA . public )
174174 const key = new RSAKey ( keyObject )
175175
176- test ( ` RSA Public key (with alg)` , hasProperty , new RSAKey ( keyObject , { alg : 'RS256' } ) , 'alg' , 'RS256' )
177- test ( ` RSA Public key (with kid)` , hasProperty , new RSAKey ( keyObject , { kid : 'foobar' } ) , 'kid' , 'foobar' )
178- test ( ` RSA Public key (with use)` , hasProperty , new RSAKey ( keyObject , { use : 'sig' } ) , 'use' , 'sig' )
179- test ( ` RSA Public key` , hasNoProperties , key , 'k' , 'x' , 'y' , 'd' , 'p' , 'q' , 'dp' , 'dq' , 'qi' )
180- test ( ` RSA Public key` , hasProperties , key , 'e' , 'n' )
181- test ( ` RSA Public key` , hasProperty , key , 'alg' , undefined )
182- test ( ` RSA Public key` , hasProperty , key , 'kid' , 'Bj1ccHv-y_ZoejJKWhAhBHLpnGSlawNAQUAMEQBd5L8' )
183- test ( ` RSA Public key` , hasProperty , key , 'kty' , 'RSA' )
184- test ( ` RSA Public key` , hasProperty , key , 'length' , 2048 )
185- test ( ` RSA Public key` , hasProperty , key , 'private' , false )
186- test ( ` RSA Public key` , hasProperty , key , 'public' , true )
187- test ( ` RSA Public key` , hasProperty , key , 'secret' , false )
188- test ( ` RSA Public key` , hasProperty , key , 'type' , 'public' )
189- test ( ` RSA Public key` , hasProperty , key , 'use' , undefined )
176+ test ( ' RSA Public key (with alg)' , hasProperty , new RSAKey ( keyObject , { alg : 'RS256' } ) , 'alg' , 'RS256' )
177+ test ( ' RSA Public key (with kid)' , hasProperty , new RSAKey ( keyObject , { kid : 'foobar' } ) , 'kid' , 'foobar' )
178+ test ( ' RSA Public key (with use)' , hasProperty , new RSAKey ( keyObject , { use : 'sig' } ) , 'use' , 'sig' )
179+ test ( ' RSA Public key' , hasNoProperties , key , 'k' , 'x' , 'y' , 'd' , 'p' , 'q' , 'dp' , 'dq' , 'qi' )
180+ test ( ' RSA Public key' , hasProperties , key , 'e' , 'n' )
181+ test ( ' RSA Public key' , hasProperty , key , 'alg' , undefined )
182+ test ( ' RSA Public key' , hasProperty , key , 'kid' , 'Bj1ccHv-y_ZoejJKWhAhBHLpnGSlawNAQUAMEQBd5L8' )
183+ test ( ' RSA Public key' , hasProperty , key , 'kty' , 'RSA' )
184+ test ( ' RSA Public key' , hasProperty , key , 'length' , 2048 )
185+ test ( ' RSA Public key' , hasProperty , key , 'private' , false )
186+ test ( ' RSA Public key' , hasProperty , key , 'public' , true )
187+ test ( ' RSA Public key' , hasProperty , key , 'secret' , false )
188+ test ( ' RSA Public key' , hasProperty , key , 'type' , 'public' )
189+ test ( ' RSA Public key' , hasProperty , key , 'use' , undefined )
190190
191191 if ( oaepHashSupported ) {
192192 test ( 'RSA EC Public key algorithms (no operation)' , t => {
@@ -209,54 +209,54 @@ test(`RSA key .algorithms invalid operation`, t => {
209209 t . deepEqual ( [ ...result ] , [ 'RS256' ] )
210210 } )
211211
212- test ( ` RSA Public key cannot sign` , t => {
212+ test ( ' RSA Public key cannot sign' , t => {
213213 const result = key . algorithms ( 'sign' )
214214 t . is ( result . constructor , Set )
215215 t . deepEqual ( [ ...result ] , [ ] )
216216 } )
217217
218- test ( ` RSA Public key supports verify alg (no use)` , t => {
218+ test ( ' RSA Public key supports verify alg (no use)' , t => {
219219 const result = key . algorithms ( 'verify' )
220220 t . is ( result . constructor , Set )
221221 t . deepEqual ( [ ...result ] , [ 'PS256' , 'RS256' , 'PS384' , 'RS384' , 'PS512' , 'RS512' ] )
222222 } )
223223
224- test ( ` RSA Public key cannot sign even when \ `use\ ` is "sig")` , t => {
224+ test ( ' RSA Public key cannot sign even when `use` is "sig")' , t => {
225225 const sigKey = new RSAKey ( keyObject , { use : 'sig' } )
226226 const result = sigKey . algorithms ( 'sign' )
227227 t . is ( result . constructor , Set )
228228 t . deepEqual ( [ ...result ] , [ ] )
229229 } )
230230
231- test ( ` RSA Public key supports verify alg when \ `use\ ` is "sig")` , t => {
231+ test ( ' RSA Public key supports verify alg when `use` is "sig")' , t => {
232232 const sigKey = new RSAKey ( keyObject , { use : 'sig' } )
233233 const result = sigKey . algorithms ( 'verify' )
234234 t . is ( result . constructor , Set )
235235 t . deepEqual ( [ ...result ] , [ 'PS256' , 'RS256' , 'PS384' , 'RS384' , 'PS512' , 'RS512' ] )
236236 } )
237237
238- test ( ` RSA Public key cannot sign even when \ `alg\ ` is set)` , t => {
238+ test ( ' RSA Public key cannot sign even when `alg` is set)' , t => {
239239 const sigKey = new RSAKey ( keyObject , { alg : 'RS256' } )
240240 const result = sigKey . algorithms ( 'sign' )
241241 t . is ( result . constructor , Set )
242242 t . deepEqual ( [ ...result ] , [ ] )
243243 } )
244244
245- test ( ` RSA Public key supports single verify alg when \ `alg\ ` is set)` , t => {
245+ test ( ' RSA Public key supports single verify alg when `alg` is set)' , t => {
246246 const sigKey = new RSAKey ( keyObject , { alg : 'RS256' } )
247247 const result = sigKey . algorithms ( 'verify' )
248248 t . is ( result . constructor , Set )
249249 t . deepEqual ( [ ...result ] , [ 'RS256' ] )
250250 } )
251251
252- test ( ` RSA Public key no sign support when \ `use\ ` is "enc"` , t => {
252+ test ( ' RSA Public key no sign support when `use` is "enc"' , t => {
253253 const encKey = new RSAKey ( keyObject , { use : 'enc' } )
254254 const result = encKey . algorithms ( 'sign' )
255255 t . is ( result . constructor , Set )
256256 t . deepEqual ( [ ...result ] , [ ] )
257257 } )
258258
259- test ( ` RSA Public key no verify support when \ `use\ ` is "enc"` , t => {
259+ test ( ' RSA Public key no verify support when `use` is "enc"' , t => {
260260 const encKey = new RSAKey ( keyObject , { use : 'enc' } )
261261 const result = encKey . algorithms ( 'verify' )
262262 t . is ( result . constructor , Set )
0 commit comments