// 
// Decompiled by Procyon v0.6.0
// 

package com.google.crypto.tink.subtle;

import javax.crypto.KeyAgreement;
import java.security.KeyFactory;
import java.security.Signature;
import java.security.MessageDigest;
import java.security.KeyPairGenerator;
import javax.crypto.Mac;
import javax.crypto.Cipher;
import java.security.GeneralSecurityException;
import java.security.Provider;

public interface EngineWrapper<T>
{
    T getInstance(final String algorithm, final Provider provider) throws GeneralSecurityException;
    
    public static class TCipher implements EngineWrapper<Cipher>
    {
        @Override
        public Cipher getInstance(final String algorithm, final Provider provider) throws GeneralSecurityException {
            if (provider == null) {
                return Cipher.getInstance(algorithm);
            }
            return Cipher.getInstance(algorithm, provider);
        }
    }
    
    public static class TMac implements EngineWrapper<Mac>
    {
        @Override
        public Mac getInstance(final String algorithm, final Provider provider) throws GeneralSecurityException {
            if (provider == null) {
                return Mac.getInstance(algorithm);
            }
            return Mac.getInstance(algorithm, provider);
        }
    }
    
    public static class TKeyPairGenerator implements EngineWrapper<KeyPairGenerator>
    {
        @Override
        public KeyPairGenerator getInstance(final String algorithm, final Provider provider) throws GeneralSecurityException {
            if (provider == null) {
                return KeyPairGenerator.getInstance(algorithm);
            }
            return KeyPairGenerator.getInstance(algorithm, provider);
        }
    }
    
    public static class TMessageDigest implements EngineWrapper<MessageDigest>
    {
        @Override
        public MessageDigest getInstance(final String algorithm, final Provider provider) throws GeneralSecurityException {
            if (provider == null) {
                return MessageDigest.getInstance(algorithm);
            }
            return MessageDigest.getInstance(algorithm, provider);
        }
    }
    
    public static class TSignature implements EngineWrapper<Signature>
    {
        @Override
        public Signature getInstance(final String algorithm, final Provider provider) throws GeneralSecurityException {
            if (provider == null) {
                return Signature.getInstance(algorithm);
            }
            return Signature.getInstance(algorithm, provider);
        }
    }
    
    public static class TKeyFactory implements EngineWrapper<KeyFactory>
    {
        @Override
        public KeyFactory getInstance(final String algorithm, final Provider provider) throws GeneralSecurityException {
            if (provider == null) {
                return KeyFactory.getInstance(algorithm);
            }
            return KeyFactory.getInstance(algorithm, provider);
        }
    }
    
    public static class TKeyAgreement implements EngineWrapper<KeyAgreement>
    {
        @Override
        public KeyAgreement getInstance(final String algorithm, final Provider provider) throws GeneralSecurityException {
            if (provider == null) {
                return KeyAgreement.getInstance(algorithm);
            }
            return KeyAgreement.getInstance(algorithm, provider);
        }
    }
}
