[Pkg-javascript-commits] [node-browserify-aes] 08/92: ofb

Bastien Roucariès rouca at moszumanska.debian.org
Sun Jun 4 09:35:15 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 eab6bef074bb35ef6238cd8f3dba2b2bcbcff0b9
Author: Calvin Metcalf <cmetcalf at appgeo.com>
Date:   Thu Oct 16 14:25:40 2014 -0400

    ofb
---
 decrypter.js       | 24 +++++++++++++++++++++-
 encrypter.js       | 21 ++++++++++++++++++-
 modes.js           | 21 +++++++++++++++++++
 test/fixtures.json | 60 +++++++++++++++++++++++++++++++++++++++++++-----------
 4 files changed, 112 insertions(+), 14 deletions(-)

diff --git a/decrypter.js b/decrypter.js
index aec8ad0..dcd8611 100644
--- a/decrypter.js
+++ b/decrypter.js
@@ -137,10 +137,32 @@ CFB.prototype._flush = function (next) {
   this._cipher.scrub();
   next();
 };
+
+//the same as encryption
+inherits(OFB, Transform);
+function OFB(key, iv) {
+  if (!(this instanceof OFB)) {
+    return new OFB(key, iv);
+  }
+  Transform.call(this);
+  this._cipher = new aes.AES(key);
+  this._prev = iv;
+}
+
+OFB.prototype._transform = function (data, _, next) {
+  this._prev = this._cipher.encryptBlock(this._prev);
+  next(null, xor(data, this._prev));
+};
+OFB.prototype._flush = function (next) {
+  this._cipher.scrub();
+  next();
+};
+
 var modeStreams = {
   ECB: ECB,
   CBC: CBC,
-  CFB: CFB
+  CFB: CFB,
+  OFB: OFB
 };
 
 module.exports = function (crypto) {
diff --git a/encrypter.js b/encrypter.js
index 96b73ff..e2000c1 100644
--- a/encrypter.js
+++ b/encrypter.js
@@ -106,10 +106,29 @@ CFB.prototype._flush = function (next) {
   this._cipher.scrub();
   next();
 };
+inherits(OFB, Transform);
+function OFB(key, iv) {
+  if (!(this instanceof OFB)) {
+    return new OFB(key, iv);
+  }
+  Transform.call(this);
+  this._cipher = new aes.AES(key);
+  this._prev = iv;
+}
+
+OFB.prototype._transform = function (data, _, next) {
+  this._prev = this._cipher.encryptBlock(this._prev);
+  next(null, xor(data, this._prev));
+};
+OFB.prototype._flush = function (next) {
+  this._cipher.scrub();
+  next();
+};
 var modeStreams = {
   ECB: ECB,
   CBC: CBC,
-  CFB: CFB
+  CFB: CFB,
+  OFB:OFB
 };
 module.exports = function (crypto) {
   function createCipheriv(suite, password, iv) {
diff --git a/modes.js b/modes.js
index 9a364bf..f7c9133 100644
--- a/modes.js
+++ b/modes.js
@@ -57,4 +57,25 @@ exports['aes-256-cfb'] = {
   iv: 16,
   mode: 'CFB',
   padding: false
+};
+exports['aes-128-ofb'] = {
+  cipher: 'AES',
+  key: 128,
+  iv: 16,
+  mode: 'OFB',
+  padding: false
+};
+exports['aes-192-ofb'] = {
+  cipher: 'AES',
+  key: 192,
+  iv: 16,
+  mode: 'OFB',
+  padding: false
+};
+exports['aes-256-ofb'] = {
+  cipher: 'AES',
+  key: 256,
+  iv: 16,
+  mode: 'OFB',
+  padding: false
 };
\ No newline at end of file
diff --git a/test/fixtures.json b/test/fixtures.json
index 6905318..f44fd69 100644
--- a/test/fixtures.json
+++ b/test/fixtures.json
@@ -16,7 +16,10 @@
                 "aes256": "138839b0499e9bce8731bf0b9861b60c",
                 "aes-128-cfb": "6f60e632",
                 "aes-192-cfb": "7e595268",
-                "aes-256-cfb": "df60cff2"
+                "aes-256-cfb": "df60cff2",
+                "aes-128-ofb": "6f60e632",
+                "aes-192-ofb": "7e595268",
+                "aes-256-ofb": "df60cff2"
             },
             "cipherivs": {
                 "aes-128-cbc": "f7407490d4cc14c7a0c026cbe19fb350",
@@ -27,7 +30,10 @@
                 "aes256": "ad3e265d8c7375c2941850fcf59337e9",
                 "aes-128-cfb": "e914ee82",
                 "aes-192-cfb": "3620077c",
-                "aes-256-cfb": "9e495087"
+                "aes-256-cfb": "9e495087",
+                "aes-128-ofb": "e914ee82",
+                "aes-192-ofb": "3620077c",
+                "aes-256-ofb": "9e495087"
             }
         }
     },
@@ -48,7 +54,10 @@
                 "aes256": "e61484b76c26d646d10783110cad453244353988d80f0fe34e9c5991b75acccc08863d2f6ea0c9c9a69362566dfbeb98fea8029681bb8698895a02ed9887a90786ba168f594552805d41a8616aaef0a5b50c259a23b803f7cd24b2ad97e5f4b745f46643074818d946dc42fa0a9d6e1da1256818be90118a643b281971bbc12260de04d3256ceb11e87917712c1bdc0512f104a00ff5d5e2bdc532ba42035787c83b64ecbdb1b860058938241efdcc43ef62be6cbae85e582d9d5e846603909d9a9bf1019909c15d4cf36ebdfb7dd4666ae84c06568e531f50e59ba9b924cca3d46f76ab1d88324d0 [...]
                 "aes-128-cfb": "5225ff2b15584561697dcf84b17f68b72018561895e734cccedafb3c03929f4a1bc2d201e6b990f8debdc4b1228d43e4b89ab30797aa1b28dddf658bdc31ac2ba79229db43db926abdd94c50b6fd7b168ac4ab9ddde316cbe3e659de632bc9db56beff0f6c6b19e73c675ce9101ae2a6e86644dc66661b3f2253a6e6571d905a11971bce0f83877c0406d678cbce7f0876412bbac6faedcce9b95dcbfb5aa94fc610c4307e9d43f7a2c4ebbdce72d272ba8b7bc78f202bf376acf26d3557dd990c56ff80be5e0e8459f558d0b069ee569ea75287a1ebe74f11e912ea2d9cb68d9d72bacd4313 [...]
                 "aes-192-cfb": "431c4b713428cfc419ea2917b318efb47ccd70c259bfa69d6b6e591e12a811626722ef3ee2bf3215a74004a47395e09c62e4e58e9bba52765cf17814ea8e17545db49ef6a99b347b31a87fbabdd3a5d6266b5e567cd39f32e03f70d004c08e07f68e1057a7e230217b502b1c957ff2568f1dc6ebd957e514f77b120b2df4a3eb082c0f5492d76c57543aee46955658404c641438edc25d9a41ceb1e9e4bc3c952358b776ad696e51bb18451394c106455599933e50ac17d8011b37853535385a8e9dfe9dde74b83c2980511a31e02106e41aff550229afa242c7ea4dc1b251b0983de149ed3d [...]
-                "aes-256-cfb": "e225d6eb312195de58f18d155953985d9abcda4baa27503ff1963ee8aa733781a9f8bd10480af779eb637c6248c5e35929c39e75d2fa0ecfb993c6eb6c3ad339d9145079e77e9f809ceffaaada4d8992ee74a86835ef2cf6a1cfbe2389414b880d39b940a486b8937897c17f87cb80e3411a5478a6e51a593fe74fd9ff64a6376f10d259e27e2a2d7a0835abf6a240587665c5172bb19f0635e0d7918b1c8420785f03ee4835bae213a16ed6719e41ac9273ae1e94105e7dbad369acb14441e1cc2ab94d3f0eb210ac19dd6fbb84396672d92322b483ba482263ecd153f42894735c08fb03cb [...]
+                "aes-256-cfb": "e225d6eb312195de58f18d155953985d9abcda4baa27503ff1963ee8aa733781a9f8bd10480af779eb637c6248c5e35929c39e75d2fa0ecfb993c6eb6c3ad339d9145079e77e9f809ceffaaada4d8992ee74a86835ef2cf6a1cfbe2389414b880d39b940a486b8937897c17f87cb80e3411a5478a6e51a593fe74fd9ff64a6376f10d259e27e2a2d7a0835abf6a240587665c5172bb19f0635e0d7918b1c8420785f03ee4835bae213a16ed6719e41ac9273ae1e94105e7dbad369acb14441e1cc2ab94d3f0eb210ac19dd6fbb84396672d92322b483ba482263ecd153f42894735c08fb03cb [...]
+                "aes-128-ofb": "5225ff2b15584561697dcf84b17f68b79360ced0b4f824b01735cafce0d2ec40f0e53a3a2dc6e3e00fdf4f48b4b96259b4b6562c1fa5243e830635f37009143c79d8d0725c667d5648ff0518659864fc13e599d212184581af0a3a336f964e9d74cdd9c5dfce4ff52933e66044f599e76c411322ff339d2aa6aec0fe61b3e68edf1cea0579c5ad95255a4d421e7793c52aac072841b63ed7e42ccd54cc7d343b6e0487f9db501154f1ae5b167382b24baba97cbcd8dc895b8373f534e364a1d43e4d88b62877bbe2c7f13262a021a7b5636fa928ea71467a9dd9dbd690daea36702213f9ce67 [...]
+                "aes-192-ofb": "431c4b713428cfc419ea2917b318efb4ce84e949bfcfeeecb3b6cbd7f1cad51845bae93ae11b102a79f80ddaebde0dae0e8182d8ba18933b2009e8236db3a8b1089d2bc0d2c18dcab0553f9fc68ecfc337a9dd30e28a9da51769cd14204d65723173f0cbcd06ce09712469f6956e71b658f12caad50350fe3f022ea9f1418e582bd344f67c436e8e62378fa1f9acc33455c3c812a7e95c44c6296d5fadc31a3ec7555fee50dd785ee686f9260929a80876c4768311be45dbc28908d781fa2988129d66bbbc4956b77b71c2c097adb1bf3d34d0fe593b13f139f7109828dd7c159efc49b2f2c4 [...]
+                "aes-256-ofb": "e225d6eb312195de58f18d155953985d9164e437e3e4faabd64390984e64c29459edfc68ad14bf6f1d1b7fde3d8f72c0c7ebf8d9ff4f8d086b1f28b0605b41b8d6bc26fcb5cc9bf53f9517960d7bc1b3c54f1721da5c60c7b438d1223bcc14f473247e1e15e14847cc1c1c0681085d7c17a17d831234b36010abf84c43c5c9a4c197a3bade4563eb3aa7920bff71fcb7c1956cd79c902273b9e1b109e371cd1c370fb0a22eacd2a37386293af9b018ae65bc5c8fe9a3c8fee5d512bfb7ca9e36420bbbf9b8aac4f5f4c7bc452ce307cc10886be8cf67c0fe1172127dc346b6f9a90233bc25d2 [...]
             },
             "cipherivs": {
                 "aes-128-cbc": "772b4d8e20a224a6ec0392b1fc6569693accb2709509ba265ddf5aafaecc11d77016a69e70255b7d7a5ddf7ad4d87511aa12ab987115ca157f1b9d9c3583339576e81f66cd716dfe0c561bfdff14eb842f05859c69da073759c5706da8afffc951b7dfd3c689e6cb8cc32426846f375043fe519872ec27796f6ad9cd588b800206ff4115198341c321198689f5d83e5f8e60c7c6e9dfe06dc17697dc058888a1180601ae2932ff8cfa9e15546422db6b74b05fb7e79ccc143b41cb7e8b4ede73a1f11da476bf89f106e655171848ec0ccf9c94ae3e858d06acc06712d54ab8a3791a67fb61c6 [...]
@@ -59,7 +68,10 @@
                 "aes256": "4bd525802cd2ed487bbfad28a81764d381b7c83291edb366c73cca3167e19760a5023fa52821dfd44d22e314583c842659aba2d23e3118756a302426699415d88d6cf7eac4ea53a01e7ba1e9251ecc62d5ded26bf4b5420b19d1e96bce7453122ace17cc0621995429436693c584cfffc66d27a0d00419b499e672b2813730cbf97d142c68ac5f52e08632c4f76c6f8b9a0140429d731e996c17e3dca3d6b07af330c4189ed6eecd338b28c989736011cd2b8704ad43e5604f3655e86cfb6a3788a508f01896cb468926cf79be1a665e435d2d54844597575292b989a81f424a4f2190bcb829aadfb [...]
                 "aes-128-cfb": "0304a8ae497c46305a87df178b39538be455205fd10d1828ecaad1939fdb385352c904b5b18fd89fe5a18ecd09ac677fbad2261d4693e4dd9e6d880d390f1eadb4bee741b9616c24f0b5aad321e26f0164829411db3e4da23eebe6f2e2aff49b2b62719bbbbdc6b9b8f03093b1ed4b35b3d1bf2f51b1b7859fb6f31b1e8bf722900ead0497594a96c8686da60100c349caa3a814a322c775604875d2d6fb0db51a539d4d0d52b312fa5c9d6e8816b78b16c0a8909c80096e2744d54d7505e7d375d3373d007bdbf2ecc60d9b0fe70ffd1937ae32c59925770530778c96bbbb198ccb5d526d47 [...]
                 "aes-192-cfb": "35f1e120808e87537835e1cce77e65736fd163fc25dca73c86a9e1a7d49a66be47d2fc9c307faac6691cf12816a8166f2053a5728007a85535694b4dc9f0337e9b17e4c1e9ced6c5c58a1b747e2765a54141e864a2c9500b3d96d7f861b2259f777cd74dffe2f5def6cae7969384a163b7adf61fd6cdb05cf9d10bda269c91f5cfcbc325cc50f1fb3424af848d4308b3103223e4757b01b87f1408c6608fd4a401da33d1c1199271d757f8d9b7a5e58924ef76914c34f2fb35a86b2707b50bae259f3fb7bad9991cb2dd3e33ade251ac52052d87fb9415921d35a5d223a4385d384a33b27276 [...]
-                "aes-256-cfb": "831ec789aecaa6fd45e28074bea498ffb82b9c36faf042949fda04f02cee48f0a4a3e0db27e6fa4297c4d715885dc54bcb341d13de8a20985eaaad64fff240e068cc62dbacb9698e98d33b6a3d22ce16e6c178f6999441f55f434f95a988e5db92a96ecb1815e68f1b26f777faa98b95fcd91905ee8a26efe62a4069080eec24a82eaf22f2256cb4a2d714309e0bc69f580e20d8ddabcd67a3c859531c9b9190b23068e4729d5647c2b959084ae976c9bf284d0b9299e638c3afa5cf3b97c03a78cc9bde27ea1107513fd7b9cbe085726a06fa301cc63a3aa30ba962fc63ff00199899500f20 [...]
+                "aes-256-cfb": "831ec789aecaa6fd45e28074bea498ffb82b9c36faf042949fda04f02cee48f0a4a3e0db27e6fa4297c4d715885dc54bcb341d13de8a20985eaaad64fff240e068cc62dbacb9698e98d33b6a3d22ce16e6c178f6999441f55f434f95a988e5db92a96ecb1815e68f1b26f777faa98b95fcd91905ee8a26efe62a4069080eec24a82eaf22f2256cb4a2d714309e0bc69f580e20d8ddabcd67a3c859531c9b9190b23068e4729d5647c2b959084ae976c9bf284d0b9299e638c3afa5cf3b97c03a78cc9bde27ea1107513fd7b9cbe085726a06fa301cc63a3aa30ba962fc63ff00199899500f20 [...]
+                "aes-128-ofb": "0304a8ae497c46305a87df178b39538ba663b35f244b9d3b3c0ff196bdd8c205c0e805a07ab677ce669f38a6a14a377752d405506fdfb2419251adf9a707a0749f3732bdd728b571c9242a91f803b6cba0acb2c76b23a382c7093724b71a3911aa37544db5222290442ab987aadc556f63f00de8745895ea878a0aff3c6e8c794ecafcc9b300882cbc3c7cac954fae148cb674f3aaf188406fcf93f80467a6a1bcaf0209593ab0b8c059a070b84eadd4ecd98e685f67ee8b6261b09d66967d2adfceed3902c79b10d16bece5b6fb3eae5056dbb92dab53118df93cd9fdd4283be1ebfd0de2c8 [...]
+                "aes-192-ofb": "35f1e120808e87537835e1cce77e6573ca589636935296ac5e65ca5ef0dbb3a14367483e97709739e42a1a14cdc8c8fc65117bb7eb71fd989379a6ec55ce1913ef13e23f64cda6fe196ac5e83fad4ed03870b7b5db8dd9c024436592eb2efedf6172de8ad06ca7d96ecceb53ea52c57ebaa92136c12bd29962979d8b6bc21c32e4c5ba19bf2f48a3dbe23621ef29afc241d0ff9cce3b771f492f704ef842fa28fc50b54b2560a81b9b1370a947925195ccc9a165184ca9c680c7e66ca42df1a82a5bd74bf7d641603165dcbcf3f59ee8e21e258b6c784d77e27a28d2142dbcfddd155bfe0737 [...]
+                "aes-256-ofb": "831ec789aecaa6fd45e28074bea498ffd18388fa47fa74443b375df6b84ae7893e68769ea5f345a1f2607ae0e107580a7ad9845baa4d58f2c88ba8c2d704c66c33e6ba13979d4131b0ae2700a379d3f8d1c58c485ab3198a5946374fcff536d3a4c8f84207609c3e7dd4f0feec180dcc34e1c4691f52dba052800f64dc30c2263c57487cbe2233ea09f3c52668e3eef132113655c5a27eab3a7a93916cf8f430066fe3f2fd206dc8475868994deec10497023cc2b91411325447ccaf676df858a8b25c0384ee75579546bdac462a80f953129be4cf211cd330c5c22cf583aed1ea50cb3c184f [...]
             }
         }
     },
@@ -80,7 +92,10 @@
                 "aes256": "185a9f2225cb2319e862aa7b4720fed5",
                 "aes-128-cfb": "5afc1eadf2fb",
                 "aes-192-cfb": "30a3f27b7709",
-                "aes-256-cfb": "9266e13911f6"
+                "aes-256-cfb": "9266e13911f6",
+                "aes-128-ofb": "5afc1eadf2fb",
+                "aes-192-ofb": "30a3f27b7709",
+                "aes-256-ofb": "9266e13911f6"
             },
             "cipherivs": {
                 "aes-128-cbc": "c9f85747bd44921917d9266f7d7253b3",
@@ -91,7 +106,10 @@
                 "aes256": "d6a6ee4a29a679aca37d6b3e2f0be7e8",
                 "aes-128-cfb": "5b5d3c47f2ac",
                 "aes-192-cfb": "64809bc44b10",
-                "aes-256-cfb": "9205f2d6c23b"
+                "aes-256-cfb": "9205f2d6c23b",
+                "aes-128-ofb": "5b5d3c47f2ac",
+                "aes-192-ofb": "64809bc44b10",
+                "aes-256-ofb": "9205f2d6c23b"
             }
         }
     },
@@ -112,7 +130,10 @@
                 "aes256": "664d1b94ece9c943085d5ea4a30cbe339838f3b675dc6b6ba5f8023738d9e144",
                 "aes-128-cfb": "7e09b31f9ac9adea39976b33fdac6abd",
                 "aes-192-cfb": "4d8ded889a7b6188942c253a68b7af09",
-                "aes-256-cfb": "ad31744277697cdddfc361ecb2233d6d"
+                "aes-256-cfb": "ad31744277697cdddfc361ecb2233d6d",
+                "aes-128-ofb": "7e09b31f9ac9adea39976b33fdac6abd",
+                "aes-192-ofb": "4d8ded889a7b6188942c253a68b7af09",
+                "aes-256-ofb": "ad31744277697cdddfc361ecb2233d6d"
             },
             "cipherivs": {
                 "aes-128-cbc": "98e1b648e99996a2dff688b8418cd173fc2d2b809ff8659e45291ed92f7741f2",
@@ -123,7 +144,10 @@
                 "aes256": "7fce06852a9f19a946833b950d2e0f7fb89dd1889581165c350ccbe1f2360685",
                 "aes-128-cfb": "34adb0e5b44d764af0808eff9745d704",
                 "aes-192-cfb": "957ea1bcb6d9a139d5153623813db192",
-                "aes-256-cfb": "7ce64552d7320552347e2d3af0830ca0"
+                "aes-256-cfb": "7ce64552d7320552347e2d3af0830ca0",
+                "aes-128-ofb": "34adb0e5b44d764af0808eff9745d704",
+                "aes-192-ofb": "957ea1bcb6d9a139d5153623813db192",
+                "aes-256-ofb": "7ce64552d7320552347e2d3af0830ca0"
             }
         }
     },
@@ -144,7 +168,10 @@
                 "aes256": "161455bf919792f95ac914496f47784c590d42ed00e25414720ecc77fc094fe6",
                 "aes-128-cfb": "facb6cdc767f419c4ea03c256bac19979b",
                 "aes-192-cfb": "34aafbec0b57819744ba53b5d481a9b52a",
-                "aes-256-cfb": "13b4a117b97c730cd4195cd447005c6d3f"
+                "aes-256-cfb": "13b4a117b97c730cd4195cd447005c6d3f",
+                "aes-128-ofb": "facb6cdc767f419c4ea03c256bac1997e4",
+                "aes-192-ofb": "34aafbec0b57819744ba53b5d481a9b5cb",
+                "aes-256-ofb": "13b4a117b97c730cd4195cd447005c6d48"
             },
             "cipherivs": {
                 "aes-128-cbc": "ca7451a2b66305ea1a1793d5417b0b3c4d477abb2a42e08bbcc3ecae51cc1e1a",
@@ -155,7 +182,10 @@
                 "aes256": "4ba2f481b6f30a74268d08ae153f39ad3dbfa4ece13ea16e8a56b0efc5df026e",
                 "aes-128-cfb": "7af8f9e6715c1a95f27021ca5e43fe7e96",
                 "aes-192-cfb": "4c3a98af7e03e16563c1636a26d3508eda",
-                "aes-256-cfb": "6892cdc900665063523fb9b4940b2c111a"
+                "aes-256-cfb": "6892cdc900665063523fb9b4940b2c111a",
+                "aes-128-ofb": "7af8f9e6715c1a95f27021ca5e43fe7e48",
+                "aes-192-ofb": "4c3a98af7e03e16563c1636a26d3508e41",
+                "aes-256-ofb": "6892cdc900665063523fb9b4940b2c11b0"
             }
         }
     },
@@ -176,7 +206,10 @@
                 "aes256": "8f25a9f28db8f672adc91354652306cc",
                 "aes-128-cfb": "e51979ccd953c85c1c62cd3e064197",
                 "aes-192-cfb": "4e7906adbde09e88c2ea4ee5e6e645",
-                "aes-256-cfb": "f39fb153dead5bac4926ac4c1f69a9"
+                "aes-256-cfb": "f39fb153dead5bac4926ac4c1f69a9",
+                "aes-128-ofb": "e51979ccd953c85c1c62cd3e064197",
+                "aes-192-ofb": "4e7906adbde09e88c2ea4ee5e6e645",
+                "aes-256-ofb": "f39fb153dead5bac4926ac4c1f69a9"
             },
             "cipherivs": {
                 "aes-128-cbc": "af45c639b04747b2eaf310b52c51dfeb",
@@ -187,7 +220,10 @@
                 "aes256": "8bfb71ae015f795c20c41d403b2ba973",
                 "aes-128-cfb": "a0f218d4ca8260b99c321ce17cee51",
                 "aes-192-cfb": "59206a4c437279d2bb397f55d23236",
-                "aes-256-cfb": "24fcfa77fd9ab62df106f9ad36d62b"
+                "aes-256-cfb": "24fcfa77fd9ab62df106f9ad36d62b",
+                "aes-128-ofb": "a0f218d4ca8260b99c321ce17cee51",
+                "aes-192-ofb": "59206a4c437279d2bb397f55d23236",
+                "aes-256-ofb": "24fcfa77fd9ab62df106f9ad36d62b"
             }
         }
     }

-- 
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