Questions tagged [spongycastle]

a repackage of the Bouncy Castle Java cryptographic libraries, targeted specificlly at Android

The Android platform unfortunately ships with a cut-down version of Bouncy Castle - as well as being crippled, it also makes installing an updated version of the libraries difficult due to classloader conflicts.

Spongy Castle is the stock Bouncy Castle libraries with a couple of small changes to make it work on Android:

  • all package names have been moved from org.bouncycastle.* to org.spongycastle.* - to avoid classloader conflicts the Java Security
  • API Provider name is now SC rather than BC no class names change, so
  • the BouncyCastleProvider class remains Bouncy, not Spongy, but moves to the org.spongycastle.jce.provider package.

In general Spongy Castle should be a drop-in replacement for Bouncy Castle, but there are a couple of pain points:

  • ProGuard can often remove crucial classes from the Spongy Castle libs (internally, Bouncy Castle uses a lot of class-loading-by-name, which means ProGuard will over-aggressively remove it's classes). ProGuard config must be tweaked to keep the appropriate classes for whatever crypto algorithms you need.
  • Not all classes from Oracle Java are present on Android - for example, missing AWT classes block usage of the S/MIME API.
119 questions
1
vote
0 answers

Spongycastle write certificate to PEM then read it

I'm having trouble with reading a PEM file of a certificate that I generated and wrote to disk with SpongyCastle. I'm saving my certificate with the following function private static void saveCertificate(Context context, X509CertificateHolder…
SnyersK
  • 1,296
  • 8
  • 23
1
vote
1 answer

SpongyCastle Provider loads SHA1withRSA algorithm, but still not available

I am using SpongCastle Provider v1.51. I added following maven to my project which are as follows(only relevant to SpongyCastle) Based on answer here from StackOverflow, Already have added SpongyCastle PGP to maven pom file. I am still testing on…
Akhil Jain
  • 13,872
  • 15
  • 57
  • 93
1
vote
0 answers

Android: How to read Digital Signature Certificates from a secured USB token

I have a requirement of reading the certificates that are installed on a USB token which is connected to the android device (Phone/tablet). The USB dongle also has associated public and private keys with it. For this, Should I use UsbInterface,…
1
vote
0 answers

Mina sshd and spongycastle: KeyPairGenerator EC implementation not found

I'm trying to use mina sshd 0.12.0 on android using spongycastle 1.51. I've followed the instructions available, registered Spongycastle using static { Security.insertProviderAt( new org.spongycastle.jce.provider.BouncyCastleProvider(),…
atheb
  • 11
  • 2
1
vote
0 answers

OpenSSL and Java elliptic curve keys compatibility

I have C application that has to generate elliptic curve private key and export it for Java application that uses Spongycastle. I need that my application produces completely the same keys as Spongycastle, so I use in OpenSSL the same format as…
Vitalii
  • 4,434
  • 4
  • 35
  • 77
1
vote
1 answer

UnsupportedDataTypeException: no object DCH for MIME type application/pkcs7-mime

I am trying to create encrypted mail on Android, using: Javamail libs from here, SpongyCastel libs Core-1.51.0.0.jar, pg-1.51.0.0.jar, pkix-1.51.0.0.jar, prov-1.51.0.0.jar & scmail-jdk15on-1.47.0.3.jar. Below is the code [copied from spongycastel…
Rajesh N
  • 21
  • 3
1
vote
1 answer

Client Certificate not working from Android - How to debug?

I'm trying to implement a Client Certificates communication for an Android App, so far without much success - and it seems that this feature is, if at all possible, very hard. The full flow I'm implementing is described in my previous question. I…
Felix
  • 1,034
  • 1
  • 9
  • 29
1
vote
2 answers

Read encrypted PKCS8 SpongyCastle Java

I am following the code in: https://stackoverflow.com/a/18161536/1753951 but I am getting an Exception in the following line: FileInputStream fis = new FileInputStream(priv); DataInputStream dis = new DataInputStream(fis); byte[] keyBytes = new…
Alan Faz
  • 142
  • 14
1
vote
1 answer

RSA using SpongyCastle

My knowledge of encryption is very basic, so apologies for any ignorance on my part. Within an Android app I am currently trying to mimic the execution of this command using the SpongyCastle library and standard java.security libs: echo 'test' |…
Ed Holloway-George
  • 5,092
  • 2
  • 37
  • 66
1
vote
1 answer

ECDSA for Android using SpongyCastle

I've just added SpongyCastle to Eclipse for my Android Project, however I don't seem to be able to find a single good/complete example of how to use ECDSA for encryption & decryption of plain texts. I would imagine this should be a 'hello world' for…
1
vote
1 answer

iText SpongyCastle error

I've tried this with various versions of itext including itextgoogle with a trial license, and I keep getting the following error when I try to run my code: InputStream object = this.getResources().openRawResource(R.raw.itextkey); …
1
vote
1 answer

Setting up an SSLContext using Spongy Castle

How can I set up an SSLContext with TLS using Spongy Castle? I'm searching online but cannot find any good examples.
Phillip
  • 5,366
  • 10
  • 43
  • 62
1
vote
1 answer

Fail to add Spongycastle as provider in android

I am trying to make use of spongycastle and followed all the help I could get to include it but when the application execute it crashes at the code where I add it as a provider: static { Security.addProvider(new…
LJB
  • 47
  • 9
0
votes
1 answer

Why ECDSA verification fails in Android using Spongy Castle?

I am trying to verify a signature in Android using spongy castle. This dependency has been added to gradle as: implementation group: 'com.madgag.spongycastle', name: 'bcpkix-jdk15on', version: '1.58.0.0' When running below code in Android Flamingo…
MJay
  • 987
  • 1
  • 13
  • 36
0
votes
1 answer

Sign data in PKCS#7 format using SpongyCastle

I'm trying to sign a String in PKCS#7 format with SpongyCastle (using these dependencies "com.madgag.spongycastle:core:1.58.0.0" and "com.madgag.spongycastle:pkix:1.54.0.0") in Android. Here is my key pair generation code: KeyPairGenerator…