• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.bouncycastle.jcajce.provider.digest;
2 
3 import org.bouncycastle.asn1.nist.NISTObjectIdentifiers;
4 import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
5 import org.bouncycastle.crypto.CipherKeyGenerator;
6 import org.bouncycastle.crypto.digests.SHA384Digest;
7 import org.bouncycastle.crypto.macs.HMac;
8 // BEGIN android-removed
9 // import org.bouncycastle.crypto.macs.OldHMac;
10 // END android-removed
11 import org.bouncycastle.jcajce.provider.config.ConfigurableProvider;
12 import org.bouncycastle.jcajce.provider.symmetric.util.BaseKeyGenerator;
13 import org.bouncycastle.jcajce.provider.symmetric.util.BaseMac;
14 
15 public class SHA384
16 {
SHA384()17     private SHA384()
18     {
19 
20     }
21 
22     static public class Digest
23         extends BCMessageDigest
24         implements Cloneable
25     {
Digest()26         public Digest()
27         {
28             super(new SHA384Digest());
29         }
30 
clone()31         public Object clone()
32             throws CloneNotSupportedException
33         {
34             Digest d = (Digest)super.clone();
35             d.digest = new SHA384Digest((SHA384Digest)digest);
36 
37             return d;
38         }
39     }
40 
41     public static class HashMac
42         extends BaseMac
43     {
HashMac()44         public HashMac()
45         {
46             super(new HMac(new SHA384Digest()));
47         }
48     }
49 
50     /**
51      * HMACSHA384
52      */
53     public static class KeyGenerator
54         extends BaseKeyGenerator
55     {
KeyGenerator()56         public KeyGenerator()
57         {
58             super("HMACSHA384", 384, new CipherKeyGenerator());
59         }
60     }
61 
62     // BEGIN android-removed
63     // public static class OldSHA384
64     //     extends BaseMac
65     // {
66     //     public OldSHA384()
67     //     {
68     //         super(new OldHMac(new SHA384Digest()));
69     //     }
70     // }
71     // END android-removed
72 
73     public static class Mappings
74         extends DigestAlgorithmProvider
75     {
76         private static final String PREFIX = SHA384.class.getName();
77 
Mappings()78         public Mappings()
79         {
80         }
81 
configure(ConfigurableProvider provider)82         public void configure(ConfigurableProvider provider)
83         {
84             provider.addAlgorithm("MessageDigest.SHA-384", PREFIX + "$Digest");
85             provider.addAlgorithm("Alg.Alias.MessageDigest.SHA384", "SHA-384");
86             provider.addAlgorithm("Alg.Alias.MessageDigest." + NISTObjectIdentifiers.id_sha384, "SHA-384");
87             // BEGIN android-removed
88             // provider.addAlgorithm("Mac.OLDHMACSHA384", PREFIX + "$OldSHA384");
89             // END android-removed
90 
91             addHMACAlgorithm(provider, "SHA384", PREFIX + "$HashMac",  PREFIX + "$KeyGenerator");
92             addHMACAlias(provider, "SHA384", PKCSObjectIdentifiers.id_hmacWithSHA384);
93         }
94     }
95 }
96