2014-01-09 16 views
5

JCA가 JCE를 대신하는 것이 간단하다고 생각했습니다. 그러나 내 시스템에 모든 공급자를 확보하기위한 테스트 코드 작성은 그렇지 않습니다. JCA와 공급자의 관계는 JCE입니까?

나는 다음과 같은주의 :

  1. 일부 알고리즘은 여러 공급자가 :
  2. JCA는 JCE
  3. 에 무엇이 넘어 알고리즘의 type가있는 것 (예를 들면 MD5withRSASunRsaSign에뿐만 아니라 SunJSSE)

항목 1은 JCE 공급자가 제공하는 라이브러리/배열로 JCA가 표시되는 것처럼 의미가 있습니다.

항목 2는 JCA가 "동일한"JCE 공급자의 배열과 정확히 일치하지 않기 때문에 조금 혼란 스럽습니다. 그것은 모든 종류의 공급자, JCE 인터페이스 또는 연결되지 않는 모든 종류의 물 공급 구멍입니다.

그래서 은 JCA, 제공자 및 JCE 간의 작업 관계는 무엇입니까? 공급자는 독립적 인 사일로에도 존재합니까? 아니면 서로를 "구축"합니까? 코드에 관심이 사람이 질문을하라는 메시지가 결과에 대한

는, 그는


import java.security.Provider; 
import java.security.Security; 
import java.util.ArrayList; 

public class ConsoleListJca 
{ 
    public static void main(String[] args) 
    { 
     for (Provider provider : Security.getProviders()) 
     { 
      System.out.println("Provider: " + provider.getName() + " (ver " + provider.getVersion() + ")"); 
      System.out.print(" Algorithms: "); 
      ArrayList<String> algos = new ArrayList<String>(); 
      for (Provider.Service service : provider.getServices()) 
      { 
       algos.add(String.format("%s (%s)", service.getAlgorithm(), service.getType())); 
      } 
      java.util.Collections.sort(algos); 
      String algorsStr = algos.toString(); 
      // remove [ and ] from ArrayList's toString() 
      algorsStr = algorsStr.substring(1, algorsStr.length()-1); 
      System.out.println(algorsStr); 
      System.out.println(); 
     } 
    } 
} 

아래에 나열하고 (SO 포맷) 결과는

Provider: SUN (ver 1.7) 
    Algorithms: CaseExactJKS (KeyStore), Collection (CertStore), DSA (AlgorithmParameterGenerator), 
       DSA (AlgorithmParameters), DSA (KeyFactory), DSA (KeyPairGenerator), 
       JKS (KeyStore), JavaLoginConfig (Configuration), JavaPolicy (Policy), 
       LDAP (CertStore), MD2 (MessageDigest), MD5 (MessageDigest), NONEwithDSA (Signature), 
       NativePRNG (SecureRandom), PKIX (CertPathBuilder), PKIX (CertPathValidator), 
       SHA (MessageDigest), SHA-256 (MessageDigest), SHA-384 (MessageDigest), 
       SHA-512 (MessageDigest), SHA1PRNG (SecureRandom), SHA1withDSA (Signature), 
       X.509 (CertificateFactory), com.sun.security.IndexedCollection (CertStore) 

Provider: SunRsaSign (ver 1.7) 
    Algorithms: MD2withRSA (Signature), MD5withRSA (Signature), RSA (KeyFactory), RSA (KeyPairGenerator), 
       SHA1withRSA (Signature), SHA256withRSA (Signature), SHA384withRSA (Signature), 
       SHA512withRSA (Signature) 

Provider: SunEC (ver 1.7) 
    Algorithms: EC (AlgorithmParameters), EC (KeyFactory), EC (KeyPairGenerator), ECDH (KeyAgreement), 
       NONEwithECDSA (Signature), SHA1withECDSA (Signature), SHA256withECDSA (Signature), 
       SHA384withECDSA (Signature), SHA512withECDSA (Signature) 

Provider: SunJSSE (ver 1.7) 
    Algorithms: Default (SSLContext), MD2withRSA (Signature), MD5andSHA1withRSA (Signature), 
       MD5withRSA (Signature), NewSunX509 (KeyManagerFactory), PKCS12 (KeyStore), 
       PKIX (TrustManagerFactory), RSA (KeyFactory), RSA (KeyPairGenerator), 
       SHA1withRSA (Signature), SunX509 (KeyManagerFactory), SunX509 (TrustManagerFactory), 
       TLSv1 (SSLContext), TLSv1.1 (SSLContext), TLSv1.2 (SSLContext) 

Provider: SunJCE (ver 1.7) 
    Algorithms: AES (AlgorithmParameters), AES (Cipher), AES (KeyGenerator), AESWrap (Cipher), 
       ARCFOUR (Cipher), ARCFOUR (KeyGenerator), Blowfish (AlgorithmParameters), 
       Blowfish (Cipher), Blowfish (KeyGenerator), DES (AlgorithmParameters), 
       DES (Cipher), DES (KeyGenerator), DES (SecretKeyFactory), DESede (AlgorithmParameters), 
       DESede (Cipher), DESede (KeyGenerator), DESede (SecretKeyFactory), DESedeWrap (Cipher), 
       DiffieHellman (AlgorithmParameterGenerator), DiffieHellman (AlgorithmParameters), 
       DiffieHellman (KeyAgreement), DiffieHellman (KeyFactory), 
       DiffieHellman (KeyPairGenerator), HmacMD5 (KeyGenerator), HmacMD5 (Mac), 
       HmacPBESHA1 (Mac), HmacSHA1 (KeyGenerator), HmacSHA1 (Mac), HmacSHA256 (KeyGenerator), 
       HmacSHA256 (Mac), HmacSHA384 (KeyGenerator), HmacSHA384 (Mac), HmacSHA512 (KeyGenerator), 
       HmacSHA512 (Mac), JCEKS (KeyStore), OAEP (AlgorithmParameters), PBE (AlgorithmParameters), 
       PBEWithMD5AndDES (AlgorithmParameters), PBEWithMD5AndDES (Cipher), 
       PBEWithMD5AndDES (SecretKeyFactory), PBEWithMD5AndTripleDES (AlgorithmParameters), 
       PBEWithMD5AndTripleDES (Cipher), PBEWithMD5AndTripleDES (SecretKeyFactory), 
       PBEWithSHA1AndDESede (AlgorithmParameters), PBEWithSHA1AndDESede (Cipher), 
       PBEWithSHA1AndDESede (SecretKeyFactory), PBEWithSHA1AndRC2_40 (AlgorithmParameters), 
       PBEWithSHA1AndRC2_40 (Cipher), PBEWithSHA1AndRC2_40 (SecretKeyFactory), 
       PBKDF2WithHmacSHA1 (SecretKeyFactory), RC2 (AlgorithmParameters), RC2 (Cipher), 
       RC2 (KeyGenerator), RSA (Cipher), SslMacMD5 (Mac), SslMacSHA1 (Mac), 
       SunTls12Prf (KeyGenerator), SunTlsKeyMaterial (KeyGenerator), SunTlsMasterSecret (KeyGenerator), 
       SunTlsPrf (KeyGenerator), SunTlsRsaPremasterSecret (KeyGenerator) 

Provider: SunJGSS (ver 1.7) 
    Algorithms: 1.2.840.113554.1.2.2 (GssApiMechanism), 1.3.6.1.5.5.2 (GssApiMechanism) 

Provider: SunSASL (ver 1.7) 
    Algorithms: CRAM-MD5 (SaslClientFactory), CRAM-MD5 (SaslServerFactory), DIGEST-MD5 (SaslClientFactory), 
       DIGEST-MD5 (SaslServerFactory), EXTERNAL (SaslClientFactory), GSSAPI (SaslClientFactory), 
       GSSAPI (SaslServerFactory), NTLM (SaslClientFactory), NTLM (SaslServerFactory), PLAIN (SaslClientFactory) 

Provider: XMLDSig (ver 1.0) 
    Algorithms: DOM (KeyInfoFactory), DOM (XMLSignatureFactory), 
       http://www.w3.org/2000/09/xmldsig#base64 (TransformService), 
       http://www.w3.org/2000/09/xmldsig#enveloped-signature (TransformService), 
       http://www.w3.org/2001/10/xml-exc-c14n# (TransformService), 
       http://www.w3.org/2001/10/xml-exc-c14n#WithComments (TransformService), 
       http://www.w3.org/2002/06/xmldsig-filter2 (TransformService), 
       http://www.w3.org/2006/12/xml-c14n11 (TransformService), 
       http://www.w3.org/2006/12/xml-c14n11#WithComments (TransformService), 
       http://www.w3.org/TR/1999/REC-xpath-19991116 (TransformService), 
       http://www.w3.org/TR/1999/REC-xslt-19991116 (TransformService), 
       http://www.w3.org/TR/2001/REC-xml-c14n-20010315 (TransformService), 
       http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments (TransformService) 

Provider: SunPCSC (ver 1.7) 
    Algorithms: PC/SC (TerminalFactory) 

Provider: Apple (ver 1.1) 
    Algorithms: KeychainStore (KeyStore) 
+4

JCA는 대체되지 않습니다. 그것은 건축입니다. JCE 구현입니다. – EJP

답변

6

이다 JCA와 JCE의 기본적인 차이점은 JCE가 JCA의 확장이며 대체가 아니라는 것입니다. JCA에는 MessageDigest, SecureRandom, KeyFactory, SignatureKeyStore과 같은 클래스가 포함됩니다. JCECipher, KeyGeneration, MacKeyGeneration과 같은 암호화 클래스를 더 추가합니다. JCE와 JCE의 구별은 JCE에 표준 런타임이 제공되기 때문에 거의 사라졌습니다.

JCA/JCE은 암호화 구현을 추상화와 분리하도록 설계되었습니다. 프로 바이더베이스의 아키텍쳐로, 표준의 Java 런타임에 포함되는 프로 바이더에 의해 제공되는 것보다 많은 암호화 알고리즘을 지원하는 임의의 프로 바이더 (예를 들어 BouncyCastle)를 플러그 인 할 수가 있습니다.