sha384.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. var inherits = require('inherits')
  2. var SHA512 = require('./sha512')
  3. var Hash = require('./hash')
  4. var W = new Array(160)
  5. function Sha384 () {
  6. this.init()
  7. this._w = W
  8. Hash.call(this, 128, 112)
  9. }
  10. inherits(Sha384, SHA512)
  11. Sha384.prototype.init = function () {
  12. this._ah = 0xcbbb9d5d
  13. this._bh = 0x629a292a
  14. this._ch = 0x9159015a
  15. this._dh = 0x152fecd8
  16. this._eh = 0x67332667
  17. this._fh = 0x8eb44a87
  18. this._gh = 0xdb0c2e0d
  19. this._hh = 0x47b5481d
  20. this._al = 0xc1059ed8
  21. this._bl = 0x367cd507
  22. this._cl = 0x3070dd17
  23. this._dl = 0xf70e5939
  24. this._el = 0xffc00b31
  25. this._fl = 0x68581511
  26. this._gl = 0x64f98fa7
  27. this._hl = 0xbefa4fa4
  28. return this
  29. }
  30. Sha384.prototype._hash = function () {
  31. var H = new Buffer(48)
  32. function writeInt64BE (h, l, offset) {
  33. H.writeInt32BE(h, offset)
  34. H.writeInt32BE(l, offset + 4)
  35. }
  36. writeInt64BE(this._ah, this._al, 0)
  37. writeInt64BE(this._bh, this._bl, 8)
  38. writeInt64BE(this._ch, this._cl, 16)
  39. writeInt64BE(this._dh, this._dl, 24)
  40. writeInt64BE(this._eh, this._el, 32)
  41. writeInt64BE(this._fh, this._fl, 40)
  42. return H
  43. }
  44. module.exports = Sha384