384.js 768 B

123456789101112131415161718192021222324252627282930313233343536
  1. 'use strict';
  2. var utils = require('../utils');
  3. var SHA512 = require('./512');
  4. function SHA384() {
  5. if (!(this instanceof SHA384))
  6. return new SHA384();
  7. SHA512.call(this);
  8. this.h = [
  9. 0xcbbb9d5d, 0xc1059ed8,
  10. 0x629a292a, 0x367cd507,
  11. 0x9159015a, 0x3070dd17,
  12. 0x152fecd8, 0xf70e5939,
  13. 0x67332667, 0xffc00b31,
  14. 0x8eb44a87, 0x68581511,
  15. 0xdb0c2e0d, 0x64f98fa7,
  16. 0x47b5481d, 0xbefa4fa4 ];
  17. }
  18. utils.inherits(SHA384, SHA512);
  19. module.exports = SHA384;
  20. SHA384.blockSize = 1024;
  21. SHA384.outSize = 384;
  22. SHA384.hmacStrength = 192;
  23. SHA384.padLength = 128;
  24. SHA384.prototype._digest = function digest(enc) {
  25. if (enc === 'hex')
  26. return utils.toHex32(this.h.slice(0, 12), 'big');
  27. else
  28. return utils.split32(this.h.slice(0, 12), 'big');
  29. };