Bouncy Castle Java 平臺輕量級密碼術包
阿新 • • 發佈:2019-01-27
Bouncy Castle 是一種用於 Java 平臺的開放原始碼的輕量級密碼術包。它支援大量的密碼術演算法,並提供 JCE 1.2.1 的實現。因為 Bouncy Castle 被設計成輕量級的,所以從 J2SE 1.4 到 J2ME(包括 MIDP)平臺,它都可以執行。它是在 MIDP 上執行的唯一完整的密碼術包。
Bouncy Castle的Java JCE安裝方法
1、去官方站點下載Bouncy Castle的JCE Provider包 bcprov-ext-jdk15-145.jar 2、把jar檔案複製到 $JAVA_HOME$\jre\lib\ext 目錄下面 3、修改配置檔案\jre\lib\security\java.security security.provider.1=sun.security.provider.Sun security.provider.2=sun.security.rsa.SunRsaSign security.provider.3=com.sun.net.ssl.internal.ssl.Provider security.provider.4=com.sun.crypto.provider.SunJCE security.provider.5=sun.security.jgss.SunProvider security.provider.6=com.sun.security.sasl.Provider #前面是java環境已經提供的,尾部加上這一行即可 security.provider.7=org.bouncycastle.jce.provider.BouncyCastleProvider 4、可以寫個小程式檢視本地java系統中安裝的所有的JCE提供者,和一些相應演算法。import java.security.*;
public class Check {
public static void main(String[] args) {
System.out.println("-------列出加密服務提供者-----");
Provider[] pro = Security.getProviders();
for (Provider p : pro) {
System.out.println("Provider:" + p.getName() + " - version:" + p.getVersion());
System.out.println(p.getInfo());
}
System.out.println("");
System.out.println("-------列出系統支援的訊息摘要演算法:");
for (String s : Security.getAlgorithms("MessageDigest")) {
System.out.println(s);
}
System.out.println("-------列出系統支援的生成公鑰和私鑰對的演算法:");
for (String s : Security.getAlgorithms("KeyPairGenerator")) {
System.out.println(s);
}
}
}
Java程式碼
-------列出加密服務提供者-----
Provider:SUN - version:1.6
SUN (DSA key/parameter generation; DSA signing; SHA-1, MD5 digests; SecureRandom; X.509 certificates; JKS keystore; PKIX CertPathValidator; PKIX CertPathBuilder; LDAP, Collection CertStores, JavaPolicy Policy; JavaLoginConfig Configuration)
Provider:SunRsaSign - version:1.5
Sun RSA signature provider
Provider:SunJSSE - version:1.6
Sun JSSE provider(PKCS12, SunX509 key/trust factories, SSLv3, TLSv1)
Provider:SunJCE - version:1.6
SunJCE Provider (implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE, Diffie-Hellman, HMAC)
Provider:SunJGSS - version:1.0
Sun (Kerberos v5, SPNEGO)
Provider:SunSASL - version:1.5
Sun SASL provider(implements client mechanisms for: DIGEST-MD5, GSSAPI, EXTERNAL, PLAIN, CRAM-MD5; server mechanisms for: DIGEST-MD5, GSSAPI, CRAM-MD5)
Provider:XMLDSig - version:1.0
XMLDSig (DOM XMLSignatureFactory; DOM KeyInfoFactory)
Provider:SunPCSC - version:1.6
Sun PC/SC provider
Provider:SunMSCAPI - version:1.6
Sun's Microsoft Crypto API provider
Provider:BC - version:1.5
BouncyCastle Security Provider v1.50
-------列出系統支援的訊息摘要演算法:
SKEIN-256-160
SKEIN-512-160
SHA3-256
RIPEMD320
SHA-384
SKEIN-1024-512
SKEIN-512-512
RIPEMD128
SHA
SHA3-512
SKEIN-256-256
SKEIN-256-128
SKEIN-512-256
WHIRLPOOL
SHA-224
RIPEMD160
SHA3-384
SHA-512/256
SM3
RIPEMD256
SKEIN-1024-1024
GOST3411
MD5
SHA3-224
TIGER
SKEIN-512-224
MD4
MD2
SHA-256
SHA-512
SKEIN-1024-384
SKEIN-512-384
SHA-512/224
SKEIN-256-224
SKEIN-512-128
SHA-1
-------列出系統支援的生成公鑰和私鑰對的演算法:
DSTU4145
GOST3410
ECGOST3410
EC
DSA
ECDSA
RSA
ELGAMAL
ECIES
ECMQV
DIFFIEHELLMAN
ECDH
ECDHC
DH