NamedJcaJceHelper.java revision e6bf3e8dfa2804891a82075cb469b736321b4827
1package org.bouncycastle.jcajce; 2 3import java.security.AlgorithmParameterGenerator; 4import java.security.AlgorithmParameters; 5import java.security.KeyFactory; 6import java.security.KeyPairGenerator; 7import java.security.MessageDigest; 8import java.security.NoSuchAlgorithmException; 9import java.security.NoSuchProviderException; 10import java.security.Signature; 11import java.security.cert.CertificateException; 12import java.security.cert.CertificateFactory; 13 14import javax.crypto.Cipher; 15import javax.crypto.KeyAgreement; 16import javax.crypto.KeyGenerator; 17import javax.crypto.Mac; 18import javax.crypto.NoSuchPaddingException; 19 20public class NamedJcaJceHelper 21 implements JcaJceHelper 22{ 23 protected final String providerName; 24 25 public NamedJcaJceHelper(String providerName) 26 { 27 this.providerName = providerName; 28 } 29 30 public Cipher createCipher( 31 String algorithm) 32 throws NoSuchAlgorithmException, NoSuchPaddingException, NoSuchProviderException 33 { 34 return Cipher.getInstance(algorithm, providerName); 35 } 36 37 public Mac createMac(String algorithm) 38 throws NoSuchAlgorithmException, NoSuchProviderException 39 { 40 return Mac.getInstance(algorithm, providerName); 41 } 42 43 public KeyAgreement createKeyAgreement(String algorithm) 44 throws NoSuchAlgorithmException, NoSuchProviderException 45 { 46 return KeyAgreement.getInstance(algorithm, providerName); 47 } 48 49 public AlgorithmParameterGenerator createAlgorithmParameterGenerator(String algorithm) 50 throws NoSuchAlgorithmException, NoSuchProviderException 51 { 52 return AlgorithmParameterGenerator.getInstance(algorithm, providerName); 53 } 54 55 public AlgorithmParameters createAlgorithmParameters(String algorithm) 56 throws NoSuchAlgorithmException, NoSuchProviderException 57 { 58 return AlgorithmParameters.getInstance(algorithm, providerName); 59 } 60 61 public KeyGenerator createKeyGenerator(String algorithm) 62 throws NoSuchAlgorithmException, NoSuchProviderException 63 { 64 return KeyGenerator.getInstance(algorithm, providerName); 65 } 66 67 public KeyFactory createKeyFactory(String algorithm) 68 throws NoSuchAlgorithmException, NoSuchProviderException 69 { 70 return KeyFactory.getInstance(algorithm, providerName); 71 } 72 73 public KeyPairGenerator createKeyPairGenerator(String algorithm) 74 throws NoSuchAlgorithmException, NoSuchProviderException 75 { 76 return KeyPairGenerator.getInstance(algorithm, providerName); 77 } 78 79 public MessageDigest createDigest(String algorithm) 80 throws NoSuchAlgorithmException, NoSuchProviderException 81 { 82 return MessageDigest.getInstance(algorithm, providerName); 83 } 84 85 public Signature createSignature(String algorithm) 86 throws NoSuchAlgorithmException, NoSuchProviderException 87 { 88 return Signature.getInstance(algorithm, providerName); 89 } 90 91 public CertificateFactory createCertificateFactory(String algorithm) 92 throws NoSuchAlgorithmException, CertificateException, NoSuchProviderException 93 { 94 return CertificateFactory.getInstance(algorithm, providerName); 95 } 96} 97