IPWorks Encrypt 2020 Node.js Edition

Questions / Feedback?

Algorithm Property

The algorithm used when signing.

Syntax

 jws.getAlgorithm([callback])
 jws.setAlgorithm( algorithm, [callback])

Possible Values

  0 (jwsHS256), 
  1 (jwsHS384), 
  2 (jwsHS512), 
  3 (jwsRS256), 
  4 (jwsRS384), 
  5 (jwsRS512), 
  6 (jwsES256), 
  7 (jwsES384), 
  8 (jwsES512), 
  9 (jwsPS256), 
  10 (jwsPS384), 
  11 (jwsPS512), 
  12 (jwsNone), 
  13 (jwsES256K)

Default Value

0

Callback

The 'callback' parameter specifies a function which will be called when the operation completes (or an error is encountered). If the 'callback' parameter is not specified, then the method will block and will not return until the operation completes (or an error is encountered).

The callback for the getAlgorithm([callback]) method is defined as:

function(err, data){ }

'err' is the error that occurred. If there was no error, then 'err' is 'null'.

'data' is the value returned by the method.

The callback for the setAlgorithm([callback]) method is defined as:

function(err){ }

'err' is the error that occurred. If there was no error, then 'err' is 'null'.

'err' has 2 properties which hold detailed information:

err.code
err.message

Remarks

This property specifies the algorithm to use when signing.

When signing with an HMAC algorithm Key must be specified. When an RSA or ECDSA algorithm is selected Certificate must be set before calling Sign and Certificate must be set before calling Verify. The following values are supported:

AlgorithmDescriptionPrivate Key Location
0 (jwsHS256 - default) HMAC using SHA-256 Key
1 (jwsHS384) HMAC using SHA-384 Key
2 (jwsHS512) HMAC using SHA-512 Key
3 (jwsRS256) RSASSA-PKCS1-v1_5 using SHA-256 Certificate
4 (jwsRS384) RSASSA-PKCS1-v1_5 using SHA-384 Certificate
5 (jwsRS512) RSASSA-PKCS1-v1_5 using SHA-512 Certificate
6 (jwsPS256) RSASSA-PSS using SHA-256 and MGF1 with SHA-256 Certificate
7 (jwsPS384) RSASSA-PSS using SHA-384 and MGF1 with SHA-384 Certificate
8 (jwsPS512) RSASSA-PSS using SHA-512 and MGF1 with SHA-512 Certificate
9 (jwsES256) ECDSA using P-256 and SHA-256 Certificate
10 (jwsES384) ECDSA using P-384 and SHA-384 Certificate
11 (jwsES512) ECDSA using P-521 and SHA-512 Certificate
12 (jwsNone) None (unprotected) Not Applicable
13 (jwsES256K) ECDSA using secp256k1 curve and SHA-256 Certificate

Note: This setting is also applicable when StrictValidation is enabled before calling Verify.

Data Type

Integer

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Encrypt 2020 Node.js Edition - Version 20.0 [Build 8155]