IPWorks Encrypt 2020 Node.js Edition

Questions / Feedback?

PaddingMode Property

The padding mode.

Syntax

 cast.getPaddingMode([callback])
 cast.setPaddingMode( paddingMode, [callback])

Possible Values

  0 (pmPKCS7), 
  1 (pmZeros), 
  2 (pmNone), 
  3 (pmANSIX923), 
  4 (pmISO10126)

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 getPaddingMode([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 setPaddingMode([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

PaddingMode is used to pad the final input block to guarantee that it is the correct size required for the selected CipherMode. If the input size is a multiple of the cipher's BlockSize, an extra block of padding will be appended to the input. This enables the decrypting agent to know with certainty how many bytes of padding are included. Each mode pads the data differently. Possible values are:

0 (pmPKCS7 - default) The data is padded with a series of bytes that are each equal to the number of bytes used. For instance, in the example below the data must be padded with 3 additional bytes, so each byte value will be 3.

Raw Data:
AA AA AA AA AA
PKCS7 Padded Data:
AA AA AA AA AA 03 03 03
1 (pmZeros) The data is padded with null bytes.
2 (pmNone) No padding will be performed.
3 (pmANSIX923) The ANSIX923 padding string consists of a sequence of bytes filled with zeros before the length. For instance, in the example below the data must be padded with 3 additional bytes, so last byte value will be 3.

Raw Data:
AA AA AA AA AA
ANSIX923 padding Data:
AA AA AA AA AA 00 00 03
4 (pmISO10126) The ISO10126 padding string consists of random data before the length. For instance, in the example below the data must be padded with 3 additional bytes, so last byte value will be 3.

Raw Data:
AA AA AA AA AA
ISO10126 padding Data:
AA AA AA AA AA F8 EF 03

When calling Decrypt the PaddingMode must match the value used when the data was encrypted.

Note: When using a value of 2 (pmNone), unless the length of input is an exact multiple of the cipher's input BlockSize, the final block of plaintext may be lost.

Data Type

Integer

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