本文整理汇总了Java中org.bouncycastle.crypto.digests.SHA512Digest类的典型用法代码示例。如果您正苦于以下问题:Java SHA512Digest类的具体用法?Java SHA512Digest怎么用?Java SHA512Digest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SHA512Digest类属于org.bouncycastle.crypto.digests包,在下文中一共展示了SHA512Digest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHash
import org.bouncycastle.crypto.digests.SHA512Digest; //导入依赖的package包/类
public static final Digest createHash(int hashAlgorithm)
{
switch (hashAlgorithm)
{
case HashAlgorithm.md5:
return new MD5Digest();
case HashAlgorithm.sha1:
return new SHA1Digest();
case HashAlgorithm.sha224:
return new SHA224Digest();
case HashAlgorithm.sha256:
return new SHA256Digest();
case HashAlgorithm.sha384:
return new SHA384Digest();
case HashAlgorithm.sha512:
return new SHA512Digest();
default:
throw new IllegalArgumentException("unknown HashAlgorithm");
}
}
示例2: cloneHash
import org.bouncycastle.crypto.digests.SHA512Digest; //导入依赖的package包/类
public static final Digest cloneHash(int hashAlgorithm, Digest hash)
{
switch (hashAlgorithm)
{
case HashAlgorithm.md5:
return new MD5Digest((MD5Digest)hash);
case HashAlgorithm.sha1:
return new SHA1Digest((SHA1Digest)hash);
case HashAlgorithm.sha224:
return new SHA224Digest((SHA224Digest)hash);
case HashAlgorithm.sha256:
return new SHA256Digest((SHA256Digest)hash);
case HashAlgorithm.sha384:
return new SHA384Digest((SHA384Digest)hash);
case HashAlgorithm.sha512:
return new SHA512Digest((SHA512Digest)hash);
default:
throw new IllegalArgumentException("unknown HashAlgorithm");
}
}
示例3: createHMACDigest
import org.bouncycastle.crypto.digests.SHA512Digest; //导入依赖的package包/类
protected Digest createHMACDigest(int macAlgorithm)
throws IOException
{
switch (macAlgorithm)
{
case MACAlgorithm._null:
return null;
case MACAlgorithm.hmac_md5:
return new MD5Digest();
case MACAlgorithm.hmac_sha1:
return new SHA1Digest();
case MACAlgorithm.hmac_sha256:
return new SHA256Digest();
case MACAlgorithm.hmac_sha384:
return new SHA384Digest();
case MACAlgorithm.hmac_sha512:
return new SHA512Digest();
default:
throw new TlsFatalAlert(AlertDescription.internal_error);
}
}
示例4: createHash
import org.bouncycastle.crypto.digests.SHA512Digest; //导入依赖的package包/类
public static Digest createHash(short hashAlgorithm)
{
switch (hashAlgorithm)
{
case HashAlgorithm.md5:
return new MD5Digest();
case HashAlgorithm.sha1:
return new SHA1Digest();
case HashAlgorithm.sha224:
return new SHA224Digest();
case HashAlgorithm.sha256:
return new SHA256Digest();
case HashAlgorithm.sha384:
return new SHA384Digest();
case HashAlgorithm.sha512:
return new SHA512Digest();
default:
throw new IllegalArgumentException("unknown HashAlgorithm");
}
}
示例5: cloneHash
import org.bouncycastle.crypto.digests.SHA512Digest; //导入依赖的package包/类
public static Digest cloneHash(short hashAlgorithm, Digest hash)
{
switch (hashAlgorithm)
{
case HashAlgorithm.md5:
return new MD5Digest((MD5Digest)hash);
case HashAlgorithm.sha1:
return new SHA1Digest((SHA1Digest)hash);
case HashAlgorithm.sha224:
return new SHA224Digest((SHA224Digest)hash);
case HashAlgorithm.sha256:
return new SHA256Digest((SHA256Digest)hash);
case HashAlgorithm.sha384:
return new SHA384Digest((SHA384Digest)hash);
case HashAlgorithm.sha512:
return new SHA512Digest((SHA512Digest)hash);
default:
throw new IllegalArgumentException("unknown HashAlgorithm");
}
}
示例6: createUser
import org.bouncycastle.crypto.digests.SHA512Digest; //导入依赖的package包/类
private HttpResponse createUser(byte[] username, byte[] ltpk, byte[] proof) throws Exception {
HKDFBytesGenerator hkdf = new HKDFBytesGenerator(new SHA512Digest());
hkdf.init(new HKDFParameters(k, "Pair-Setup-Controller-Sign-Salt".getBytes(StandardCharsets.UTF_8),
"Pair-Setup-Controller-Sign-Info".getBytes(StandardCharsets.UTF_8)));
byte[] okm = new byte[32];
hkdf.generateBytes(okm, 0, 32);
byte[] completeData = ByteUtils.joinBytes(okm, username, ltpk);
if (!new EdsaVerifier(ltpk).verify(completeData, proof)) {
throw new Exception("Invalid signature");
}
authInfo.createUser(authInfo.getMac()+new String(username, StandardCharsets.UTF_8), ltpk);
advertiser.setDiscoverable(false);
return createResponse();
}
示例7: SHA512
import org.bouncycastle.crypto.digests.SHA512Digest; //导入依赖的package包/类
/**
* Creates a new SHA512 digest that may optionally be initialized with
* random data.
*
* @param randomize
* True to randomize initial state of digest, false otherwise.
*/
public SHA512(final boolean randomize) {
super(new SHA512Digest());
if (randomize) {
setRandomProvider(new SecureRandom());
setSalt(getRandomSalt());
}
}
示例8: createHash
import org.bouncycastle.crypto.digests.SHA512Digest; //导入依赖的package包/类
public static final Digest createHash(short hashAlgorithm)
{
switch (hashAlgorithm)
{
case HashAlgorithm.md5:
return new MD5Digest();
case HashAlgorithm.sha1:
return new SHA1Digest();
case HashAlgorithm.sha224:
return new SHA224Digest();
case HashAlgorithm.sha256:
return new SHA256Digest();
case HashAlgorithm.sha384:
return new SHA384Digest();
case HashAlgorithm.sha512:
return new SHA512Digest();
default:
throw new IllegalArgumentException("unknown HashAlgorithm");
}
}
示例9: cloneHash
import org.bouncycastle.crypto.digests.SHA512Digest; //导入依赖的package包/类
public static final Digest cloneHash(short hashAlgorithm, Digest hash)
{
switch (hashAlgorithm)
{
case HashAlgorithm.md5:
return new MD5Digest((MD5Digest)hash);
case HashAlgorithm.sha1:
return new SHA1Digest((SHA1Digest)hash);
case HashAlgorithm.sha224:
return new SHA224Digest((SHA224Digest)hash);
case HashAlgorithm.sha256:
return new SHA256Digest((SHA256Digest)hash);
case HashAlgorithm.sha384:
return new SHA384Digest((SHA384Digest)hash);
case HashAlgorithm.sha512:
return new SHA512Digest((SHA512Digest)hash);
default:
throw new IllegalArgumentException("unknown HashAlgorithm");
}
}
示例10: createHMACDigest
import org.bouncycastle.crypto.digests.SHA512Digest; //导入依赖的package包/类
protected Digest createHMACDigest(int macAlgorithm) throws IOException
{
switch (macAlgorithm)
{
case MACAlgorithm._null:
return null;
case MACAlgorithm.hmac_md5:
return new MD5Digest();
case MACAlgorithm.hmac_sha1:
return new SHA1Digest();
case MACAlgorithm.hmac_sha256:
return new SHA256Digest();
case MACAlgorithm.hmac_sha384:
return new SHA384Digest();
case MACAlgorithm.hmac_sha512:
return new SHA512Digest();
default:
throw new TlsFatalAlert(AlertDescription.internal_error);
}
}
示例11: guessDigest
import org.bouncycastle.crypto.digests.SHA512Digest; //导入依赖的package包/类
private Digest guessDigest(int size)
{
switch (size)
{
case 20:
return new SHA1Digest();
case 28:
return new SHA224Digest();
case 32:
return new SHA256Digest();
case 48:
return new SHA384Digest();
case 64:
return new SHA512Digest();
}
return null;
}
示例12: getDigest
import org.bouncycastle.crypto.digests.SHA512Digest; //导入依赖的package包/类
public static Digest getDigest(
String digestName)
{
digestName = Strings.toUpperCase(digestName);
if (sha1.contains(digestName))
{
return new SHA1Digest();
}
if (md5.contains(digestName))
{
return new MD5Digest();
}
if (sha224.contains(digestName))
{
return new SHA224Digest();
}
if (sha256.contains(digestName))
{
return new SHA256Digest();
}
if (sha384.contains(digestName))
{
return new SHA384Digest();
}
if (sha512.contains(digestName))
{
return new SHA512Digest();
}
return null;
}
示例13: clone
import org.bouncycastle.crypto.digests.SHA512Digest; //导入依赖的package包/类
public Object clone()
throws CloneNotSupportedException
{
Digest d = (Digest)super.clone();
d.digest = new SHA512Digest((SHA512Digest)digest);
return d;
}
示例14: getNewDSAParameterSpec
import org.bouncycastle.crypto.digests.SHA512Digest; //导入依赖的package包/类
public static DSAParameterSpec getNewDSAParameterSpec(int plength, int qlength,
SecureRandom random) {
final int certainty = 80;
SecureRandom tmpRandom = (random == null) ? new SecureRandom() : random;
DSAParametersGenerator paramGen = new DSAParametersGenerator(new SHA512Digest());
DSAParameterGenerationParameters genParams = new DSAParameterGenerationParameters(
plength, qlength, certainty, tmpRandom);
paramGen.init(genParams);
DSAParameters dsaParams = paramGen.generateParameters();
return new DSAParameterSpec(dsaParams.getP(), dsaParams.getQ(), dsaParams.getG());
}
示例15: createDigest
import org.bouncycastle.crypto.digests.SHA512Digest; //导入依赖的package包/类
static Digest createDigest(int algorithm)
throws PGPException
{
switch (algorithm)
{
case HashAlgorithmTags.SHA1:
return new SHA1Digest();
case HashAlgorithmTags.SHA224:
return new SHA224Digest();
case HashAlgorithmTags.SHA256:
return new SHA256Digest();
case HashAlgorithmTags.SHA384:
return new SHA384Digest();
case HashAlgorithmTags.SHA512:
return new SHA512Digest();
case HashAlgorithmTags.MD2:
return new MD2Digest();
case HashAlgorithmTags.MD5:
return new MD5Digest();
case HashAlgorithmTags.RIPEMD160:
return new RIPEMD160Digest();
case HashAlgorithmTags.TIGER_192:
return new TigerDigest();
default:
throw new PGPException("cannot recognise digest");
}
}