SHA224.java revision 87490acd76f544251011cf49753d4d0a61f86a66
1package org.bouncycastle.jcajce.provider.digest; 2 3import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; 4import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; 5import org.bouncycastle.crypto.CipherKeyGenerator; 6import org.bouncycastle.crypto.digests.SHA224Digest; 7import org.bouncycastle.crypto.macs.HMac; 8import org.bouncycastle.jcajce.provider.config.ConfigurableProvider; 9import org.bouncycastle.jcajce.provider.symmetric.util.BaseKeyGenerator; 10import org.bouncycastle.jcajce.provider.symmetric.util.BaseMac; 11 12public class SHA224 13{ 14 private SHA224() 15 { 16 17 } 18 19 static public class Digest 20 extends BCMessageDigest 21 implements Cloneable 22 { 23 public Digest() 24 { 25 super(new SHA224Digest()); 26 } 27 28 public Object clone() 29 throws CloneNotSupportedException 30 { 31 Digest d = (Digest)super.clone(); 32 d.digest = new SHA224Digest((SHA224Digest)digest); 33 34 return d; 35 } 36 } 37 38 public static class HashMac 39 extends BaseMac 40 { 41 public HashMac() 42 { 43 super(new HMac(new SHA224Digest())); 44 } 45 } 46 47 public static class KeyGenerator 48 extends BaseKeyGenerator 49 { 50 public KeyGenerator() 51 { 52 super("HMACSHA224", 224, new CipherKeyGenerator()); 53 } 54 } 55 56 public static class Mappings 57 extends DigestAlgorithmProvider 58 { 59 private static final String PREFIX = SHA224.class.getName(); 60 61 public Mappings() 62 { 63 } 64 65 public void configure(ConfigurableProvider provider) 66 { 67 provider.addAlgorithm("MessageDigest.SHA-224", PREFIX + "$Digest"); 68 provider.addAlgorithm("Alg.Alias.MessageDigest.SHA224", "SHA-224"); 69 provider.addAlgorithm("Alg.Alias.MessageDigest." + NISTObjectIdentifiers.id_sha224, "SHA-224"); 70 71 addHMACAlgorithm(provider, "SHA224", PREFIX + "$HashMac", PREFIX + "$KeyGenerator"); 72 addHMACAlias(provider, "SHA224", PKCSObjectIdentifiers.id_hmacWithSHA224); 73 74 } 75 } 76} 77