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

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

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

HMac.getMacSize介绍

暂无

代码示例

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

public int getMacLength()
{
  return hmac.getMacSize();
}

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

/**
 * Base constructor.
 *
 * @param digest digest to build the HMAC on.
 */
public HMacDSAKCalculator(Digest digest)
{
  this.hMac = new HMac(digest);
  this.V = new byte[hMac.getMacSize()];
  this.K = new byte[hMac.getMacSize()];
}

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

public byte[] getMac()
{
  byte[] res = new byte[hMac.getMacSize()];
  hMac.doFinal(res, 0);
  return res;
}

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

public byte[] calculateMAC()
{
  byte[] rv = new byte[hmac.getMacSize()];
  hmac.doFinal(rv, 0);
  return rv;
}

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

public byte[] getMac()
{
  byte[] res = new byte[hMac.getMacSize()];
  hMac.doFinal(res, 0);
  return res;
}

代码示例来源: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/scprov-jdk15on

public void engineStore(OutputStream stream, char[] password) 
  throws IOException
{
  DataOutputStream    dOut = new DataOutputStream(stream);
  byte[]              salt = new byte[STORE_SALT_SIZE];
  int                 iterationCount = MIN_ITERATIONS + (random.nextInt() & 0x3ff);
  random.nextBytes(salt);
  dOut.writeInt(STORE_VERSION);
  dOut.writeInt(salt.length);
  dOut.write(salt);
  dOut.writeInt(iterationCount);
  HMac                    hMac = new HMac(new SHA1Digest());
  MacOutputStream         mOut = new MacOutputStream(hMac);
  PBEParametersGenerator  pbeGen = new PKCS12ParametersGenerator(new SHA1Digest());
  byte[]                  passKey = PBEParametersGenerator.PKCS12PasswordToBytes(password);
  pbeGen.init(passKey, salt, iterationCount);
  hMac.init(pbeGen.generateDerivedMacParameters(hMac.getMacSize() * 8));
  for (int i = 0; i != passKey.length; i++)
  {
    passKey[i] = 0;
  }
  saveStore(new TeeOutputStream(dOut, mOut));
  byte[]  mac = new byte[hMac.getMacSize()];
  hMac.doFinal(mac, 0);
  dOut.write(mac);
  dOut.close();
}

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

macParams = pbeGen.generateDerivedMacParameters(hMac.getMacSize());
  macParams = pbeGen.generateDerivedMacParameters(hMac.getMacSize() * 8);
byte[] mac = new byte[hMac.getMacSize()];
hMac.doFinal(mac, 0);
byte[] oldMac = new byte[hMac.getMacSize()];
dIn.readFully(oldMac);
byte[] oldMac = new byte[hMac.getMacSize()];
dIn.readFully(oldMac);

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

hMac.init(pbeGen.generateDerivedMacParameters(hMac.getMacSize()));
  hMac.init(pbeGen.generateDerivedMacParameters(hMac.getMacSize() * 8));
byte[]  mac = new byte[hMac.getMacSize()];

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

macParams = pbeGen.generateDerivedMacParameters(hMac.getMacSize());
  macParams = pbeGen.generateDerivedMacParameters(hMac.getMacSize() * 8);
byte[] mac = new byte[hMac.getMacSize()];
hMac.doFinal(mac, 0);
byte[] oldMac = new byte[hMac.getMacSize()];
dIn.readFully(oldMac);
byte[] oldMac = new byte[hMac.getMacSize()];
dIn.readFully(oldMac);

代码示例来源: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: 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: OPCFoundation/UA-Java-Legacy

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

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

byte[] macOutput = new byte[mac.getMacSize()];
mac.init(new KeyParameter(macKey));

相关文章