Skip to content

Initialization Vector length in createCipheriv/createeciperiv for aes-128-ecb #10263

Closed
@UppaJung

Description

@UppaJung
  • Version: v6.7.0
  • Platform: 64-bit windows
  • Subsystem: crypto

The following node.js code attempts to create a cipher using AES 128 in ECB mode with an initialization vector (IV) filled with 0 bytes.

    let keyBuffer = Buffer.from("DoNotUseUTF8Keys",'utf8');
    let ivBuffer = Buffer.alloc(16); // 16 bytes set to 0
    try {
      let cipher = createCipheriv("AES-128-ECB", keyBuffer, ivBuffer);
    } catch (e)
    {
      console.log(e.message);
    }

When createCipheriv (or createDeciperiv) is called, the node.js code throws "Invalid IV length".

For a 128-bit (16-byte) cipher, AES should have a 16-byte Initialization Vector (IV), so I do not understand why the parameter would yield an exception. (Regardless of whether I'm in error, it would sure be nice to see an exception thrown which says what the correct length is.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    cryptoIssues and PRs related to the crypto subsystem.questionIssues that look for answers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions