Skip to content

Commit 551358c

Browse files
committed
1.3.10
1 parent d83ac7d commit 551358c

File tree

8 files changed

+34
-25
lines changed

8 files changed

+34
-25
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
== 1.3.10
2+
3+
* Update to latest jsbn to fix global variable leak (issue #11)
4+
15
== 1.3.9
26

37
* Fix issue #14 in safari where an svg element in a form would prevent submission. Thanks to @oveddan (Dan Oved) for the fix (pull request #15)

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2009-2013 Braintree Payment Solutions
1+
Copyright (c) 2009-2014 Braintree, a division of PayPal, Inc.
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
44

build/minified_header.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* Braintree End-to-End Encryption Library
33
* https://www.braintreepayments.com
4-
* Copyright (c) 2009-2013 Braintree Payment Solutions
4+
* Copyright (c) 2009-2014 Braintree, a division of PayPal, Inc.
55
*
66
* JSBN
77
* Copyright (c) 2005 Tom Wu

lib/braintree.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
var Braintree = {
1010
sjcl: sjcl,
11-
version: "1.3.9"
11+
version: "1.3.10"
1212
};
1313

1414
Braintree.generateAesKey = function () {
@@ -148,8 +148,13 @@ Braintree.EncryptionClient = function (publicKey) {
148148
signature = hmac.sign(sjcl.codec.base64.toBits(ciphertext)),
149149
combinedKey = sjcl.bitArray.concat(aes.key, hmac.key),
150150
encodedKey = sjcl.codec.base64.fromBits(combinedKey),
151-
encryptedKey = rsa.encrypt_b64(encodedKey),
152-
prefix = "$bt4|javascript_" + self.version.replace(/\./g, "_") + "$";
151+
hexEncryptedKey = rsa.encrypt(encodedKey),
152+
prefix = "$bt4|javascript_" + self.version.replace(/\./g, "_") + "$",
153+
encryptedKey = null;
154+
155+
if(hexEncryptedKey) {
156+
encryptedKey = hex2b64(hexEncryptedKey);
157+
}
153158

154159
return prefix + encryptedKey + "$" + ciphertext + "$" + signature;
155160
};

lib/jsbn/base64.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var b64map="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2-
var b64pad="=";
2+
var b64padchar="=";
33

44
function hex2b64(h) {
55
var i;
@@ -17,18 +17,19 @@ function hex2b64(h) {
1717
c = parseInt(h.substring(i,i+2),16);
1818
ret += b64map.charAt(c >> 2) + b64map.charAt((c & 3) << 4);
1919
}
20-
while((ret.length & 3) > 0) ret += b64pad;
20+
while((ret.length & 3) > 0) ret += b64padchar;
2121
return ret;
2222
}
2323

2424
// convert a base64 string to hex
2525
function b64tohex(s) {
26-
var ret = ""
26+
var ret = "";
2727
var i;
2828
var k = 0; // b64 state, 0-3
2929
var slop;
30+
var v;
3031
for(i = 0; i < s.length; ++i) {
31-
if(s.charAt(i) == b64pad) break;
32+
if(s.charAt(i) == b64padchar) break;
3233
v = b64map.indexOf(s.charAt(i));
3334
if(v < 0) continue;
3435
if(k == 0) {

lib/jsbn/jsbn.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function bnpFromInt(x) {
118118
this.t = 1;
119119
this.s = (x<0)?-1:0;
120120
if(x > 0) this[0] = x;
121-
else if(x < -1) this[0] = x+DV;
121+
else if(x < -1) this[0] = x+this.DV;
122122
else this.t = 0;
123123
}
124124

lib/jsbn/rsa.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ function byte2Hex(b) {
2727
// PKCS#1 (type 2, random) pad input string s to n bytes, and return a bigint
2828
function pkcs1pad2(s,n) {
2929
if(n < s.length + 11) { // TODO: fix for utf-8
30-
alert("Message too long for RSA");
31-
return null;
30+
throw new Error("Message too long for RSA");
3231
}
3332
var ba = new Array();
3433
var i = s.length - 1;
@@ -86,7 +85,7 @@ function RSASetPublic(N,E) {
8685
this.e = parseInt(E,16);
8786
}
8887
else
89-
alert("Invalid RSA public key");
88+
throw new Error("Invalid RSA public key");
9089
}
9190

9291
// Perform raw public operation on "x": return x^e (mod n)
@@ -105,15 +104,15 @@ function RSAEncrypt(text) {
105104
}
106105

107106
// Return the PKCS#1 RSA encryption of "text" as a Base64-encoded string
108-
function RSAEncryptB64(text) {
109-
var h = this.encrypt(text);
110-
if(h) return hex2b64(h); else return null;
111-
}
107+
//function RSAEncryptB64(text) {
108+
// var h = this.encrypt(text);
109+
// if(h) return hex2b64(h); else return null;
110+
//}
112111

113112
// protected
114113
RSAKey.prototype.doPublic = RSADoPublic;
115114

116115
// public
117116
RSAKey.prototype.setPublic = RSASetPublic;
118117
RSAKey.prototype.encrypt = RSAEncrypt;
119-
RSAKey.prototype.encrypt_b64 = RSAEncryptB64;
118+
//RSAKey.prototype.encrypt_b64 = RSAEncryptB64;

spec/infrastructure/rsa2.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function RSASetPrivate(N,E,D) {
3838
this.d = parseBigInt(D,16);
3939
}
4040
else
41-
alert("Invalid RSA private key");
41+
throw new Error("Invalid RSA private key");
4242
}
4343

4444
// Set the private key fields N, e, d and CRT params from hex strings
@@ -54,7 +54,7 @@ function RSASetPrivateEx(N,E,D,P,Q,DP,DQ,C) {
5454
this.coeff = parseBigInt(C,16);
5555
}
5656
else
57-
alert("Invalid RSA private key");
57+
throw new Error("Invalid RSA private key");
5858
}
5959

6060
// Generate a new random private key B bits long, using public expt E
@@ -116,10 +116,10 @@ function RSADecrypt(ctext) {
116116

117117
// Return the PKCS#1 RSA decryption of "ctext".
118118
// "ctext" is a Base64-encoded string and the output is a plain string.
119-
function RSAB64Decrypt(ctext) {
120-
var h = b64tohex(ctext);
121-
if(h) return this.decrypt(h); else return null;
122-
}
119+
//function RSAB64Decrypt(ctext) {
120+
// var h = b64tohex(ctext);
121+
// if(h) return this.decrypt(h); else return null;
122+
//}
123123

124124
// protected
125125
RSAKey.prototype.doPrivate = RSADoPrivate;
@@ -129,4 +129,4 @@ RSAKey.prototype.setPrivate = RSASetPrivate;
129129
RSAKey.prototype.setPrivateEx = RSASetPrivateEx;
130130
RSAKey.prototype.generate = RSAGenerate;
131131
RSAKey.prototype.decrypt = RSADecrypt;
132-
RSAKey.prototype.b64_decrypt = RSAB64Decrypt;
132+
//RSAKey.prototype.b64_decrypt = RSAB64Decrypt;

0 commit comments

Comments
 (0)