Skip to content

Commit

Permalink
Build for Node.JS v6
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxwolf committed Jun 6, 2016
2 parents 8e8f779 + 69d1480 commit bfd9bcc
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 58 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ node_js:
- 'iojs'
- '4'
- '5'
- '6'

addons:
apt:
Expand Down
6 changes: 0 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,6 @@ var KARMA_CONFIG = {
base: "SauceLabs",
browserName: "firefox"
},
"SL_Safari_7": {
base: "SauceLabs",
platform: "OS X 10.9",
browserName: "safari",
version: "7"
},
"SL_Safari_8": {
base: "SauceLabs",
platform: "OS X 10.10",
Expand Down
8 changes: 2 additions & 6 deletions lib/algorithms/aes-cbc-hmac-sha2.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ function commonCbcEncryptFN(size) {
return helpers.subtleCrypto.encrypt(alg, key, pdata);
});
promise = promise.then(function(cdata) {
// wrap in *augmented* Uint8Array -- Buffer without copies
cdata = new Uint8Array(cdata);
cdata = Buffer._augment(cdata);
cdata = new Buffer(cdata);
return cdata;
});

Expand Down Expand Up @@ -165,9 +163,7 @@ function commonCbcDecryptFN(size) {
return helpers.subtleCrypto.decrypt(alg, key, cdata);
});
promise = promise.then(function(pdata) {
// wrap in *augmented* Uint8Array -- Buffer without copies
pdata = new Uint8Array(pdata);
pdata = Buffer._augment(pdata);
pdata = new Buffer(pdata);
return pdata;
});

Expand Down
12 changes: 3 additions & 9 deletions lib/algorithms/aes-gcm.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,11 @@ function gcmEncryptFN(size) {
promise = promise.then(function(result) {
var tagStart = result.byteLength - 16;

// wrap in *augmented* Uint8Array -- Buffer without copies
var tag = result.slice(tagStart);
tag = new Uint8Array(tag);
tag = Buffer._augment(tag);
tag = new Buffer(tag);

// wrap in *augmented* Uint8Array -- Buffer without copies
var cdata = result.slice(0, tagStart);
cdata = new Uint8Array(cdata);
cdata = Buffer._augment(cdata);
cdata = new Buffer(cdata);

return {
data: cdata,
Expand Down Expand Up @@ -274,9 +270,7 @@ function gcmDecryptFN(size) {
return helpers.subtleCrypto.decrypt(alg, key, cdata);
});
promise = promise.then(function(pdata) {
// wrap *augmented* Uint8Array -- Buffer without copies
pdata = new Uint8Array(pdata);
pdata = Buffer._augment(pdata);
pdata = new Buffer(pdata);
return pdata;
});

Expand Down
8 changes: 2 additions & 6 deletions lib/algorithms/aes-kw.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ function kwEncryptFN(size) {
alg);
});
promise = promise.then(function(result) {
// wrap in *augmented* Uint8Array -- Buffer without copies
result = new Uint8Array(result);
result = Buffer._augment(result);
result = new Buffer(result);

return {
data: result
Expand Down Expand Up @@ -196,9 +194,7 @@ function kwDecryptFN(size) {
return helpers.subtleCrypto.exportKey("raw", result);
});
promise = promise.then(function(result) {
// wrap in *augmented* Uint8Array -- Buffer without copies
result = new Uint8Array(result);
result = Buffer._augment(result);
result = new Buffer(result);
return result;
});
return promise;
Expand Down
3 changes: 1 addition & 2 deletions lib/algorithms/ecdh.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ function ecdhDeriveFn() {
return helpers.subtleCrypto.deriveBits(algParams, privKey, keyLen * 8);
});
promise = promise.then(function(result) {
result = new Uint8Array(result);
Buffer._augment(result);
result = new Buffer(result);
return result;
});
return promise;
Expand Down
3 changes: 1 addition & 2 deletions lib/algorithms/ecdsa.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ function ecdsaSignFN(hash) {
return helpers.subtleCrypto.sign(alg, key, pdata);
});
promise = promise.then(function(result) {
result = new Uint8Array(result);
result = Buffer._augment(result);
result = new Buffer(result);
return {
data: pdata,
mac: result
Expand Down
8 changes: 2 additions & 6 deletions lib/algorithms/hmac.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ function hmacSignFN(name) {
return helpers.subtleCrypto.sign(alg, key, pdata);
});
promise = promise.then(function(result) {
// wrap in *augmented* Uint8Array - Buffer without copies
var sig = new Uint8Array(result);
sig = Buffer._augment(sig);
var sig = new Buffer(result);
return {
data: pdata,
mac: sig
Expand Down Expand Up @@ -138,9 +136,7 @@ function hmacVerifyFN(name) {
return helpers.subtleCrypto.sign(alg, key, pdata);
});
promise = promise.then(function(result) {
// wrap in *augmented* Uint8Array - Buffer without copies
var sig = new Uint8Array(result);
sig = Buffer._augment(sig);
var sig = new Buffer(result);
return compare(true, mac, sig);
});
} else {
Expand Down
8 changes: 2 additions & 6 deletions lib/algorithms/rsaes.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ function rsaesEncryptFn(name) {
return helpers.subtleCrypto.encrypt(alg, key, pdata);
});
promise = promise.then(function(result) {
// wrap in *augmented* Uint8Array - Buffer without copies
var cdata = new Uint8Array(result);
cdata = Buffer._augment(cdata);
var cdata = new Buffer(result);
return {
data: cdata
};
Expand Down Expand Up @@ -130,9 +128,7 @@ function rsaesDecryptFn(name) {
return helpers.subtleCrypto.decrypt(alg, key, pdata);
});
promise = promise.then(function(result) {
// wrap in *augmented* Uint8Array - Buffer without copies
var pdata = new Uint8Array(result);
pdata = Buffer._augment(pdata);
var pdata = new Buffer(result);
return pdata;
});

Expand Down
4 changes: 1 addition & 3 deletions lib/algorithms/rsassa.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ function rsassaV15SignFn(name) {
return helpers.subtleCrypto.sign(alg, key, pdata);
});
promise = promise.then(function(result) {
// wrap in *augmented* Uint8Array - Buffer without copies
var sig = new Uint8Array(result);
sig = Buffer._augment(sig);
var sig = new Buffer(result);
return {
data: pdata,
mac: sig
Expand Down
4 changes: 1 addition & 3 deletions lib/algorithms/sha.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ function hashDigestFN(hash) {
var promise;
promise = helpers.subtleCrypto.digest(alg, pdata);
promise = promise.then(function(result) {
// wrap in *augmented* Uint8Array -- Buffer without copies
result = new Uint8Array(result);
result = Buffer._augment(result);
result = new Buffer(result);
return result;
});
return promise;
Expand Down
10 changes: 2 additions & 8 deletions lib/util/databuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,6 @@ DataBuffer.prototype.getBytes = function(count) {
return rval;
};
DataBuffer.prototype.putBytes = function(bytes, encoding) {
function augmentIt(src) {
return (Buffer._augment) ?
Buffer._augment(src) :
new Buffer(src);
}

if ("string" === typeof bytes) {
// fixup encoding
encoding = encoding || "binary";
Expand Down Expand Up @@ -303,14 +297,14 @@ DataBuffer.prototype.putBytes = function(bytes, encoding) {
src = new Buffer(bytes);
} else if (forge.util.isArrayBuffer(bytes)) {
src = new Uint8Array(bytes);
src = augmentIt(src);
src = new Buffer(src);
} else if (forge.util.isArrayBufferView(bytes)) {
src = (bytes instanceof Uint8Array) ?
bytes :
new Uint8Array(bytes.buffer,
bytes.byteOffset,
bytes.byteLength);
src = augmentIt(src);
src = new Buffer(src);
} else {
throw new TypeError("invalid source type");
}
Expand Down
2 changes: 1 addition & 1 deletion test/algorithms/aes-gcm-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ describe("algorithms/aes-gcm", function() {
var decryptFailer = function(){
var runner = function() {
var size = algSize(alg);
var key = new Buffer(size, "binary"),
var key = new Buffer(size),
iv = new Buffer("a5a5a5a5a5a5a5a5a5a5a5a5", "hex"),
tag,
plaintext = new Buffer("00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff", "hex"),
Expand Down

0 comments on commit bfd9bcc

Please sign in to comment.