[Pkg-javascript-commits] [node-browserify-aes] 25/92: rm internal padding option

Bastien Roucariès rouca at moszumanska.debian.org
Sun Jun 4 09:35:17 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-browserify-aes.

commit b9933580f89622bc0bdcc52c0dbd19c7480a0017
Author: Calvin Metcalf <cmetcalf at appgeo.com>
Date:   Tue Oct 28 15:46:45 2014 -0400

    rm internal padding option
---
 decrypter.js | 19 ++++++-------------
 encrypter.js | 20 ++++++--------------
 modes.js     |  9 ---------
 3 files changed, 12 insertions(+), 36 deletions(-)

diff --git a/decrypter.js b/decrypter.js
index 5d840d2..cbcefee 100644
--- a/decrypter.js
+++ b/decrypter.js
@@ -6,17 +6,12 @@ var StreamCipher = require('./streamCipher');
 var ebtk = require('./EVP_BytesToKey');
 
 inherits(Decipher, Transform);
-function Decipher(padding, mode, key, iv) {
+function Decipher(mode, key, iv) {
   if (!(this instanceof Decipher)) {
-    return new Decipher(padding, mode, key, iv);
+    return new Decipher(mode, key, iv);
   }
   Transform.call(this);
   this._cache = new Splitter();
-   if (padding === false) {
-    this._padding = false;
-  } else {
-    this._padding = true;
-  }
   this._last = void 0;
   this._cipher = new aes.AES(key);
   this._prev = new Buffer(iv.length);
@@ -38,11 +33,9 @@ Decipher.prototype._flush = function (next) {
   if (!chunk) {
     return next;
   }
-  if (this._padding) {
-    this.push(unpad(this._mode.decrypt(this, chunk)));
-  } else {
-    this.push(this._mode.decrypt(this, chunk));
-  }
+
+  this.push(unpad(this._mode.decrypt(this, chunk)));
+
   next();
 };
 
@@ -106,7 +99,7 @@ module.exports = function (crypto) {
     if (config.type === 'stream') {
       return new StreamCipher(modelist[config.mode], password, iv, true);
     }
-    return new Decipher(config.padding, modelist[config.mode], password, iv);
+    return new Decipher(modelist[config.mode], password, iv);
   }
 
   function createDecipher (suite, password) {
diff --git a/encrypter.js b/encrypter.js
index d05fe64..d981190 100644
--- a/encrypter.js
+++ b/encrypter.js
@@ -5,12 +5,12 @@ var modes = require('./modes');
 var ebtk = require('./EVP_BytesToKey');
 var StreamCipher = require('./streamCipher');
 inherits(Cipher, Transform);
-function Cipher(padding, mode, key, iv) {
+function Cipher(mode, key, iv) {
   if (!(this instanceof Cipher)) {
-    return new Cipher(padding, mode, key, iv);
+    return new Cipher(mode, key, iv);
   }
   Transform.call(this);
-  this._cache = new Splitter(padding);
+  this._cache = new Splitter();
   this._cipher = new aes.AES(key);
   this._prev = new Buffer(iv.length);
   iv.copy(this._prev);
@@ -34,14 +34,9 @@ Cipher.prototype._flush = function (next) {
 };
 
 
-function Splitter(padding) {
+function Splitter() {
    if (!(this instanceof Splitter)) {
-    return new Splitter(padding);
-  }
-  if (padding === false) {
-    this._padding = false;
-  } else {
-    this._padding = true;
+    return new Splitter();
   }
   this.cache = new Buffer('');
 }
@@ -58,9 +53,6 @@ Splitter.prototype.get = function () {
   return null;
 };
 Splitter.prototype.flush = function () {
-  if (!this._padding) {
-    return this.cache;
-  }
   var len = 16 - this.cache.length;
   var padBuff = new Buffer(len);
 
@@ -99,7 +91,7 @@ module.exports = function (crypto) {
     if (config.type === 'stream') {
       return new StreamCipher(modelist[config.mode], password, iv);
     }
-    return new Cipher(config.padding, modelist[config.mode], password, iv);
+    return new Cipher(modelist[config.mode], password, iv);
   }
   function createCipher (suite, password) {
     var config = modes[suite];
diff --git a/modes.js b/modes.js
index 10f6321..78e62fd 100644
--- a/modes.js
+++ b/modes.js
@@ -48,7 +48,6 @@ exports['aes-128-cfb'] = {
   key: 128,
   iv: 16,
   mode: 'CFB',
-  padding: false,
   type: 'stream'
 };
 exports['aes-192-cfb'] = {
@@ -56,7 +55,6 @@ exports['aes-192-cfb'] = {
   key: 192,
   iv: 16,
   mode: 'CFB',
-  padding: false,
   type: 'stream'
 };
 exports['aes-256-cfb'] = {
@@ -64,7 +62,6 @@ exports['aes-256-cfb'] = {
   key: 256,
   iv: 16,
   mode: 'CFB',
-  padding: false,
   type: 'stream'
 };
 exports['aes-128-ofb'] = {
@@ -72,7 +69,6 @@ exports['aes-128-ofb'] = {
   key: 128,
   iv: 16,
   mode: 'OFB',
-  padding: false,
   type: 'stream'
 };
 exports['aes-192-ofb'] = {
@@ -80,7 +76,6 @@ exports['aes-192-ofb'] = {
   key: 192,
   iv: 16,
   mode: 'OFB',
-  padding: false,
   type: 'stream'
 };
 exports['aes-256-ofb'] = {
@@ -88,7 +83,6 @@ exports['aes-256-ofb'] = {
   key: 256,
   iv: 16,
   mode: 'OFB',
-  padding: false,
   type: 'stream'
 };
 exports['aes-128-ctr'] = {
@@ -96,7 +90,6 @@ exports['aes-128-ctr'] = {
   key: 128,
   iv: 16,
   mode: 'CTR',
-  padding: false,
   type: 'stream'
 };
 exports['aes-192-ctr'] = {
@@ -104,7 +97,6 @@ exports['aes-192-ctr'] = {
   key: 192,
   iv: 16,
   mode: 'CTR',
-  padding: false,
   type: 'stream'
 };
 exports['aes-256-ctr'] = {
@@ -112,6 +104,5 @@ exports['aes-256-ctr'] = {
   key: 256,
   iv: 16,
   mode: 'CTR',
-  padding: false,
   type: 'stream'
 };
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-browserify-aes.git



More information about the Pkg-javascript-commits mailing list