rsacryptoserviceprovider

Why does RSACryptoServiceProvider.VerifyHash need an LDAP check?

I recently encountered an odd problem with RSACryptoServiceProvider.VerifyHash. I have a web application using it for decryption. When users running the web service were doing so over our VPN it became very very slow. When they had no connection or a internet connection they were fine. After much digging I found that every time RSACry...

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

Hi everyone. 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 encrypted. I don't want them to be able to know how I encrypted my message. ...

Implementing RSA in C#

I'm currently trying to implement a class to handle secure communications between instances of my app using RSACrytoServiceProveider class. First question : is it a good idea implement a single class to handle sender/reciever roles or should i split the roles into individual classes ?. This is what i have done so far: using System; usi...

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 System.Security.Cryptography.Xml; namespace XmlCryptographySendingTest { class Program { ...

Error occurred while decoding OAEP padding

Hi, I am half th way of my problem,,. Please Help I have succesfuly encrypted the text using public key of digital signatures but while decrypting it. i am getting error Error occurred while decoding OAEP padding my piece of code #region Test Encryption public void a() { using (var rsa = new RSACryptoServiceProvider()) { // This St...

Error occurred while decoding OAEP padding

in continuation of the http://stackoverflow.com/questions/949907/error-occurred-while-decoding-oaep-padding question I have modified my code and now i am trying this code CspParameters cspParam = new CspParameters(); cspParam = new CspParameters(); cspParam.Flags = CspProviderFlags.UseMachineKeyStore; clsCertificates cc = new clsCer...

.Net Simple RSA encryption

Hi, I'm trying to encrypt something simple, like int or long. Simplest way I found looks like: int num = 2; RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); byte[] numBytes = BitConverter.GetBytes(num); byte[] encryptedBytes = rsa.Encrypt(numBytes, true); Problem is, the encryptedBytes is 128 bytes long. How can I encry...

Verify integrity Ceritifcate { RSACryptoServiceProvider - SHA1 - thumbprint }

Hello, sorry for my english. I have a little problem. I want to verify the integrity of my certificat. I make this code: using System.Security.Cryptography; using System.Runtime.InteropServices; using System.Security.Cryptography.X509Certificates; SHA1Managed sha1 = new SHA1Managed(); RSACryptoServiceProvider csp = null; AsymmetricA...

RSA Key Store Permissions

Since yesterday I haven't been able to generate strong name keys using sn.exe or through Visual Studio which also uses sn.exe. When attempting to generate a key file the following cimmand is executed sn - k "key file.snk" sn.exe then responds with Failed to generate a strong name key pair -- Access is denied. After repeating this pr...

Decrypting with private key from .pem file in c# with .NET crypto library

I know this is a similar question to this one but before I head down the Bouncey Castle route, does anyone know if its possible to load an RSA KeyPair from a .pem file (-----BEGIN RSA PRIVATE KEY-----) directly with the .NET 3.5 crypto library without having to go to a 3rd party or roll my own? ...

"Bad Key." exception when decrypting with RSACryptoServiceProvider (C#.NET)

Hello. I am trying to decrypt data that has been encrypted previously in RSA (don't worry, I'm supposed to be able to, I have the keys. Nothing illegal :). However, I get a "Bad Key." error at the decryption line. I am sure this key is right, as I took it from vectors. The vectors are provided in the following code. Theoretically, I ha...

Can the data at UseMachineKeyStore be backed up and recovered?

I have the following code: const int PROVIDER_RSA_FULL = 1; const string CONTAINER_NAME = "Example"; CspParameters cspParams; cspParams = new CspParameters(PROVIDER_RSA_FULL); cspParams.KeyContainerName = CONTAINER_NAME; cspParams.Flags = CspProviderFlags.UseMachineKeyStore; cspParams.ProviderName = "Microsoft Strong Cryptographic Provi...

C# RSA encrypt/decrypt throws exception

Hi I'm trying to set up a simple server side RSA encryption of a small chunk of info which is to be decrypted on the client side. Just as a proof of concept I wrote a few lines to ensure that the public and private key could be loaded from xml. However, I'm struggling to make even the most simple stuff work on my machine: byte[] byte...

Window CryptoAPI: Can I choose the public exponent when generating an RSA key pair?

Using the Windows CryptoAPI, is there any way to specify which public exponent to use when generating a new key-pair (ie. 3 instead of 65537)? As a bonus question: how would I access this functionality using .NET RSACryptoServiceProvider? EDIT: My guess is that the answer is "No", but I would like to get confirmation. ...

RSA KEY Encryption/Decryption Problem

I tried C:\dev>aspnet_regiis -pc "NetFrameworkConfigurationKey" -exp Creating RSA Key container... The RSA key container could not be opened. Failed! and C:\dev>aspnet_regiis -pa "NetFrameworkConfigurationKey" "ASPNET" Adding ACL for access to the RSA Key container... The RSA key container was not found. Failed! B...

Web.config Encryption Error

Having problem with encryption. I gave full permissions to all users to RSA folders. I did C:\>aspnet_regiis -pe "appSettings" -location "web.config" -prov "RsaProtectedCo nfigurationProvider" Encrypting configuration section... An error occurred executing the configuration section handler for appSettings. Failed to encrypt the section...

How to store a public key in a machine-level RSA key container

I'm having a problem using a machine level RSA key container when storing only the public key of a public/private key pair. The following code creates a public/private pair and extracts the public key from that pair. The pair and the public key are stored in separate key containers. The keys are then obtained from those key containers ...

How to encrypt Amazon CloudFront signature for private content access using canned policy

Has anyone using .net actually worked out how to successfully sign a signature to use with CloudFront private content? After a couple of days of attempts all I can get is Access Denied. I have been working with variations of the following code and also tried using OpenSSL.Net and AWSSDK but that does not have a sign method for RSA-SHA1 ...

RSA Encryption C#

Hi guys, 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 perform another encrypt operation on the input hello, using the same keys (public an...

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 making use of it in several Methods. With this setup I cannot use the using statement. Ins...