public-key-encryption

Python code that decrypts RSA encrypted file in chunks of 64 bit using a private exponent and modulus

余生长醉 提交于 2019-12-24 17:03:09
问题 I have an encrypted file that I am trying to decode as part of an experiment. After working hard and long, I have been able to extract the private exponent from the public key since the modulus was small: openssl rsa -pubin -inform PEM -text -noout < public_key.pem Public-Key: (64 bit) Modulus: 16513720463601767803 (0xe52c8544a915157b) Exponent: 65537 Now, I have: Factors: 3917781347 x 4215069449 Private exponent: 9440767265896423601 Now, to derive the plaintext, I need to raise each 64-bit

.net core PGP Encryption Decryption

廉价感情. 提交于 2019-12-24 07:49:03
问题 Running into error on the void Encryption(). public void Encryption() { #region PGP Encryption PgpEncryptionKeys encryptionKeys = new PgpEncryptionKeys(@"C:\Keys\PGPPublicKey.asc", @"C:\Keys\PGPPrivateKey.asc", "password"); PgpEncrypt encrypter = new PgpEncrypt(encryptionKeys); using (Stream outputStream = File.Create("C:\\Keys\\EncryptData.txt")) { encrypter.EncryptAndSign(outputStream, new FileInfo(@"D:\Keys\PlainText.txt")); } Console.WriteLine("Encryption Done !"); #endregion } I used

unable to verify string signed by openssl with dsa key

僤鯓⒐⒋嵵緔 提交于 2019-12-24 06:23:06
问题 Adapting the directions at Creating a DSA Signature from the Linux command line I created a DSA signed message: echo "foobar" > foo.txt openssl dgst -dss1 -sign dsa_priv.pem foo.txt > sigfile.bin The directions actually used foo.sha1 instead of foo.txt, where foo.sha1 was generated by sha1sum but signing a hash seems a bit redundant since DSA is, itself, supposed to do hashing. So, anyway, I did that. Here's the private key I used (I generated it specifically for testing purposes): -----BEGIN

RSA private exponent determination

对着背影说爱祢 提交于 2019-12-24 05:11:49
问题 My question is about RSA signing. In case of RSA signing: encryption -> y = x^d mod n, decryption -> x = y^e mod n x -> original message y -> encrypted message n -> modulus (1024 bit) e -> public exponent d -> private exponent I know x, y, n and e. Knowing these can I determine d? 回答1: If you can factor n = p*q, then d*e ≡ 1 (mod m) where m = φ(n) = (p-1)*(q-1), (φ(m) is Euler's totient function) in which case you can use the extended Euclidean algorithm to determine d from e. (d*e - k*m = 1

RSA private exponent determination

笑着哭i 提交于 2019-12-24 05:10:32
问题 My question is about RSA signing. In case of RSA signing: encryption -> y = x^d mod n, decryption -> x = y^e mod n x -> original message y -> encrypted message n -> modulus (1024 bit) e -> public exponent d -> private exponent I know x, y, n and e. Knowing these can I determine d? 回答1: If you can factor n = p*q, then d*e ≡ 1 (mod m) where m = φ(n) = (p-1)*(q-1), (φ(m) is Euler's totient function) in which case you can use the extended Euclidean algorithm to determine d from e. (d*e - k*m = 1

Load a Certificate Using X509Certificate2 with ECC Public Key

一曲冷凌霜 提交于 2019-12-24 04:56:50
问题 This is a newbie question. I'm trying to load a .der certificate using: X509Certificate2 cert = new X509Certificate2(@"c:\temp\mycert.der"); RSACryptoServiceProvider csp = (RSACryptoServiceProvider)cert.PublicKey.Key But I get a "The certificate key algorithm is not supported" error on the 2nd line. When I import this certificate to MMC I can see the public key like . Is it valid? How do I get it in code? 回答1: Prior to .NET 4.6.1 ECDSA keys were not supported. For legacy/compatibility reasons

Load a Certificate Using X509Certificate2 with ECC Public Key

梦想与她 提交于 2019-12-24 04:56:04
问题 This is a newbie question. I'm trying to load a .der certificate using: X509Certificate2 cert = new X509Certificate2(@"c:\temp\mycert.der"); RSACryptoServiceProvider csp = (RSACryptoServiceProvider)cert.PublicKey.Key But I get a "The certificate key algorithm is not supported" error on the 2nd line. When I import this certificate to MMC I can see the public key like . Is it valid? How do I get it in code? 回答1: Prior to .NET 4.6.1 ECDSA keys were not supported. For legacy/compatibility reasons

Do I need to seed any random number generator before using EVP_PKEY_keygen of OpenSSL?

隐身守侯 提交于 2019-12-24 04:35:10
问题 On the OpenSSL Wiki page called EVP Key and Parameter Generation it states the following: Since these functions use random numbers you should ensure that the random number generator is appropriately seeded But nowhere on EVP_PKEY_keygen does it make mention of seeding a random number generator. It only discusses the low-level doc pages for non-EVP functions for generating keys. I have also searched and everywhere no mention is made of seeding when the EVP functions are used. So my question is

Encryption using X.509 2048 bit public key in iOS

╄→尐↘猪︶ㄣ 提交于 2019-12-24 03:28:04
问题 In my iOS library, I have a Base64 encoded string containing the X.509 RSA 2048 bit public key. I want to encrypt a string using this public key. Can anyone please provide some Objective C code reference, mentioning the libraries I need to include? The equivalent java code looks as below: byte[] keyBytes = Base64.decodeBase64(publicKeyData); // Get Public Key X509EncodedKeySpec rsaPublicKeySpec = new X509EncodedKeySpec(keyBytes); KeyFactory fact = KeyFactory.getInstance("RSA"); PublicKey

Public Key Encryption

别来无恙 提交于 2019-12-24 01:45:40
问题 I was thinking about communication between two computers using public-key encryption. Let us assume that on one computer side I generate a private key and a public key. If I send the public key to the other computer, can it still be captured by a packet sniffer and use it to decrypt my message? If yes, what can be done to prevent this and what is the use of public key encryption then? Update Is SSL equivalent to public-key encryption? Should I use it instead? 回答1: No. The public key is not