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