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.Provider; 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 ProviderJcaJceHelper 21 implements JcaJceHelper 22{ 23 protected final Provider provider; 24 25 public ProviderJcaJceHelper(Provider provider) 26 { 27 this.provider = provider; 28 } 29 30 public Cipher createCipher( 31 String algorithm) 32 throws NoSuchAlgorithmException, NoSuchPaddingException 33 { 34 return Cipher.getInstance(algorithm, provider); 35 } 36 37 public Mac createMac(String algorithm) 38 throws NoSuchAlgorithmException 39 { 40 return Mac.getInstance(algorithm, provider); 41 } 42 43 public KeyAgreement createKeyAgreement(String algorithm) 44 throws NoSuchAlgorithmException 45 { 46 return KeyAgreement.getInstance(algorithm, provider); 47 } 48 49 public AlgorithmParameterGenerator createAlgorithmParameterGenerator(String algorithm) 50 throws NoSuchAlgorithmException 51 { 52 return AlgorithmParameterGenerator.getInstance(algorithm, provider); 53 } 54 55 public AlgorithmParameters createAlgorithmParameters(String algorithm) 56 throws NoSuchAlgorithmException 57 { 58 return AlgorithmParameters.getInstance(algorithm, provider); 59 } 60 61 public KeyGenerator createKeyGenerator(String algorithm) 62 throws NoSuchAlgorithmException 63 { 64 return KeyGenerator.getInstance(algorithm, provider); 65 } 66 67 public KeyFactory createKeyFactory(String algorithm) 68 throws NoSuchAlgorithmException 69 { 70 return KeyFactory.getInstance(algorithm, provider); 71 } 72 73 public KeyPairGenerator createKeyPairGenerator(String algorithm) 74 throws NoSuchAlgorithmException 75 { 76 return KeyPairGenerator.getInstance(algorithm, provider); 77 } 78 79 public MessageDigest createDigest(String algorithm) 80 throws NoSuchAlgorithmException 81 { 82 return MessageDigest.getInstance(algorithm, provider); 83 } 84 85 public Signature createSignature(String algorithm) 86 throws NoSuchAlgorithmException 87 { 88 return Signature.getInstance(algorithm, provider); 89 } 90 91 public CertificateFactory createCertificateFactory(String algorithm) 92 throws NoSuchAlgorithmException, CertificateException 93 { 94 return CertificateFactory.getInstance(algorithm, provider); 95 } 96} 97