org.spongycastle.crypto.macs.HMac.update()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中org.spongycastle.crypto.macs.HMac.update()方法的一些代码示例,展示了HMac.update()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HMac.update()方法的具体详情如下:
包路径:org.spongycastle.crypto.macs.HMac
类名称:HMac
方法名:update

HMac.update介绍

暂无

代码示例

代码示例来源:origin: com.madgag.spongycastle/bctls-jdk15on

public void update(byte[] input, int inOff, int length)
{
  hmac.update(input, inOff, length);
}

代码示例来源:origin: com.madgag.spongycastle/core

/**
 * Performs the expand part of the key derivation function, using currentT
 * as input and output buffer.
 *
 * @throws DataLengthException if the total number of bytes generated is larger than the one
 * specified by RFC 5869 (255 * HashLen)
 */
private void expandNext()
  throws DataLengthException
{
  int n = generatedBytes / hashLen + 1;
  if (n >= 256)
  {
    throw new DataLengthException(
      "HKDF cannot generate more than 255 blocks of HashLen size");
  }
  // special case for T(0): T(0) is empty, so no update
  if (generatedBytes != 0)
  {
    hMacHash.update(currentT, 0, hashLen);
  }
  hMacHash.update(info, 0, info.length);
  hMacHash.update((byte)n);
  hMacHash.doFinal(currentT, 0);
}

代码示例来源:origin: fr.acinq/bitcoinj-core

static byte[] hmacSha512(HMac hmacSha512, byte[] input) {
  hmacSha512.reset();
  hmacSha512.update(input, 0, input.length);
  byte[] out = new byte[64];
  hmacSha512.doFinal(out, 0);
  return out;
}

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

static byte[] hmacSha512(HMac hmacSha512, byte[] input) {
  hmacSha512.reset();
  hmacSha512.update(input, 0, input.length);
  byte[] out = new byte[64];
  hmacSha512.doFinal(out, 0);
  return out;
}

代码示例来源:origin: com.google/bitcoinj

static byte[] hmacSha512(HMac hmacSha512, byte[] input) {
  hmacSha512.reset();
  hmacSha512.update(input, 0, input.length);
  byte[] out = new byte[64];
  hmacSha512.doFinal(out, 0);
  return out;
}

代码示例来源:origin: HashEngineering/dashj

static byte[] hmacSha512(HMac hmacSha512, byte[] input) {
  hmacSha512.reset();
  hmacSha512.update(input, 0, input.length);
  byte[] out = new byte[64];
  hmacSha512.doFinal(out, 0);
  return out;
}

代码示例来源:origin: greenaddress/GreenBits

static byte[] hmacSha512(HMac hmacSha512, byte[] input) {
  hmacSha512.reset();
  hmacSha512.update(input, 0, input.length);
  byte[] out = new byte[64];
  hmacSha512.doFinal(out, 0);
  return out;
}

代码示例来源:origin: com.madgag.spongycastle/core

public BigInteger nextK()
{
  byte[] t = new byte[((n.bitLength() + 7) / 8)];
  for (;;)
  {
    int tOff = 0;
    while (tOff < t.length)
    {
      hMac.update(V, 0, V.length);
      hMac.doFinal(V, 0);
      int len = Math.min(t.length - tOff, V.length);
      System.arraycopy(V, 0, t, tOff, len);
      tOff += len;
    }
    BigInteger k = bitsToInt(t);
    if (k.compareTo(ZERO) > 0 && k.compareTo(n) < 0)
    {
      return k;
    }
    hMac.update(V, 0, V.length);
    hMac.update((byte)0x00);
    hMac.doFinal(K, 0);
    hMac.init(new KeyParameter(K));
    hMac.update(V, 0, V.length);
    hMac.doFinal(V, 0);
  }
}

代码示例来源:origin: com.madgag.spongycastle/bctls-jdk15on

protected void hmacHash(Digest digest, byte[] secret, int secretOff, int secretLen, byte[] seed, byte[] output)
{
  HMac mac = new HMac(digest);
  mac.init(new KeyParameter(secret, secretOff, secretLen));
  byte[] a = seed;
  int macSize = mac.getMacSize();
  byte[] b1 = new byte[macSize];
  byte[] b2 = new byte[macSize];
  int pos = 0;
  while (pos < output.length)
  {
    mac.update(a, 0, a.length);
    mac.doFinal(b1, 0);
    a = b1;
    mac.update(a, 0, a.length);
    mac.update(seed, 0, seed.length);
    mac.doFinal(b2, 0);
    System.arraycopy(b2, 0, output, pos, Math.min(macSize, output.length - pos));
    pos += macSize;
  }
}

代码示例来源:origin: com.madgag.spongycastle/core

hMac.update(V, 0, V.length);
hMac.update((byte)0x00);
hMac.update(x, 0, x.length);
hMac.update(m, 0, m.length);
hMac.update(V, 0, V.length);
hMac.update(V, 0, V.length);
hMac.update((byte)0x01);
hMac.update(x, 0, x.length);
hMac.update(m, 0, m.length);
hMac.update(V, 0, V.length);

代码示例来源:origin: com.madgag.spongycastle/core

static void hmac_hash(Digest digest, byte[] secret, byte[] seed, byte[] out)
{
  HMac mac = new HMac(digest);
  mac.init(new KeyParameter(secret));
  byte[] a = seed;
  int size = digest.getDigestSize();
  int iterations = (out.length + size - 1) / size;
  byte[] buf = new byte[mac.getMacSize()];
  byte[] buf2 = new byte[mac.getMacSize()];
  for (int i = 0; i < iterations; i++)
  {
    mac.update(a, 0, a.length);
    mac.doFinal(buf, 0);
    a = buf;
    mac.update(a, 0, a.length);
    mac.update(seed, 0, seed.length);
    mac.doFinal(buf2, 0);
    System.arraycopy(buf2, 0, out, (size * i), Math.min(size, out.length - (size * i)));
  }
}

代码示例来源:origin: com.madgag/sc-light-jdk15on

private static void hmac_hash(Digest digest, byte[] secret, byte[] seed, byte[] out)
{
  HMac mac = new HMac(digest);
  KeyParameter param = new KeyParameter(secret);
  byte[] a = seed;
  int size = digest.getDigestSize();
  int iterations = (out.length + size - 1) / size;
  byte[] buf = new byte[mac.getMacSize()];
  byte[] buf2 = new byte[mac.getMacSize()];
  for (int i = 0; i < iterations; i++)
  {
    mac.init(param);
    mac.update(a, 0, a.length);
    mac.doFinal(buf, 0);
    a = buf;
    mac.init(param);
    mac.update(a, 0, a.length);
    mac.update(seed, 0, seed.length);
    mac.doFinal(buf2, 0);
    System.arraycopy(buf2, 0, out, (size * i), Math.min(size, out.length - (size * i)));
  }
}

代码示例来源:origin: OPCFoundation/UA-Java-Legacy

/** {@inheritDoc} */
@Override
public void signSymm(SecurityPolicy policy, byte[] key, byte[] input, int inputOffset, int verifyLen,
    byte[] output, int outputOffset) throws ServiceResultException {
  HMac hmac = createMac(policy.getSymmetricSignatureAlgorithm(), new KeyParameter(key));
  hmac.update(input, inputOffset, verifyLen);
  hmac.doFinal(output, outputOffset);
}

代码示例来源:origin: com.madgag.spongycastle/core

/**
 * Performs the extract part of the key derivation function.
 *
 * @param salt the salt to use
 * @param ikm  the input keying material
 * @return the PRK as KeyParameter
 */
private KeyParameter extract(byte[] salt, byte[] ikm)
{
  if (salt == null)
  {
    // TODO check if hashLen is indeed same as HMAC size
    hMacHash.init(new KeyParameter(new byte[hashLen]));
  }
  else
  {
    hMacHash.init(new KeyParameter(salt));
  }
  hMacHash.update(ikm, 0, ikm.length);
  byte[] prk = new byte[hashLen];
  hMacHash.doFinal(prk, 0);
  return new KeyParameter(prk);
}

代码示例来源:origin: OPCFoundation/UA-Java-Legacy

new KeyParameter(key));
byte[] computedSignature = new byte[hmac.getMacSize()];
hmac.update(dataToVerify, inputOffset, verifyLen);
hmac.doFinal(computedSignature, 0);

相关文章