Questions tagged [rsa]

RSA is a common public key algorithm, which can be used for encryption and signature. It is a core component of most the security protocols used on the Internet, including the SSL/TLS protocol suite. For questions about IBM Rational Software Architect, use the rational-rsa tag.

RSA is a public key cryptography algorithm. It is used in many Internet protocols that use cryptography, including /-based protocols (, etc.), , , and more. The name RSA comes from its inventors: Rivest, Shamir and Adleman.

RSA Security, Inc. is also the name of a security firm. Among other things, RSA publishes a series of standards related to public-key cryptography known as PKCS. The standard defines RSA.

RSA can be used for both encryption and signature. It is an asymmetric algorithm. A public key consists of two numbers: the modulus n, which is a large integer and determines the key size (1024 bits, 2048 bits and 4096 bits are common key sizes), and the public exponent e, which can be any odd integer between 3 and n but is often 3 or 65537. A private key consists of n and the private exponent d, which is generally almost as large as n. A private key may contain other fields to speed up computations.

The raw RSA operation is a mathematically simple operation: exponentiation modulo n. The exponent is the private exponent for encryption and signature, and the public exponent for decryption and verification. Only numbers up to n can be encrypted or signed. Therefore, instead of encrypting a whole message for RSA, one usually generates a session key (a symmetric key, for example an key) and encrypts this key with RSA. Instead of signing a message with RSA, one usually generates a cryptographic digest of the message (, , , …) and signs this digest.

The raw RSA operation is not secure. RSA requires a padding scheme. Common padding scheme include OAEP for encryption and PSS for signing, as well as other algorithms defined by .

For IBM Rational Software Architect, use .

6847 questions
99
votes
4 answers

What command do I use to see what the ECDSA key fingerprint of my server is?

I see stuff all over Google on how to see the RSA key fingerprint, but not the ECDSA fingerprint.
trusktr
  • 44,284
  • 53
  • 191
  • 263
95
votes
10 answers

How to read a PEM RSA private key from .NET

I've got an RSA private key in PEM format, is there a straight forward way to read that from .NET and instantiate an RSACryptoServiceProvider to decrypt data encrypted with the corresponding public key?
Simone
  • 3,607
  • 1
  • 31
  • 37
95
votes
5 answers

C# RSA encryption/decryption with transmission

I've seen plenty of encryption/decryption tutorials and examples on the net in C# that use the System.Security.Cryptography.RSACryptoServiceProvider, but what I'm hoping to be able to do is: Create an RSA public/private keypair Transmit the public…
Transmission
  • 1,219
  • 1
  • 10
  • 11
81
votes
7 answers

Verifying JWT signed with the RS256 algorithm using public key in C#

Ok, I understand that the question I am asking may be pretty obvious, but unfortunately I lack the knowledge on this subject and this task seems to be quite tricky for me. I have an id token (JWT) returned by OpenID Connect Provider. Here it…
Dmitry Nikolaev
  • 3,803
  • 2
  • 19
  • 23
76
votes
3 answers

How does the RSA private key passphrase work under the hood?

RSA private keys may be assigned a "passphrase" which - as I understand it - is intended to provide some secondary security in case someone makes off with the private key file. How is the passphrase layer of security implemented?
qfinder
  • 1,155
  • 2
  • 9
  • 9
75
votes
3 answers

Save and load crypto/rsa PrivateKey to and from the disk

I'm using crypto/rsa, and trying to find a way to properly save and load a key. Is there a correct way to create a []byte from an rsa.PrivateKey. If so, is there a way to properly do so for an rsa.PublicKey? Thank you all very much.
Alexander Bauer
  • 10,663
  • 8
  • 29
  • 40
71
votes
7 answers

Using SHA1 and RSA with java.security.Signature vs. MessageDigest and Cipher

I'm trying to understand what the Java java.security.Signature class does. If I compute an SHA1 message digest, and then encrypt that digest using RSA, I get a different result to asking the Signature class to sign the same thing: // Generate new…
Kothar
  • 6,579
  • 3
  • 33
  • 42
71
votes
3 answers

How to Generate Unique Public and Private Key via RSA

I am building a custom shopping cart where CC numbers and Exp date will be stored in a database until processing (then deleted). I need to encrypt this data (obviously). I want to use the RSACryptoServiceProvider class. Here is my code to create my…
David Murdoch
  • 87,823
  • 39
  • 148
  • 191
70
votes
7 answers

RSA: Get exponent and modulus given a public key

I need to encrypt some data using RSA in JavaScript. All of the libraries around ask for an exponent and a modulus, yet I get a single public.key file from my opponent. How do you retrieve the public exponent and modulus part from an RSA file?
Pierre Spring
  • 10,525
  • 13
  • 49
  • 44
68
votes
7 answers

CryptographicException "Key not valid for use in specified state." while trying to export RSAParameters of a X509 private key

I am staring at this for quite a while and thanks to the MSDN documentation I cannot really figure out what's going. Basically I am loading a PFX file from the disc into a X509Certificate2 and trying to encrypt a string using the public key and…
kalrashi
  • 1,423
  • 3
  • 14
  • 15
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
68
votes
4 answers

RSA Encryption, getting bad length

When calling the following function : byte[] bytes = rsa.Encrypt(System.Text.UTF8Encoding.UTF8.GetBytes(stringToEncrypt), true); I am now getting the error: bad length. With a smaller string it works, any ideas what the problem could be the string…
JL.
  • 78,954
  • 126
  • 311
  • 459
65
votes
6 answers

getting a IllegalBlockSizeException: Data must not be longer than 256 bytes when using rsa

I am using rsa key to encrypt a long string which I will send to my server(will encrypt it with server's public key and my private key) But it throws an exception like javax.crypto.IllegalBlockSizeException: Data must not be longer than 256 bytes I…
Ashwin
  • 12,691
  • 31
  • 118
  • 190
64
votes
2 answers

Why does RSA encrypted text give me different results for the same text

I am encrypting data with openSSL using RSA encryption, which works fine. My understanding of RSA is, that encrypting the same data with the same public key will always give you the same result (as stated here or here). However, using openssl I get…
psibar
  • 1,910
  • 1
  • 12
  • 17
63
votes
2 answers

How to Load RSA Private Key From File

I am working on a test harness for a SAML 1.1 Assertion Consumer Service. The test must generate a signed SAMLResponse and submit it to the ACS encoded in Base64. The ACS must be able to verify the signed message using the X509 public cert. I am…
AJ.
  • 27,586
  • 18
  • 84
  • 94