当前位置: 首页>>代码示例>>Java>>正文


Java SHA1Digest类代码示例

本文整理汇总了Java中org.bouncycastle.crypto.digests.SHA1Digest的典型用法代码示例。如果您正苦于以下问题:Java SHA1Digest类的具体用法?Java SHA1Digest怎么用?Java SHA1Digest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SHA1Digest类属于org.bouncycastle.crypto.digests包,在下文中一共展示了SHA1Digest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createHash

import org.bouncycastle.crypto.digests.SHA1Digest; //导入依赖的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");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:21,代码来源:TlsUtils.java

示例2: calculateKeyId

import org.bouncycastle.crypto.digests.SHA1Digest; //导入依赖的package包/类
static byte[] calculateKeyId(SubjectPublicKeyInfo info)
{
    Digest dig = new SHA1Digest();    // TODO: include definition of SHA-1 here
    byte[] hash = new byte[dig.getDigestSize()];
    byte[] spkiEnc = new byte[0];
    try
    {
        spkiEnc = info.getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        return new byte[0];
    }

    // try the outlook 2010 calculation
    dig.update(spkiEnc, 0, spkiEnc.length);

    dig.doFinal(hash, 0);

    return hash;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:22,代码来源:MSOutlookKeyIdCalculator.java

示例3: OldPKCS12ParametersGenerator

import org.bouncycastle.crypto.digests.SHA1Digest; //导入依赖的package包/类
/**
 * Construct a PKCS 12 Parameters generator. This constructor will
 * accept MD5, SHA1, and RIPEMD160.
 *
 * @param digest the digest to be used as the source of derived keys.
 * @exception IllegalArgumentException if an unknown digest is passed in.
 */
public OldPKCS12ParametersGenerator(
    Digest  digest)
{
    this.digest = digest;
    if (digest instanceof MD5Digest)
    {
        u = 128 / 8;
        v = 512 / 8;
    }
    else if (digest instanceof SHA1Digest)
    {
        u = 160 / 8;
        v = 512 / 8;
    }
    else if (digest instanceof RIPEMD160Digest)
    {
        u = 160 / 8;
        v = 512 / 8;
    }
    else
    {
        throw new IllegalArgumentException("Digest " + digest.getAlgorithmName() + " unsupported");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:32,代码来源:BrokenPBE.java

示例4: PRF_legacy

import org.bouncycastle.crypto.digests.SHA1Digest; //导入依赖的package包/类
static byte[] PRF_legacy(byte[] secret, byte[] label, byte[] labelSeed, int size)
{
    int s_half = (secret.length + 1) / 2;
    byte[] s1 = new byte[s_half];
    byte[] s2 = new byte[s_half];
    System.arraycopy(secret, 0, s1, 0, s_half);
    System.arraycopy(secret, secret.length - s_half, s2, 0, s_half);

    byte[] b1 = new byte[size];
    byte[] b2 = new byte[size];
    hmac_hash(new MD5Digest(), s1, labelSeed, b1);
    hmac_hash(new SHA1Digest(), s2, labelSeed, b2);
    for (int i = 0; i < size; i++)
    {
        b1[i] ^= b2[i];
    }
    return b1;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:19,代码来源:TlsUtils.java

示例5: cloneHash

import org.bouncycastle.crypto.digests.SHA1Digest; //导入依赖的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");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:21,代码来源:TlsUtils.java

示例6: createHMACDigest

import org.bouncycastle.crypto.digests.SHA1Digest; //导入依赖的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);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:22,代码来源:DefaultTlsCipherFactory.java

示例7: AuthorityKeyIdentifier

import org.bouncycastle.crypto.digests.SHA1Digest; //导入依赖的package包/类
/**
 * create an AuthorityKeyIdentifier with the GeneralNames tag and
 * the serial number provided as well.
 */
public AuthorityKeyIdentifier(
    SubjectPublicKeyInfo    spki,
    GeneralNames            name,
    BigInteger              serialNumber)
{
    Digest  digest = new SHA1Digest();
    byte[]  resBuf = new byte[digest.getDigestSize()];

    byte[] bytes = spki.getPublicKeyData().getBytes();
    digest.update(bytes, 0, bytes.length);
    digest.doFinal(resBuf, 0);

    this.keyidentifier = new DEROctetString(resBuf);
    this.certissuer = GeneralNames.getInstance(name.toASN1Primitive());
    this.certserno = new ASN1Integer(serialNumber);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:21,代码来源:AuthorityKeyIdentifier.java

示例8: sign

import org.bouncycastle.crypto.digests.SHA1Digest; //导入依赖的package包/类
private static byte[] sign() throws Exception {
	RSAEngine rsa = new RSAEngine();
	Digest dig = new SHA1Digest();

	RSAPrivateKey privateKey = (RSAPrivateKey) getPrivate(privateKeyFilename);
	BigInteger big = ((RSAKey) privateKey).getModulus();
	ISO9796d2Signer eng = new ISO9796d2Signer(rsa, dig, true);
	RSAKeyParameters rsaPriv = new RSAKeyParameters(true, big, privateKey.getPrivateExponent());
	eng.init(true, rsaPriv);
	eng.update(message[0]);
	eng.update(message, 1, message.length - 1);

	byte[] signature = eng.generateSignature();

	return signature;
}
 
开发者ID:true-gler,项目名称:ISO9796SignerVerifier,代码行数:17,代码来源:App.java

示例9: PKCS12ParametersGenerator

import org.bouncycastle.crypto.digests.SHA1Digest; //导入依赖的package包/类
/**
 * Construct a PKCS 12 Parameters generator. This constructor will
 * accept MD5, SHA1, and RIPEMD160.
 *
 * @param digest the digest to be used as the source of derived keys.
 * @exception IllegalArgumentException if an unknown digest is passed in.
 */
public PKCS12ParametersGenerator(
    Digest  digest)
{
    this.digest = digest;
    if (digest instanceof MD5Digest)
    {
        u = 128 / 8;
        v = 512 / 8;
    }
    else if (digest instanceof SHA1Digest)
    {
        u = 160 / 8;
        v = 512 / 8;
    }
    else if (digest instanceof RIPEMD160Digest)
    {
        u = 160 / 8;
        v = 512 / 8;
    }
    else
    {
        throw new IllegalArgumentException("Digest " + digest.getAlgorithmName() + " unsupported");
    }
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:32,代码来源:PKCS12ParametersGenerator.java

示例10: AuthorityKeyIdentifier

import org.bouncycastle.crypto.digests.SHA1Digest; //导入依赖的package包/类
/**
 * create an AuthorityKeyIdentifier with the GeneralNames tag and
 * the serial number provided as well.
 */
public AuthorityKeyIdentifier(
    SubjectPublicKeyInfo    spki,
    GeneralNames            name,
    BigInteger              serialNumber)
{
    Digest  digest = new SHA1Digest();
    byte[]  resBuf = new byte[digest.getDigestSize()];

    byte[] bytes = spki.getPublicKeyData().getBytes();
    digest.update(bytes, 0, bytes.length);
    digest.doFinal(resBuf, 0);

    this.keyidentifier = new DEROctetString(resBuf);
    this.certissuer = GeneralNames.getInstance(name.toASN1Object());
    this.certserno = new DERInteger(serialNumber);
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:21,代码来源:AuthorityKeyIdentifier.java

示例11: createHash

import org.bouncycastle.crypto.digests.SHA1Digest; //导入依赖的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");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:21,代码来源:TlsUtils.java

示例12: cloneHash

import org.bouncycastle.crypto.digests.SHA1Digest; //导入依赖的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");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:21,代码来源:TlsUtils.java

示例13: AuthorityKeyIdentifier

import org.bouncycastle.crypto.digests.SHA1Digest; //导入依赖的package包/类
/**
 * create an AuthorityKeyIdentifier with the GeneralNames tag and
 * the serial number provided as well.
 * @deprecated create the extension using org.bouncycastle.cert.X509ExtensionUtils
 */
public AuthorityKeyIdentifier(
    SubjectPublicKeyInfo    spki,
    GeneralNames            name,
    BigInteger              serialNumber)
{
    Digest  digest = new SHA1Digest();
    byte[]  resBuf = new byte[digest.getDigestSize()];

    byte[] bytes = spki.getPublicKeyData().getBytes();
    digest.update(bytes, 0, bytes.length);
    digest.doFinal(resBuf, 0);

    this.keyidentifier = new DEROctetString(resBuf);
    this.certissuer = GeneralNames.getInstance(name.toASN1Primitive());
    this.certserno = new ASN1Integer(serialNumber);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:22,代码来源:AuthorityKeyIdentifier.java

示例14: performTest

import org.bouncycastle.crypto.digests.SHA1Digest; //导入依赖的package包/类
public void performTest()
{
    checkMask(1, new MGF1BytesGenerator(new ShortenedDigest(new SHA256Digest(), 20)), seed1, mask1);
    checkMask(2, new MGF1BytesGenerator(new SHA1Digest()), seed2, mask2);
    checkMask(3, new MGF1BytesGenerator(new ShortenedDigest(new SHA256Digest(), 20)), seed3, mask3);
    
    try
    {
        new MGF1BytesGenerator(new SHA1Digest()).generateBytes(new byte[10], 0, 20);
        
        fail("short input array not caught");
    }
    catch (DataLengthException e)
    {
        // expected 
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:18,代码来源:MGF1GeneratorTest.java

示例15: performTest

import org.bouncycastle.crypto.digests.SHA1Digest; //导入依赖的package包/类
public void performTest()
{
    checkMask(1, new KDF1BytesGenerator(new ShortenedDigest(new SHA256Digest(), 20)), seed1, mask1);
    checkMask(2, new KDF1BytesGenerator(new SHA1Digest()), seed2, mask2);
    checkMask(3, new KDF1BytesGenerator(new ShortenedDigest(new SHA256Digest(), 20)), seed3, mask3);
    
    try
    {
        new KDF1BytesGenerator(new SHA1Digest()).generateBytes(new byte[10], 0, 20);
        
        fail("short input array not caught");
    }
    catch (DataLengthException e)
    {
        // expected 
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:18,代码来源:KDF1GeneratorTest.java


注:本文中的org.bouncycastle.crypto.digests.SHA1Digest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。