bouncycastle

java sign public pgp key with bouncycastle

大兔子大兔子 提交于 2019-12-09 20:56:28
问题 I've got a doubt.. I have to sign a pgp public key using bouncycastle api supposedly. Now: to my understanding signing a key with another means ultimately adding to this public key a "certificate". Thus lacking any other way, I've gone blind searching in the library. my only find so far has been method generateCertification inside PGPSignatureGenerator. But this method generate a certification between a master PgpPublicKey and another PgpPublicKey.. And this strikes me as strange: I assumed

Why keyStore.aliases() is empty for pkcs12

只谈情不闲聊 提交于 2019-12-09 18:36:22
问题 I'm trying to load PrivateKey from .p12 file by using this code: Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); java.security.KeyStore keyStore = KeyStore.getInstance("PKCS12", "BC"); keyStore.load(new FileInputStream(new File("my_domain_com.p12")), password); keyStore.aliases().hasMoreElements(); //this is false java.security.PrivateKey privateKey = (PrivateKey) keyStore.getKey("SomeAlias", password); I'm trying to find the reason why there is no aliases. But

Smartcard CMS Decrypt

白昼怎懂夜的黑 提交于 2019-12-09 06:53:15
问题 I'm using Bouncycastle to manage the Encrypt function of my project. I managed out to use CMS for encrypt and decrypt where both key are stored in my file system (a .cert and a .p12 ). These are the two function I'm actually using: private static byte[] CmsEncrypt(byte[] message) { var envelopGenerator = new CmsEnvelopedDataGenerator(); var certificateStream = new FileStream("Test.cer", FileMode.Open, FileAccess.Read); var cert = new X509CertificateParser().ReadCertificate(certificateStream);

How to get PublicKey from PKCS10CertificationRequest using new Bouncy Castle library?

佐手、 提交于 2019-12-09 05:59:42
问题 In the new version of Bouncy Castle library there are changes in PKCS10CertificationRequest . In previous versions it was possible to get PublicKey from such request using getPublicKey() method (see old doc). Now this method disappered. How can I get PublicKey from with from such request? There is getSubjectPublicKeyInfo().parsePublicKey() but it returns ASN1Primitive . I see that from SPKAC NetscapeCertRequest I still can read PublicKey directly by calling getPublicKey() . 回答1: There is a

RSA signing and verification with C#,BouncyCastle and imported RSA key - Working Python example and non-working C# code sample inside

孤街浪徒 提交于 2019-12-09 05:56:30
问题 I have been tearing what is left of my hair out trying to get a trivial example of RSA data signing and verification with C# and BouncyCastle working. RSACryptoServiceProvider.VerifyHash() always returns false on an example that works for me with Python and M2Crypto. I have verified that the hash signatures are identical between the working example and the C# example and it is there I am stuck. I feel I am missing some vital detail. The working Python code and non working C# code follow. The

AES 256bit encryption with Bouncy Castle: Unlimited Strength Policy still required?

五迷三道 提交于 2019-12-09 01:27:24
问题 I want to use AES 256bit encryption with Bouncy Castle and I'm wondering if the "Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files" are still required despite BC because I'm receiving a java.security.InvalidKeyException: Illegal key size exception for the following code: public class AES256 { public static void main(String[] args) throws Exception { Security.addProvider(new BouncyCastleProvider()); final KeyGenerator keyGen = KeyGenerator.getInstance("AES");

Cryptography and Authentication via TLS with Web of Trust in Java

假装没事ソ 提交于 2019-12-08 22:10:14
问题 For a program I am writing, I would like to use TLS (or something similar) to encapsulate my application's protocol. This will minimize both the amount of work I have to do as well as the number of vulnerabilities I could accidentally create. My program is designed to be peer-to-peer although one or more servers provide some services to help one user locate another (it registers IP address/port combos) but do little else. I want to make this system very fault-tolerant so having these servers

decrypt TLS 1.2 AES-GCM packet

一曲冷凌霜 提交于 2019-12-08 17:36:12
问题 I'm working on a Java program to decrypt a TLS 1.2 Session which is using the TLS_RSA_WITH_AES_128_GCM_SHA256 cipher. I recorded a test session using wireshark. The Master Secret is known. No. Time Protocol Length Info 4 0.000124000 TLSv1.2 166 Client Hello 6 0.000202000 TLSv1.2 1074 Server Hello, Certificate, Server Hello Done 8 0.001071000 TLSv1.2 393 Client Key Exchange, Change Cipher Spec, Finished 9 0.003714000 TLSv1.2 301 New Session Ticket, Change Cipher Spec, Finished 11 6.443056000

sign the message and verify with recover message by Bouncy Castle

五迷三道 提交于 2019-12-08 14:48:39
问题 I write the following code for signing the message and then verify it, in java by Bouncy Castle. signing work properly but verifying not work. the result of code print: signature tampered can not recover and return null. why eng.hasFullMessage() function return false and why the following code doesn't work? thanks all. public static String sigVer(PublicKey pu, PrivateKey pr, String original) throws Exception{ //sign BigInteger big = ((RSAKey) pu).getModulus(); byte[] text = original.getBytes(

Publickey from bouncycastle RSAKeyParameters

ぃ、小莉子 提交于 2019-12-08 13:32:46
问题 I have the following code that reads a CSR from a string and outputs the public key in a PEM format. I also need to get the public key as java RSAPublickey but I can't work out how to do this. import org.bouncycastle.crypto.params.RSAKeyParameters; import org.bouncycastle.crypto.util.PublicKeyFactory; import org.bouncycastle.pkcs.PKCS10CertificationRequest; import org.bouncycastle.util.io.pem.PemObject; import org.bouncycastle.util.io.pem.PemReader; import org.bouncycastle.util.io.pem