sha256: minor.

This commit is contained in:
Christopher Jeffrey 2017-07-16 00:06:01 -07:00
parent 94b5487847
commit 20da155a08
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -18,14 +18,9 @@
const DESC = Buffer.allocUnsafe(8); const DESC = Buffer.allocUnsafe(8);
const BUFFER64 = Buffer.allocUnsafe(64); const BUFFER64 = Buffer.allocUnsafe(64);
let K, PADDING; const PADDING = Buffer.allocUnsafe(64);
let ctx, mctx;
PADDING = Buffer.allocUnsafe(64); const K = [
PADDING.fill(0);
PADDING[0] = 0x80;
K = [
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
@ -44,6 +39,9 @@ K = [
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
]; ];
PADDING.fill(0);
PADDING[0] = 0x80;
/** /**
* SHA256 * SHA256
* @alias module:crypto/sha256.SHA256 * @alias module:crypto/sha256.SHA256
@ -341,8 +339,8 @@ function readU32(buf, offset) {
* Context Helpers * Context Helpers
*/ */
ctx = new SHA256(); const ctx = new SHA256();
mctx = new SHA256Hmac(); const mctx = new SHA256Hmac();
/** /**
* Hash buffer with sha256. * Hash buffer with sha256.