rsacryptoserviceprovider

C# RSA encrypt/decrypt throws exception

ε祈祈猫儿з 提交于 2019-12-23 03:59:10
问题 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[] bytes = Encoding.UTF8.GetBytes("Some text"); bool fOAEP = true; // seeding a public and private key RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); var

RSA Key Values and Modulus in Public/Private Keys

廉价感情. 提交于 2019-12-22 06:38:11
问题 I am writing an application that used PKI to secure email, files etc. Using the System.Cryptography namespace, I am generating a new key pair using RSACryptoServiceProvider . The method is: public static void GenerateKeys(int keySize, out string publicKey, out string privateKey) { using (var provider = new RSACryptoServiceProvider(keySize)) { publicKey = provider.ToXmlString(false); privateKey = provider.ToXmlString(true); } } keySize = 2048. This results in a public key like (this has been

how to decrypt an encrypted text using RSACryptoServiceProvider?

╄→гoц情女王★ 提交于 2019-12-21 20:17:59
问题 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 = "<RSAKeyValue><Modulus>sIzQmj4vqK0QPd7RXKigD7Oi4GKPwvIPoiUyiKJMGP0qcbUkRPioe2psE/d3c1a2NY9oj4Da2y1qetjvKKFad2QAhXuql/gPIb1WmI+f6q555GClvHWEjrJrD/ho7SLoHbWd6oY6fY609N28lWJUYO97RLVaeg2jfNAUSu5bGC8=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";

RSACryptoServiceProvider(RSACryptoServiceProvider) constructor crashing in .NET 3.5 for certain key names

好久不见. 提交于 2019-12-14 03:42:40
问题 If you look at the code below it is doing nothing but creating a new instance of an RSACryptoServiceProvider . The key container name is initialized from a property that creates a name based on various parameters. I have added hardcoded values in this demo code. The code is running on a Windows 2008 R2 server installation and has worked for months with a constant value being returned for the key container name. Some days ago the code stopped working and we're facing the exception below. Using

RSA signing in C# for licensing

本秂侑毒 提交于 2019-12-13 09:13:45
问题 (Approach #2) I need to make a software activation mechanism. So i ended up with this scheme: App creates a unique id, based on computer's hardware. Buyer emails this id to me. I sign it with my private key and i send back the signed string. App verifies string (decodes it with contained public key and compares it with hardware id). So far i am done with hardware id and i have created the keys (1024bit) with openssl, that's two files private.pem and public.pem. I tried to apply the solution

Convert RSACryptoServiceProvider RSA XML key to PKCS8

我的梦境 提交于 2019-12-12 08:54:24
问题 I use RSACryptoServiceProvider in my C# code, and it's working good I could Export RSA XML private and public keys, but for some reason I need to convert this key to *.pem with format (PKCS8 Unencrypted) my private key like <RSAKeyValue> <Modulus>zYs6baSaRDgLc5fG3/ozwGwS8OAvxd9quE2su+7//Lnz2WuIbe8jMc5kL7p2gsPZUEoB88SFHdGZSYiZJhERDc/1iQ4VsW2/ra8DBW+1m3K33EDvvI3rJ0NIyuRNuwoYql3hYdY0cdW6Gru9ZARCpptgBSJEiUSPjlzDEXz3RaU=</Modulus> <Exponent>AQAB</Exponent> <P

Azure KeyVault how to load X509Certificate? [duplicate]

≡放荡痞女 提交于 2019-12-12 01:53:50
问题 This question already has answers here : How to serialize and deserialize a PFX certificate in Azure Key Vault? (4 answers) Closed 3 years ago . I uploaded a Certificate to Azure KeyVault and obtained "all" access to it using an application registered into the Active Directory. That all works fine. Now I need to load the obtained key into an X509Certificate to be able to use it as a client certificate for calling a 3rdparty legacy SOAP webservice. As far as I know I can only use a

RSA Key Store Permissions

青春壹個敷衍的年華 提交于 2019-12-11 15:53:33
问题 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 process while running Process Monitor I now know that the locations to which sn.exe is denied access all reside within the following directory \ProgramData\Microsoft

Why is SHA256 and invalid hash algorithm when signing with RSA?

喜欢而已 提交于 2019-12-11 07:37:19
问题 I am trying to sign a stream using the method below but I always get a Cryptographic Exception saying that it is not a valid hash algorithm even though it is listed in the documentation: byte[] SignData(RSACryptoServiceProvider rsa, Stream stream, string hashName) { HashAlgorithm hash = HashAlgorithm.Create(hashName); byte[] signature = rsa.SignData(stream, hash); return signature; } I am calling it with "SHA256" as the hashName parameter. and the exception is thrown at the line where rsa

Microsoft RSA CSP key size

坚强是说给别人听的谎言 提交于 2019-12-11 02:49:46
问题 From what I can see, Microsoft's RSA CSP always generates identical bitlength pseudo prime numbers. So if the key size is 1024, the P and Q values seem to be (?) guaranteed to be 512 bits each? Does anyone know for sure if this, in fact, is the case? I'm building an interoperability module between my own RSA implementation and Microsoft's. In my case I have built in a small random variance between P & Q values so for 1024 bit key I could end up with one value being 506 bits and the other 518.