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
3
votes
2 answers

RSACryptoServiceProvider doesn't produce consistent output

I need to encrypt some text with RSA, and then recover it later using the private key. My problem is that RSACryptoServiceProvider.Encrypt() outputs a different value every time, even when using the same key. Here is my code which I put into…
Gordon Leigh
  • 1,263
  • 2
  • 11
  • 23
3
votes
3 answers

how to decrypt an encrypted text using RSACryptoServiceProvider?

I have encrypted a text using RSACryptoServiceProvider. I exported the public and private key. Obviously I just want to expose the public key inside the decoder application, so I have written a code as follows : private const string PublicKey =…
user848609
  • 71
  • 1
  • 2
  • 4
3
votes
1 answer

Creating PublicKey using Oid/ASNEncodeData throws CryptographyException

I'm trying to create a PublicKey instance using an Oid and RSA public Key but I'm getting a CryptographyException with "ASN1 bad tag value met". I'm following the answer found here to eventually create a RSACryptoServiceProvider. Here's my…
markf78
  • 597
  • 2
  • 7
  • 25
3
votes
1 answer

Verifying a Digital Signature produced by C# on an Android Device

I'm writing an Android application that would like to verify that a string produced by a C# program is authentic (i.e. produced by another application that I've written). To do that, I'm signing the string and transmitting the string and the hash of…
Bill Carey
  • 1,395
  • 1
  • 11
  • 20
3
votes
1 answer

How to set public key in RSAParameters

I have RSA public key encoded in Base64. After decoding I can get RSA public key like: -----BEGIN PUBLIC KEY----- XXXXXXXXXXXXXXXXXXXXXXX -----END PUBLIC KEY----- Now I need to import this key into RSACryptoServiceProvider. I was looking for…
Filip Szesto
  • 153
  • 2
  • 14
3
votes
1 answer

Perl & .NET RSA working together? Encrypting in .NET from Perl public key? Loading private key from Perl?

I've got an application that is going to be taking a public key from a 3rd party. The public key is generated in Perl using Crypt::RSA::Key. Using the BigInteger class, I'm able to load this key and encrypt values that should be able to be decrypted…
Doug S
  • 115
  • 2
  • 10
3
votes
1 answer

Can another application access a private key stored in a key container using RSACryptoServiceProvider?

I am using RSACryptoServiceProvider to generate public/private key pair and using cspParameters object to store it in a key container. My problem is that after i store the private key in a key container, can another application access the key…
3
votes
0 answers

Windows 2012 R2 fails in RSACryptoServiceProvider throws The parameter is incorrect exception

We are facing issue specifically in Windows Server 2012 R2. Below is our demo code: rsa.ImportParameters(new RSAParameters { Exponent = new byte[] { 1, 0, 1 }, …
3
votes
1 answer

Convert ssh-keys to c# format to encrypt in Windows (c#) and decrypt in Linux (python/shell)

I have public and private key pair generated using ssh-keygen on Centos machine. I need to convert the public key to some format that c# can understand (XML?) so that a windows application in c# can encrypt a message and Centos application…
man3
  • 161
  • 7
3
votes
1 answer

RSA Encryption C#

I have a class which in C# doing RSA encryption where I used the default RSACryptoServiceProvider class. But I have a concern regarding the following; If you have the word hello for an input and the encrypted string is returned as ABCDE, if you…
Ryan
  • 265
  • 1
  • 6
  • 17
3
votes
0 answers

Why is C# so much faster at generating RSA keys than Python?

I need to use basic RSA cryptography in my program so I use the RSACryptoServiceProvider class to do so. I noticed it generates keys much faster than PyCrypto (Python) for example. Here are some benchmarks I made: Execution times (.NET with…
GuiTeK
  • 1,561
  • 5
  • 20
  • 39
3
votes
0 answers

Convert SSH2 Public Key to RSACryptoServiceProvider

I have a Windows machine that needs to connect (programmatically) to a Linux machine. I've got a public key to that machine, but I cannot seem to use it in C# using RSACryptoServiceProvider. I get an exception: Invalid syntax on line 10. on this…
Joseph
  • 2,155
  • 6
  • 20
  • 32
3
votes
1 answer

The RSA key container could not be opened for one of two sections

I have encrypted two sections of a webconfig file, one is called connectionStrings and other is userAccount using the same Provider. In my code connectionString section is decrypted just fine without any problem but when it comes to decrypt second…
kdnerd
  • 341
  • 3
  • 10
3
votes
1 answer

RSAParameters to pfx (X509Certificate2) conversion

I want to create a pfx file from keys created by RSACryptoServiceProvider. I tried: certificate.PrivateKey = rsa as AsymmetricAlgorithm; which is the reverse of: rsa = (RSACryptoServiceProvider)certificate.PrivateKey; which seems to work (the…
ispiro
  • 26,556
  • 38
  • 136
  • 291
3
votes
1 answer

Cryptographic Exception Invalid flags Specified

Here is my code: RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(128); try { string publicKeyXML = rsa.ToXmlString(false); string privateKeyXML = rsa.ToXmlString(true); …
coffeeak
  • 2,980
  • 7
  • 44
  • 87