Java 类org.bouncycastle.crypto.digests.MD5Digest 实例源码

项目:ipack    文件:TlsUtils.java   
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");
    }
}
项目:ipack    文件:BrokenPBE.java   
/**
 * 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");
    }
}
项目:ipack    文件:TlsUtils.java   
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;
}
项目:ipack    文件:TlsUtils.java   
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");
    }
}
项目:ipack    文件:DefaultTlsCipherFactory.java   
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);
    }
}
项目:assignables    文件:MD5AssignmentPolicy.java   
public void assign(Object value, Assignable variable) {
    // Adds the security provider.
    logger.debug("Adding security provider.");
    Security.addProvider(new BouncyCastleProvider());

    logger.debug("Calculating MD5 Hash.");
    // Converts the input to a byte array.
    byte input[] = value.toString().getBytes();

    // Calculates the MD5 digest.
    MD5Digest md5 = new MD5Digest();
    md5.update(input, 0, input.length);

    // Gets the digest size and hashes it.
    byte[] digest = new byte[md5.getDigestSize()];
    md5.doFinal(digest, 0);

    String hash = new String(Hex.encode(digest));
    logger.debug("Setting Hash [{}] into variable [{}].", hash, variable);
    variable.set(hash);
}
项目:Direct-File-Downloader    文件:PKCS12ParametersGenerator.java   
/**
 * 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");
    }
}
项目:gwt-crypto    文件:TlsUtils.java   
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");
    }
}
项目:gwt-crypto    文件:TlsUtils.java   
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");
    }
}
项目:Aki-SSL    文件:BrokenPBE.java   
/**
 * 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");
    }
}
项目:Aki-SSL    文件:TlsUtils.java   
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");
    }
}
项目:Aki-SSL    文件:TlsUtils.java   
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");
    }
}
项目:jackcessencrypt    文件:MSISAMCryptCodecHandler.java   
private static byte[] createPasswordDigest(
    ByteBuffer buffer, String password, Charset charset)
{
    Digest digest =
      (((buffer.get(ENCRYPTION_FLAGS_OFFSET) & USE_SHA1) != 0) ?
       new SHA1Digest() : new MD5Digest());

    byte[] passwordBytes = new byte[PASSWORD_LENGTH];

    if (password != null) {
      ByteBuffer bb = ColumnImpl.encodeUncompressedText(
          password.toUpperCase(), charset);
      bb.get(passwordBytes, 0,
             Math.min(passwordBytes.length, bb.remaining()));
    }

    // Get digest value
    byte[] digestBytes = hash(digest, passwordBytes, PASSWORD_DIGEST_LENGTH);
    return digestBytes;
}
项目:TinyTravelTracker    文件:TlsUtils.java   
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");
    }
}
项目:TinyTravelTracker    文件:TlsUtils.java   
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");
    }
}
项目:AcademicTorrents-Downloader    文件:PKCS12ParametersGenerator.java   
/**
 * 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");
    }
}
项目:CryptMeme    文件:BrokenPBE.java   
/**
 * 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");
    }
}
项目:CryptMeme    文件:TlsUtils.java   
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;
}
项目:CryptMeme    文件:TlsUtils.java   
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");
    }
}
项目:CryptMeme    文件:TlsUtils.java   
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");
    }
}
项目:CryptMeme    文件:DefaultTlsCipherFactory.java   
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);
    }
}
项目:irma_future_id    文件:TlsUtils.java   
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;
}
项目:irma_future_id    文件:TlsUtils.java   
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");
    }
}
项目:irma_future_id    文件:TlsUtils.java   
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");
    }
}
项目:irma_future_id    文件:DefaultTlsCipherFactory.java   
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);
    }
}
项目:irma_future_id    文件:BrokenPBE.java   
/**
 * 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");
    }
}
项目:bc-java    文件:TlsUtils.java   
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;
}
项目:bc-java    文件:TlsUtils.java   
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");
    }
}
项目:bc-java    文件:TlsUtils.java   
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");
    }
}
项目:bc-java    文件:DefaultTlsCipherFactory.java   
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);
    }
}
项目:bc-java    文件:BrokenPBE.java   
/**
 * 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");
    }
}
项目:jradius    文件:TlsUtils.java   
protected static byte[] PRF(byte[] secret, String asciiLabel, byte[] seed, int size)
{
    byte[] label = Strings.toByteArray(asciiLabel);

    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[] ls = concat(label, seed);

    byte[] buf = new byte[size];
    byte[] prf = new byte[size];
    hmac_hash(new MD5Digest(), s1, ls, prf);
    hmac_hash(new SHA1Digest(), s2, ls, buf);
    for (int i = 0; i < size; i++)
    {
        buf[i] ^= prf[i];
    }
    return buf;
}
项目:ipack    文件:TlsUtils.java   
static byte[] calculateKeyBlock_SSL(byte[] master_secret, byte[] random, int size)
{
    Digest md5 = new MD5Digest();
    Digest sha1 = new SHA1Digest();
    int md5Size = md5.getDigestSize();
    byte[] shatmp = new byte[sha1.getDigestSize()];
    byte[] tmp = new byte[size + md5Size];

    int i = 0, pos = 0;
    while (pos < size)
    {
        byte[] ssl3Const = SSL3_CONST[i];

        sha1.update(ssl3Const, 0, ssl3Const.length);
        sha1.update(master_secret, 0, master_secret.length);
        sha1.update(random, 0, random.length);
        sha1.doFinal(shatmp, 0);

        md5.update(master_secret, 0, master_secret.length);
        md5.update(shatmp, 0, shatmp.length);
        md5.doFinal(tmp, pos);

        pos += md5Size;
        ++i;
    }

    byte rval[] = new byte[size];
    System.arraycopy(tmp, 0, rval, 0, size);
    return rval;
}
项目:ipack    文件:TlsUtils.java   
static byte[] calculateMasterSecret_SSL(byte[] pre_master_secret, byte[] random)
{
    Digest md5 = new MD5Digest();
    Digest sha1 = new SHA1Digest();
    int md5Size = md5.getDigestSize();
    byte[] shatmp = new byte[sha1.getDigestSize()];

    byte[] rval = new byte[md5Size * 3];
    int pos = 0;

    for (int i = 0; i < 3; ++i)
    {
        byte[] ssl3Const = SSL3_CONST[i];

        sha1.update(ssl3Const, 0, ssl3Const.length);
        sha1.update(pre_master_secret, 0, pre_master_secret.length);
        sha1.update(random, 0, random.length);
        sha1.doFinal(shatmp, 0);

        md5.update(pre_master_secret, 0, pre_master_secret.length);
        md5.update(shatmp, 0, shatmp.length);
        md5.doFinal(rval, pos);

        pos += md5Size;
    }

    return rval;
}
项目:ipack    文件:DigestFactory.java   
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;
}
项目:ipack    文件:MD5.java   
public Object clone()
    throws CloneNotSupportedException
{
    Digest d = (Digest)super.clone();
    d.digest = new MD5Digest((MD5Digest)digest);

    return d;
}
项目:gwt-crypto    文件:BcImplProvider.java   
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");
    }
}
项目:vsDiaryWriter    文件:Digesters.java   
private static void initDigesters() {
    digesters.put("Blake2b", Blake2bDigest.class);
    digesters.put("GOST3411", GOST3411Digest.class);
    digesters.put("Keccak", KeccakDigest.class);
    digesters.put("MD2", MD2Digest.class);
    digesters.put("MD4", MD4Digest.class);
    digesters.put("MD5", MD5Digest.class);
    digesters.put("RIPEMD128", RIPEMD128Digest.class);
    digesters.put("RIPEMD160", RIPEMD160Digest.class);
    digesters.put("RIPEMD256", RIPEMD256Digest.class);
    digesters.put("RIPEMD320", RIPEMD320Digest.class);
    digesters.put("SHA1", SHA1Digest.class);
    digesters.put("SHA224", SHA224Digest.class);
    digesters.put("SHA256", SHA256Digest.class);
    digesters.put("SHA384", SHA384Digest.class);
    digesters.put("SHA3-512", SHA3Digest.class);
    digesters.put("SHA3-256", SHA3Digest.class);
    digesters.put("SHA3-224", SHA3Digest.class);
    digesters.put("SHA3-384", SHA3Digest.class);
    digesters.put("SHA512", SHA512Digest.class);
    digesters.put("SHAKE-128", SHAKEDigest.class);
    digesters.put("SHAKE-256", SHAKEDigest.class);
    digesters.put("Skein256", SkeinDigest.class);
    digesters.put("Skein512", SkeinDigest.class);
    digesters.put("Skein1024", SkeinDigest.class);
    digesters.put("SM3", SM3Digest.class);
    digesters.put("Tiger", TigerDigest.class);
    digesters.put("Whirlpool", WhirlpoolDigest.class);
}
项目:Aki-SSL    文件:DigestFactory.java   
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();
    }
    if (sha512_224.contains(digestName))
    {
        return new SHA512tDigest(224);
    }
    if (sha512_256.contains(digestName))
    {
        return new SHA512tDigest(256);
    }

    return null;
}
项目:Aki-SSL    文件:MD5.java   
public Object clone()
    throws CloneNotSupportedException
{
    Digest d = (Digest)super.clone();
    d.digest = new MD5Digest((MD5Digest)digest);

    return d;
}