Skip to content

Commit

Permalink
Merge pull request #13 from wojpawlik/buffer-alloc-unsafe
Browse files Browse the repository at this point in the history
Use `buffer-alloc-unsafe`
  • Loading branch information
Bruce17 committed Mar 4, 2021
2 parents 8e8c1c4 + a96e0fb commit ad212fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions index.js
Expand Up @@ -6,7 +6,7 @@
'use strict';

var crypto = require('crypto');
var bufferAlloc = require('buffer-alloc');
var bufferAllocUnsafe = require('buffer-alloc-unsafe');


/**
Expand Down Expand Up @@ -59,9 +59,9 @@ var nativeTimingSafeEqual = function nativeTimingSafeEqual(a, b) {
// Always use length of a to avoid leaking the length. Even if this is a
// false positive because one is a prefix of the other, the explicit length
// check at the end will catch that.
var bufA = bufferAlloc(aLen, 0, 'utf8');
var bufA = bufferAllocUnsafe(aLen);
bufA.write(strA);
var bufB = bufferAlloc(aLen, 0, 'utf8');
var bufB = bufferAllocUnsafe(aLen);
bufB.write(strB);

return crypto.timingSafeEqual(bufA, bufB) && aLen === bLen;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -41,6 +41,6 @@
"mocha": "^3.1.2"
},
"dependencies": {
"buffer-alloc": "^1.2.0"
"buffer-alloc-unsafe": "1.1.0"
}
}

0 comments on commit ad212fc

Please sign in to comment.