Examples of MD5Digest


Examples of org.bouncycastle.crypto.digests.MD5Digest

        }

        byte[] cur = bytes;

        for (int i = 0; i < iter; ++i) {
            MD5Digest digest = new MD5Digest();
            digest.update(cur, 0, cur.length);

            cur = new byte[digest.getDigestSize()];
            digest.doFinal(cur, 0);
        }

        byte[] out = new byte[16];

        for (int i = 0; i < out.length; ++i) {
View Full Code Here

Examples of org.bouncycastle.crypto.digests.MD5Digest

        return "MD5HMac";
    }

    public TestResult perform()
    {
        HMac hmac = new HMac(new MD5Digest());
        byte[] resBuf = new byte[hmac.getMacSize()];

        for (int i = 0; i < messages.length; i++)
        {
            byte[] m = messages[i].getBytes();
View Full Code Here

Examples of org.bouncycastle.crypto.digests.MD5Digest

        return "MD5";
    }

    public TestResult perform()
    {
        Digest  digest = new MD5Digest();
        byte[]  resBuf = new byte[digest.getDigestSize()];
        String  resStr;

        //
        // test 1
        //
        digest.doFinal(resBuf, 0);

        resStr = new String(Hex.encode(resBuf));
        if (!resVec1.equals(resStr))
        {
            return new SimpleTestResult(false,
                "MD5 failing standard vector test 1"
                + System.getProperty("line.separator")
                + "    expected: " + resVec1
                + System.getProperty("line.separator")
                + "    got     : " + resStr);
        }

        //
        // test 2
        //
        byte[]  bytes = Hex.decode(testVec2);

        digest.update(bytes, 0, bytes.length);

        digest.doFinal(resBuf, 0);

        resStr = new String(Hex.encode(resBuf));
        if (!resVec2.equals(resStr))
        {
            return new SimpleTestResult(false,
                "MD5 failing standard vector test 2"
                + System.getProperty("line.separator")
                + "    expected: " + resVec2
                + System.getProperty("line.separator")
                + "    got     : " + resStr);
        }

        //
        // test 3
        //
        bytes = Hex.decode(testVec3);

        digest.update(bytes, 0, bytes.length);

        digest.doFinal(resBuf, 0);

        resStr = new String(Hex.encode(resBuf));
        if (!resVec3.equals(resStr))
        {
            return new SimpleTestResult(false,
                "MD5 failing standard vector test 3"
                + System.getProperty("line.separator")
                + "    expected: " + resVec3
                + System.getProperty("line.separator")
                + "    got     : " + resStr);
        }

        //
        // test 4
        //
        bytes = Hex.decode(testVec4);

        digest.update(bytes, 0, bytes.length);

        digest.doFinal(resBuf, 0);

        resStr = new String(Hex.encode(resBuf));
        if (!resVec4.equals(resStr))
        {
            return new SimpleTestResult(false,
                "MD5 failing standard vector test 4"
                + System.getProperty("line.separator")
                + "    expected: " + resVec4
                + System.getProperty("line.separator")
                + "    got     : " + resStr);
        }

        //
        // test 5
        //
        bytes = Hex.decode(testVec4);

        digest.update(bytes, 0, bytes.length/2);

        // clone the Digest
        Digest d = new MD5Digest((MD5Digest)digest);

        digest.update(bytes, bytes.length/2, bytes.length - bytes.length/2);
        digest.doFinal(resBuf, 0);

        resStr = new String(Hex.encode(resBuf));
        if (!resVec4.equals(resStr))
        {
            return new SimpleTestResult(false,
                "MD5 failing standard vector test 5"
                + System.getProperty("line.separator")
                + "    expected: " + resVec4
                + System.getProperty("line.separator")
                + "    got     : " + resStr);
        }

        d.update(bytes, bytes.length/2, bytes.length - bytes.length/2);
        d.doFinal(resBuf, 0);

        resStr = new String(Hex.encode(resBuf));
        if (!resVec4.equals(resStr))
        {
            return new SimpleTestResult(false,
View Full Code Here

Examples of org.bouncycastle.crypto.digests.MD5Digest

public class MD5 implements HASH{
  private MD5Digest md;

  public int getBlockSize(){return 16;}
  public void init() throws Exception{
    try{ md=new MD5Digest(); }
    catch(Exception e){
      System.out.println(e);
    }
  }
View Full Code Here

Examples of org.bouncycastle.crypto.digests.MD5Digest

      byte[] tmp=new byte[bsize];
      System.arraycopy(key, 0, tmp, 0, bsize);   
      key=tmp;
    }
    CipherParameters param=new KeyParameter(key);
    mac=new HMac(new MD5Digest());
    mac.init(param);
  }
View Full Code Here

Examples of org.bouncycastle.crypto.digests.MD5Digest

      byte[] tmp=new byte[16];
      System.arraycopy(key, 0, tmp, 0, 16);   
      key=tmp;
    }
    CipherParameters param=new KeyParameter(key);
    mac=new HMac(new MD5Digest());
    mac.init(param);
  }
View Full Code Here

Examples of org.bouncycastle.crypto.digests.MD5Digest

        byte[] ls = new byte[label.length + seed.length];
        System.arraycopy(label, 0, ls, 0, label.length);
        System.arraycopy(seed, 0, ls, label.length, seed.length);

        byte[] prf = new byte[buf.length];
        hmac_hash(new MD5Digest(), s1, ls, prf);
        hmac_hash(new SHA1Digest(), s2, ls, buf);
        for (int i = 0; i < buf.length; i++)
        {
            buf[i] ^= prf[i];
        }
View Full Code Here

Examples of org.bouncycastle.crypto.digests.MD5Digest

    static public class MD5WithRSAEncryption
        extends JDKDigestSignature
    {
        public MD5WithRSAEncryption()
        {
            super(PKCSObjectIdentifiers.md5, new MD5Digest(), new PKCS1Encoding(new RSABlindedEngine()));
        }
View Full Code Here

Examples of org.bouncycastle.crypto.digests.MD5Digest

        {
            return new SHA1Digest();
        }
        if (md5.contains(digestName))
        {
            return new MD5Digest();
        }
        if (sha224.contains(digestName))
        {
            return new SHA224Digest();
        }
View Full Code Here

Examples of org.bouncycastle.crypto.digests.MD5Digest

    static public class MD5WithRSAEncryption
        extends JDKDigestSignature
    {
        public MD5WithRSAEncryption()
        {
            super("MD5withRSA", md5, new MD5Digest(), new PKCS1Encoding(new RSAEngine()));
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.