rsa

C# RSA decrypt parameter is incorrect

岁酱吖の 提交于 2021-01-29 17:21:58
问题 I am trying to decrypt communication from web sockets secured with SSL certificate. The certificate is installed on the machine and the private key is present. I have this decrypt function public static string DecryptTry(X509Certificate2 x509, string stringTodecrypt) { try { if (x509 == null || string.IsNullOrEmpty(stringTodecrypt)) throw new Exception("A x509 certificate and string for decryption must be provided"); if (!x509.HasPrivateKey) throw new Exception("x509 certificate does not

C# RSA FromXmlString() BadData Exception

自闭症网瘾萝莉.ら 提交于 2021-01-29 15:45:27
问题 I generate a key like so: ssh-keygen -t rsa1 -b 768 -C Test I get a public key that looks like: 768 65537 1244818534536334574875801623177648392314095757825816788136360615069738317432684324135107640137961040160008388231420349935694006787032419425836353385388446738225464450963417153771331511902010734528761152834146019053540579969112124269 Test I'm having issues with importing a public key. As far as I'm aware the below should work. The call to FromXmlString() fails with BadData crypto exception

Cannot decrypt in C# an encrypted string done by openssl. Always get Org.BouncyCastle.Security.InvalidKeyException

北城余情 提交于 2021-01-29 11:07:24
问题 I trying to decrypt a string in C# that was encrypted by openssl via command line but it keep thrown the exception below: Exception thrown: 'Org.BouncyCastle.Security.InvalidKeyException' in BouncyCastle.Crypto.dll An unhandled exception of type 'Org.BouncyCastle.Security.InvalidKeyException' occurred in BouncyCastle.Crypto.dll Not an RSA key I am using RSA encryption and these are the commands (from git bash) that I use to generate the .pem file sand encrypt/decrypt a test string: // Create

phpseclib decrypt and encrypt data with only public key

纵饮孤独 提交于 2021-01-29 10:48:23
问题 Hi I would like to know why RSA can be performed (encrypt/decrypt) with only one public key in phpseclib? $rsa is an instance of phpseclib/Crypt/RSA.php (link: https://github.com/phpseclib/phpseclib/blob/master/phpseclib/Crypt/RSA.php) $publicKey keys here are the same. function encryptData($data, $publicKey) { $rsa = new Crypt_RSA(); $rsa->loadKey($publicKey); // public key $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1); $output = $rsa->encrypt($data); return base64_encode($output); }

Generate a public key with a predefined modulus and exponent (strange values)

一曲冷凌霜 提交于 2021-01-29 04:58:19
问题 "n": "rKZ-1zdz_CoLekSynOtyWv6cPSSkV28Kb9kZZHyYL-yhkKnH_bHl8OpWiGxQiKP0ulLRIaq1IhSMetkZ8FfXH-iptIDu4lPb8gt0HQYkjcy3HoaKRXBw2F8fJQO4jQ-ufR4l-E0HRqwLywzdtAImNWmju3A4kx8s0iSGHGSHyE4EUdh5WKt-NMtfUPfB5v9_2bC-w6wH7zAEsI5nscMXnvz1u8w7g2_agyhKSK0D9OkJ02w3I4xLMlrtKEv2naoBGerWckKcQ1kBYUh6WASPdvTqX4pcAJi7Tg6jwQXIP1aEq0JU8C0zE3d33kaMoCN3SenIxpRczRzUHpbZ-gk5PQ", "e": "AQAB", How can I generate a public key from these values? Preferable via python or Linux programs. I'm sorry if the question is nonsense

RSA Disposed Object Error - every other test

南笙酒味 提交于 2021-01-29 03:01:38
问题 We have several tests that that generate a jwt request to call a server to retrieve a token. We have 6 tests that make the same call to the same method using the same data. Here is the method: ''' private static string GenerateSignedTokenRequest( string privateKey, string privateKeyPass, string clientID, string audience, int lifetime) { var jti = Guid.NewGuid().ToString(); var claims = new[] { new Claim(JwtRegisteredClaimNames.Jti, jti), new Claim(JwtRegisteredClaimNames.Sub, clientID), };

aspnet_regiis web.config encryption [Error message from the provider: Bad Data.]

ぐ巨炮叔叔 提交于 2021-01-29 02:00:08
问题 I'm trying to encrypt a web app's web.config, but this application exists on 2 different environments (stage, production), each of which should use a different key container. So I'm using this encryption header on my stage config: <configProtectedData defaultProvider="ApplicationProvider"> <providers> <add name="ApplicationProvider" type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,

aspnet_regiis web.config encryption [Error message from the provider: Bad Data.]

前提是你 提交于 2021-01-29 01:57:57
问题 I'm trying to encrypt a web app's web.config, but this application exists on 2 different environments (stage, production), each of which should use a different key container. So I'm using this encryption header on my stage config: <configProtectedData defaultProvider="ApplicationProvider"> <providers> <add name="ApplicationProvider" type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,

how can realize openssl pkeyutl -sign by java

不问归期 提交于 2021-01-28 21:46:38
问题 the command line is openssl pkeyutl -sign -inkey pkcs1.pem -pkeyopt digest:sha1 -in testlog I want to realize it by java. But NONEwithRSA or SHA1withRSA neither give the same output. the NONEwithRSA's output is the same with openssl pkeyutl -sign -inkey pkcs1.pem -in testlog which has no -pkeyopt digest:sha1 the java code just like Signature sign = Signature.getInstance(algorithm); sign.initSign(privatekey); sign.update(keyByte); return sign.sign(); I don't know how to amend this. thank's

how can realize openssl pkeyutl -sign by java

放肆的年华 提交于 2021-01-28 21:06:53
问题 the command line is openssl pkeyutl -sign -inkey pkcs1.pem -pkeyopt digest:sha1 -in testlog I want to realize it by java. But NONEwithRSA or SHA1withRSA neither give the same output. the NONEwithRSA's output is the same with openssl pkeyutl -sign -inkey pkcs1.pem -in testlog which has no -pkeyopt digest:sha1 the java code just like Signature sign = Signature.getInstance(algorithm); sign.initSign(privatekey); sign.update(keyByte); return sign.sign(); I don't know how to amend this. thank's