private-key

Java: write and read password based encrypted private key

给你一囗甜甜゛ 提交于 2019-12-06 12:41:40
问题 I am trying to read a password based encrypted private key from a file, but I'm getting the following exception: java.io.IOException: DerInputStream.getLength(): lengthTag=109, too big. at sun.security.util.DerInputStream.getLength(DerInputStream.java:561) at sun.security.util.DerValue.init(DerValue.java:365) at sun.security.util.DerValue.<init>(DerValue.java:294) at javax.crypto.EncryptedPrivateKeyInfo.<init>(EncryptedPrivateKeyInfo.java:84) ... This is how I encrypt and write to file the

CryptographicException in RSA.ImportParameters() - Bad Data in special 1024 keys

僤鯓⒐⒋嵵緔 提交于 2019-12-06 11:15:25
问题 We have a C#/.Net 4.0 application which imports RSA Private Keys from a String in Base64 received in a WebService. This application works perfectly for RSA-Keys in 1024 bits, but doesn't with a special kind of rsa private keys (around 1% of keys). Here are the byte lengths: Working-Key: Modulus => 128 Bytes Exponent => 3 Bytes D => 128 Bytes P => 64 Bytes Q => 64 Bytes DP => 64 Bytes DQ => 64 Bytes IQ => 64 Bytes Not-Working-Key: Modulus => 128 Bytes Exponent => 3 Bytes D => 127 Bytes P => 64

Generate RSA key pair using WebCrypto API and protect it with passphrase

ε祈祈猫儿з 提交于 2019-12-06 11:09:08
问题 title says it all. I was wondering how do I generate RSA key pair using WebCrypto API and how do I secure it with a passphrase so I can store it in a database. 回答1: You can generate an RSA key pair with WebCrypto and export it as jwk (Json Web Key), pkcs#8 (private) or spki (public). See SubtleCrypto.exportKey() and the example code bellow To export the key to an external system in a protected way you could use an standard like: PKCS#8: The PKCS#8 private key format defined at IETF Public Key

How to recover lost private key of instance of aws server?

本秂侑毒 提交于 2019-12-06 09:26:14
问题 I have lost private key of my AWS instance.I searched the option in console panel. 回答1: I'm afraid you might be out of luck: When you launch an instance, you should specify the name of the key pair you plan to use to connect to the instance. If you don't specify the name of an existing key pair when you launch an instance, you won't be able to connect to the instance. When you connect to the instance, you must specify the private key that corresponds to the key pair you specified when you

Java byte array to ECCPrivateKey - InvalidKeySpecException: encoded key spec not recognised

一世执手 提交于 2019-12-06 09:05:32
When I try to make ECC private key from byte array, I get exception mentioned below. I have public/private keys and out signed output from C library micro-ecc/uECC.h. C used secp192r1 curve. I am trying to verify data with C generated keys in Java. How to convert byte array to private/public key? Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); byte[] kb = new byte[]{(byte)0x24, (byte)0xF4, (byte)0x36, (byte)0x16, (byte)0xD0, (byte)0x96, (byte)0x12, (byte)0x63, (byte)0x90, (byte)0x2E, (byte)0x51, (byte)0xF6, (byte)0x87, (byte)0x55, (byte)0xAB, (byte)0xCB, (byte

Casting private key to RSACryptoServiceProvider not working

核能气质少年 提交于 2019-12-06 08:17:48
I have a X509Certificate2 variable and I'm trying to cast the private key of the variable to a RSACryptoServiceProvider RSACryptoServiceProvider pkey = (RSACryptoServiceProvider)cert.PrivateKey; However I get this exception. System.InvalidCastException: 'Unable to cast object of type 'System.Security.Cryptography.RSACng' to type 'System.Security.Cryptography.RSACryptoServiceProvider'.' It's weird that this happens because other answers in SO suggested the same procedure as mine but I get an exception. Any solutions to this? So after a few tries and discussions in the comments I came up with

Creation of ECDSA private key given curve and private exponent?

▼魔方 西西 提交于 2019-12-06 07:54:35
I am new to cryptopp and have been struggling for a while with the creation of private keys for ECDSA signing. I have a hex encoded private exponent E4A6CFB431471CFCAE491FD566D19C87082CF9FA7722D7FA24B2B3F5669DBEFB . This is stored as a string. I want to use this to sign a text block using ECDSA. My code looks a bit like this string Sig::genSignature(const string& privKeyIn, const string& messageIn) { AutoSeededRandomPool prng; ECDSA<ECP, SHA256>::PrivateKey privateKey; privateKey.AccessGroupParameters().Initialize(ASN1::secp256r1()); privateKey.Load(StringSource(privKeyIn, true, NULL).Ref());

Create a RSAParamaters Object from public+private key

空扰寡人 提交于 2019-12-06 07:23:01
I need to create a RSAParameters object in .Net using a private and public key (.key and .cer file). Is it possible to do this in .Net without the use of third party software? If so, where should I be looking. I ultimately need to extract the Exponent, Modulus, D, P, Q, DP, DQ, InverseQ from this object in order to create a keyblob for a cryptoServer. Thanks! ".key" and ".cer" file extensions are in no way an unambiguous specification of how the keys are encoded. However, it is plausible that the ".cer" file is an X.509 certificate, which contains (among many other things) the public key;

Issue Connection to server using Remote-FTP atom package and Private Keys

给你一囗甜甜゛ 提交于 2019-12-06 04:29:26
I'm trying to connect to my server using the atom package "Remote-FTP" and using a private key. I have the SSH keys set up on my server and can connect successfully using putty. The private key is saved in my project folder and I have an existing .ftpconfig file (without a private key) that connects successfully when I replace the information inside the file. The Key has been converted to the necessary ssh format and I have no passphrase at the moment. I have also gave the full path of the private key file Here is my .ftpconfig file - { "protocol": "sftp", "host": "user@server", "port": 22,

Extracting private key in java

Deadly 提交于 2019-12-06 00:37:59
I have certificate created using java class CertAndKeyGen and X500Name and I am able to generate the certificate which is in byte array. Now I want the private key I used in certificate and convert it into readable format. Below is the code I used to create the certificate, CertAndKeyGen keypair = new CertAndKeyGen("RSA", "SHA1WithRSA", null); X500Name x500Name = new X500Name(commonName, organizationalUnit, organization, city, state, country); keypair.generate(keysize); PrivateKey privKey = keypair.getPrivateKey(); PKCS10 certReq = keypair.getCertRequest(x500Name); X509Certificate[] chain =