Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
fix(WalletCrypto): pass bit len of blocks to padding function
Browse files Browse the repository at this point in the history
  • Loading branch information
jtormey committed Feb 5, 2016
1 parent 1b97b5c commit 3cd453e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/wallet-crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ var crypto = require('crypto')

var SUPPORTED_ENCRYPTION_VERSION = 3
, SALT_BYTES = 16
, KEY_BIT_LEN = 256;
, KEY_BIT_LEN = 256
, BLOCK_BIT_LEN = 128;

var ALGO = {
SHA1 : 'sha1',
Expand Down Expand Up @@ -101,7 +102,7 @@ var AES = {
var cipher = crypto.createCipheriv(options.mode || AES.CBC, key, salt || '');
cipher.setAutoPadding(!options.padding);

if (options.padding) dataBytes = options.padding.pad(dataBytes, KEY_BIT_LEN / 8);
if (options.padding) dataBytes = options.padding.pad(dataBytes, BLOCK_BIT_LEN / 8);
var encryptedBytes = Buffer.concat([ cipher.update(dataBytes), cipher.final() ]);

return encryptedBytes;
Expand Down

0 comments on commit 3cd453e

Please sign in to comment.