spongycastle

RSA using SpongyCastle

半世苍凉 提交于 2019-11-30 10:37:21
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' | openssl rsautl -encrypt -pubin -inkey test.pub | base64 > encrypted_file It should be noted that the reading/writing to and from files in the command are not going to be implemented and I have my public key (i.e. test.pub ) as a Base64 encoded string base64key in my code. I have attempted the following but am certain it does not work: static { Security

Creating an Https connecion with Client Side Certificate from PKCS#10 with SpongyCastle

放肆的年华 提交于 2019-11-30 07:42:36
The goal I'm working on implementing communication with Client-Certificate. Step 1: Create a PKCS#10 request (CSR) and give it to the my server for signing. The server contacts passes the CSR to the CA, and the CA signs it, and returns a PKCS#7 (with the signed PKCS#10 and the CA's certificate). Step 2: Create a PKCS#12, store it securely on the Android device Step 3: Create SSL connection so that the client will be authenticated according to the certificate. Now, Step 1 works perfectly using SpongyCastle 1.50.0.0, but I'm stuck on the other steps... I'm currently getting an SSL-Handshake

Export RSA public key to PEM String using java

半腔热情 提交于 2019-11-30 05:33:02
问题 So I'm using Spongy Castle (Android) to generate a PEM encoded string for an RSA public key that will be uploaded to a server. This is what I'm currently doing: PublicKey publicKey = keyPair.getPublic(); StringWriter writer = new StringWriter(); PemWriter pemWriter = new PemWriter(writer); pemWriter.writeObject(new PemObject("RSA PUBLIC KEY", publicKey.getEncoded())); pemWriter.flush(); pemWriter.close(); return writer.toString(); Now as you can probably tell I'm not sure how to construct the

Generating PublicKey from x and y values of elliptic curve point

♀尐吖头ヾ 提交于 2019-11-30 03:53:15
问题 I am trying to generate a shared secret in my app like this: public static byte[] generateSharedSecret(PrivateKey privateKey PublicKey publicKey) { KeyAgreement keyAgreement = KeyAgreement.getInstance("ECDH", "SC"); keyAgreement.init(privateKey); keyAgreement.doPhase(publicKey, true); return keyAgreement.generateSecret(); } This is working fine, but the PublicKey I use here should be coming from the backend. The backend just sends me the x and y value of a point on an elliptic curve and now I

Client Certificate not working from Android - How to debug?

 ̄綄美尐妖づ 提交于 2019-11-29 12:41:13
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 followed the code there and code from this blog post , describing the same scenario, more or less, without results. What doesn't work: Opening an SSL Connection ( HttpsURLConnection ) between the Android Client and the Server causes the server to return an 403 status code . AFAIK, this 403 is because the server doesn't get or doesn't trust the Client

Creating an Https connecion with Client Side Certificate from PKCS#10 with SpongyCastle

梦想与她 提交于 2019-11-29 10:27:23
问题 The goal I'm working on implementing communication with Client-Certificate. Step 1: Create a PKCS#10 request (CSR) and give it to the my server for signing. The server contacts passes the CSR to the CA, and the CA signs it, and returns a PKCS#7 (with the signed PKCS#10 and the CA's certificate). Step 2: Create a PKCS#12, store it securely on the Android device Step 3: Create SSL connection so that the client will be authenticated according to the certificate. Now, Step 1 works perfectly using

Android to server communication using SSL with Bouncy Castle

為{幸葍}努か 提交于 2019-11-27 23:23:17
I understand this is something which is not so difficult but very unfortunately I am stuck here and fighting it since yesterday, I have followed this Mutual Authentication in Android tutorial, to place a keystore in resources and trying to connect to my server over SSL, but getting the following exception java.lang.RuntimeException: org.spongycastle.jcajce.provider.asymmetric.x509.CertificateFactory$ExCertificateException I have placed my sslapptruststore.pfx file under res/raw/sslapptruststore.pfx and using this piece of code try { KeyStore clientCert = KeyStore.getInstance("PKCS12");

How to include the Spongy Castle JAR in Android?

≡放荡痞女 提交于 2019-11-26 08:07:30
问题 Apparently Spongy Castle is the Android alternative to using a full version of Bouncy Castle. However, on importing the jar I\'m getting all kinds of \"cannot be resolved\" errors because it relies on packages not included with Android, primarily javax.mail, javax.activation, and javax.awt.datatransfer. So what\'s the best way around this? Responses to this question and this indicate those packages shouldn\'t be used at all, and this popular question doesn\'t even consider finding a way to