Questions tagged [rsacryptoserviceprovider]

The RSACryptoServiceProvider object performs asymmetric encryption and decryption using the implementation of the RSA algorithm provided by the cryptographic service provider (CSP).

216 questions
5
votes
1 answer

Generate a 2048 key with custom exponent size?

Is there a way to generate a 2048 RSA key pair, using RSACryptoServiceProvider with a custom defined exponent? new RSACryptoServiceProvider(2048); // = 65537 always For example, I want to set the exponent to 65535, but the hard-coded value seems to…
Guapo
  • 3,446
  • 9
  • 36
  • 63
5
votes
1 answer

Translating C# RSACryptoServiceProvider code to Java

I need to encrypt String for project related purpose and was given the below code for the same by vendor. public static string EncryptString(string StringToEncrypt) { RSACryptoServiceProvider provider = new RSACryptoServiceProvider(); string…
RahulMuk07
  • 53
  • 6
5
votes
3 answers

Does RSA Private key always contain the Public key, or is it just .NET?

I'm using RSACryptoServiceProvider in .NET 2 and it seems that the Private part of a Public/Private key pair always contains the Public part as well. I need to encrypt some info using my Public key, and allow the other party to ONLY DECRYPT what I…
TheAgent
5
votes
1 answer

How do I manually Dispose RSACryptoServiceProvider?

I have read on MSDN(see Important note) that RSACryptoServiceProvider must be disposed. They give the example: using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider()) Now I'm trying to include RSACryptoServiceProvider into MyClass…
hultqvist
  • 17,451
  • 15
  • 64
  • 101
5
votes
1 answer

Generating public and private key pairs in c# and saving public key as plain text

I need to implement encryption between a C# application and a micro controller (pic32mx795). The issue I'm having is generating a public and private key pair I'm using RSACryptoServiceProvider, but I can only get the key attributes and not the…
5
votes
1 answer

signature with SHA256

I have a smartcard and I need to sign a file with this. That is a big problem as I see in stackover. I couldnt use RSACryptoServiceProvider, bkz it doesnt support RSA-SHA256 alogrithm. At First I used CAPICOM.dll , like code bellow, SignedData sed =…
Turgay Gençer
  • 121
  • 1
  • 4
  • 11
4
votes
2 answers

C# USB eToken signature and validation issue

I have an x509 certificate with a public and private key that is stored on a safenet usb token. I have some data I want to sign. I need to use the public key of the certificate to verify the signature. Ultimate code doing the signing with my own…
user2709214
  • 185
  • 2
  • 12
4
votes
1 answer

RSACryptoServiceProvider "Key does not exist" on .Net 4.6.2

I am using PackageDigitalSignatureManager to sign a Zip file and its contents. My code worked fine, until I updated to .Net 4.6.2 suddenly I get the following expection: System.Security.Cryptography.CryptographicException: Key does not exist bei…
Bluuu
  • 482
  • 4
  • 12
4
votes
0 answers

Verify certificate is valid for encryption/decryption

As mentioned in questions like this, this and this, if you try to encrypt/decrypt using a certificate that's only valid for digital signatures, you'll get a CryptographicException: "Bad Key" from RSACryptoServiceProvider. My question is how verify…
explunit
  • 18,967
  • 6
  • 69
  • 94
4
votes
1 answer

MS CSP: Difference between AT_SIGNATURE and RSA_KEY_SIGN (and also AT_KEYEXCHANGE and CALG_RSA_KEYX)

I'm writing CSP library (for CryptoAPI) for smartcards my company sells. I have question about difference between AT_SIGNATURE key type and CALG_RSA_SIGN algorithm for private key (the same also for AT_KEYEXCHANGE and CALG_RSA_KEYX). I know what is…
4
votes
1 answer

What is the correct way for saving a cryptographic key?

I have: RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); And either one of these: byte[] Csp = rsa.ExportCspBlob(true); RSAParameters parameters = rsa.ExportParameters(true); What is the correct way to save them, and what file…
ispiro
  • 26,556
  • 38
  • 136
  • 291
3
votes
0 answers

Error occurred while decoding OAEP padding

I am half way through my problem.. Please Help.. I have successfully encrypted the text using public key of digital signatures but while decrypting it, I am getting the error. Error occurred while decoding OAEP padding. My code is a follows. #region…
3
votes
2 answers

RSA in C# does not produce same encrypted string for specific keys?

I have a requirement, where I need to encrypt my connection string in one application and decrypt it in another. With this in mind, I save the public key and private keys in App.Config of the application respectively. Now, shouldn't RSA should give…
Nagaraj Tantri
  • 5,172
  • 12
  • 54
  • 78
3
votes
3 answers

RSA Encryption public key not returned from container?

I feel like what I am trying to do is very simple. But for some reason it doesn't want to work: Here is a complete code snippet to test what I am trying to do: using System; using System.Xml; using System.Security.Cryptography; using…
3
votes
2 answers

How can I load client certificates from personal store using ASP.NET?

How can I load client certificates from personal store using ASP.NET? If it is possible, can I a crypt data with it? For that I created an application in ASP.NET 2.0 that retrieves all certificates installed in the client certificate store…
1 2
3
14 15