Package org.bouncycastle.crypto.macs

Examples of org.bouncycastle.crypto.macs.HMac


   * @see ca.coolman.auth.oauth1.OAuthSigner#createSignature(java.lang.String,
   * java.lang.String)
   */
  protected byte[] createSignature(byte[] key, byte[] data) {
    SHA1Digest digest = new SHA1Digest();
    HMac mac = new HMac(digest);
    mac.init(new KeyParameter(key));
    mac.update(data, 0, data.length);
    byte[] b = new byte[digest.getDigestSize()];
    mac.doFinal(b, 0);
    return b;
  }
View Full Code Here


   *           If the key string is improperly encoded.
   */
  public static String computePin(String secret, Long counter) {
    try {
      final byte[] keyBytes = Base32String.decode(secret);
      Mac mac = new HMac(new SHA1Digest());
      mac.init(new KeyParameter(keyBytes));
      PasscodeGenerator pcg = new PasscodeGenerator(mac);
      if (counter == null) { // time-based totp
        return pcg.generateTimeoutCode();
      } else { // counter-based hotp
        return pcg.generateResponseCode(counter.longValue());
View Full Code Here

    public static class MD2
        extends JCEMac
    {
        public MD2()
        {
            super(new HMac(new MD2Digest()));
        }
View Full Code Here

    public static class MD4
        extends JCEMac
    {
        public MD4()
        {
            super(new HMac(new MD4Digest()));
        }
View Full Code Here

    public static class MD5
        extends JCEMac
    {
        public MD5()
        {
            super(new HMac(new MD5Digest()));
        }
View Full Code Here

    public static class SHA1
        extends JCEMac
    {
        public SHA1()
        {
            super(new HMac(new SHA1Digest()));
        }
View Full Code Here

    public static class SHA224
        extends JCEMac
    {
        public SHA224()
        {
            super(new HMac(new SHA224Digest()));
        }
View Full Code Here

    public static class SHA256
        extends JCEMac
    {
        public SHA256()
        {
            super(new HMac(new SHA256Digest()));
        }
View Full Code Here

    public static class SHA384
        extends JCEMac
    {
        public SHA384()
        {
            super(new HMac(new SHA384Digest()));
        }
View Full Code Here

    public static class SHA512
        extends JCEMac
    {
        public SHA512()
        {
            super(new HMac(new SHA512Digest()));
        }
View Full Code Here

TOP

Related Classes of org.bouncycastle.crypto.macs.HMac

Copyright © 2018 www.massapicom. 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.