You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
  3. * in FIPS 180-2
  4. * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
  5. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  6. *
  7. */
  8. var inherits = require('inherits')
  9. var Sha256 = require('./sha256')
  10. var Hash = require('./hash')
  11. var Buffer = require('safe-buffer').Buffer
  12. var W = new Array(64)
  13. function Sha224 () {
  14. this.init()
  15. this._w = W // new Array(64)
  16. Hash.call(this, 64, 56)
  17. }
  18. inherits(Sha224, Sha256)
  19. Sha224.prototype.init = function () {
  20. this._a = 0xc1059ed8
  21. this._b = 0x367cd507
  22. this._c = 0x3070dd17
  23. this._d = 0xf70e5939
  24. this._e = 0xffc00b31
  25. this._f = 0x68581511
  26. this._g = 0x64f98fa7
  27. this._h = 0xbefa4fa4
  28. return this
  29. }
  30. Sha224.prototype._hash = function () {
  31. var H = Buffer.allocUnsafe(28)
  32. H.writeInt32BE(this._a, 0)
  33. H.writeInt32BE(this._b, 4)
  34. H.writeInt32BE(this._c, 8)
  35. H.writeInt32BE(this._d, 12)
  36. H.writeInt32BE(this._e, 16)
  37. H.writeInt32BE(this._f, 20)
  38. H.writeInt32BE(this._g, 24)
  39. return H
  40. }
  41. module.exports = Sha224