How to use the long.Long.ZERO function in long

To help you get started, weā€™ve selected a few long examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github christkv / node-pure-crypto / lib / hash / tiger.js View on Github external
var Tiger = exports.Tiger = function() {
  // Tiger variables
  this.buf = [Long.ZERO, Long.ZERO, Long.ZERO, Long.ZERO, Long.ZERO, Long.ZERO, Long.ZERO, Long.ZERO, ];
  this.bOff = 0;

  this.x = [Long.ZERO, Long.ZERO, Long.ZERO, Long.ZERO, Long.ZERO, Long.ZERO, Long.ZERO, Long.ZERO, ];
  this.xOff = 0;
  this.byteCount = Long.ZERO;
  this.a = Long.ZERO;
  this.b = Long.ZERO;
  this.c = Long.ZERO;
  
  // Reset 
  this.reset();
}
github christkv / node-pure-crypto / lib / hash / sha384.js View on Github external
this.H1 = this.H1.add(a);
  this.H2 = this.H2.add(b);
  this.H3 = this.H3.add(c);
  this.H4 = this.H4.add(d);
  this.H5 = this.H5.add(e);
  this.H6 = this.H6.add(f);
  this.H7 = this.H7.add(g);
  this.H8 = this.H8.add(h);

  //
  // reset the offset and clean out the word buffer.
  //
  this.wOff = 0;
  for(var i = 0; i < 16; i++) {
    this.W[i] = Long.ZERO;
  }
}
github christkv / node-pure-crypto / lib / hash / sha512.js View on Github external
SHA512.prototype.reset = function() {
  // SHA-256 initial hash value
  this.H1 = Long.fromString("6a09e667f3bcc908", 16);
  this.H2 = Long.fromString("bb67ae8584caa73b", 16);
  this.H3 = Long.fromString("3c6ef372fe94f82b", 16);
  this.H4 = Long.fromString("a54ff53a5f1d36f1", 16);
  this.H5 = Long.fromString("510e527fade682d1", 16);
  this.H6 = Long.fromString("9b05688c2b3e6c1f", 16);
  this.H7 = Long.fromString("1f83d9abfb41bd6b", 16);
  this.H8 = Long.fromString("5be0cd19137e2179", 16);

  this.byteCount1 = Long.ZERO;
  this.byteCount2 = Long.ZERO;

  this.xBufOff = 0;  
  for (var i = 0; i != this.xBuf.length; i++) {
    this.xBuf[i] = 0;
  }

  this.wOff = 0;  
  for (var i = 0; i != this.W.length; i++) {
    this.W[i] = Long.ZERO;
  }
}
github christkv / node-pure-crypto / lib / hash / sha512.js View on Github external
SHA512.prototype.reset = function() {
  // SHA-256 initial hash value
  this.H1 = Long.fromString("6a09e667f3bcc908", 16);
  this.H2 = Long.fromString("bb67ae8584caa73b", 16);
  this.H3 = Long.fromString("3c6ef372fe94f82b", 16);
  this.H4 = Long.fromString("a54ff53a5f1d36f1", 16);
  this.H5 = Long.fromString("510e527fade682d1", 16);
  this.H6 = Long.fromString("9b05688c2b3e6c1f", 16);
  this.H7 = Long.fromString("1f83d9abfb41bd6b", 16);
  this.H8 = Long.fromString("5be0cd19137e2179", 16);

  this.byteCount1 = Long.ZERO;
  this.byteCount2 = Long.ZERO;

  this.xBufOff = 0;  
  for (var i = 0; i != this.xBuf.length; i++) {
    this.xBuf[i] = 0;
  }

  this.wOff = 0;  
  for (var i = 0; i != this.W.length; i++) {
    this.W[i] = Long.ZERO;
  }
}
github christkv / node-pure-crypto / lib / hash / base.js View on Github external
var BaseDigest = exports.BaseDigest = function() {
  // Common variables
  this.xBuf = [0, 0, 0, 0];
  this.xBufOff = 0;
  this.byteCount = Long.ZERO;  
}
github christkv / node-pure-crypto / lib / symmetric / block / treefish.js View on Github external
var b0 = Long.fromString(util.toHex(input.slice(0, 8).reverse()), 16);
  var b1 = Long.fromString(util.toHex(input.slice(8, 16).reverse()), 16);
  var b2 = Long.fromString(util.toHex(input.slice(16, 24).reverse()), 16);
  var b3 = Long.fromString(util.toHex(input.slice(24, 32).reverse()), 16);

  // Unpack key
  var k0 = this.expanedKey[0];
  var k1 = this.expanedKey  [1];
  var k2 = this.expanedKey[2];
  var k3 = this.expanedKey[3];
  var k4 = this.expanedKey[4];
  // Unpack tweak
  var t0 = this.expandedTweak[0];
  var t1 = this.expandedTweak[1];
  var t2 = this.expandedTweak[2];
  var tmp = Long.ZERO;  

  b0 = b0.subtract(k3);
  b1 = b1.subtract(k4.add(t0));
  b2 = b2.subtract(k0.add(t1));
  b3 = b3.subtract(k1.add(Long.fromNumber(18)));
  tmp = b3.xor(b0);
  b3 = tmp.shiftRightUnsigned(32).or(tmp.shiftLeft(64 - 32));
  b0 = b0.subtract(b3);
  tmp = b1.xor(b2);
  b1 = tmp.shiftRightUnsigned(32).or(tmp.shiftLeft(64 - 32));
  b2 = b2.subtract(b1);
  tmp = b1.xor(b0);
  b1 = tmp.shiftRightUnsigned(58).or(tmp.shiftLeft(64 - 58));
  b0 = b0.subtract(b1);
  tmp = b3.xor(b2);
  b3 = tmp.shiftRightUnsigned(22).or(tmp.shiftLeft(64 - 22));
github christkv / node-pure-crypto / lib / hash / tiger.js View on Github external
Tiger.prototype.processWord = function(src, inOff) {
  this.x[this.xOff++] = Long.fromBits(util.decodeUInt32R(src, inOff + 0), util.decodeUInt32R(src, inOff + 4));
  if (this.xOff == this.x.length) {
    this.processBlock();
  }

  this.bOff = Long.ZERO;
}
github christkv / node-pure-crypto / lib / hash / sha384.js View on Github external
this.H5 = Long.fromString("67332667ffc00b31", 16);
  this.H6 = Long.fromString("8eb44a8768581511", 16);
  this.H7 = Long.fromString("db0c2e0d64f98fa7", 16);
  this.H8 = Long.fromString("47b5481dbefa4fa4", 16);

  this.byteCount1 = Long.ZERO;
  this.byteCount2 = Long.ZERO;

  this.xBufOff = 0;  
  for (var i = 0; i != this.xBuf.length; i++) {
    this.xBuf[i] = 0;
  }

  this.wOff = 0;  
  for (var i = 0; i != this.W.length; i++) {
    this.W[i] = Long.ZERO;
  }
}
github christkv / node-pure-crypto / lib / hash / gost3411.js View on Github external
GOST3411.prototype.reset = function() {
  this.byteCount = Long.ZERO;
  this.xBufOff = 0;
  
  for(var i = 0; i < this.H.length; i++) {
    this.H[i] = 0;
  }

  for(var i = 0; i < this.L.length; i++) {
    this.L[i] = 0;
  }
  
  for(var i = 0; i < this.M.length; i++) {
    this.M[i] = 0;
  }

  for(var i = 0; i < this.C[1].length; i++) {
    this.C[1][i] = 0;
github christkv / node-pure-crypto / lib / hash / skein.js View on Github external
UbiTweak.prototype.isBitPad = function() {
  return this.tweak[1].and(T1FlagBitPad).notEquals(Long.ZERO);
}