Questions tagged [pkcs#1]

PKCS #1 is a standard that defines the RSA algorithm and padding schemes.

PKCS #1 is a security standard, published by RSA Security, which describes the RSA algorithm and padding schemes. The current version, PKCS #1 v2.1, is also available as RFC 3447.

Besides the RSA algorithm, PKCS #1 v2.1 defines the OAEP padding scheme for encryption, the PSS padding scheme for signature, and the legacy PKCS1-v1.5 scheme for encryption and signature. PKCS #1 also defines an ASN.1 syntax for RSA keys.

87 questions
155
votes
5 answers

How can I transform between the two styles of public key format, one "BEGIN RSA PUBLIC KEY", the other is "BEGIN PUBLIC KEY"

How can I transform between the two styles of public key format, one format is: -----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY----- the other format is: -----BEGIN RSA PUBLIC KEY----- ... -----END RSA PUBLIC KEY----- for example I generated…
welkinwalker
  • 2,062
  • 3
  • 18
  • 21
68
votes
2 answers

PKCS#1 and PKCS#8 format for RSA private key

Can some one help me understand how an RSA key literally is stored in these formats? I would like to know the difference between the PKCS formats vs Encodings(DER, PEM). From what I understand PEM is more human readable. Is PEM/DER for keys/certs…
akd
  • 1,427
  • 3
  • 16
  • 21
27
votes
6 answers

Generating RSA keys in PKCS#1 format in Java

When I generate an RSA key pair using the Java API, the public key is encoded in the X.509 format and the private key is encoded in the PKCS#8 format. I'm looking to encode both as PKCS#1. Is this possible? I've spent a considerable amount of…
Anthony
  • 399
  • 1
  • 6
  • 13
22
votes
1 answer

Generate PKCS#8 private key with openssl

Is it possible to use openssl to generate a PKCS#8 private key directly, or do I have to first generate a PKCS#1 key with genrsa and then convert it?
Benjy Wiener
  • 1,085
  • 2
  • 9
  • 27
22
votes
2 answers

Encrypted Private Key to RSA Private Key

I have an Encrypted Private Key(say,servenc.key) in below format: -----BEGIN ENCRYPTED PRIVATE…
Vivek Kashyap
  • 243
  • 1
  • 3
  • 10
15
votes
3 answers

How to generate PKCS#1 RSA keys in PEM Format?

Sorry for my english and honestly I have a very little understanding on this so please bear with me. I am developing a java application that sends a signed request to a Server. To do so, I have to generate a PKCS#1 RSA key pair in PEM format for…
Johne Altamera
  • 204
  • 1
  • 2
  • 7
13
votes
1 answer

Why is RSACryptoServiceProvider.Encrypt() output not stable?

Until today I was living under the impression that RSA encryption using RSA is deterministic. After all, how should signature verification work if it wasn't? To my big suprise, .NETs RSACryptoServiceProvider does not have a stable output when…
Johannes Rudolph
  • 35,298
  • 14
  • 114
  • 172
12
votes
1 answer

ASN.1 DER formatted private key

Why is the modulus padded with leading zeros? I was reading PKCS#1 and PKCS#8 but didn't find anything about it. In c# the leading zeros must be removed, does anybody know why? At http://etherhack.co.uk/asymmetric/docs/rsa_key_breakdown.html, you…
hs2d
  • 6,027
  • 24
  • 64
  • 103
12
votes
3 answers

Converting A public key in SubjectPublicKeyInfo format to RSAPublicKey format java

The PublicKey.getEncoded(), returns a byte array containing the public key in SubjectPublicKeyInfo (x.509) format, how do i convert it to RSA public key encoding?
Ashish Kumar Shah
  • 512
  • 1
  • 9
  • 26
8
votes
2 answers

Decrypting an OpenSSL PEM Encoded RSA private key with Java?

I have an encrypted private key and I know the password. I need to decrypt it using a Java library. I'd prefer not to use BouncyCastle though, unless there is no other option. Based on previous experience, there is too much change and not enough…
rimsoft
  • 105
  • 1
  • 1
  • 5
8
votes
1 answer

Getting error "data too large for key size" with Crypto Node.js

I'm getting the error "Error: error:0406C06E:rsa routines:RSA_padding_add_PKCS1_type_1:data too large for key size" when I do: var crypto = require('crypto'); var fs = require('fs'); var first_keys = { public_key:…
arturojain
  • 167
  • 1
  • 4
  • 15
6
votes
1 answer

Is PKCS#1 V2.0 implemented for Java?

I need encrypt data using exactly the PKCS#1 V2.0 encryption method (defined in item 7.2.1 of the PKCS#1V2 specification). Is it already implemented for Java? I'm thinking in something like just pass a parameter to javax.crypto.Cipher specifying…
The Student
  • 27,520
  • 68
  • 161
  • 264
6
votes
2 answers

Is there a perl implementation of SHA256withRSA

I need to be able to craft JSON Web Token signatures (which only accepts 'RSASSA-PKCS1-V1_5-SIGN with the SHA-256 hash function' signatures), but the obvious CPAN contender for this task (Crypt::RSA) will only generate signatures using MD2, MD5 or…
Cebjyre
  • 6,552
  • 3
  • 32
  • 57
5
votes
1 answer

Can JcaPEMWriter generate PKCS#8 output?

The following code uses the JcaPEMWriter class from BouncyCastle to output a randomly generated RSA private key in PKCS#1 format (-----BEGIN RSA PRIVATE KEY-----): public static void main(String[] args) throws Exception { final KeyPairGenerator…
Simon Kissane
  • 4,373
  • 3
  • 34
  • 59
5
votes
2 answers

Convert PKCS#1-formatted private key to PKCS#8-formatted private key by java

I have a PKCS#1-formatted private key (generated by opendkim-genkey) like this -----BEGIN RSA PRIVATE KEY----- Base64 encoded data -----END RSA PRIVATE KEY----- Now I have to use it in Java to generate java.security.PrivateKey But Java only…
Thanh Vũ
  • 55
  • 1
  • 5
1
2 3 4 5 6