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
0
votes
1 answer

Validating PKCS#7 detached signature on Android using BouncyCastle [NoSuchAlgorithmException: no such algorithm: 1.2.840.113549.1.1.11]

Currently trying to validate a PKCS#7 signature, where the verified content is the SHA-256 hash of a file and receiving the below error. Error org.bouncycastle.cms.CMSException: can't create digest calculator: exception on setup:…
Bill Zangardi
  • 93
  • 1
  • 7
0
votes
0 answers

How to fix or avoid "RSA engine faulty decryption/signing detected" error when signing in java

I am trying to sign a string using basic RSA code with SpongyCastle on android: Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1); ... Signature sign = Signature.getInstance("SHA256withRSA"); …
mnesarco
  • 2,619
  • 23
  • 31
0
votes
1 answer

Timestamp request with OkHttp

I'm trying to make a post call to a Timestamp server but getting a 500. This is my code: Security.addProvider(new BouncyCastleProvider()); TimeStampRequestGenerator reqGen = new TimeStampRequestGenerator(); …
Jaime Alcántara Arnela
  • 2,062
  • 5
  • 25
  • 56
0
votes
1 answer

Android Q bouncy castle issue

From API level 28, Google has restricted Security provider feature(bouncy castle issue). So alternatively we have added Security provider using spongy castle Now we can able to generate a keypair. But the key pair is not matching with the previous…
user11415509
0
votes
1 answer

JSCEP-Wrong 3rd argument type. Found: 'org.spongycastle.pkcs.PKCS10CertificationRequest', required: 'org.bouncycastle.pkcs.PKCS10CertificationRequest'

I'm implementing Jscep for android. Initially, I tried Jscep for java and it worked fine. Now in Android, I used SpongyCastle instead of BouncyCastle. Now my problem is that the enrol method of Client class is using BouncyCastle. And so when I try…
Saravana Kumar
  • 140
  • 2
  • 16
0
votes
1 answer

Using SpongyCastle Provider on AndroidStudio

I am trying to write an ECDH code for my android app. As a starting point, I managed to instal lSpongyCastle Jar's on my AndroidStudion, but now I am having an issue when I run: KeyPairGenerator aliceKeyGen = KeyPairGenerator.getInstance("ECDH",…
user4674659
0
votes
0 answers

PemWriter does not write before pemWriter.close()

I am using the spongyCastle library in my Android class and I have the following implementation: StringWriter stringWriter = new StringWriter(); PemWriter pemWriter = new PEMWriter(stringWriter); pemWriter.writeObject(someObject); //Printing the…
arnav bhartiya
  • 303
  • 1
  • 3
  • 9
0
votes
2 answers

Cannot find any provider supporting AES/CBC/ISO7816-4Padding in unit tests

I'm using SpongyCastle to support the transformation AES/CBC/ISO7816-4Padding. I have included the following dependencies in the build.gradle file of the Android project: compile "com.madgag.spongycastle:core:1.58.0.0" compile…
Diego Palomar
  • 6,958
  • 2
  • 31
  • 42
0
votes
1 answer

Android BouncyCastle (SpongyCastle) HTTPS POST request

I am trying to login to my TLS1.2 server on an old Android device running Jellybean 4.1.2, with the BouncyCastle (SpongyCastle) library, but it doesn't work. That version of Android does not have TLS enabled by default, so I needed the 3rd party lib…
eoinzy
  • 2,152
  • 4
  • 36
  • 67
0
votes
0 answers

Using SHA512 but signature algorithm is SHA1 with spongycastle

I am using the CsrHelper class from here: Certificate enrollment process but my default_signature_algorithm is sha512withrsa. Although, when I put the csr in a file to analyse it using openssl's tool to analyze the csr: openssl req -in file.txt…
0
votes
1 answer

How to create AsymmetricKeyParameter from the java.security.PublicKey

I am trying to remove the spongy castle provider from my cryptography class and to use the Spongy castle light library directly (maven:com.madgag:sc-light-jdk15on:1.47.0.3) I have a problem during changing a RSA encrypt logic, below is the code…
Prabhakaran
  • 1,264
  • 2
  • 20
  • 47
0
votes
1 answer

Read/Write Certificate Signing Request on Android (spongycastle)

I try to write code on Android to generate RSA key-pair and then generate Certificate Request file (.csr) like this image below: First I use spongycastle lib to generate Key Pair (public key and private key) KeyPairGenerator keyPairGenerator =…
ThanhLam112358
  • 878
  • 1
  • 20
  • 51
0
votes
1 answer

Create PrivateKey from base64 string ECDSA private key

I have ECDSA private key string in base64 (i check this string with regexp from this https://stackoverflow.com/a/8571649/7661555 answer). And i try to generate PrivateKey instance from this string. I include SpongyCastle in my project, and try to…
0
votes
0 answers

Java: BouncyCastle - SpongyCastle and Conditional Compiling

Thanks to Android shipping its own, outdated versions of the BouncyCastle crypto libraries I'm in an ugly situation. I've built a library that talks REST to our own webservice where data is encrypted and decrypted on the fly by the client. The…
Robert Lohr
  • 635
  • 8
  • 21
0
votes
1 answer

UnsupportedOperationException raised on Android 4.4 when signing/checking signature using SpongyCastle

The following piece of code throws an UnsupportedOperationException when executed on Android 4.4 but it works fine on Android 5 and 6 (tested on device and emulator). The exception is thrown on the setParameter. Signature signature =…
Pierre Leonard
  • 265
  • 2
  • 13