JCE - 如何找到活动的加密服务提供商

时间:2018-03-21 16:30:50

标签: java ssl jce

在我看到document时,JCE有多个提供者。如何查找默认可用的提供程序?

1 个答案:

答案 0 :(得分:1)

致电Security.getProviders(),例如

for (Provider provider : Security.getProviders())
    System.out.printf("%-11s %s%n", provider.getName(), provider.getInfo());

Windows上的Oracle Java 9.0.1上的输出:

SUN         SUN (DSA key/parameter generation; DSA signing; SHA-1, MD5 digests; SecureRandom; X.509 certificates; PKCS12, JKS & DKS keystores; PKIX CertPathValidator; PKIX CertPathBuilder; LDAP, Collection CertStores, JavaPolicy Policy; JavaLoginConfig Configuration)
SunRsaSign  Sun RSA signature provider
SunEC       Sun Elliptic Curve provider (EC, ECDSA, ECDH)
SunJSSE     Sun JSSE provider(PKCS12, SunX509/PKIX key/trust factories, SSLv3/TLSv1/TLSv1.1/TLSv1.2/DTLSv1.0/DTLSv1.2)
SunJCE      SunJCE Provider (implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE, Diffie-Hellman, HMAC)
SunJGSS     Sun (Kerberos v5, SPNEGO)
SunSASL     Sun SASL provider(implements client mechanisms for: DIGEST-MD5, EXTERNAL, PLAIN, CRAM-MD5, NTLM; server mechanisms for: DIGEST-MD5, CRAM-MD5, NTLM)
XMLDSig     XMLDSig (DOM XMLSignatureFactory; DOM KeyInfoFactory; C14N 1.0, C14N 1.1, Exclusive C14N, Base64, Enveloped, XPath, XPath2, XSLT TransformServices)
SunPCSC     Sun PC/SC provider
JdkLDAP     JdkLDAP Provider (implements LDAP CertStore)
JdkSASL     JDK SASL provider(implements client and server mechanisms for GSSAPI)
SunMSCAPI   Sun's Microsoft Crypto API provider
SunPKCS11   Unconfigured and unusable PKCS11 provider

如果您想查看每个提供商提供的服务,请尝试以下方法:

for (Provider provider : Security.getProviders()) {
    System.out.printf("%-11s %s%n", provider.getName(), provider.getInfo());
    for (Service service : provider.getServices())
        System.out.printf("  %s: %s%n", service.getType(), service.getAlgorithm());
}

输出

SUN         SUN (DSA key/parameter generation; DSA signing; SHA-1, MD5 digests; SecureRandom; X.509 certificates; PKCS12, JKS & DKS keystores; PKIX CertPathValidator; PKIX CertPathBuilder; LDAP, Collection CertStores, JavaPolicy Policy; JavaLoginConfig Configuration)
  SecureRandom: DRBG
  SecureRandom: SHA1PRNG
  Signature: SHA1withDSA
  Signature: NONEwithDSA
  Signature: SHA224withDSA
  Signature: SHA256withDSA
  Signature: SHA1withDSAinP1363Format
  Signature: NONEwithDSAinP1363Format
  Signature: SHA224withDSAinP1363Format
  Signature: SHA256withDSAinP1363Format
  KeyPairGenerator: DSA
  MessageDigest: MD2
  MessageDigest: MD5
  MessageDigest: SHA
  MessageDigest: SHA-224
  MessageDigest: SHA-256
  MessageDigest: SHA-384
  MessageDigest: SHA-512
  MessageDigest: SHA-512/224
  MessageDigest: SHA-512/256
  MessageDigest: SHA3-224
  MessageDigest: SHA3-256
  MessageDigest: SHA3-384
  MessageDigest: SHA3-512
  AlgorithmParameterGenerator: DSA
  AlgorithmParameters: DSA
  KeyFactory: DSA
  CertificateFactory: X.509
  KeyStore: PKCS12
  KeyStore: JKS
  KeyStore: CaseExactJKS
  KeyStore: DKS
  Policy: JavaPolicy
  Configuration: JavaLoginConfig
  CertPathBuilder: PKIX
  CertPathValidator: PKIX
  CertStore: Collection
  CertStore: com.sun.security.IndexedCollection
SunRsaSign  Sun RSA signature provider
  KeyFactory: RSA
  KeyPairGenerator: RSA
  Signature: MD2withRSA
  Signature: MD5withRSA
  Signature: SHA1withRSA
  Signature: SHA224withRSA
  Signature: SHA256withRSA
  Signature: SHA384withRSA
  Signature: SHA512withRSA
SunEC       Sun Elliptic Curve provider (EC, ECDSA, ECDH)
  KeyFactory: EC
  AlgorithmParameters: EC
  Signature: NONEwithECDSA
  Signature: SHA1withECDSA
  Signature: SHA224withECDSA
  Signature: SHA256withECDSA
  Signature: SHA384withECDSA
  Signature: SHA512withECDSA
  Signature: NONEwithECDSAinP1363Format
  Signature: SHA1withECDSAinP1363Format
  Signature: SHA224withECDSAinP1363Format
  Signature: SHA256withECDSAinP1363Format
  Signature: SHA384withECDSAinP1363Format
  Signature: SHA512withECDSAinP1363Format
  KeyPairGenerator: EC
  KeyAgreement: ECDH
SunJSSE     Sun JSSE provider(PKCS12, SunX509/PKIX key/trust factories, SSLv3/TLSv1/TLSv1.1/TLSv1.2/DTLSv1.0/DTLSv1.2)
  KeyFactory: RSA
  KeyPairGenerator: RSA
  Signature: MD2withRSA
  Signature: MD5withRSA
  Signature: SHA1withRSA
  Signature: MD5andSHA1withRSA
  KeyManagerFactory: SunX509
  KeyManagerFactory: NewSunX509
  TrustManagerFactory: SunX509
  TrustManagerFactory: PKIX
  SSLContext: TLSv1
  SSLContext: TLSv1.1
  SSLContext: TLSv1.2
  SSLContext: TLS
  SSLContext: DTLSv1.0
  SSLContext: DTLSv1.2
  SSLContext: DTLS
  SSLContext: Default
  KeyStore: PKCS12
SunJCE      SunJCE Provider (implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE, Diffie-Hellman, HMAC)
  Cipher: RSA
  Cipher: DES
  Cipher: DESede
  Cipher: DESedeWrap
  Cipher: PBEWithMD5AndDES
  Cipher: PBEWithMD5AndTripleDES
  Cipher: PBEWithSHA1AndDESede
  Cipher: PBEWithSHA1AndRC2_40
  Cipher: PBEWithSHA1AndRC2_128
  Cipher: PBEWithSHA1AndRC4_40
  Cipher: PBEWithSHA1AndRC4_128
  Cipher: PBEWithHmacSHA1AndAES_128
  Cipher: PBEWithHmacSHA224AndAES_128
  Cipher: PBEWithHmacSHA256AndAES_128
  Cipher: PBEWithHmacSHA384AndAES_128
  Cipher: PBEWithHmacSHA512AndAES_128
  Cipher: PBEWithHmacSHA1AndAES_256
  Cipher: PBEWithHmacSHA224AndAES_256
  Cipher: PBEWithHmacSHA256AndAES_256
  Cipher: PBEWithHmacSHA384AndAES_256
  Cipher: PBEWithHmacSHA512AndAES_256
  Cipher: Blowfish
  Cipher: AES
  Cipher: AES_128/ECB/NoPadding
  Cipher: AES_128/CBC/NoPadding
  Cipher: AES_128/OFB/NoPadding
  Cipher: AES_128/CFB/NoPadding
  Cipher: AES_128/GCM/NoPadding
  Cipher: AES_192/ECB/NoPadding
  Cipher: AES_192/CBC/NoPadding
  Cipher: AES_192/OFB/NoPadding
  Cipher: AES_192/CFB/NoPadding
  Cipher: AES_192/GCM/NoPadding
  Cipher: AES_256/ECB/NoPadding
  Cipher: AES_256/CBC/NoPadding
  Cipher: AES_256/OFB/NoPadding
  Cipher: AES_256/CFB/NoPadding
  Cipher: AES_256/GCM/NoPadding
  Cipher: AESWrap
  Cipher: AESWrap_128
  Cipher: AESWrap_192
  Cipher: AESWrap_256
  Cipher: RC2
  Cipher: ARCFOUR
  KeyGenerator: DES
  KeyGenerator: DESede
  KeyGenerator: Blowfish
  KeyGenerator: AES
  KeyGenerator: RC2
  KeyGenerator: ARCFOUR
  KeyGenerator: HmacMD5
  KeyGenerator: HmacSHA1
  KeyGenerator: HmacSHA224
  KeyGenerator: HmacSHA256
  KeyGenerator: HmacSHA384
  KeyGenerator: HmacSHA512
  KeyPairGenerator: DiffieHellman
  AlgorithmParameterGenerator: DiffieHellman
  KeyAgreement: DiffieHellman
  AlgorithmParameters: DiffieHellman
  AlgorithmParameters: DES
  AlgorithmParameters: DESede
  AlgorithmParameters: PBE
  AlgorithmParameters: PBEWithMD5AndDES
  AlgorithmParameters: PBEWithMD5AndTripleDES
  AlgorithmParameters: PBEWithSHA1AndDESede
  AlgorithmParameters: PBEWithSHA1AndRC2_40
  AlgorithmParameters: PBEWithSHA1AndRC2_128
  AlgorithmParameters: PBEWithSHA1AndRC4_40
  AlgorithmParameters: PBEWithSHA1AndRC4_128
  AlgorithmParameters: PBES2
  AlgorithmParameters: PBEWithHmacSHA1AndAES_128
  AlgorithmParameters: PBEWithHmacSHA224AndAES_128
  AlgorithmParameters: PBEWithHmacSHA256AndAES_128
  AlgorithmParameters: PBEWithHmacSHA384AndAES_128
  AlgorithmParameters: PBEWithHmacSHA512AndAES_128
  AlgorithmParameters: PBEWithHmacSHA1AndAES_256
  AlgorithmParameters: PBEWithHmacSHA224AndAES_256
  AlgorithmParameters: PBEWithHmacSHA256AndAES_256
  AlgorithmParameters: PBEWithHmacSHA384AndAES_256
  AlgorithmParameters: PBEWithHmacSHA512AndAES_256
  AlgorithmParameters: Blowfish
  AlgorithmParameters: AES
  AlgorithmParameters: GCM
  AlgorithmParameters: RC2
  AlgorithmParameters: OAEP
  KeyFactory: DiffieHellman
  SecretKeyFactory: DES
  SecretKeyFactory: DESede
  SecretKeyFactory: PBEWithMD5AndDES
  SecretKeyFactory: PBEWithMD5AndTripleDES
  SecretKeyFactory: PBEWithSHA1AndDESede
  SecretKeyFactory: PBEWithSHA1AndRC2_40
  SecretKeyFactory: PBEWithSHA1AndRC2_128
  SecretKeyFactory: PBEWithSHA1AndRC4_40
  SecretKeyFactory: PBEWithSHA1AndRC4_128
  SecretKeyFactory: PBEWithHmacSHA1AndAES_128
  SecretKeyFactory: PBEWithHmacSHA224AndAES_128
  SecretKeyFactory: PBEWithHmacSHA256AndAES_128
  SecretKeyFactory: PBEWithHmacSHA384AndAES_128
  SecretKeyFactory: PBEWithHmacSHA512AndAES_128
  SecretKeyFactory: PBEWithHmacSHA1AndAES_256
  SecretKeyFactory: PBEWithHmacSHA224AndAES_256
  SecretKeyFactory: PBEWithHmacSHA256AndAES_256
  SecretKeyFactory: PBEWithHmacSHA384AndAES_256
  SecretKeyFactory: PBEWithHmacSHA512AndAES_256
  SecretKeyFactory: PBKDF2WithHmacSHA1
  SecretKeyFactory: PBKDF2WithHmacSHA224
  SecretKeyFactory: PBKDF2WithHmacSHA256
  SecretKeyFactory: PBKDF2WithHmacSHA384
  SecretKeyFactory: PBKDF2WithHmacSHA512
  Mac: HmacMD5
  Mac: HmacSHA1
  Mac: HmacSHA224
  Mac: HmacSHA256
  Mac: HmacSHA384
  Mac: HmacSHA512
  Mac: HmacSHA512/224
  Mac: HmacSHA512/256
  Mac: HmacPBESHA1
  Mac: PBEWithHmacSHA1
  Mac: PBEWithHmacSHA224
  Mac: PBEWithHmacSHA256
  Mac: PBEWithHmacSHA384
  Mac: PBEWithHmacSHA512
  Mac: SslMacMD5
  Mac: SslMacSHA1
  KeyStore: JCEKS
  KeyGenerator: SunTlsPrf
  KeyGenerator: SunTls12Prf
  KeyGenerator: SunTlsMasterSecret
  KeyGenerator: SunTlsKeyMaterial
  KeyGenerator: SunTlsRsaPremasterSecret
SunJGSS     Sun (Kerberos v5, SPNEGO)
  GssApiMechanism: 1.2.840.113554.1.2.2
  GssApiMechanism: 1.3.6.1.5.5.2
SunSASL     Sun SASL provider(implements client mechanisms for: DIGEST-MD5, EXTERNAL, PLAIN, CRAM-MD5, NTLM; server mechanisms for: DIGEST-MD5, CRAM-MD5, NTLM)
  SaslClientFactory: DIGEST-MD5
  SaslClientFactory: NTLM
  SaslClientFactory: EXTERNAL
  SaslClientFactory: PLAIN
  SaslClientFactory: CRAM-MD5
  SaslServerFactory: CRAM-MD5
  SaslServerFactory: DIGEST-MD5
  SaslServerFactory: NTLM
XMLDSig     XMLDSig (DOM XMLSignatureFactory; DOM KeyInfoFactory; C14N 1.0, C14N 1.1, Exclusive C14N, Base64, Enveloped, XPath, XPath2, XSLT TransformServices)
  XMLSignatureFactory: DOM
  KeyInfoFactory: DOM
  TransformService: http://www.w3.org/TR/2001/REC-xml-c14n-20010315
  TransformService: http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments
  TransformService: http://www.w3.org/2006/12/xml-c14n11
  TransformService: http://www.w3.org/2006/12/xml-c14n11#WithComments
  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/2000/09/xmldsig#base64
  TransformService: http://www.w3.org/2000/09/xmldsig#enveloped-signature
  TransformService: http://www.w3.org/2002/06/xmldsig-filter2
  TransformService: http://www.w3.org/TR/1999/REC-xpath-19991116
  TransformService: http://www.w3.org/TR/1999/REC-xslt-19991116
SunPCSC     Sun PC/SC provider
  TerminalFactory: PC/SC
JdkLDAP     JdkLDAP Provider (implements LDAP CertStore)
  CertStore: LDAP
JdkSASL     JDK SASL provider(implements client and server mechanisms for GSSAPI)
  SaslClientFactory: GSSAPI
  SaslServerFactory: GSSAPI
SunMSCAPI   Sun's Microsoft Crypto API provider
  SecureRandom: Windows-PRNG
  KeyStore: Windows-MY
  KeyStore: Windows-ROOT
  Signature: NONEwithRSA
  Signature: SHA1withRSA
  Signature: SHA256withRSA
  Signature: SHA384withRSA
  Signature: SHA512withRSA
  Signature: MD5withRSA
  Signature: MD2withRSA
  KeyPairGenerator: RSA
  Cipher: RSA
  Cipher: RSA/ECB/PKCS1Padding
SunPKCS11   Unconfigured and unusable PKCS11 provider