Wednesday, December 19, 2012

Obfuscating to a small self contained library .jar

In the case you would like to create a library jar file, you could:

  • Run Proguard once on the library .jar file - this can make the library self-contained and prevent package name collisions.
  • Run Proguard once on the application that uses the library file.


Step by step:

  1. Ofuscation of library jar is based on http://proguard.sourceforge.net/index.html#manual/examples.html - A typical library.
  2. To make the library .jar small, list classes to be kept explicitely instead of -keep public class * {public protected *;}
    • -keep public class my.package1.* {*;}
    • -keep public class my.package2.* {*;}
  3. To make the library smaller, remove unused classes and obfuscate the used ones, omit -dontshrink
  4. To optimize and remove dead code, omit -dontoptimize
  5. In the case of "Unknown verification type [32] in stack map frame" problems when obfuscating the app, try disabling optimizing rules of the library according to http://proguard.sourceforge.net/index.html#manual/optimizations.html. Examples that can be tried until no more errors:
    1. -optimizations !class/merging/*, !field/*, !method/*, !code/*
    2. -optimizations  !code/*, !field/*
    3. -optimizations !field/*
    4. -optimizations !field/propagation/value
  6. Finally, repackage classes to your organizations domain (www.package.my):
    1. -allowaccessmodification
    2. -repackageclasses 'my.package'
You should now have a library .jar where all or most classes are obfuscated located under my.package.*.class


Wednesday, November 14, 2012

Encap won the award in the Funded category for Norwegian Startups in the Nordic Startup Awards 2012-11-13 at MESH. Thank you for the votes, and thanks to our sustaining investor Alliance Venture. The award includes mentoring and partly TINC funding. The Nordic finale is in Copenhagen 7 Dec 2012.

Ensafer was also among the finalists in the Bootstrapper category - it belongs to the story that Encap and Ensafer apply for a research project together. Ensafer launches Dropbox encryption.

Encap has passed several phases during development. Initially, we put effort in making the product covering ca. 80% of the mobile devices in the consumer market, university and third party evaluations, and approval for the norwegian banking standards. Recently, effort has been made to make the product easy available for developers and integrators, this will be available at http://developer.encapsecurity.com within Dec 2012.

Tuesday, April 10, 2012

Update of Samsung Nexus S from 2.3.6 to Android 4.0 OTA A pop-up dialog is shown approximately after update is downloaded and ready for install. Pushing the the button for “More Information” reveals it’s an OTA update to Android 4.0.4. Pushing the button for restart and install starts the update that will last a few minutes before Android 4 is waking up:

Saturday, March 10, 2012

List of SSL/TLS root certificates

Before purchasing an SSL/TLS certificate for a web server, it is interesting to know whether the mobile device accepts the certificate.

Procedure

1. Download http://bouncycastle.org/download/bcprov-jdk16-141.jar and place it on $JAVA_HOME/jre/lib/ext/

2. get the certificates file

adb pull /system/etc/security/cacerts.bks cacerts.bks 

3. List certificates with keytool.

keytool -list -v -storetype BKS \
      -provider org.bouncycastle.jce.provider.BouncyCastleProvider \
      -keystore ~/Downloads/cacerts.bks.SE_X10 \
       | grep ^Issuer | sort | cut -b 9-

Enter keystore password:

When prompted for password, push enter and ignore the warning. The result will be a list of TLS/SSL certificates that can be inspected. Example findings:

  • Sony Ericsson X10 mini pro: RapidSSL not present.

Monday, February 6, 2012

Wednesday, February 1, 2012

Mobile platform security links

The following links contain information relevant for mobile platform security.

Custom URL

Starting an app by opening a custom URL will fail if the app is not installed. Exampes.

Operating system, update and security

Android, generic update overview:

Android security:

iiOS OTA update:

iOS Security:

Keychain / crypto

iOS keyChain

Android keychain:

iOS Data protection

Crypto libraries

Android

iOS

Application Stores

Overview

Threats / malware

Android

Windows Phone Marketplace

Nokia store

Firewall and anti trojan / anti virus

Firewall
  • Wikipedia: "permit or deny network transmissions based upon a set of rules"

Firewall programs from the application stores App Store / Market:

  • Android: Droidwall (requires root)
  • iOS: None (Lookout: Warn if on unencrypted WiFi)
Anti trojan / anti virus

Protection from malicious apps - anti-virus, block outgoing calls and SMS, and similar.

Android Market:

Developing

Sunday, January 29, 2012

Android up to including 2.2 includes a stripped down Bouncy Castle.

BouncyCastle versions on Android :

Alternative: Spongy Castle 1.46 = Bouncy Castle 1.46 with another package name.

Security provider parameter names available

The filtered and sorted output from a small program listing the Java security provider parameter names (keys) that are supported on Samsung i5800, running Android 2.1:

Alg.Alias.AlgorithmParameterGenerator.2.16.840.1.101.3.4.1.2
Alg.Alias.AlgorithmParameterGenerator.2.16.840.1.101.3.4.1.22
Alg.Alias.AlgorithmParameterGenerator.2.16.840.1.101.3.4.1.42
Alg.Alias.AlgorithmParameterGenerator.2.16.840.1.101.3.4.2
Alg.Alias.AlgorithmParameterGenerator.2.16.840.1.101.3.4.22
Alg.Alias.AlgorithmParameterGenerator.2.16.840.1.101.3.4.42
Alg.Alias.AlgorithmParameters.1.2.840.113549.1.1.10
Alg.Alias.AlgorithmParameters.1.2.840.113549.1.1.7
Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.1
Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.2
Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.3
Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.4
Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.5
Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.6
Alg.Alias.AlgorithmParameters.1.3.14.3.2.7
Alg.Alias.AlgorithmParameters.2.16.840.1.101.3.4.1.2
Alg.Alias.AlgorithmParameters.2.16.840.1.101.3.4.1.22
Alg.Alias.AlgorithmParameters.2.16.840.1.101.3.4.1.42
Alg.Alias.AlgorithmParameters.2.16.840.1.101.3.4.2
Alg.Alias.AlgorithmParameters.2.16.840.1.101.3.4.22
Alg.Alias.AlgorithmParameters.2.16.840.1.101.3.4.42
Alg.Alias.AlgorithmParameters.PBEWITHSHA-1AND128BITAES-CBC-BC
Alg.Alias.AlgorithmParameters.PBEWITHSHA-1AND192BITAES-CBC-BC
Alg.Alias.AlgorithmParameters.PBEWITHSHA-1AND256BITAES-CBC-BC
Alg.Alias.AlgorithmParameters.PBEWITHSHA-256AND128BITAES-CBC-BC
Alg.Alias.AlgorithmParameters.PBEWITHSHA-256AND192BITAES-CBC-BC
Alg.Alias.AlgorithmParameters.PBEWITHSHA-256AND256BITAES-CBC-BC
Alg.Alias.AlgorithmParameters.PBEWITHSHA1AND128BITAES-CBC-BC
Alg.Alias.AlgorithmParameters.PBEWITHSHA1AND192BITAES-CBC-BC
Alg.Alias.AlgorithmParameters.PBEWITHSHA1AND256BITAES-CBC-BC
Alg.Alias.AlgorithmParameters.PBEWITHSHA1ANDRC2
Alg.Alias.AlgorithmParameters.PBEWITHSHA1ANDRC2-CBC
Alg.Alias.AlgorithmParameters.PBEWITHSHA256AND128BITAES-CBC-BC
Alg.Alias.AlgorithmParameters.PBEWITHSHA256AND192BITAES-CBC-BC
Alg.Alias.AlgorithmParameters.PBEWITHSHA256AND256BITAES-CBC-BC
Alg.Alias.AlgorithmParameters.PBEWITHSHAAND128BITAES-CBC-BC
Alg.Alias.AlgorithmParameters.PBEWITHSHAAND128BITRC2-CBC
Alg.Alias.AlgorithmParameters.PBEWITHSHAAND128BITRC4
Alg.Alias.AlgorithmParameters.PBEWITHSHAAND192BITAES-CBC-BC
Alg.Alias.AlgorithmParameters.PBEWITHSHAAND2-KEYTRIPLEDES
Alg.Alias.AlgorithmParameters.PBEWITHSHAAND2-KEYTRIPLEDES-CBC
Alg.Alias.AlgorithmParameters.PBEWITHSHAAND256BITAES-CBC-BC
Alg.Alias.AlgorithmParameters.PBEWITHSHAAND3-KEYTRIPLEDES
Alg.Alias.AlgorithmParameters.PBEWITHSHAAND3-KEYTRIPLEDES-CBC
Alg.Alias.AlgorithmParameters.PBEWITHSHAAND40BITRC2-CBC
Alg.Alias.AlgorithmParameters.PBEWITHSHAAND40BITRC4
Alg.Alias.AlgorithmParameters.PBEWITHSHAANDDES2KEY-CBC
Alg.Alias.AlgorithmParameters.PBEWITHSHAANDDES3KEY-CBC
Alg.Alias.AlgorithmParameters.PBEWITHSHAANDIDEA
Alg.Alias.AlgorithmParameters.PBEWITHSHAANDRC2
Alg.Alias.AlgorithmParameters.PBEWITHSHAANDRC4
Alg.Alias.AlgorithmParameters.PBEWITHSHAANDTWOFISH
Alg.Alias.AlgorithmParameters.PBEWithSHAAnd3KeyTripleDES
Alg.Alias.AlgorithmParameters.SHA1WITHRSAANDMGF1
Alg.Alias.AlgorithmParameters.SHA224WITHRSAANDMGF1
Alg.Alias.AlgorithmParameters.SHA256WITHRSAANDMGF1
Alg.Alias.AlgorithmParameters.SHA384WITHRSAANDMGF1
Alg.Alias.AlgorithmParameters.SHA512WITHRSAANDMGF1
Alg.Alias.CertificateFactory.X.509
Alg.Alias.CertificateFactory.X509
Alg.Alias.Cipher.1.2.840.113549.1.12.1.3
Alg.Alias.Cipher.1.2.840.113549.1.12.1.4
Alg.Alias.Cipher.1.2.840.113549.1.12.1.6
Alg.Alias.Cipher.2.16.840.1.101.3.4.1.25
Alg.Alias.Cipher.2.16.840.1.101.3.4.1.45
Alg.Alias.Cipher.2.16.840.1.101.3.4.1.5
Alg.Alias.Cipher.2.16.840.1.101.3.4.2
Alg.Alias.Cipher.2.16.840.1.101.3.4.22
Alg.Alias.Cipher.2.16.840.1.101.3.4.42
Alg.Alias.Cipher.PBEWITHSHA-1AND128BITAES-CBC-BC
Alg.Alias.Cipher.PBEWITHSHA-1AND192BITAES-CBC-BC
Alg.Alias.Cipher.PBEWITHSHA-1AND256BITAES-CBC-BC
Alg.Alias.Cipher.PBEWITHSHA-256AND128BITAES-CBC-BC
Alg.Alias.Cipher.PBEWITHSHA-256AND192BITAES-CBC-BC
Alg.Alias.Cipher.PBEWITHSHA-256AND256BITAES-CBC-BC
Alg.Alias.Cipher.PBEWITHSHA1AND128BITAES-CBC-BC
Alg.Alias.Cipher.PBEWITHSHA1AND192BITAES-CBC-BC
Alg.Alias.Cipher.PBEWITHSHA1AND2-KEYTRIPLEDES-CBC
Alg.Alias.Cipher.PBEWITHSHA1AND256BITAES-CBC-BC
Alg.Alias.Cipher.PBEWITHSHA1AND3-KEYTRIPLEDES-CBC
Alg.Alias.Cipher.PBEWITHSHA1AND40BITRC2-CBC
Alg.Alias.Cipher.PBEWITHSHA1ANDDESEDE
Alg.Alias.Cipher.PBEWithSHAAnd3KeyTripleDES
Alg.Alias.Cipher.RSA//ISO9796-1PADDING
Alg.Alias.Cipher.RSA//NOPADDING
Alg.Alias.Cipher.RSA//OAEPPADDING
Alg.Alias.Cipher.RSA//PKCS1PADDING
Alg.Alias.Cipher.RSA//RAW
Alg.Alias.KeyFactory.1.2.840.10040.4.1
Alg.Alias.KeyFactory.1.2.840.10040.4.1
Alg.Alias.KeyFactory.1.2.840.113549.1.1.1
Alg.Alias.KeyFactory.1.3.14.3.2.12
Alg.Alias.KeyGenerator.1.2.840.113549.2.10
Alg.Alias.KeyGenerator.1.2.840.113549.2.11
Alg.Alias.KeyGenerator.1.2.840.113549.2.7
Alg.Alias.KeyGenerator.1.2.840.113549.2.8
Alg.Alias.KeyGenerator.1.2.840.113549.2.9
Alg.Alias.KeyGenerator.1.3.14.3.2.7
Alg.Alias.KeyGenerator.1.3.6.1.5.5.8.1.1
Alg.Alias.KeyGenerator.1.3.6.1.5.5.8.1.2
Alg.Alias.KeyGenerator.HMAC-MD5
Alg.Alias.KeyGenerator.HMAC-SHA1
Alg.Alias.KeyGenerator.HMAC-SHA224
Alg.Alias.KeyGenerator.HMAC-SHA256
Alg.Alias.KeyGenerator.HMAC-SHA384
Alg.Alias.KeyGenerator.HMAC-SHA512
Alg.Alias.KeyGenerator.HMAC/MD5
Alg.Alias.KeyGenerator.HMAC/SHA1
Alg.Alias.KeyGenerator.HMAC/SHA224
Alg.Alias.KeyGenerator.HMAC/SHA256
Alg.Alias.KeyGenerator.HMAC/SHA384
Alg.Alias.KeyGenerator.HMAC/SHA512
Alg.Alias.KeyPairGenerator.1.2.840.113549.1.1.1
Alg.Alias.KeyStore.BOUNCYCASTLE
Alg.Alias.KeyStore.UBER
Alg.Alias.KeyStore.bouncycastle
Alg.Alias.Mac.1.2.840.113549.2.10
Alg.Alias.Mac.1.2.840.113549.2.11
Alg.Alias.Mac.1.2.840.113549.2.7
Alg.Alias.Mac.1.2.840.113549.2.8
Alg.Alias.Mac.1.2.840.113549.2.9
Alg.Alias.Mac.1.3.14.3.2.26
Alg.Alias.Mac.1.3.6.1.5.5.8.1.1
Alg.Alias.Mac.1.3.6.1.5.5.8.1.2
Alg.Alias.Mac.DES
Alg.Alias.Mac.DES/CFB8
Alg.Alias.Mac.DESEDE
Alg.Alias.Mac.DESEDE/CFB8
Alg.Alias.Mac.DESEDE64
Alg.Alias.Mac.DESISO9797MAC
Alg.Alias.Mac.HMAC-MD5
Alg.Alias.Mac.HMAC-SHA1
Alg.Alias.Mac.HMAC-SHA224
Alg.Alias.Mac.HMAC-SHA256
Alg.Alias.Mac.HMAC-SHA384
Alg.Alias.Mac.HMAC-SHA512
Alg.Alias.Mac.HMAC/MD5
Alg.Alias.Mac.HMAC/SHA1
Alg.Alias.Mac.HMAC/SHA224
Alg.Alias.Mac.HMAC/SHA256
Alg.Alias.Mac.HMAC/SHA384
Alg.Alias.Mac.HMAC/SHA512
Alg.Alias.Mac.ISO9797ALG3
Alg.Alias.MessageDigest.1.2.840.113549.2.5
Alg.Alias.MessageDigest.1.3.14.3.2.26
Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.1
Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.2
Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.3
Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.4
Alg.Alias.MessageDigest.SHA
Alg.Alias.MessageDigest.SHA
Alg.Alias.MessageDigest.SHA1
Alg.Alias.MessageDigest.SHA1
Alg.Alias.MessageDigest.SHA224
Alg.Alias.MessageDigest.SHA256
Alg.Alias.MessageDigest.SHA384
Alg.Alias.MessageDigest.SHA512
Alg.Alias.SSLContext.TLSv1
Alg.Alias.SecretKeyFactory.1.2.840.113549.1.12.1.3
Alg.Alias.SecretKeyFactory.1.2.840.113549.1.12.1.6
Alg.Alias.SecretKeyFactory.1.3.14.3.2.26
Alg.Alias.SecretKeyFactory.BROKENPBEWITHMD5ANDDES
Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHA1ANDDES
Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHAAND2-KEYTRIPLEDES-CBC
Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHAAND3-KEYTRIPLEDES-CBC
Alg.Alias.SecretKeyFactory.OLDPBEWITHSHAAND3-KEYTRIPLEDES-CBC
Alg.Alias.SecretKeyFactory.PBE
Alg.Alias.SecretKeyFactory.PBEWITHHMACSHA
Alg.Alias.SecretKeyFactory.PBEWITHSHA-1AND128BITAES-CBC-BC
Alg.Alias.SecretKeyFactory.PBEWITHSHA-1AND192BITAES-CBC-BC
Alg.Alias.SecretKeyFactory.PBEWITHSHA-1AND256BITAES-CBC-BC
Alg.Alias.SecretKeyFactory.PBEWITHSHA-256AND128BITAES-CBC-BC
Alg.Alias.SecretKeyFactory.PBEWITHSHA-256AND192BITAES-CBC-BC
Alg.Alias.SecretKeyFactory.PBEWITHSHA-256AND256BITAES-CBC-BC
Alg.Alias.SecretKeyFactory.PBEWITHSHA1AND128BITAES-CBC-BC
Alg.Alias.SecretKeyFactory.PBEWITHSHA1AND192BITAES-CBC-BC
Alg.Alias.SecretKeyFactory.PBEWITHSHA1AND256BITAES-CBC-BC
Alg.Alias.SecretKeyFactory.PBEWithSHAAnd3KeyTripleDES
Alg.Alias.Signature.1.2.840.10040.4.3
Alg.Alias.Signature.1.2.840.10040.4.3
Alg.Alias.Signature.1.2.840.113549.1.1.11
Alg.Alias.Signature.1.2.840.113549.1.1.12
Alg.Alias.Signature.1.2.840.113549.1.1.13
Alg.Alias.Signature.1.2.840.113549.1.1.14
Alg.Alias.Signature.1.2.840.113549.1.1.3
Alg.Alias.Signature.1.2.840.113549.1.1.4
Alg.Alias.Signature.1.2.840.113549.1.1.5
Alg.Alias.Signature.1.2.840.113549.2.5with1.2.840.113549.1.1.1
Alg.Alias.Signature.1.3.14.3.2.13
Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.10040.4.1
Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.10040.4.3
Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.113549.1.1.1
Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.113549.1.1.5
Alg.Alias.Signature.1.3.14.3.2.27
Alg.Alias.Signature.1.3.14.3.2.29
Alg.Alias.Signature.DSA
Alg.Alias.Signature.DSAWITHSHA1
Alg.Alias.Signature.DSAWithSHA1
Alg.Alias.Signature.DSAwithSHA1
Alg.Alias.Signature.DSAwithSHA1
Alg.Alias.Signature.DSS
Alg.Alias.Signature.MD4/RSA
Alg.Alias.Signature.MD4WithRSA
Alg.Alias.Signature.MD4withRSA
Alg.Alias.Signature.MD4withRSAEncryption
Alg.Alias.Signature.MD5/RSA
Alg.Alias.Signature.MD5WITHRSA
Alg.Alias.Signature.MD5WITHRSAENCRYPTION
Alg.Alias.Signature.MD5WithRSA
Alg.Alias.Signature.MD5WithRSA/ISO9796-2
Alg.Alias.Signature.MD5withRSA
Alg.Alias.Signature.MD5withRSAEncryption
Alg.Alias.Signature.OID.1.2.840.10040.4.3
Alg.Alias.Signature.RAWDSA
Alg.Alias.Signature.RMD160WITHRSA
Alg.Alias.Signature.SHA-1/DSA
Alg.Alias.Signature.SHA-1/RSA
Alg.Alias.Signature.SHA/DSA
Alg.Alias.Signature.SHA/DSA
Alg.Alias.Signature.SHA1/DSA
Alg.Alias.Signature.SHA1/RSA
Alg.Alias.Signature.SHA1WITHDSA
Alg.Alias.Signature.SHA1WITHRSA
Alg.Alias.Signature.SHA1WITHRSAENCRYPTION
Alg.Alias.Signature.SHA1WithDSA
Alg.Alias.Signature.SHA1WithRSA
Alg.Alias.Signature.SHA1WithRSA/ISO9796-2
Alg.Alias.Signature.SHA1withDSA
Alg.Alias.Signature.SHA1withRSA
Alg.Alias.Signature.SHA1withRSAEncryption
Alg.Alias.Signature.SHA1withRSAandMGF1
Alg.Alias.Signature.SHA224WithRSA
Alg.Alias.Signature.SHA224withRSA
Alg.Alias.Signature.SHA224withRSAEncryption
Alg.Alias.Signature.SHA224withRSAandMGF1
Alg.Alias.Signature.SHA256WITHRSAENCRYPTION
Alg.Alias.Signature.SHA256WithRSA
Alg.Alias.Signature.SHA256WithRSAEncryption
Alg.Alias.Signature.SHA256withRSA
Alg.Alias.Signature.SHA256withRSAEncryption
Alg.Alias.Signature.SHA256withRSAandMGF1
Alg.Alias.Signature.SHA384WITHRSAENCRYPTION
Alg.Alias.Signature.SHA384WithRSA
Alg.Alias.Signature.SHA384WithRSAEncryption
Alg.Alias.Signature.SHA384withRSA
Alg.Alias.Signature.SHA384withRSAEncryption
Alg.Alias.Signature.SHA384withRSAandMGF1
Alg.Alias.Signature.SHA512WITHRSAENCRYPTION
Alg.Alias.Signature.SHA512WithRSA
Alg.Alias.Signature.SHA512WithRSAEncryption
Alg.Alias.Signature.SHA512withRSA
Alg.Alias.Signature.SHA512withRSAEncryption
Alg.Alias.Signature.SHA512withRSAandMGF1
Alg.Alias.Signature.SHAwithDSA
AlgorithmParameterGenerator.1.2.840.113549.3.7
AlgorithmParameterGenerator.1.3.14.3.2.7
AlgorithmParameterGenerator.AES
AlgorithmParameterGenerator.DES
AlgorithmParameterGenerator.DESEDE
AlgorithmParameterGenerator.DH
AlgorithmParameterGenerator.DSA
AlgorithmParameters.1.2.840.113549.3.7
AlgorithmParameters.AES
AlgorithmParameters.DES
AlgorithmParameters.DESEDE
AlgorithmParameters.DH
AlgorithmParameters.DSA
AlgorithmParameters.IES
AlgorithmParameters.OAEP
AlgorithmParameters.PKCS12PBE
AlgorithmParameters.PSS
CertPathBuilder.PKIX
CertPathBuilder.PKIX ValidationAlgorithm
CertPathValidator.PKIX
CertPathValidator.PKIX ValidationAlgorithm
CertStore.Collection
CertificateFactory.X.509
CertificateFactory.X509
Cipher.1.2.840.113549.1.1.1
Cipher.1.2.840.113549.1.1.7
Cipher.1.2.840.113549.1.9.16.3.6
Cipher.1.2.840.113549.3.7
Cipher.1.3.14.3.2.7
Cipher.2.16.840.1.101.3.4.1.1
Cipher.2.16.840.1.101.3.4.1.2
Cipher.2.16.840.1.101.3.4.1.21
Cipher.2.16.840.1.101.3.4.1.22
Cipher.2.16.840.1.101.3.4.1.23
Cipher.2.16.840.1.101.3.4.1.24
Cipher.2.16.840.1.101.3.4.1.3
Cipher.2.16.840.1.101.3.4.1.4
Cipher.2.16.840.1.101.3.4.1.41
Cipher.2.16.840.1.101.3.4.1.42
Cipher.2.16.840.1.101.3.4.1.43
Cipher.2.16.840.1.101.3.4.1.44
Cipher.2.5.8.1.1
Cipher.AES
Cipher.AESWRAP
Cipher.BROKENPBEWITHMD5ANDDES
Cipher.BROKENPBEWITHSHA1ANDDES
Cipher.BROKENPBEWITHSHAAND2-KEYTRIPLEDES-CBC
Cipher.BROKENPBEWITHSHAAND3-KEYTRIPLEDES-CBC
Cipher.BrokenIES
Cipher.DES
Cipher.DESEDE
Cipher.DESEDEWRAP
Cipher.IES
Cipher.OLDPBEWITHSHAAND3-KEYTRIPLEDES-CBC
Cipher.PBEWITHMD5AND128BITAES-CBC-OPENSSL
Cipher.PBEWITHMD5AND192BITAES-CBC-OPENSSL
Cipher.PBEWITHMD5AND256BITAES-CBC-OPENSSL
Cipher.PBEWITHMD5ANDDES
Cipher.PBEWITHMD5ANDRC2
Cipher.PBEWITHSHA1ANDDES
Cipher.PBEWITHSHA256AND128BITAES-CBC-BC
Cipher.PBEWITHSHA256AND192BITAES-CBC-BC
Cipher.PBEWITHSHA256AND256BITAES-CBC-BC
Cipher.PBEWITHSHAAND128BITAES-CBC-BC
Cipher.PBEWITHSHAAND192BITAES-CBC-BC
Cipher.PBEWITHSHAAND2-KEYTRIPLEDES-CBC
Cipher.PBEWITHSHAAND256BITAES-CBC-BC
Cipher.PBEWITHSHAAND3-KEYTRIPLEDES-CBC
Cipher.PBEWITHSHAAND40BITRC2-CBC
Cipher.RSA
Cipher.RSA/1
Cipher.RSA/2
Cipher.RSA/ISO9796-1
Cipher.RSA/OAEP
Cipher.RSA/PKCS1
Cipher.RSA/RAW
KeyAgreement.DH
KeyFactory.DH
KeyFactory.DSA
KeyFactory.DSA
KeyFactory.RSA
KeyFactory.X.509
KeyGenerator.1.2.840.113549.3.7
KeyGenerator.2.16.840.1.101.3.4.1.1
KeyGenerator.2.16.840.1.101.3.4.1.2
KeyGenerator.2.16.840.1.101.3.4.1.21
KeyGenerator.2.16.840.1.101.3.4.1.22
KeyGenerator.2.16.840.1.101.3.4.1.23
KeyGenerator.2.16.840.1.101.3.4.1.24
KeyGenerator.2.16.840.1.101.3.4.1.25
KeyGenerator.2.16.840.1.101.3.4.1.3
KeyGenerator.2.16.840.1.101.3.4.1.4
KeyGenerator.2.16.840.1.101.3.4.1.41
KeyGenerator.2.16.840.1.101.3.4.1.42
KeyGenerator.2.16.840.1.101.3.4.1.43
KeyGenerator.2.16.840.1.101.3.4.1.44
KeyGenerator.2.16.840.1.101.3.4.1.45
KeyGenerator.2.16.840.1.101.3.4.1.5
KeyGenerator.2.16.840.1.101.3.4.2
KeyGenerator.2.16.840.1.101.3.4.22
KeyGenerator.2.16.840.1.101.3.4.42
KeyGenerator.AES
KeyGenerator.AESWRAP
KeyGenerator.DES
KeyGenerator.DESEDE
KeyGenerator.DESEDEWRAP
KeyGenerator.HMACMD5
KeyGenerator.HMACSHA1
KeyGenerator.HMACSHA224
KeyGenerator.HMACSHA256
KeyGenerator.HMACSHA384
KeyGenerator.HMACSHA512
KeyManagerFactory.X509
KeyPairGenerator.DH
KeyPairGenerator.DSA
KeyPairGenerator.RSA
KeyStore.BCPKCS12
KeyStore.BKS
KeyStore.BouncyCastle
KeyStore.PKCS12
KeyStore.PKCS12-DEF
Mac.DESEDEMAC
Mac.DESEDEMAC/CFB8
Mac.DESEDEMAC64
Mac.DESMAC
Mac.DESMAC/CFB8
Mac.DESWITHISO9797
Mac.HMACMD5
Mac.HMACSHA1
Mac.HMACSHA224
Mac.HMACSHA256
Mac.HMACSHA384
Mac.HMACSHA512
Mac.ISO9797ALG3MAC
Mac.PBEWITHHMACSHA
Mac.PBEWITHHMACSHA1
MessageDigest.MD5
MessageDigest.SHA-1
MessageDigest.SHA-1
MessageDigest.SHA-224
MessageDigest.SHA-256
MessageDigest.SHA-384
MessageDigest.SHA-512
SSLContext.TLS
SecretKeyFactory.DES
SecretKeyFactory.DESEDE
SecretKeyFactory.PBEWITHHMACSHA1
SecretKeyFactory.PBEWITHMD5AND128BITAES-CBC-OPENSSL
SecretKeyFactory.PBEWITHMD5AND192BITAES-CBC-OPENSSL
SecretKeyFactory.PBEWITHMD5AND256BITAES-CBC-OPENSSL
SecretKeyFactory.PBEWITHMD5ANDDES
SecretKeyFactory.PBEWITHMD5ANDRC2
SecretKeyFactory.PBEWITHSHA1ANDDES
SecretKeyFactory.PBEWITHSHA1ANDRC2
SecretKeyFactory.PBEWITHSHA256AND128BITAES-CBC-BC
SecretKeyFactory.PBEWITHSHA256AND192BITAES-CBC-BC
SecretKeyFactory.PBEWITHSHA256AND256BITAES-CBC-BC
SecretKeyFactory.PBEWITHSHAAND128BITAES-CBC-BC
SecretKeyFactory.PBEWITHSHAAND192BITAES-CBC-BC
SecretKeyFactory.PBEWITHSHAAND2-KEYTRIPLEDES-CBC
SecretKeyFactory.PBEWITHSHAAND256BITAES-CBC-BC
SecretKeyFactory.PBEWITHSHAAND3-KEYTRIPLEDES-CBC
SecretKeyFactory.PBEWITHSHAAND40BITRC2-CBC
SecureRandom.SHA1PRNG
Signature.1.2.840.113549.1.1.10
Signature.DSA
Signature.MD4WithRSAEncryption
Signature.MD5WithRSAEncryption
Signature.MD5withRSA/ISO9796-2
Signature.NONEWITHDSA
Signature.RSASSA-PSS
Signature.SHA1WithRSAEncryption
Signature.SHA1withDSA
Signature.SHA1withDSA ImplementedIn
Signature.SHA1withRSA/ISO9796-2
Signature.SHA1withRSA/PSS
Signature.SHA224WithRSAEncryption
Signature.SHA224withRSA/PSS
Signature.SHA256WithRSAEncryption
Signature.SHA256withRSA/PSS
Signature.SHA384WithRSAEncryption
Signature.SHA384withRSA/PSS
Signature.SHA512WithRSAEncryption
Signature.SHA512withRSA/PSS
TrustManagerFactory.X509
Program stub
Provider p[] = Security.getProviders();
for (int i = 0; i < p.length; i++) {
 log("Security Provider [" + i + "]");
 log("Name: " + p[i].getName()
     + " Version: " + p[i].getVersion()
     + " Info: " + p[i].getInfo());
 log("Keys: " + i);
 for (Enumeration e = p[i].keys(); e.hasMoreElements();) {
     log("    " + e.nextElement());
 }
}
Filter
$ cat Samsung-i5800-security-providers.log | sort \
| cut -b 39- | grep -v Provider | grep -v ImplementedIn

This is the original Bouncy Castle 1.34 specification.
Bouncy Castle Crypto Package

Bouncy Castle Crypto Package


1.0 Introduction

The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. The package is organised so that it contains a light-weight API suitable for use in any environment (including the newly released J2ME) with the additional infrastructure to conform the algorithms to the JCE framework.

This software is distributed under a license based on the MIT X Consortium license. To view the license, see here

If you have the full package you will have six jar files, bcprov*.jar which contains the BC provider, jce-*.jar which contains the JCE provider, clean room API, and bcmail*.jar which contains the mail API.

Note: if you are using JDK 1.0, you will just find a class hierarchy in the classes directory.

To view examples, look at the test programs in the packages:

  • org.bouncycastle.crypto.test
  • org.bouncycastle.jce.provider.test

To verify the packages, run the following Java programs with the appropriate classpath:

  • java org.bouncycastle.crypto.test.RegressionTest
  • java org.bouncycastle.jce.provider.test.RegressionTest

2.0 Patents

Some of the algorithms in the Bouncy Castle APIs are patented in some places. It is upon the user of the library to be aware of what the legal situation is in their own situation, however we have been asked to specifically mention the patent below at the request of the patent holder.

The IDEA encryption algorithm is patented in the USA, Japan, and Europe including at least Austria, France, Germany, Italy, Netherlands, Spain, Sweden, Switzerland and the United Kingdom. Non-commercial use is free, however any commercial products that make use of IDEA are liable for royalties. Please see www.mediacrypt.com for further details.

3.0 Specifications

  • clean room implementation of the JCE API
  • light-weight cryptographic API consisting of support for
    • BlockCipher
    • BufferedBlockCipher
    • AsymmetricBlockCipher
    • BufferedAsymmetricBlockCipher
    • StreamCipher
    • BufferedStreamCipher
    • KeyAgreement
    • IESCipher
    • Digest
    • Mac
    • PBE
    • Signers
  • JCE compatible framework for a Bouncy Castle provider

4.0 Light-weight API

This API has been specifically developed for those circumstances where the rich API and integration requirements of the JCE are not required.

However as a result, the light-weight API requires more effort and understanding on the part of a developer to initialise and utilise the algorithms.

4.1 Example

To utilise the light-weight API in a program, the fundamentals are as follows;



 /*
  * This will use a supplied key, and encrypt the data
  * This is the equivalent of DES/CBC/PKCS5Padding
  */
 BlockCipher engine = new DESEngine();
 BufferedBlockCipher cipher = new PaddedBlockCipher(new CBCCipher(engine));

 byte[] key = keyString.getBytes();
 byte[] input = inputString.getBytes();

 cipher.init(true, new KeyParameter(key));

 byte[] cipherText = new byte[cipher.getOutputSize(input.length)];
 
 int outputLen = cipher.processBytes(input, 0, input.length, cipherText, 0);
 try
 {
  cipher.doFinal(cipherText, outputLen);
 }
 catch (CryptoException ce)
 {
  System.err.println(ce);
  System.exit(1);
 }

4.2 Algorithms

The light-weight API has built in support for the following:

Symmetric (Block)

The base interface is BlockCipher and has the following implementations which match the modes the block cipher can be operated in.

NameConstructorNotes
BufferedBlockCipherBlockCipher
CBCBlockCipherBlockCipher
CFBBlockCipherBlockCipher, block size (in bits)
OFBBlockCipherBlockCipher, block size (in bits)
SICBlockCipherBlockCipher, block size (in bits)Also known as CTR mode
OpenPGPCFBBlockCipherBlockCipher
GOFBBlockCipherBlockCipherGOST OFB mode

BufferedBlockCipher has a further sub-classes

NameConstructorNotes
PaddedBufferedBlockCipherBlockCiphera buffered block cipher that can use padding - default PKCS5/7 padding
CTSBlockCipherBlockCipherCipher Text Stealing

The following paddings can be used with the PaddedBufferedBlockCipher.

NameDescription
PKCS7PaddingPKCS7/PKCS5 padding
ISO10126d2PaddingISO 10126-2 padding
X932PaddingX9.23 padding
ISO7816d4PaddingISO 7816-4 padding (ISO 9797-1 scheme 2)
ZeroBytePaddingPad with Zeros (not recommended)

The following cipher engines are implemented that can be used with the above modes.

NameKeySizes (in bits) Block SizeNotes
AESEngine0 .. 256 128 bit
AESWrapEngine0 .. 256 128 bitImplements FIPS AES key wrapping
BlowfishEngine0 .. 448 64 bit
CAST5Engine0 .. 128 64 bit
CAST6Engine0 .. 256 128 bit
DESEngine6464 bit
DESedeEngine128, 19264 bit
DESedeWrapEngine128, 19264 bitImplements Draft IETF DESede key wrapping
IDEAEngine12864 bit
RC2Engine0 .. 1024 64 bit
RC532Engine0 .. 128 64 bitUses a 32 bit word
RC564Engine0 .. 128 128 bitUses a 64 bit word
RC6Engine0 .. 256 128 bit
RijndaelEngine0 .. 256 128 bit, 160 bit, 192 bit, 224 bit, 256 bit
SkipjackEngine0 .. 128 64 bit
TwofishEngine128, 192, 256 128 bit
SerpentEngine128, 192, 256 128 bit
GOST28147Engine25664 bitHas a range of S-boxes
CamelliaEngine128, 192, 256128 bit

Symmetric (Stream)

The base interface is StreamCipher and has the following implementations which match the modes the stream cipher can be operated in.

NameConstructorNotes
BlockStreamCipherBlockCipher

The following cipher engines are implemented that can be used with the above modes.

NameKeySizes (in bits) Notes
RC4Engine40 .. 2048

Block Asymmetric

The base interface is AsymmetricBlockCipher and has the following implementations which match the modes the cipher can be operated in.

NameConstructorNotes
BufferedAsymmetricBlockCipherAsymmetricBlockCipher
OAEPEncodingAsymmetricBlockCipher
PKCS1EncodingAsymmetricBlockCipher
ISO9796d1EncodingAsymmetricBlockCipherISO9796-1

The following cipher engines are implemented that can be used with the above modes.

NameKeySizes (in bits)Notes
RSAEngineany multiple of 8 large enough for the encoding.
ElGamalEngineany multiple of 8 large enough for the encoding.

Digest

The base interface is Digest and has the following implementations

NameOutput (in bits)Notes
MD2Digest128
MD4Digest128
MD5Digest128
RipeMD128Digest128basic RipeMD
RipeMD160Digest160enhanced version of RipeMD
RipeMD256Digest256expanded version of RipeMD128
RipeMD320Digest320expanded version of RipeMD160
SHA1Digest160
SHA224Digest224FIPS 180-2
SHA256Digest256FIPS 180-2
SHA384Digest384FIPS 180-2
SHA512Digest512FIPS 180-2
TigerDigest192The Tiger Digest.
GOST3411Digest256The GOST-3411 Digest.
WhirlpoolDigest512The Whirlpool Digest.

MAC

The base interface is Mac and has the following implementations

NameOutput (in bits)Notes
CBCBlockCipherMacblocksize/2 unless specified
CFBBlockCipherMacblocksize/2, in CFB 8 mode, unless specified
HMacdigest length

PBE

The base class is PBEParametersGenerator and has the following sub-classes

NameConstructorNotes
PKCS5S1ParametersGeneratorDigest
PKCS5S2ParametersGenerator Uses SHA1/Hmac as defined
PKCS12ParametersGeneratorDigest
OpenSSLPBEParametersGenerator Uses MD5 as defined

Key Agreement

Two versions of Diffie-Hellman key agreement are supported, the basic version, and one for use with long term public keys. Two versions of key agreement using Elliptic Curve cryptography are also supported, standard Diffie-Hellman key agreement and standard key agreement with co-factors.

The agreement APIs are in the org.bouncycastle.crypto.agreement package. Classes for generating Diffie-Hellman parameters can be found in the org.bouncycastle.crypto.params and org.bouncycastle.crypto.generators packages.

IESCipher

The IES cipher is based on the one described in IEEE P1363a (draft 10), for use with either traditional Diffie-Hellman or Elliptic Curve Diffie-Hellman.

Note: At the moment this is still a draft, don't use it for anything that may be subject to long term storage, the key values produced may well change as the draft is finalised.

Signers

DSA, ECDSA, ISO-9796-2, GOST-3410-94, GOST-3410-2001, and RSA-PSS are supported by the org.bouncycastle.crypto.signers package. Note: as these are light weight classes, if you need to use SHA1 or GOST-3411 (as defined in the relevant standards) you'll also need to make use of the appropriate digest class in conjunction with these. Classes for generating DSA and ECDSA parameters can be found in the org.bouncycastle.crypto.params and org.bouncycastle.crypto.generators packages.

4.3 ASN.1 package

The light-weight API has direct interfaces into a package capable of reading and writing DER-encoded ASN.1 objects and for the generation of X.509 V3 certificate objects and PKCS12 files. BER InputStream and OutputStream classes are provided as well.

5.0 Bouncy Castle Provider

The Bouncy Castle provider is a JCE compliant provider that is a wrapper built on top of the light-weight API.

The advantage for writing application code that uses the provider interface to cryptographic algorithms is that the actual provider used can be selected at run time. This is extremely valuable for applications that may wish to make use of a provider that has underlying hardware for cryptographic computation, or where an application may have been developed in an environment with cryptographic export controls.

5.1 Example

To utilise the JCE provider in a program, the fundamentals are as follows;


 /*
  * This will generate a random key, and encrypt the data
  */
 Key  key;
 KeyGenerator keyGen;
 Cipher  encrypt;

 Security.addProvider(new BouncyCastleProvider());

 try
 {
  // "BC" is the name of the BouncyCastle provider
  keyGen = KeyGenerator.getInstance("DES", "BC");
  keyGen.init(new SecureRandom());

  key = keyGen.generateKey();

  encrypt = Cipher.getInstance("DES/CBC/PKCS5Padding", "BC");
 }
 catch (Exception e)
 {
  System.err.println(e);
  System.exit(1);
 }

 encrypt.init(Cipher.ENCRYPT_MODE, key);

 bOut = new ByteArrayOutputStream();
 cOut = new CipherOutputStream(bOut, encrypt);

 cOut.write("plaintext".getBytes());
 cOut.close();

 // bOut now contains the cipher text

The provider can also be configured as part of your environment via static registration by adding an entry to the java.security properties file (found in $JAVA_HOME/jre/lib/security/java.security, where $JAVA_HOME is the location of your JDK/JRE distribution). You'll find detailed instructions in the file but basically it comes down to adding a line:


   security.provider.<n>=org.bouncycastle.jce.provider.BouncyCastleProvider


Where <n> is the preference you want the provider at (1 being the most prefered).

Where you put the jar is up to mostly up to you, although with jdk1.3 and jdk1.4 the best (and in some cases only) place to have it is in $JAVA_HOME/jre/lib/ext. Note: under Windows there will normally be a JRE and a JDK install of Java if you think you have installed it correctly and it still doesn't work chances are you have added the provider to the installation not being used.

Note: with JDK 1.4 and later you will need to have installed the unrestricted policy files to take full advantage of the provider. If you do not install the policy files you are likely to get something like the following:


       java.lang.SecurityException: Unsupported keysize or algorithm parameters
               at javax.crypto.Cipher.init(DashoA6275)
The policy files can be found at the same place you downloaded the JDK.

5.2 Algorithms

Symmetric (Block)

Modes:

  • ECB
  • CBC
  • OFB(n)
  • CFB(n)
  • SIC (also known as CTR)
  • OpenPGPCFB
  • CTS (equivalent to CBC/WithCTS)
  • GOFB

Where (n) is a multiple of 8 that gives the blocksize in bits, eg, OFB8. Note that OFB and CFB mode can be used with plain text that is not an exact multiple of the block size if NoPadding has been specified.

Padding Schemes:

  • No padding
  • PKCS5/7
  • ISO10126/ISO10126-2
  • ISO7816-4/ISO9797-1
  • X9.23/X923
  • TBC
  • ZeroByte
  • withCTS (if used with ECB mode)

When placed together this gives a specification for an algorithm as;

  • DES/CBC/X9.23Padding
  • DES/OFB8/NoPadding
  • IDEA/CBC/ISO10126Padding
  • IDEA/CBC/ISO7816-4Padding
  • SKIPJACK/ECB/PKCS7Padding
  • DES/ECB/WithCTS

Note: default key sizes are in bold.

NameKeySizes (in bits) Block SizeNotes
AES0 .. 256 (192)128 bit
AESWrap0 .. 256 (192)128 bitA FIPS AES key wrapper
Blowfish0 .. 448 (448)64 bit
CAST50 .. 128(128)64 bit
CAST60 .. 256(256)128 bit
DES6464 bit
DESede128, 19264 bit
DESedeWrap128, 192128 bitA Draft IETF DESede key wrapper
IDEA128 (128)64 bit
RC20 .. 1024 (128)64 bit
RC50 .. 128 (128)64 bitUses a 32 bit word
RC5-640 .. 256 (256)128 bitUses a 64 bit word
RC60 .. 256 (128)128 bit
Rijndael0 .. 256 (192)128 bit
Skipjack0 .. 128 (128)64 bit
Twofish128, 192, 256 (256)128 bit
Serpent128, 192, 256 (256)128 bit
GOST2814725664 bit
Camellia128, 192, 256128 bit

Symmetric (Stream)

Note: default key sizes are in bold.

NameKeySizes (in bits)Notes
RC440 .. 2048 bits (128)

Block Asymmetric

Encoding:

  • OAEP - Optimal Asymmetric Encryption Padding
  • PCKS1 - PKCS v1.5 Padding
  • ISO9796-1 - ISO9796-1 edition 1 Padding

Note: except as indicated in PKCS 1v2 we recommend you use OAEP, as mandated in X9.44.

When placed together with RSA this gives a specification for an algorithm as;

  • RSA/NONE/NoPadding
  • RSA/NONE/PKCS1Padding
  • RSA/NONE/OAEPWithMD5AndMGF1Padding
  • RSA/NONE/OAEPWithSHA1AndMGF1Padding
  • RSA/NONE/OAEPWithSHA224AndMGF1Padding
  • RSA/NONE/OAEPWithSHA256AndMGF1Padding
  • RSA/NONE/OAEPWithSHA384AndMGF1Padding
  • RSA/NONE/OAEPWithSHA512AndMGF1Padding
  • RSA/NONE/ISO9796-1Padding
NameKeySizes (in bits)Notes
RSAany multiple of 8 bits large enough for the encryption(2048)
ElGamalany multiple of 8 bits large enough for the encryption(1024)

Key Agreement

Diffie-Hellman key agreement is supported using the "DH", "ECDH", and "ECDHC" (ECDH with cofactors) key agreement instances.

Note: with basic "DH" only the basic algorithm fits in with the JCE API, if you're using long-term public keys you may want to look at the light-weight API.

ECIES

An implementation of ECIES (stream mode) as described in IEEE P 1363a.

Note: At the moment this is still a draft, don't use it for anything that may be subject to long term storage, the key values produced may well change as the draft is finalised.

Digest

NameOutput (in bits)Notes
GOST3411256
MD2128
MD4128
MD5128
RipeMD128128basic RipeMD
RipeMD160160enhanced version of RipeMD
RipeMD256Digest256expanded version of RipeMD128
RipeMD320Digest320expanded version of RipeMD160
SHA1160
SHA-224224FIPS 180-2
SHA-256256FIPS 180-2
SHA-384384FIPS 180-2
SHA-512512FIPS 180-2
Tiger192
Whirlpool512

MAC

NameOutput (in bits)Notes
Any MAC based on a block cipher, CBC (the default) and CFB modes.half the cipher's block size (usually 32 bits)
HMac-MD2128
HMac-MD4128
HMac-MD5128
HMac-RipeMD128128
HMac-RipeMD160160
HMac-SHA1160
HMac-SHA224224
HMac-SHA256256
HMac-SHA384384
HMac-SHA512512
HMac-Tiger192

Examples:

  • DESMac
  • DESMac/CFB8
  • DESedeMac
  • DESedeMac/CFB8
  • DESedeMac64
  • SKIPJACKMac
  • SKIPJACKMac/CFB8
  • IDEAMac
  • IDEAMac/CFB8
  • RC2Mac
  • RC2Mac/CFB8
  • RC5Mac
  • RC5Mac/CFB8
  • ISO9797ALG3Mac

Signature Algorithms

Schemes:

  • GOST3411withGOST3410 (GOST3411withGOST3410-94)
  • GOST3411withECGOST3410 (GOST3411withGOST3410-2001)
  • MD2withRSA
  • MD5withRSA
  • SHA1withRSA
  • RIPEMD128withRSA
  • RIPEMD160withRSA
  • RIPEMD256withRSA
  • SHA1withDSA
  • SHA1withECDSA
  • SHA224withECDSA
  • SHA256withECDSA
  • SHA384withECDSA
  • SHA512withECDSA
  • SHA224withRSA
  • SHA256withRSA
  • SHA384withRSA
  • SHA512withRSA
  • SHA1withRSAandMGF1
  • SHA256withRSAandMGF1
  • SHA384withRSAandMGF1
  • SHA512withRSAandMGF1

PBE

Schemes:

  • PKCS5S1, any Digest, any symmetric Cipher, ASCII
  • PKCS5S2, SHA1/HMac, any symmetric Cipher, ASCII
  • PKCS12, any Digest, any symmetric Cipher, Unicode

Defined in Bouncy Castle JCE Provider

NameKey Generation SchemeKey Length (in bits)
PBEWithMD5AndDESPKCS5 Scheme 164
PBEWithMD5AndRC2PKCS5 Scheme 1128
PBEWithSHA1AndDESPKCS5 Scheme 164
PBEWithSHA1AndRC2PKCS5 Scheme 1128
PBEWithSHAAnd2-KeyTripleDES-CBCPKCS12128
PBEWithSHAAnd3-KeyTripleDES-CBCPKCS12192
PBEWithSHAAnd128BitRC2-CBCPKCS12128
PBEWithSHAAnd40BitRC2-CBCPKCS1240
PBEWithSHAAnd128BitRC4PKCS12128
PBEWithSHAAnd40BitRC4PKCS1240
PBEWithSHAAndTwofish-CBCPKCS12256
PBEWithSHAAndIDEA-CBCPKCS12128

5.3 Certificates

The Bouncy Castle provider will read X.509 certficates (v2 or v3) as per the examples in the java.security.cert.CertificateFactory class. They can be provided either in the normal PEM encoded format, or as DER binaries.

The CertificiateFactory will also read X.509 CRLs (v2) from either PEM or DER encodings.

In addition to the classes in the org.bouncycastle.ans1.x509 package for certificate generation a more JCE "friendly" class is provided in the package org.bouncycastle.jce. The JCE "friendly" class supports RSA, DSA, and EC-DSA.

5.4 Keystore

The Bouncy Castle package has three implementation of a keystore.

The first "BKS" is a keystore that will work with the keytool in the same fashion as the Sun "JKS" keystore. The keystore is resistent to tampering but not inspection.

The second, Keystore.BouncyCastle, or Keystore.UBER will only work with the keytool if the password is provided on the command line, as the entire keystore is encrypted with a PBE based on SHA1 and Twofish. PBEWithSHAAndTwofish-CBC. This makes the entire keystore resistant to tampering and inspection, and forces verification. The Sun JDK provided keytool will attempt to load a keystore even if no password is given, this is impossible for this version. (One might wonder about going to all this trouble and then having the password on the command line! New keytool anyone?).

In the first case, the keys are encrypted with 3-Key-TripleDES.

The third is a PKCS12 compatabile keystore. PKCS12 provides a slightly different situation from the regular key store, the keystore password is currently the only password used for storing keys. Otherwise it supports all the functionality required for it to be used with the keytool. In some situations other libraries always expect to be dealing with Sun certificates, if this is the case use PKCS12-DEF, and the certificates produced by the key store will be made using the default provider.

There is an example program that produces PKCS12 files suitable for loading into browsers. It is in the package org.bouncycastle.jce.examples.

5.5 Additional support classes for Elliptic Curve.

There are no classes for supporting EC in the JDK prior to JDK 1.5. If you are using an earlier JDK you can find classes for using EC in the following packages:

  • org.bouncycastle.jce.spec
  • org.bouncycastle.jce.interfaces
  • org.bouncycastle.jce

6.0 BouncyCastle S/MIME

To be able to fully compile and utilise the BouncyCastle S/MIME package (including the test classes) you need the jar files for the following APIs.

6.1 Setting up BouncyCastle S/MIME in JavaMail

The BouncyCastle S/MIME handlers may be set in JavaMail two ways.
  • STATICALLY Add the following entries to the mailcap file:
       application/pkcs7-signature;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.pkcs7_signature
       application/pkcs7-mime;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.pkcs7_mime
       application/x-pkcs7-signature;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.x_pkcs7_signature
       application/x-pkcs7-mime;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.x_pkcs7_mime
       multipart/signed;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.multipart_signed
       
  • DYNAMICALLY The following code will add the BouncyCastle S/MIME handlers dynamically:
       import javax.activation.MailcapCommandMap;
       import javax.activation.CommandMap;
    
       public static void setDefaultMailcap()
       {
           MailcapCommandMap _mailcap =
               (MailcapCommandMap)CommandMap.getDefaultCommandMap();
    
           _mailcap.addMailcap("application/pkcs7-signature;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.pkcs7_signature");
           _mailcap.addMailcap("application/pkcs7-mime;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.pkcs7_mime");
           _mailcap.addMailcap("application/x-pkcs7-signature;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.x_pkcs7_signature");
           _mailcap.addMailcap("application/x-pkcs7-mime;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.x_pkcs7_mime");
           _mailcap.addMailcap("multipart/signed;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.multipart_signed");
    
           CommandMap.setDefaultCommandMap(_mailcap);
       }