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

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

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

HMac.<init>介绍

[英]Base constructor for one of the standard digest algorithms that the byteLength of the algorithm is know for.
[中]标准摘要算法之一的基构造函数,该算法的字节长度是已知的。

代码示例

代码示例来源:origin: ethereum/ethereumj

private static EthereumIESEngine makeIESEngine(boolean isEncrypt, ECPoint pub, BigInteger prv, byte[] IV) {
  AESEngine aesFastEngine = new AESEngine();
  EthereumIESEngine iesEngine = new EthereumIESEngine(
      new ECDHBasicAgreement(),
      new ConcatKDFBytesGenerator(new SHA256Digest()),
      new HMac(new SHA256Digest()),
      new SHA256Digest(),
      new BufferedBlockCipher(new SICBlockCipher(aesFastEngine)));
  byte[]         d = new byte[] {};
  byte[]         e = new byte[] {};
  IESParameters p = new IESWithCipherParameters(d, e, KEY_SIZE, KEY_SIZE);
  ParametersWithIV parametersWithIV = new ParametersWithIV(p, IV);
  iesEngine.init(isEncrypt, new ECPrivateKeyParameters(prv, CURVE), new ECPublicKeyParameters(pub, CURVE), parametersWithIV);
  return iesEngine;
}

代码示例来源:origin: ethereum/ethereumj

/**
 *  Encryption equivalent to the Crypto++ default ECIES<ECP> settings:
 *
 *  DL_KeyAgreementAlgorithm:        DL_KeyAgreementAlgorithm_DH<struct ECPPoint,struct EnumToType<enum CofactorMultiplicationOption,0> >
 *  DL_KeyDerivationAlgorithm:       DL_KeyDerivationAlgorithm_P1363<struct ECPPoint,0,class P1363_KDF2<class SHA1> >
 *  DL_SymmetricEncryptionAlgorithm: DL_EncryptionAlgorithm_Xor<class HMAC<class SHA1>,0>
 *  DL_PrivateKey:                   DL_Key<ECPPoint>
 *  DL_PrivateKey_EC<class ECP>
 *
 *  Used for Whisper V3
 */
public static byte[] decryptSimple(BigInteger privKey, byte[] cipher) throws IOException, InvalidCipherTextException {
  EthereumIESEngine iesEngine = new EthereumIESEngine(
      new ECDHBasicAgreement(),
      new MGF1BytesGeneratorExt(new SHA1Digest(), 1),
      new HMac(new SHA1Digest()),
      new SHA1Digest(),
      null);
  IESParameters p = new IESParameters(null, null, KEY_SIZE);
  ParametersWithIV parametersWithIV = new ParametersWithIV(p, new byte[0]);
  iesEngine.setHashMacKey(false);
  iesEngine.init(new ECPrivateKeyParameters(privKey, CURVE), parametersWithIV,
      new ECIESPublicKeyParser(ECKey.CURVE));
  return iesEngine.processBlock(cipher, 0, cipher.length);
}

代码示例来源:origin: ethereum/ethereumj

public static byte[] decrypt(ECPoint ephem, BigInteger prv, byte[] IV, byte[] cipher, byte[] macData) throws InvalidCipherTextException {
  AESEngine aesFastEngine = new AESEngine();
  EthereumIESEngine iesEngine = new EthereumIESEngine(
      new ECDHBasicAgreement(),
      new ConcatKDFBytesGenerator(new SHA256Digest()),
      new HMac(new SHA256Digest()),
      new SHA256Digest(),
      new BufferedBlockCipher(new SICBlockCipher(aesFastEngine)));
  byte[]         d = new byte[] {};
  byte[]         e = new byte[] {};
  IESParameters p = new IESWithCipherParameters(d, e, KEY_SIZE, KEY_SIZE);
  ParametersWithIV parametersWithIV =
      new ParametersWithIV(p, IV);
  iesEngine.init(false, new ECPrivateKeyParameters(prv, CURVE), new ECPublicKeyParameters(ephem, CURVE), parametersWithIV);
  return iesEngine.processBlock(cipher, 0, cipher.length, macData);
}

代码示例来源:origin: ethereum/ethereumj

new ECDHBasicAgreement(),
new MGF1BytesGeneratorExt(new SHA1Digest(), 1),
new HMac(new SHA1Digest()),
new SHA1Digest(),
null);

代码示例来源:origin: ethereum/ethereumj

new ECDHBasicAgreement(),
new KDF2BytesGenerator(new SHA256Digest()),
new HMac(new SHA256Digest()),
new BufferedBlockCipher(new SICBlockCipher(aesFastEngine)));
new ECDHBasicAgreement(),
new KDF2BytesGenerator (new SHA256Digest()),
new HMac(new SHA256Digest()),
new BufferedBlockCipher(new SICBlockCipher(aesFastEngine)));

代码示例来源:origin: ethereum/ethereumj

private static EthereumIESEngine makeIESEngine(boolean isEncrypt, ECPoint pub, BigInteger prv, byte[] IV) {
  AESEngine aesFastEngine = new AESEngine();
  EthereumIESEngine iesEngine = new EthereumIESEngine(
      new ECDHBasicAgreement(),
      new ConcatKDFBytesGenerator(new SHA256Digest()),
      new HMac(new SHA256Digest()),
      new SHA256Digest(),
      new BufferedBlockCipher(new SICBlockCipher(aesFastEngine)));
  byte[]         d = new byte[] {};
  byte[]         e = new byte[] {};
  IESParameters p = new IESWithCipherParameters(d, e, KEY_SIZE, KEY_SIZE);
  ParametersWithIV parametersWithIV = new ParametersWithIV(p, IV);
  iesEngine.init(isEncrypt, new ECPrivateKeyParameters(prv, curve), new ECPublicKeyParameters(pub, curve), parametersWithIV);
  return iesEngine;
}

代码示例来源:origin: ethereum/ethereumj

new ECDHBasicAgreement(),
new KDF2BytesGenerator(new SHA256Digest()),
new HMac(new SHA256Digest()),
new BufferedBlockCipher(new SICBlockCipher(aesFastEngine)));
new ECDHBasicAgreement(),
new KDF2BytesGenerator (new SHA256Digest()),
new HMac(new SHA256Digest()),
new BufferedBlockCipher(new SICBlockCipher(aesFastEngine)));

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

/**
 * Creates a HKDFBytesGenerator based on the given hash function.
 *
 * @param hash the digest to be used as the source of generatedBytes bytes
 */
public HKDFBytesGenerator(Digest hash)
{
  this.hMacHash = new HMac(hash);
  this.hashLen = hash.getDigestSize();
}

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

public HashMac()
  {
    super(new HMac(new SHA1Digest()));
  }
}

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

public HashMac_512_224()
  {
    super(new HMac(new SkeinDigest(SkeinDigest.SKEIN_512, 224)));
  }
}

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

public HashMac_1024_384()
  {
    super(new HMac(new SkeinDigest(SkeinDigest.SKEIN_1024, 384)));
  }
}

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

public HashMac2012_512()
  {
    super(new HMac(new GOST3411_2012_512Digest()));
  }
}

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

public HashMac()
  {
    super(new HMac(new RIPEMD128Digest()));
  }
}

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

public TLS12withSHA384()
  {
    super("TLS12withSHA384KDF", new HMac(new SHA384Digest()));
  }
}

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

public HashMac384()
  {
    super(new HMac(new KeccakDigest(384)));
  }
}

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

public HashMac()
  {
    super(new HMac(new RIPEMD160Digest()));
  }
}

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

public HashMac()
  {
    super(new HMac(new RIPEMD320Digest()));
  }
}

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

public HashMac()
  {
    super(new HMac(new RIPEMD256Digest()));
  }
}

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

public HashMacT256()
  {
    super(new HMac(new SHA512tDigest(256)));
  }
}

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

public ECIES()
  {
    super(new IESEngine(new ECDHBasicAgreement(),
      new KDF2BytesGenerator(DigestFactory.createSHA1()),
      new HMac(DigestFactory.createSHA1())));
  }
}

相关文章