bouncycastle

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

北城以北 提交于 2019-12-21 21:38:41
问题 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 = KeyStore.getInstance("PKCS12", "SC"); keystore.load(new FileInputStream(pkcs12Keystore), password.toCharArray()); Certificate[] chain = keystore.getCertificateChain(keyalias); /* Get the private key to sign the message with */ PrivateKey privateKey = (PrivateKey) keystore.getKey(keyalias,

Using encryption that would need Java Policy Files in openjre

喜你入骨 提交于 2019-12-21 20:56:07
问题 if i want to use java and encryption with keys longer than 128bit i have to use the Java Policy Files. How to get those applications up and running with openjre? I get the same error i get using oracle jre without policy files, but i can't simply use the Oracle Policy Files? or can i? Or would building the project with openjdk help? Thank You 回答1: I found the following. It seems to solve all the policy problems i ever had. try { Field field = Class.forName("javax.crypto.JceSecurity")

Java BouncyCastle ECC Keys and Self Signed Certificates

孤人 提交于 2019-12-21 16:47:12
问题 I've been scouring the internet for hours looking for a Java example for creating Elliptic Curve (EC) keys and self signed certificates. So far I've only found snippets and examples, many of which do not work. UPDATE: I've made some progress here, here's my code for anybody that might find it useful! Just need to work out how to self sign it now! import org.bouncycastle.asn1.x500.X500Name; import org.bouncycastle.jce.ECNamedCurveTable; import org.bouncycastle.jce.provider.BouncyCastleProvider

Combining All of the Tasks Needed to Verify a PKCS#7 Signature

£可爱£侵袭症+ 提交于 2019-12-21 15:01:01
问题 I've been banging my head against the wall with this problem for about 20 hours now and I am probably missing something easy. However, I've gotten to the point where I think I need help. I have read dozens of explanations for how to do different parts of the problem, but I cannot figure out how to bring them all together. I have a DER-encoded detached PKCS#7 digital signature. The signature conforms to RFC 3852 (Cryptographic Message Syntax). For my project I need to step through each of the

Combining All of the Tasks Needed to Verify a PKCS#7 Signature

蹲街弑〆低调 提交于 2019-12-21 14:59:51
问题 I've been banging my head against the wall with this problem for about 20 hours now and I am probably missing something easy. However, I've gotten to the point where I think I need help. I have read dozens of explanations for how to do different parts of the problem, but I cannot figure out how to bring them all together. I have a DER-encoded detached PKCS#7 digital signature. The signature conforms to RFC 3852 (Cryptographic Message Syntax). For my project I need to step through each of the

OCSP response does not give Certificate Status

孤街浪徒 提交于 2019-12-21 09:25:25
问题 I created an OCSP client using Bouncy castle API. I am having a trouble in finding the Certificate Status (Saying whether its revoked or not) from the OCSP response I get. The value returned from resp.getCertStatus() is always null. This is how I create the OCSP request. private OCSPReq generateOCSPRequest(X509Certificate issuerCert, BigInteger serialNumber) throws CertificateVerificationException { //Add provider BC Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider(

Generate AES key without password using BouncyCastle

旧巷老猫 提交于 2019-12-21 06:08:22
问题 I need to generate a key to use when encrypting a file symmetrically using AES256/CBC The key itself will be encrypted with RSA public/private so I don't need a password applied. In Java, this seems to be done as follows: SecureRandom random = new SecureRandom(); byte[] keyBytes = new byte[32]; //32 Bytes = 256 Bits random.nextBytes(keyBytes); SecretKeySpec key = new SecretKeySpec(keyBytes, "AES"); However, SecretKeySpec isn't defined in the C# BouncyCastle library available via NuGet. What's

java.lang.IllegalArgumentException: string curve25519 not an OID bouncycastle 1.52

亡梦爱人 提交于 2019-12-21 05:40:53
问题 I'm trying to generate a key pair using the /java bouncy castle 1.52 implementation for curve 25519 what gives me java.lang.IllegalArgumentException: string curve25519 not an OID Here is my code: public KeyPair generateKeys() throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("curve25519"); KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", "BC"); g.initialize(ecSpec, new

Verify rsa.SignPKCS1v15 signature generated in golang in Java

故事扮演 提交于 2019-12-21 05:40:45
问题 I am trying to get Java to verify a signed SHA-1 hash but it keeps returning false. I have the following code in Go which generates an RSA Key Pair and signs and returns any message that hits the /sign endpoint along with the hex encoded hash and the public key modulus and exponent: package main import ( "crypto" "crypto/rand" "crypto/rsa" "encoding/hex" "encoding/json" "fmt" "io" "net/http" "strconv" ) var PrivKey *rsa.PrivateKey type Message struct { Message string `json:"message"` } func

Elliptic curve point

痴心易碎 提交于 2019-12-21 05:40:17
问题 Presently iam working on a project that uses elliptic curve. Please provide me a solution that determines whether a point is on the elliptic curve or not? and also how to get a point on the elliptic curve 回答1: Checking whether a point is on the elliptic curve is easy. Just check whether your point (x,y) fulfills the equation defining your elliptic curve : y^2 = x^3 + ax + b (remember to perform the calculation in the correct field). Using Bouncycastle you can do it like this: ECCurve curve =