bouncycastle

BouncyCastle Cryptography provider library used with applet on Java 7u40

蹲街弑〆低调 提交于 2019-12-18 11:12:30
问题 The case: I am maintaining a Java applet which uses the BouncyCastle libraries bcpkix-jdk15on-149.jar , and bcprov-jdk15on-149.jar . Problem is when the applet is run on a JRE version 7_u40 enabled browser. The behavior has changed from version 7_u25 in a way that it always prompts a modal window like "Security prompt for an app using a self-signed certificate" (which cannot be permanently hidden anymore), just to trust bcprov . https://www.java.com/en/download/help/appsecuritydialogs.xml As

Reading PEM RSA Public Key Only using Bouncy Castle

狂风中的少年 提交于 2019-12-18 10:45:03
问题 I am trying to use C# to read in a .pem file that contains only a RSA public key. I do not have access to the private key information, nor does my application require it. The file myprivatekey.pem file begins with -----BEGIN PUBLIC KEY----- and ends with -----END PUBLIC KEY----- . My current code is as follows: Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair keyPair; using (var reader = File.OpenText(@"c:\keys\myprivatekey.pem")) keyPair = (Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair)new

An example of encrypting an xml file in Java using bouncy castle

白昼怎懂夜的黑 提交于 2019-12-18 10:24:07
问题 Can anyone show me (or provide a link to) an example of how to encrypt a file in Java using bouncy castle? I've looked over bouncycastle.org but cannot find any documentation of their API. Even just knowing which classes to use would be a big help for me to get started! 回答1: What type of encryption do you want to perform? Password-based (PBE), symmetric, asymmetric? Its all in how you configure the Cipher. You shouldn't have to use any BouncyCastle specific APIs, just the algorithms it

Generate ECPublicKey from ECPrivateKey

别等时光非礼了梦想. 提交于 2019-12-18 07:07:27
问题 I'm trying to generate a public key given a private key and known curve. Below is my code: // Generate Keys ECGenParameterSpec ecGenSpec = new ECGenParameterSpec("secp256r1"); KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("ECDSA", "BC"); keyPairGenerator.initialize(ecGenSpec, new SecureRandom()); java.security.KeyPair pair = keyPairGenerator.generateKeyPair(); ECPrivateKey privateKey = (ECPrivateKey) pair.getPrivate(); ECPublicKey publicKeyExpected = (ECPublicKey) pair

C# serialize a class without a parameterless constructor

戏子无情 提交于 2019-12-18 05:46:09
问题 I'm implementing a factory pattern for 3 different cryptography classes. The factory will determine which one to create and then get a serialized instance of the correct class from a database and return it to the requester. Right now I'm working on serializing the classes to store them in the database. I'm writing one for a PGP cryptography class called BouncyCastle . I can create the class and the keys from files but when I try to serialize it, it says that the two member variables, which

How to validate Distinguish Name(DN) in Java?

六眼飞鱼酱① 提交于 2019-12-18 05:25:34
问题 I am trying to validate DN in java. So far I have tried to validate it using Bouncy castle libry private boolean isValidDn(String dn) { try { X509Name name = new X509Name(dn); return true; } catch (IllegalArgumentException e) { } return false; } This code is working but the problem is this code allows to have multiple CN. For example: this code return true for CN=first,CN=second,ou=org,ou=org2,c=US But I want validation that return true only if there is one cn,ou,o,c etc.. Any help would be

Encrypt/Decrypt using Bouncy Castle in C#

大兔子大兔子 提交于 2019-12-18 03:08:43
问题 I am using the "BouncyCastle.Crypto.dll" for encrypt/decrypt a string in my app. I am using the following code from this blog: I have a class BCEngine, exactly the same as the one given in the link mentioned above. public class BCEngine { private readonly Encoding _encoding; private readonly IBlockCipher _blockCipher; private PaddedBufferedBlockCipher _cipher; private IBlockCipherPadding _padding; public BCEngine(IBlockCipher blockCipher, Encoding encoding) { _blockCipher = blockCipher;

Bad Padding Exception - RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING in pkcs11

故事扮演 提交于 2019-12-18 03:03:11
问题 My application is accessing e-Token for decrypting the response coming from the server The session key from the server is encrypted using :- RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING I am using SunPKCS11 Provider for implementing the access to crypto token. Whenever i try to decrypt this using the above mechanishm i.e. with RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING i am getting :- **javax.crypto.BadPaddingException: doFinal() failed at sun.security.pkcs11.P11RSACipher.implDoFinal(P11RSACipher.java

Bad Padding Exception - RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING in pkcs11

半城伤御伤魂 提交于 2019-12-18 03:03:11
问题 My application is accessing e-Token for decrypting the response coming from the server The session key from the server is encrypted using :- RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING I am using SunPKCS11 Provider for implementing the access to crypto token. Whenever i try to decrypt this using the above mechanishm i.e. with RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING i am getting :- **javax.crypto.BadPaddingException: doFinal() failed at sun.security.pkcs11.P11RSACipher.implDoFinal(P11RSACipher.java

Converting an RSA Public Key into a RFC 4716 Public Key with Bouncy Castle

痞子三分冷 提交于 2019-12-17 18:59:56
问题 I am looking to convert an RSA public key into something that I could use as an SSH public key. Currently I have Bouncy Castle producing me a public key that looks like this: -----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq1Y5300i8bN+cI2U3wJE Kh3xG/.........jbuz+WB0vvG P25UwCle2k5siVMwbImEYsr+Xt0dsMmGVB3/6MHAqrM3QQdQ8p2E5TyzL+JYa1FT gwIDAQAB -----END PUBLIC KEY----- I want it to have an RFC 4716 format similar to this: ssh-rsa AAAAB3NzaC1yc2......