Skip to content

Commit 476e4d7

Browse files
committed
Fix: issues with latest browserify-buffer
1 parent 8e8f779 commit 476e4d7

File tree

12 files changed

+18
-58
lines changed

12 files changed

+18
-58
lines changed

gulpfile.js

-6
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,6 @@ var KARMA_CONFIG = {
182182
base: "SauceLabs",
183183
browserName: "firefox"
184184
},
185-
"SL_Safari_7": {
186-
base: "SauceLabs",
187-
platform: "OS X 10.9",
188-
browserName: "safari",
189-
version: "7"
190-
},
191185
"SL_Safari_8": {
192186
base: "SauceLabs",
193187
platform: "OS X 10.10",

lib/algorithms/aes-cbc-hmac-sha2.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ function commonCbcEncryptFN(size) {
7373
return helpers.subtleCrypto.encrypt(alg, key, pdata);
7474
});
7575
promise = promise.then(function(cdata) {
76-
// wrap in *augmented* Uint8Array -- Buffer without copies
77-
cdata = new Uint8Array(cdata);
78-
cdata = Buffer._augment(cdata);
76+
cdata = new Buffer(cdata);
7977
return cdata;
8078
});
8179

@@ -165,9 +163,7 @@ function commonCbcDecryptFN(size) {
165163
return helpers.subtleCrypto.decrypt(alg, key, cdata);
166164
});
167165
promise = promise.then(function(pdata) {
168-
// wrap in *augmented* Uint8Array -- Buffer without copies
169-
pdata = new Uint8Array(pdata);
170-
pdata = Buffer._augment(pdata);
166+
pdata = new Buffer(pdata);
171167
return pdata;
172168
});
173169

lib/algorithms/aes-gcm.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,11 @@ function gcmEncryptFN(size) {
108108
promise = promise.then(function(result) {
109109
var tagStart = result.byteLength - 16;
110110

111-
// wrap in *augmented* Uint8Array -- Buffer without copies
112111
var tag = result.slice(tagStart);
113-
tag = new Uint8Array(tag);
114-
tag = Buffer._augment(tag);
112+
tag = new Buffer(tag);
115113

116-
// wrap in *augmented* Uint8Array -- Buffer without copies
117114
var cdata = result.slice(0, tagStart);
118-
cdata = new Uint8Array(cdata);
119-
cdata = Buffer._augment(cdata);
115+
cdata = new Buffer(cdata);
120116

121117
return {
122118
data: cdata,
@@ -274,9 +270,7 @@ function gcmDecryptFN(size) {
274270
return helpers.subtleCrypto.decrypt(alg, key, cdata);
275271
});
276272
promise = promise.then(function(pdata) {
277-
// wrap *augmented* Uint8Array -- Buffer without copies
278-
pdata = new Uint8Array(pdata);
279-
pdata = Buffer._augment(pdata);
273+
pdata = new Buffer(pdata);
280274
return pdata;
281275
});
282276

lib/algorithms/aes-kw.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,7 @@ function kwEncryptFN(size) {
114114
alg);
115115
});
116116
promise = promise.then(function(result) {
117-
// wrap in *augmented* Uint8Array -- Buffer without copies
118-
result = new Uint8Array(result);
119-
result = Buffer._augment(result);
117+
result = new Buffer(result);
120118

121119
return {
122120
data: result
@@ -196,9 +194,7 @@ function kwDecryptFN(size) {
196194
return helpers.subtleCrypto.exportKey("raw", result);
197195
});
198196
promise = promise.then(function(result) {
199-
// wrap in *augmented* Uint8Array -- Buffer without copies
200-
result = new Uint8Array(result);
201-
result = Buffer._augment(result);
197+
result = new Buffer(result);
202198
return result;
203199
});
204200
return promise;

lib/algorithms/ecdh.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ function ecdhDeriveFn() {
107107
return helpers.subtleCrypto.deriveBits(algParams, privKey, keyLen * 8);
108108
});
109109
promise = promise.then(function(result) {
110-
result = new Uint8Array(result);
111-
Buffer._augment(result);
110+
result = new Buffer(result);
112111
return result;
113112
});
114113
return promise;

lib/algorithms/ecdsa.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ function ecdsaSignFN(hash) {
7171
return helpers.subtleCrypto.sign(alg, key, pdata);
7272
});
7373
promise = promise.then(function(result) {
74-
result = new Uint8Array(result);
75-
result = Buffer._augment(result);
74+
result = new Buffer(result);
7675
return {
7776
data: pdata,
7877
mac: result

lib/algorithms/hmac.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ function hmacSignFN(name) {
5151
return helpers.subtleCrypto.sign(alg, key, pdata);
5252
});
5353
promise = promise.then(function(result) {
54-
// wrap in *augmented* Uint8Array - Buffer without copies
55-
var sig = new Uint8Array(result);
56-
sig = Buffer._augment(sig);
54+
var sig = new Buffer(result);
5755
return {
5856
data: pdata,
5957
mac: sig
@@ -138,9 +136,7 @@ function hmacVerifyFN(name) {
138136
return helpers.subtleCrypto.sign(alg, key, pdata);
139137
});
140138
promise = promise.then(function(result) {
141-
// wrap in *augmented* Uint8Array - Buffer without copies
142-
var sig = new Uint8Array(result);
143-
sig = Buffer._augment(sig);
139+
var sig = new Buffer(result);
144140
return compare(true, mac, sig);
145141
});
146142
} else {

lib/algorithms/rsaes.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ function rsaesEncryptFn(name) {
6464
return helpers.subtleCrypto.encrypt(alg, key, pdata);
6565
});
6666
promise = promise.then(function(result) {
67-
// wrap in *augmented* Uint8Array - Buffer without copies
68-
var cdata = new Uint8Array(result);
69-
cdata = Buffer._augment(cdata);
67+
var cdata = new Buffer(result);
7068
return {
7169
data: cdata
7270
};
@@ -130,9 +128,7 @@ function rsaesDecryptFn(name) {
130128
return helpers.subtleCrypto.decrypt(alg, key, pdata);
131129
});
132130
promise = promise.then(function(result) {
133-
// wrap in *augmented* Uint8Array - Buffer without copies
134-
var pdata = new Uint8Array(result);
135-
pdata = Buffer._augment(pdata);
131+
var pdata = new Buffer(result);
136132
return pdata;
137133
});
138134

lib/algorithms/rsassa.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ function rsassaV15SignFn(name) {
5050
return helpers.subtleCrypto.sign(alg, key, pdata);
5151
});
5252
promise = promise.then(function(result) {
53-
// wrap in *augmented* Uint8Array - Buffer without copies
54-
var sig = new Uint8Array(result);
55-
sig = Buffer._augment(sig);
53+
var sig = new Buffer(result);
5654
return {
5755
data: pdata,
5856
mac: sig

lib/algorithms/sha.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ function hashDigestFN(hash) {
2929
var promise;
3030
promise = helpers.subtleCrypto.digest(alg, pdata);
3131
promise = promise.then(function(result) {
32-
// wrap in *augmented* Uint8Array -- Buffer without copies
33-
result = new Uint8Array(result);
34-
result = Buffer._augment(result);
32+
result = new Buffer(result);
3533
return result;
3634
});
3735
return promise;

lib/util/databuffer.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,6 @@ DataBuffer.prototype.getBytes = function(count) {
257257
return rval;
258258
};
259259
DataBuffer.prototype.putBytes = function(bytes, encoding) {
260-
function augmentIt(src) {
261-
return (Buffer._augment) ?
262-
Buffer._augment(src) :
263-
new Buffer(src);
264-
}
265-
266260
if ("string" === typeof bytes) {
267261
// fixup encoding
268262
encoding = encoding || "binary";
@@ -303,14 +297,14 @@ DataBuffer.prototype.putBytes = function(bytes, encoding) {
303297
src = new Buffer(bytes);
304298
} else if (forge.util.isArrayBuffer(bytes)) {
305299
src = new Uint8Array(bytes);
306-
src = augmentIt(src);
300+
src = new Buffer(src);
307301
} else if (forge.util.isArrayBufferView(bytes)) {
308302
src = (bytes instanceof Uint8Array) ?
309303
bytes :
310304
new Uint8Array(bytes.buffer,
311305
bytes.byteOffset,
312306
bytes.byteLength);
313-
src = augmentIt(src);
307+
src = new Buffer(src);
314308
} else {
315309
throw new TypeError("invalid source type");
316310
}

test/algorithms/aes-gcm-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ describe("algorithms/aes-gcm", function() {
166166
var decryptFailer = function(){
167167
var runner = function() {
168168
var size = algSize(alg);
169-
var key = new Buffer(size, "binary"),
169+
var key = new Buffer(size),
170170
iv = new Buffer("a5a5a5a5a5a5a5a5a5a5a5a5", "hex"),
171171
tag,
172172
plaintext = new Buffer("00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff", "hex"),

0 commit comments

Comments
 (0)