bouncycastle

BouncyCastle on the server side with Android phones as clients

不打扰是莪最后的温柔 提交于 2019-12-06 16:16:14
I'm currently having some difficulties with getting BouncyCastle to work. Been searching on this for a couple of days now, so I'm hoping you can provide any helpful insights. Here's the set-up. Using REST-protocol, the Android-client sends POST-messages to the server. I made a separate project with classes representing these messages, so that I can include this as a library on both the client and the server. The message-objects are first parsed to a JSON-string and afterwards interpreted on the server. For the sake of data-integrity, a message contains a digital signature (DSA). I asked a

Can I use BouncyCastle's Tweakable Block Ciphers using the standard Java Cipher API?

最后都变了- 提交于 2019-12-06 14:46:02
问题 BouncyCastle provides an implementation of Threefish, which can take a tweak as a parameter: ThreeFishEngine engine = new ThreeFishEngine(256); engine.init(true, new TweakableBlockCipherParams(...)); However, TweakableBlockCipherParams is not compatible with the AlgorithmParameter type that is used by instances of Java's default Cipher . Is there a way to initialize this cipher with a tweak? Cipher cipher = Cipher.getInstance("Threefish-256/CBC/NoPadding"); cipher.init(???); 回答1: You can only

Using BouncyCastle for a simple HTTPS query

谁说胖子不能爱 提交于 2019-12-06 14:25:43
Here's a simplified version of the code I'm using to perform simple HTTPS requests: // Assume the variables host, file and postData have valid String values final URL url = new URL("https", host, file); final HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); connection.setDoInput(true); connection.setDoOutput(true); connection.setRequestProperty("Content-length", String.valueOf(postData.length())); final DataOutputStream output = new DataOutputStream(connection.getOutputStream()); output.writeBytes(postData); output.close(); final

Unable to cast object of type 'Org.BouncyCastle.Asn1.DerSequence' to type 'Org.BouncyCastle.Asn1.DerInteger'

可紊 提交于 2019-12-06 13:58:56
in my c # project, I put this piece of code : initially, I recovered from the certificate that I created with bouncy castle, the key pair, then I extract the private key, my goal is that , it is in a format. pem, AsymmetricKeyParameter private_RSA = keyPair2.Private; PrivateKeyInfo k_RSA = PrivateKeyInfoFactory.CreatePrivateKeyInfo(private_RSA); byte[] serializedKey_priv_RSA = k_RSA.ToAsn1Object().GetDerEncoded(); // byte[] clé = Org.BouncyCastle.Utilities.Encoders.Hex.Decode(serializedKey); string data_priv_RSA = Convert.ToBase64String(serializedKey_priv_RSA); using (fluxInfos2 = new

Creating Custom X509 v3 Extensions in Java with Bouncy Castle

浪子不回头ぞ 提交于 2019-12-06 13:51:48
问题 I have successfully used the X509v3CertificateBuilder Java class from Bouncy Castle to create X509 certificates with standard V3 extensions. I am now trying to create certificates with custom extensions. I can create a custom extension using the addExtension(...) method, however, the resulting value in the certificate is not what I want. For example, I would like these exact octets listed in the certificate under a custom OID 1.2.3.4: "00 00 00 00 FF FF FF FF". Everything I try wraps that

Getting No such algorithm exception while using TLSV1.2 in java 1.4

杀马特。学长 韩版系。学妹 提交于 2019-12-06 13:49:23
问题 I am trying to hit a webservice which supports TLSv1.2. I am using Java 1.4. It does not support TLSv1.2. Now someone told me that BC could solve my problem. Though does it work with a SSLEngine as drop in replacement somehow? Is this possible with BC? What do I have to do to get a working SSLEngine (for use with TLSv1 in a nonblocking io scenario) without such low restrictions on primesize for DH. What I tried: Security.addProvider(new BouncyCastleProvider()); This alone seems not to solve

Export EC private key from BouncyCastle and import into CngKey or ECDsaCng?

荒凉一梦 提交于 2019-12-06 13:35:09
I have created key pairs for elliptic curve DSA signatures using BouncyCastle and managed to import the public key into ECDsaCng using an XMLString accoding to RFC4050 . Now I want to also move the private key and have not managed to find a solution. The closest I have got is using CngKey.Import. CngKey.Import supports PKCS#8 format so if you can get your keys into valid pkcs8 then it should work. Unfortunately the following code does not quite work. var privatekey = (ECPrivateKeyParameters) keyPair.Private; var pkinfo = PrivateKeyInfoFactory.CreatePrivateKeyInfo(privatekey); byte[] pkcs8Blob

TLS 1.2 + C# + BouncyCastle

柔情痞子 提交于 2019-12-06 13:25:50
To support TLS 1.1 and above on WinCE we are using BouncyCastle library, but when making a connection it throws error "Internal TLS error, this could be an attack". Can someone advice on this. TcpClient client = new TcpClient(); client.Connect(resolvedIpAddr, PORT_TLS_11); Org.BouncyCastle.Security.SecureRandom sr = new Org.BouncyCastle.Security.SecureRandom(); TlsProtocolHandler handler = new TlsProtocolHandler(client.GetStream(), sr); handler.Connect(new MyTlsClient()); 来源: https://stackoverflow.com/questions/33776495/tls-1-2-c-sharp-bouncycastle

Bouncy Castle i cannot get all certificate

江枫思渺然 提交于 2019-12-06 12:56:04
I'm trying to read certificate from smime.p7s file, the certificate chain is: Baltimora Cyber Trust --> DigitPA --> Aruba PEC So when i'm trying to extract, I retrieve only the last two certificate, the last like subject and the first like issuer. What am I wrong? the code: private List<CertificateInfo> reading(ASN1InputStream asn1Stream) throws IOException, CMSException, CertificateException { ArrayList<CertificateInfo> infos = new ArrayList<CertificateInfo>(); ASN1Primitive obj = asn1Stream.readObject(); ContentInfo contentInfo = ContentInfo.getInstance(obj); CMSSignedData cms = new

AES decryption with bouncy castle

ⅰ亾dé卋堺 提交于 2019-12-06 12:44:58
问题 I am attempting to adapt the sample code at http://www.java2s.com/Code/Java/Security/Basicsymmetricencryptionexample.htm to have to be invoked with 3 arguments, the mode (encryption or decryption), IV and the key. It also reads and writes to specific files. As of right now I am ignoring the given IV and key until I get the rest up and running. My code successfully encrypts plaintext from a file, and writes the ciphertext to a file, but the decryption does not work. It appears that decryption