Examples of HMAC


Examples of ch.ethz.ssh2.crypto.digest.HMAC

    SHA1 sha1 = new SHA1();

    if (salt.length != sha1.getDigestLength())
      throw new IllegalArgumentException("Salt has wrong length (" + salt.length + ")");

    HMAC hmac = new HMAC(sha1, salt, salt.length);

    hmac.update(hostname.getBytes());

    byte[] dig = new byte[hmac.getDigestLength()];

    hmac.digest(dig);

    return dig;
  }
View Full Code Here

Examples of com.calclab.emite.base.crypto.HMac

    return (cfm + "," + sfm + "," + clm).getBytes();
  }

  private final byte[] clientProof() {
    final byte[] saltedPassword = new PBKDF2().doKey(credentials.getPassword().getBytes(), salt, icount);
    final byte[] clientKey = new HMac().doMac(saltedPassword, "Client Key".getBytes());
    final byte[] storedKey = new SHA1Digest().doHash(clientKey);
    final byte[] clientSignature = new HMac().doMac(storedKey, authMessage());
    return XOR(clientKey, clientSignature);
  }
View Full Code Here

Examples of org.bouncycastle.crypto.macs.HMac

        public ECIES()
        {
            super(new IESEngine(
                   new ECDHBasicAgreement(),
                   new KDF2BytesGenerator(new SHA1Digest()),
                   new HMac(new SHA1Digest())));
        }
View Full Code Here

Examples of org.bouncycastle.crypto.macs.HMac

        g.initialize(1024, new SecureRandom());
        doTest("DHIES with 1024-bit", g, "DHIES", params);

        c1 = new IESCipher(new IESEngine(new DHBasicAgreement(),
                new KDF2BytesGenerator(new SHA1Digest()),
                new HMac(new SHA1Digest()),
                new PaddedBufferedBlockCipher(new DESEngine())));
       
        c2 = new IESCipher(new IESEngine(new DHBasicAgreement(),
                new KDF2BytesGenerator(new SHA1Digest()),
                new HMac(new SHA1Digest()),
                new PaddedBufferedBlockCipher(new DESEngine())))
   
        params = new IESParameterSpec(derivation, encoding, 128, 192);
     
        // Testing DHIES with default prime using DESEDE
View Full Code Here

Examples of org.bouncycastle.crypto.macs.HMac

                this.digestOverhead = 4;
            }
        }
        else
        {
            this.mac = new HMac(digest);

            // NOTE: The input pad for HMAC is always a full digest block
        }

        this.mac.init(keyParameter);
View Full Code Here

Examples of org.bouncycastle.crypto.macs.HMac

        return c;
    }

    static void hmac_hash(Digest digest, byte[] secret, byte[] seed, byte[] out)
    {
        HMac mac = new HMac(digest);
        KeyParameter param = new KeyParameter(secret);
        byte[] a = seed;
        int size = digest.getDigestSize();
        int iterations = (out.length + size - 1) / size;
        byte[] buf = new byte[mac.getMacSize()];
        byte[] buf2 = new byte[mac.getMacSize()];
        for (int i = 0; i < iterations; i++)
        {
            mac.init(param);
            mac.update(a, 0, a.length);
            mac.doFinal(buf, 0);
            a = buf;
            mac.init(param);
            mac.update(a, 0, a.length);
            mac.update(seed, 0, seed.length);
            mac.doFinal(buf2, 0);
            System.arraycopy(buf2, 0, out, (size * i), Math.min(size, out.length - (size * i)));
        }
    }
View Full Code Here

Examples of org.bouncycastle.crypto.macs.HMac

    {
        public ECIES()
        {
            super(new IESEngine(new ECDHBasicAgreement(),
                new KDF2BytesGenerator(new SHA1Digest()),
                new HMac(new SHA1Digest())));
        }
View Full Code Here

Examples of org.bouncycastle.crypto.macs.HMac

    {
        public ECIESwithDESede()
        {
            super(new IESEngine(new ECDHBasicAgreement(),
                new KDF2BytesGenerator(new SHA1Digest()),
                new HMac(new SHA1Digest()),
                new PaddedBufferedBlockCipher(new DESedeEngine())));
        }
View Full Code Here

Examples of org.bouncycastle.crypto.macs.HMac

    {
        public ECIESwithAES()
        {
            super(new IESEngine(new ECDHBasicAgreement(),
                new KDF2BytesGenerator(new SHA1Digest()),
                new HMac(new SHA1Digest()),
                new PaddedBufferedBlockCipher(new AESEngine())));
        }
View Full Code Here

Examples of org.bouncycastle.crypto.macs.HMac

        this(new SHA1Digest());
    }

    public PKCS5S2ParametersGenerator(Digest digest)
    {
        hMac = new HMac(digest);
        state = new byte[hMac.getMacSize()];
    }
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.