Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[enhance] binary: buffer_of_binary always trims contents first

  • Loading branch information...
commit ec3ba5004a81d8fe99280d465f645e1ce0422565 1 parent 12cd27a
@Aqua-Ye Aqua-Ye authored
View
9 lib/plugins/crypto/bslCrypto.nodejs
@@ -44,7 +44,6 @@ function md5(data) {
* @register {binary -> string}
*/
function base64_encode(data) {
- BslBinary_trim(data);
return buffer_of_binary(data).toString('base64');
}
@@ -61,7 +60,6 @@ function base64_decode(data) {
* @register {binary -> string}
*/
function base64_encode_compact(bin) {
- BslBinary_trim(bin);
// compact just means no lines and no padding
var data = buffer_of_binary(bin).toString('base64');
return data.substr(0,Math.ceil((str.length * 4) / 3));
@@ -71,7 +69,6 @@ function base64_encode_compact(bin) {
* @register {binary -> string}
*/
function base64_encode_multiline(bin) {
- BslBinary_trim(bin);
// This faithfully follows the strange pattern of carriage returns
// generated by Cryptokit.
var width = 72;
@@ -102,9 +99,8 @@ function base64_decode2(data) {
* @register {string, binary -> binary}
*/
function hash_digest(algo, bin) {
- BslBinary_trim(bin);
return binary_of_buffer(
- new Buffer(Crypto.createHash(algo).update(bin.contents).digest('binary'),
+ new Buffer(Crypto.createHash(algo).update(buffer_of_binary(bin)).digest('binary'),
'binary')
);
}
@@ -113,9 +109,8 @@ function hash_digest(algo, bin) {
* @register {string, binary, binary -> binary}
*/
function hmac_digest(algo, key, bin) {
- BslBinary_trim(key); BslBinary_trim(bin);
return binary_of_buffer(
- new Buffer(Crypto.createHmac(algo, key.contents).update(bin.contents).digest('binary'),
+ new Buffer(Crypto.createHmac(algo, buffer_of_binary(key)).update(buffer_of_binary(bin)).digest('binary'),
'binary')
);
}
View
1  lib/plugins/opabsl/jsbsl/bslBinary.js
@@ -32,6 +32,7 @@ function binary_of_buffer(contents){
}
function buffer_of_binary(bin){
+ trim(bin);
return bin.contents;
}
Please sign in to comment.
Something went wrong with that request. Please try again.