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
2
votes
0 answers

Bouncycastle/Spongycastle Tls with PSK

I have a problem with my implementation with spongycastle using tls with psk. I get a psk from a webservice and try to connect to the webserver. In my HttpTransportLayer class I create a socket with the server address and the port. Then i create an…
2
votes
1 answer

How should one encrypt data on Android in 2014?

I would like to encrypt and decrypt data using public/private key pairs in a native Java app for Android. I am having trouble wading through old posts / documentation. From my understanding: Early versions of Android used a crippled version of the…
latj
  • 616
  • 1
  • 6
  • 23
2
votes
1 answer

Bouncycastle (Spongycastle) key import and use on android

Having imported a PGP key using SpongyCastle and checked that I can decrypt using it, I want to add a password to secure the keyring. So I make an encrypted copy: secretKeyRing = PGPSecretKeyRing.copyWithNewPassword(secretKeyRing, new char[] {}, …
Tom Macdonald
  • 6,433
  • 7
  • 39
  • 59
2
votes
2 answers

Creating an elliptic curve point object from coordinates

I have the x and y coordinate of a point and the name of a curve. I now want to create an org.bouncycastle.jce.interfaces.ECPublicKey object from that, automatically using the implementation that is provided. The goal is to be able to create the…
Sibbo
  • 3,796
  • 2
  • 23
  • 41
2
votes
1 answer

Using Spongy Castle library to generate a key pair in ECDH

I am a student in Taiwan. I am learning how to programming in Android. but I have a problem about using Spongy Castle library to generate a key pair in ECDH. when I start the app, android system shows the app has stopped. Here is my code and my…
PTTjanice001
  • 43
  • 1
  • 11
2
votes
2 answers

How to fix error of Spongy Castle on Android: could not find class java.awt.datatransfer.DataFlavor

I use lib Spongy Castle for signing and encrypting mail on Android according to this example. /* Add BC */ Security.addProvider(new BouncyCastleProvider()); /* Open the keystore */ KeyStore keystore =…
tungdt.bk
  • 21
  • 1
  • 2
2
votes
1 answer

Spongy Castle has any Android SDK requirements?

I intend to use Spongy Castle for my project, but I have a simple doubt about the minimum Android SDK version that I must use. Also I would like to know if there's any restriction for device capabilities... Thanks in advance!
JavierSP1209
  • 899
  • 8
  • 17
1
vote
1 answer

Why does Spongy Castle ignore the bcpg and openpgp packages

Does anyone know why SpongyCastle is explicitly excluding openpgp and bcpg packages (amongst others) from being built? I would like to get OpenPGP support working and I will require a number of those classes to do so. You can find the exclusions in…
senecaso
  • 273
  • 2
  • 10
1
vote
2 answers

Determining attributes of flutter encrypt.dart

I am using encrypt.dart to AES encrypt a string ("text") based on a 32 digit password ("password") as follows: encryptPass(String text, String password) { final key = getKey(password); final iv = encrypt.IV.fromLength(16); final encrypter =…
metamonkey
  • 427
  • 7
  • 33
1
vote
1 answer

Generate 33 bytes public key for curve25519 in python

Using Java's spongycastle, i am able to generate curve25519 private keys(32 bytes) and public keys(33 bytes). Similarly for Python, i am using Nacl library for curve25519 but here public key generated is of 32 bytes only. The one byte of y…
1
vote
1 answer

Need basic encryption understanding from existing Android code

I am new in Android and I have started to working on existing project which have some encryption algorithm, Below is existing code var secureRandom = SecureRandom() var masterKey = ByteArray(32) secureRandom.nextBytes(masterKey) var…
1
vote
0 answers

I have got below security alert from play store

• Security alert Your app contains unsafe cryptographic encryption patterns. Please see this Google Help Center article for details. Vulnerable classes: o …
nilesh
  • 11
  • 3
1
vote
0 answers

How to add AttCertValidityPeriod to PKCS10CertificationRequest CSR and retrieve it back from CSR?

I am implementing a sample code to generate CSR and sign it with a certificate. I have a requirement to add validity period as a attribute on generating the CSR and read this in the signing part to sign according to this.how can I add this attribute…
1
vote
3 answers

java.security.NoSuchAlgorithmException: no such algorithm: ECDSA for provider BC

I am trying to generate a secp256k1 keypair with KeyPairGenerator function. My function looks like public fun generateSECP256K1Keypair():KeyPair{ Security.addProvider(org.bouncycastle.jce.provider.BouncyCastleProvider()) var keypairGen:…
Naveen Kumar
  • 141
  • 3
  • 11
1
vote
1 answer

Is decoding of PKCS8 key from Base64 encoded ASN1 structure fault tolerant?

I'm using Spongy Castle library to encode my users private key (PKCS8) into an ASN1 entity and afterwards as Base64 encoded string into a QR code. One of my colleagues found out that it's possible to change some characters in the Base64 string…