bouncycastle

Get Start with BouncyCastle crypto dll c#

帅比萌擦擦* 提交于 2019-12-31 23:13:10
问题 I'm starter with cryptography I woul like to use BouncyCastle .dll for c# but I cannot found documentation and examples. In particulary I need to use to sign files with pkcs#7 (.p7m results) and add to them RFC 3161–compliant, time stamps from trusted server (.m7m results). somebody can suggest where I can found examples and documentation to do this ? Thanking in advance Best regards 回答1: I put together this little example for another question here on #SO, but it applies to you as well: using

Java ECDSAwithSHA256 signature with inconsistent length

倖福魔咒の 提交于 2019-12-31 05:31:26
问题 So I am trying to generate an ECDSAwithHA256 signature in Java, and for that, I am using the BouncyCastle provider. The curve is a secp521r1. To initalize the signer I am using: public static final String SIGNATURE_ALGORITHEM = "SHA256withECDSA"; public void init() { signer = Signature.getInstance(SIGNATURE_ALGORITHEM, BouncyCastleProvider.PROVIDER_NAME); signer.initSign(privKey); } And to sign I am using public byte[] sign(byte[] bytes) throws SignatureException { signer.update(bytes); byte[

How can I generate a valid ECDSA EC key pair?

半世苍凉 提交于 2019-12-31 02:45:29
问题 I am trying to generate ECDSA key pair using SpongyCastle in Android. This is the code: static { Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1); } public static KeyPair generate() { ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("prime256v1"); KeyPairGenerator generator = KeyPairGenerator.getInstance("ECDSA", "SC"); generator.initialize(ecSpec, new SecureRandom()); KeyPair keyPair = g.generateKeyPair(); Log.i(TAG, "EC Pub Key generated: " +

Trouble integrating BouncyCastle Jar

江枫思渺然 提交于 2019-12-30 08:13:33
问题 Okay, I'll say now that I know very little about Java. I was given the Bouncy Castle Jar and told that would contain what I needed to do this assignment. The Jar file is bcprov-jdk15on-147.jar . I'm also doing this on a Unix machine maintained by my school, so I can't go in and play with all of the Java files. When I compile my class using Javac (specifically I use the command javac -classpath bcprov-jdk15on-147.jar encrypt.java ), it compiles without error, but when I go to run the program

Exception on decrypting file using BouncyCastle PGP

廉价感情. 提交于 2019-12-30 07:13:35
问题 I was trying to decrypt this sample file given by the client, using a class called PgpDecrypt. But when the code comes to this line: Stream clear = pbe.GetDataStream(privKey); it returns an error: exception decrypting secret key Here's my decryption code: PgpDecrypt test = new PgpDecrypt(string.Concat(pathh, "TestDecryptionFile"), string.Concat(pathh, "mypgpprivatekey.key"), "mypassphrase", @"d:/test/", string.Concat(pathh, "clientpublickey.key")); FileStream fs = File.Open(string.Concat

Compare PublicKey object in java

不羁岁月 提交于 2019-12-30 04:58:27
问题 I have two PublicKey object.I want to compare both for equality or to check which is latest object using java security API or bouncy castle API.How can i achieve this? 回答1: You can use equals if (!key.equals(copyKey)){ System.out.println("not equals!"); } or check the hashcode of the keys if (key.hashCode() != copyKey.hashCode()) { System.out.println("public key hashCode check failed"); } or compare the hex string of the two public keys String encodedKey1 = new String(Hex.encode(key1

Read SSL Certificate Details on WP8

我与影子孤独终老i 提交于 2019-12-30 04:58:08
问题 I want to read certificate details (e.g. expiration date or CN) for security reasons. Usually there are some properties in network classes available, that allow to check the certificate. This is missing in WP8 implementations. Also I tried to create an SslStream but also there is no way to get any certificate detail like the RemoteCertificate on .net 4.5. var sslStream = new SslStream(new NetworkStream(e.ConnectSocket)); The SslStream is missing everything relating security. So it looks like

Detecting incorrect key using AES/GCM in JAVA

陌路散爱 提交于 2019-12-30 03:33:08
问题 I'm using AES to encrypt/decrypt some files in GCM mode using BouncyCastle. While I'm proving wrong key for decryption there is no exception. How should I check that the key is incorrect? my code is this: SecretKeySpec incorrectKey = new SecretKeySpec(keyBytes, "AES"); IvParameterSpec ivSpec = new IvParameterSpec(ivBytes); Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding", "BC"); byte[] block = new byte[1048576]; int i; cipher.init(Cipher.DECRYPT_MODE, incorrectKey, ivSpec);

PartialInputStream during Bouncycastle PGP decryption

浪子不回头ぞ 提交于 2019-12-29 08:02:11
问题 I am tryng to decrypt a file I just encrypted using bouncycastle, but im getting this exception: Premature end of stream in PartialInputStream I am using the example code from bouncycastle and haven't changed anything. I'm getting this when I use this code for encryption: private static byte[] EncryptFile(byte[] clearData, string fileName, PgpPublicKey encKey, bool withIntegrityCheck) { MemoryStream encOut = new MemoryStream(); try { MemoryStream bOut = new MemoryStream();

Using BouncyCastle's ChaCha for file encryption

不羁的心 提交于 2019-12-29 06:30:11
问题 I'm hoping to encrypt a few files using ChaCha, so I wonder if it's appropriate to use Chacha20Poly1305. It seems that this class is designed for TLS, so does that mean it's not designed for file encryption? The methods inside, e.g., encodePlaintext() and decodeCiphertext() appear to work with text rather than binary files. If that's the case, does anyone know how to work with BC's ChaCha implementation for file encryption? 回答1: You can simply use the ChaChaEngine class that is referenced by