rsacryptoserviceprovider

Decrypting the signature created by RSACryptoServiceProvider.SignData() to get the hash

断了今生、忘了曾经 提交于 2021-01-27 13:04:52
问题 I'm trying to retrieve the hash created with the RSACryptoServiceProvider class' SignData and SignHash methods. I need this to be able to store encrypted hashes that must be retrieved later because they're part of a hash chain. Initially I wanted to encrypt and decrypt hashes manually, using the private key for encryption, but the library doesn't allow it. I can't find a method that does this, and all my searches have returned answers about how private key encryption is a bad idea (when not

Generate a 2048 key with custom exponent size?

你离开我真会死。 提交于 2021-01-27 05:40:20
问题 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 be 65537 . I've looked around, but was unable to find any information. I am trying to generate a new key pair, not import an existing key, using RSACryptoServiceProvider . I know that importing an already existent key, I can define modulus,

How do I use RSACryptoServiceProvider to decrypt, given that I only have p, q, d and u?

南笙酒味 提交于 2020-01-14 03:07:36
问题 I am creating a simple client app to experiment with Mega and I am having trouble wrapping my head around the way RSA is used. Let's take, for example, the decryption of the session ID - this is one of the first things that must be done in order to log in. The API provides me the following RSA data: p (1024 bits) q (1024 bits) d (2044 bits) u (1024 bits) To start with, I do not know what "u" stands for. I see from code that it is calculated by modinverse(p, q) - is this what is commonly

Implementing RSA in C#

家住魔仙堡 提交于 2020-01-09 10:28:25
问题 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; using System.Text; using System.Security.Cryptography; namespace Agnus.Cipher { public class RSA { private byte[] plaintextBytes; private byte[] ciphertextBytes;

Why is RSACryptoServiceProvider.Encrypt() output not stable?

蹲街弑〆低调 提交于 2020-01-03 07:20:12
问题 Until today I was living under the impression that RSA encryption using RSA is deterministic. After all, how should signature verification work if it wasn't? To my big suprise, .NETs RSACryptoServiceProvider does not have a stable output when encrypting the same set of bytes with the same keys: [Fact] public void Learning() { const int keySize = 1024; System.Security.Cryptography.RSACryptoServiceProvider rsa = new System.Security.Cryptography.RSACryptoServiceProvider(keySize); var bytes =

Translating C# RSACryptoServiceProvider code to Java

戏子无情 提交于 2020-01-01 03:45:09
问题 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 xmlString = "<RSAKeyValue><Modulus>qqoWhMwGrrEBRr92VYud3j+iIEm7652Fs20HvNckH3tRDJIL465TLy7Cil8VYxJre69zwny1aUAPYItybg5pSbSORmP+hMp6Jhs+mg3qRPvHfNIl23zynb4kAi4Mx/yEkGwsa6L946lZKY8f9UjDkLJY7yXevMML1LT+h/a0a38=</Modulus><Exponent>AQAB</Exponent><P

The RSA key container could not be opened

血红的双手。 提交于 2019-12-30 00:56:14
问题 I've been developing an ASP.NET site on an older machine running XP home. I recently got a new Win 7 PC and moved all my project files across. When I try and run the project, I get this error message: "Failed to decrypt using provider 'MyRsaProtectedConfigurationProvider'. Error message from the provider: The RSA key container could not be opened." I realised that I encrypted parts of my web.config file using a RSA encryption . This is where the problem now lies. I'm not sure how to get that

Verify Private Key Protection before signing with RSACryptoServiceProvider

六月ゝ 毕业季﹏ 提交于 2019-12-24 15:10:03
问题 When signing data with RSACryptoServiceProvider in C#, I have a requirement to ensure the certificate was imported with strong key protection and a high security level to require the user enters the password every time they sign with the key. Here's a quick simplified sample of the signing code: X509Store myCurrentUserStore = new X509Store(StoreName.My, StoreLocation.CurrentUser); myCurrentUserStore.Open(OpenFlags.MaxAllowed); X509Certificate2 currentCertificate = myCurrentUserStore

Creating PublicKey using Oid/ASNEncodeData throws CryptographyException

断了今生、忘了曾经 提交于 2019-12-23 22:26:29
问题 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 code: string pem = @"-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkxqnUqh5WYis/Q+sQc5h O9i5aX7XvVEVdrhrnFcbwSb1/GyQWPvn1ZydQB88zW9CnNFq08QRg+IYaBYdqs12 EbxkET20eWY7xvI8kBICPxOdYAHBb0JWpdK4GjSCSxCFrJIXXmHtnRqj6PmSoPrb

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

帅比萌擦擦* 提交于 2019-12-23 07:51:01
问题 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 have all the information to decrypt, although it won't work. I'm thinking it might be a .NET way of decrypting that I didn't understand yet. Here is the code: static