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

项目: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");
    }
}
项目: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    文件:RIPEMD160HMacTest.java   
public TestResult perform()
{
    HMac hmac = new HMac(new RIPEMD160Digest());
    byte[] resBuf = new byte[hmac.getMacSize()];

    for (int i = 0; i < messages.length; i++)
    {
        byte[] m = messages[i].getBytes();
        if (messages[i].startsWith("0x"))
        {
            m = Hex.decode(messages[i].substring(2));
        }
        hmac.init(new KeyParameter(Hex.decode(keys[i])));
        hmac.update(m, 0, m.length);
        hmac.doFinal(resBuf, 0);

        if (!Arrays.areEqual(resBuf, Hex.decode(digests[i])))
        {
            return new SimpleTestResult(false, getName() + ": Vector " + i + " failed");
        }
    }

    return new SimpleTestResult(true, getName() + ": Okay");
}
项目: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");
    }
}
项目:subshare    文件:PgpUserIdNameHash.java   
public static PgpUserIdNameHash createFromUserAttribute(final PGPUserAttributeSubpacketVector userAttribute) {
    assertNotNull(userAttribute, "userAttribute");

    final RIPEMD160Digest digest = new RIPEMD160Digest();

    // TODO this needs to be extended, if there is ever any other attribute possible, too!
    // Currently, image seems to be the only supported attribute. Alternatively, we could get the data via reflection...
    final UserAttributeSubpacket subpacket = userAttribute.getSubpacket(UserAttributeSubpacketTags.IMAGE_ATTRIBUTE);
    assertNotNull(subpacket, "subpacket");
    final byte[] data = assertNotNull(subpacket.getData(), "subpacket.data");
    digest.update(data, 0, data.length);

    final byte[] out = new byte[digest.getDigestSize()];
    digest.doFinal(out, 0);
    return new PgpUserIdNameHash(out);
}
项目: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");
    }
}
项目:irma_future_id    文件:RIPEMD160HMacTest.java   
public TestResult perform()
{
    HMac hmac = new HMac(new RIPEMD160Digest());
    byte[] resBuf = new byte[hmac.getMacSize()];

    for (int i = 0; i < messages.length; i++)
    {
        byte[] m = messages[i].getBytes();
        if (messages[i].startsWith("0x"))
        {
            m = Hex.decode(messages[i].substring(2));
        }
        hmac.init(new KeyParameter(Hex.decode(keys[i])));
        hmac.update(m, 0, m.length);
        hmac.doFinal(resBuf, 0);

        if (!Arrays.areEqual(resBuf, Hex.decode(digests[i])))
        {
            return new SimpleTestResult(false, getName() + ": Vector " + i + " failed");
        }
    }

    return new SimpleTestResult(true, getName() + ": Okay");
}
项目: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    文件:RIPEMD160HMacTest.java   
public TestResult perform()
{
    HMac hmac = new HMac(new RIPEMD160Digest());
    byte[] resBuf = new byte[hmac.getMacSize()];

    for (int i = 0; i < messages.length; i++)
    {
        byte[] m = messages[i].getBytes();
        if (messages[i].startsWith("0x"))
        {
            m = Hex.decode(messages[i].substring(2));
        }
        hmac.init(new KeyParameter(Hex.decode(keys[i])));
        hmac.update(m, 0, m.length);
        hmac.doFinal(resBuf, 0);

        if (!Arrays.areEqual(resBuf, Hex.decode(digests[i])))
        {
            return new SimpleTestResult(false, getName() + ": Vector " + i + " failed");
        }
    }

    return new SimpleTestResult(true, getName() + ": Okay");
}
项目: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");
    }
}
项目:ipack    文件:RIPEMD160.java   
public Object clone()
    throws CloneNotSupportedException
{
    Digest d = (Digest)super.clone();
    d.digest = new RIPEMD160Digest((RIPEMD160Digest)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");
    }
}
项目:gwt-crypto    文件:ISO9796Test.java   
public void doTest6()
    throws Exception
{
    byte[] salt = Hex.decode("61DF870C4890FE85D6E3DD87C3DCE3723F91DB49");
    RSAKeyParameters pubParameters = new RSAKeyParameters(false, mod6, pub6);
    RSAKeyParameters privParameters = new RSAKeyParameters(true, mod6, pri6);
    ParametersWithSalt sigParameters = new ParametersWithSalt(privParameters, salt);
    RSAEngine rsa = new RSAEngine();
    byte[] data;

    //
    // ISO 9796-2 - PSS Signing
    //
    ISO9796d2PSSSigner eng = new ISO9796d2PSSSigner(rsa, new RIPEMD160Digest(), 20, true);

    eng.init(true, sigParameters);

    data = eng.generateSignature();

    if (eng.getRecoveredMessage().length != 0)
    {
        fail("failed zero check");
    }

    eng.init(false, pubParameters);

    if (!isSameAs(sig6, 1, data))
    {
        fail("failed ISO9796-2 generation Test 6");
    }

    if (!eng.verifySignature(data))
    {
        fail("failed ISO9796-2 verify Test 6");
    }
}
项目:gwt-crypto    文件:ISO9796Test.java   
public void doTest8()
    throws Exception
{
    byte[] salt = Hex.decode("78E293203CBA1B7F92F05F4D171FF8CA3E738FF8");
    RSAKeyParameters pubParameters = new RSAKeyParameters(false, mod6, pub6);
    RSAKeyParameters privParameters = new RSAKeyParameters(true, mod6, pri6);
    ParametersWithSalt sigParameters = new ParametersWithSalt(privParameters, salt);
    RSAEngine rsa = new RSAEngine();
    byte[] data;

    //
    // ISO 9796-2 - PSS Signing
    //
    ISO9796d2PSSSigner eng = new ISO9796d2PSSSigner(rsa, new RIPEMD160Digest(), 20, false);

    eng.init(true, sigParameters);

    eng.update(msg8[0]);
    eng.update(msg8, 1, msg8.length - 1);

    data = eng.generateSignature();

    eng.init(false, pubParameters);

    if (!isSameAs(sig8, 0, data))
    {
        fail("failed ISO9796-2 generation Test 8");
    }

    eng.update(msg8[0]);
    eng.update(msg8, 1, msg8.length - 1);

    if (!eng.verifySignature(sig8))
    {
        fail("failed ISO9796-2 verify Test 8");
    }
}
项目: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);
}
项目:SSI_Bitcoin-Storage    文件:Address.java   
/********
 * This method does all the RipeMD 160 hashing function, and after that hash has taken place, it prepends the version 
 * byte to the beginning of the Byte array
 * @param tobeHashed - Byte Array of the public key after a SHA-256 hash
 * @return - Byte Array after the RipeMD 160 hash function
 */
private byte[] RIPEMD160(byte[] tobeHashed){
    RIPEMD160Digest digester = new RIPEMD160Digest();
    byte[] retValue=new byte[digester.getDigestSize()]; 
    digester.update(tobeHashed, 0, tobeHashed.length); 
    digester.doFinal(retValue, 0);     
    byte[] version = new byte[]{0x00};
    return concateByteArray(version,retValue);  
}
项目:Aki-SSL    文件:RIPEMD160.java   
public Object clone()
    throws CloneNotSupportedException
{
    Digest d = (Digest)super.clone();
    d.digest = new RIPEMD160Digest((RIPEMD160Digest)digest);

    return d;
}
项目:SecureBitcoinWallet    文件:BitcoinUtils.java   
/**
 * Calculates the bitcoinaddress for the given byte array containing the public key and returns
 * it
 * as a String.
 *
 * @param publicKey A byte array containing the public key to calulcate the address for
 * @return The Bitcoin address as a Base58 encoded string
 */
public static String calculateBitcoinAddress(byte[] publicKey) {
  RIPEMD160Digest ripemd160 = new RIPEMD160Digest();
  MessageDigest sha256;
  try {
    sha256 = MessageDigest.getInstance("SHA-256");
  } catch (NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
  }

  byte[] sha256Hash = sha256.digest(publicKey);

  byte[] ripemdHash = new byte[ripemd160.getDigestSize() + 1];
  ripemd160.update(sha256Hash, 0, sha256Hash.length);
  ripemd160.doFinal(ripemdHash, 1);

  // Set version byte
  ripemdHash[0] = 0;

  sha256Hash = sha256.digest(ripemdHash);
  sha256Hash = sha256.digest(sha256Hash);

  byte[] addressBytes = new byte[ripemdHash.length + 4];

  System.arraycopy(ripemdHash, 0, addressBytes, 0, ripemdHash.length);
  System.arraycopy(sha256Hash, 0, addressBytes, (ripemdHash.length), 4);

  return Base58.encode(addressBytes);
}
项目:SecureBitcoinWallet    文件:BitcoinUtils.java   
/**
 * Get the hash of a signed transactoin
 *
 * @param signedTransaction the signed transaction as byte array
 * @return the hash as String (Base58 encoded)
 */
public static String getHashFromSignedTransaction(byte[] signedTransaction) {

  // TODO implemnt it correctly
  RIPEMD160Digest ripemd160 = new RIPEMD160Digest();
  MessageDigest sha256;
  try {
    sha256 = MessageDigest.getInstance("SHA-256");
  } catch (NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
  }

  byte[] sha256Hash = sha256.digest(signedTransaction);

  byte[] ripemdHash = new byte[ripemd160.getDigestSize() + 1];
  ripemd160.update(sha256Hash, 0, sha256Hash.length);
  ripemd160.doFinal(ripemdHash, 1);

  // Set version byte
  ripemdHash[0] = 0;

  sha256Hash = sha256.digest(ripemdHash);
  sha256Hash = sha256.digest(sha256Hash);

  byte[] addressBytes = new byte[ripemdHash.length + 4];

  System.arraycopy(ripemdHash, 0, addressBytes, 0, ripemdHash.length);
  System.arraycopy(sha256Hash, 0, addressBytes, (ripemdHash.length), 4);

  return Base58.encode(addressBytes);
}
项目:subshare    文件:PgpUserIdNameHash.java   
public static PgpUserIdNameHash createFromUserId(final String userId) {
    assertNotNull(userId, "userId");

    final RIPEMD160Digest digest = new RIPEMD160Digest();
    byte[] userIdBytes = userId.getBytes(StandardCharsets.UTF_8); // TODO is this correct?! really UTF-8?! check with my own name! ;-)
    digest.update(userIdBytes, 0, userIdBytes.length);
    final byte[] out = new byte[digest.getDigestSize()];
    digest.doFinal(out, 0);

    return new PgpUserIdNameHash(out);
}
项目:BitcoinCore    文件:Utils.java   
/**
 * Calculate the RIPEMD160 hash of the input
 *
 * @param       input           The byte array to be hashed
 * @return                      The hashed result
 */
public static byte[] hash160(byte[] input) {
    byte[] out = new byte[20];
    RIPEMD160Digest rDigest = new RIPEMD160Digest();
    rDigest.update(input, 0, input.length);
    rDigest.doFinal(out, 0);
    return out;
}
项目:BitcoinCore    文件:Utils.java   
/**
 * Calculate RIPEMD160(SHA256(input)).  This is used in Address calculations.
 *
 * @param       input           The byte array to be hashed
 * @return                      The hashed result
 */
public static byte[] sha256Hash160(byte[] input) {
    byte[] out = new byte[20];
    synchronized(digest) {
        digest.reset();
        byte[] sha256 = digest.digest(input);
        RIPEMD160Digest rDigest = new RIPEMD160Digest();
        rDigest.update(sha256, 0, sha256.length);
        rDigest.doFinal(out, 0);
    }
    return out;
}
项目:Java-Security    文件:RipeMD160.java   
/**
 * Creates a new RipeMD160 digest that may optionally be initialized with
 * random data.
 *
 * @param randomize
 *            True to randomize initial state of digest, false otherwise.
 */
public RipeMD160(final boolean randomize) {
    super(new RIPEMD160Digest());
    if (randomize) {
        setRandomProvider(new SecureRandom());
        setSalt(getRandomSalt());
    }
}
项目:JavaBitcoin    文件:Utils.java   
/**
 * Calculate RIPEMD160(SHA256(input)).  This is used in Address calculations.
 *
 * @param       input           The byte array to be hashed
 * @return                      The hashed result
 */
public static byte[] sha256Hash160(byte[] input) {
    byte[] out = new byte[20];
    synchronized(digest) {
        digest.reset();
        byte[] sha256 = digest.digest(input);
        RIPEMD160Digest rDigest = new RIPEMD160Digest();
        rDigest.update(sha256, 0, sha256.length);
        rDigest.doFinal(out, 0);
    }
    return out;
}
项目:CryptMeme    文件: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");
    }
}
项目:CryptMeme    文件:RIPEMD160.java   
public Object clone()
    throws CloneNotSupportedException
{
    Digest d = (Digest)super.clone();
    d.digest = new RIPEMD160Digest((RIPEMD160Digest)digest);

    return d;
}
项目:irma_future_id    文件: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");
    }
}
项目:irma_future_id    文件:ISO9796Test.java   
public void doTest6()
    throws Exception
{
    byte[] salt = Hex.decode("61DF870C4890FE85D6E3DD87C3DCE3723F91DB49");
    RSAKeyParameters pubParameters = new RSAKeyParameters(false, mod6, pub6);
    RSAKeyParameters privParameters = new RSAKeyParameters(true, mod6, pri6);
    ParametersWithSalt sigParameters = new ParametersWithSalt(privParameters, salt);
    RSAEngine rsa = new RSAEngine();
    byte[] data;

    //
    // ISO 9796-2 - PSS Signing
    //
    ISO9796d2PSSSigner eng = new ISO9796d2PSSSigner(rsa, new RIPEMD160Digest(), 20, true);

    eng.init(true, sigParameters);

    data = eng.generateSignature();

    eng.init(false, pubParameters);

    if (!isSameAs(sig6, 1, data))
    {
        fail("failed ISO9796-2 generation Test 6");
    }

    if (!eng.verifySignature(data))
    {
        fail("failed ISO9796-2 verify Test 6");
    }
}
项目:irma_future_id    文件:ISO9796Test.java   
public void doTest8()
    throws Exception
{
    byte[] salt = Hex.decode("78E293203CBA1B7F92F05F4D171FF8CA3E738FF8");
    RSAKeyParameters pubParameters = new RSAKeyParameters(false, mod6, pub6);
    RSAKeyParameters privParameters = new RSAKeyParameters(true, mod6, pri6);
    ParametersWithSalt sigParameters = new ParametersWithSalt(privParameters, salt);
    RSAEngine rsa = new RSAEngine();
    byte[] data;

    //
    // ISO 9796-2 - PSS Signing
    //
    ISO9796d2PSSSigner eng = new ISO9796d2PSSSigner(rsa, new RIPEMD160Digest(), 20, false);

    eng.init(true, sigParameters);

    eng.update(msg8[0]);
    eng.update(msg8, 1, msg8.length - 1);

    data = eng.generateSignature();

    eng.init(false, pubParameters);

    if (!isSameAs(sig8, 0, data))
    {
        fail("failed ISO9796-2 generation Test 8");
    }

    eng.update(msg8[0]);
    eng.update(msg8, 1, msg8.length - 1);

    if (!eng.verifySignature(sig8))
    {
        fail("failed ISO9796-2 verify Test 8");
    }
}
项目:irma_future_id    文件:ISO9796Test.java   
public void doTest9()
    throws Exception
{
    RSAKeyParameters pubParameters = new RSAKeyParameters(false, mod6, pub6);
    RSAKeyParameters privParameters = new RSAKeyParameters(true, mod6, pri6);
    RSAEngine rsa = new RSAEngine();
    byte[] data;

    //
    // ISO 9796-2 - PSS Signing
    //
    ISO9796d2PSSSigner eng = new ISO9796d2PSSSigner(rsa, new RIPEMD160Digest(), 0, true);

    eng.init(true, privParameters);

    eng.update(msg9[0]);
    eng.update(msg9, 1, msg9.length - 1);

    data = eng.generateSignature();

    eng.init(false, pubParameters);

    if (!isSameAs(sig9, 0, data))
    {
        fail("failed ISO9796-2 generation Test 9");
    }

    eng.update(msg9[0]);
    eng.update(msg9, 1, msg9.length - 1);

    if (!eng.verifySignature(sig9))
    {
        fail("failed ISO9796-2 verify Test 9");
    }
}
项目:irma_future_id    文件:RIPEMD160.java   
public Object clone()
    throws CloneNotSupportedException
{
    Digest d = (Digest)super.clone();
    d.digest = new RIPEMD160Digest((RIPEMD160Digest)digest);

    return d;
}
项目:bc-java    文件: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");
    }
}
项目:bc-java    文件:ISO9796Test.java   
public void doTest6()
    throws Exception
{
    byte[] salt = Hex.decode("61DF870C4890FE85D6E3DD87C3DCE3723F91DB49");
    RSAKeyParameters pubParameters = new RSAKeyParameters(false, mod6, pub6);
    RSAKeyParameters privParameters = new RSAKeyParameters(true, mod6, pri6);
    ParametersWithSalt sigParameters = new ParametersWithSalt(privParameters, salt);
    RSAEngine rsa = new RSAEngine();
    byte[] data;

    //
    // ISO 9796-2 - PSS Signing
    //
    ISO9796d2PSSSigner eng = new ISO9796d2PSSSigner(rsa, new RIPEMD160Digest(), 20, true);

    eng.init(true, sigParameters);

    data = eng.generateSignature();

    eng.init(false, pubParameters);

    if (!isSameAs(sig6, 1, data))
    {
        fail("failed ISO9796-2 generation Test 6");
    }

    if (!eng.verifySignature(data))
    {
        fail("failed ISO9796-2 verify Test 6");
    }
}
项目:bc-java    文件:ISO9796Test.java   
public void doTest8()
    throws Exception
{
    byte[] salt = Hex.decode("78E293203CBA1B7F92F05F4D171FF8CA3E738FF8");
    RSAKeyParameters pubParameters = new RSAKeyParameters(false, mod6, pub6);
    RSAKeyParameters privParameters = new RSAKeyParameters(true, mod6, pri6);
    ParametersWithSalt sigParameters = new ParametersWithSalt(privParameters, salt);
    RSAEngine rsa = new RSAEngine();
    byte[] data;

    //
    // ISO 9796-2 - PSS Signing
    //
    ISO9796d2PSSSigner eng = new ISO9796d2PSSSigner(rsa, new RIPEMD160Digest(), 20, false);

    eng.init(true, sigParameters);

    eng.update(msg8[0]);
    eng.update(msg8, 1, msg8.length - 1);

    data = eng.generateSignature();

    eng.init(false, pubParameters);

    if (!isSameAs(sig8, 0, data))
    {
        fail("failed ISO9796-2 generation Test 8");
    }

    eng.update(msg8[0]);
    eng.update(msg8, 1, msg8.length - 1);

    if (!eng.verifySignature(sig8))
    {
        fail("failed ISO9796-2 verify Test 8");
    }
}
项目:bc-java    文件:ISO9796Test.java   
public void doTest9()
    throws Exception
{
    RSAKeyParameters pubParameters = new RSAKeyParameters(false, mod6, pub6);
    RSAKeyParameters privParameters = new RSAKeyParameters(true, mod6, pri6);
    RSAEngine rsa = new RSAEngine();
    byte[] data;

    //
    // ISO 9796-2 - PSS Signing
    //
    ISO9796d2PSSSigner eng = new ISO9796d2PSSSigner(rsa, new RIPEMD160Digest(), 0, true);

    eng.init(true, privParameters);

    eng.update(msg9[0]);
    eng.update(msg9, 1, msg9.length - 1);

    data = eng.generateSignature();

    eng.init(false, pubParameters);

    if (!isSameAs(sig9, 0, data))
    {
        fail("failed ISO9796-2 generation Test 9");
    }

    eng.update(msg9[0]);
    eng.update(msg9, 1, msg9.length - 1);

    if (!eng.verifySignature(sig9))
    {
        fail("failed ISO9796-2 verify Test 9");
    }
}
项目:bc-java    文件:RIPEMD160.java   
public Object clone()
    throws CloneNotSupportedException
{
    Digest d = (Digest)super.clone();
    d.digest = new RIPEMD160Digest((RIPEMD160Digest)digest);

    return d;
}
项目:jStellarAPI    文件:StellarPublicKey.java   
public StellarAddress getAddress(){
    // Hashing of the publicKey is performed with a single SHA256 instead of
    // the typical Stellar HalfSHA512
    SHA256Digest sha256Digest = new SHA256Digest();
    sha256Digest.update(payloadBytes, 0, payloadBytes.length);
    byte[] sha256PubKeyBytes = new byte[32];
    sha256Digest.doFinal(sha256PubKeyBytes, 0);

    RIPEMD160Digest digest = new RIPEMD160Digest();
       digest.update(sha256PubKeyBytes, 0, sha256PubKeyBytes.length);
       byte[] accountIdBytes = new byte[20];
       digest.doFinal(accountIdBytes, 0);

       return new StellarAddress(accountIdBytes);
}
项目:ipack    文件:RIPEMD160.java   
public Digest()
{
    super(new RIPEMD160Digest());
}
项目:ipack    文件:RIPEMD160.java   
public HashMac()
{
    super(new HMac(new RIPEMD160Digest()));
}