public-key-encryption

ECC Encryption and Decryption in Java

依然范特西╮ 提交于 2019-11-30 00:03:21
问题 Can we encrypt large files with ECC or it is like RSA works for small only? can anyone please recommend a good website for ECC Java implementation. Thanks 回答1: In general you are required to perform hybrid encryption with ECC. ECIES for instance is basically a key agreement followed by symmetric encryption. So you cannot directly encrypt anything with ECIES, which is the most common ECC method for encryption. Basically you should couple it to a symmetric cipher. This is actually the best

How to use public and private key encryption technique in C#

ⅰ亾dé卋堺 提交于 2019-11-29 21:43:35
I want to encrypt data using public/private key technique. I mean, encrypt with the public key of receiver and the receiver can decrypt with their own private key. How can I do that? Do you have any suggestion or sample code ? Code example: private static string _privateKey; private static string _publicKey; private static UnicodeEncoding _encoder = new UnicodeEncoding(); private static void RSA() { var rsa = new RSACryptoServiceProvider(); _privateKey = rsa.ToXmlString(true); _publicKey = rsa.ToXmlString(false); var text = "Test1"; Console.WriteLine("RSA // Text to encrypt: " + text); var enc

Encrypting a file with RSA in Python

試著忘記壹切 提交于 2019-11-29 20:42:11
I'm implementing file encryption with RSA, using PyCrypto. I know it's somewhat wrong, first of all because RSA is very slow and second because PyCrypto RSA can only encrypt 128 characters, so you have to explode the file in 128 characters chunks. This is the code so far: from Crypto.PublicKey import RSA file_to_encrypt = open('my_file.ext', 'rb').read() pub_key = open('my_pub_key.pem', 'rb').read() o = RSA.importKey(pub_key) to_join = [] step = 0 while 1: # Read 128 characters at a time. s = file_to_encrypt[step*128:(step+1)*128] if not s: break # Encrypt with RSA and append the result to

What's the difference between id_rsa.pub and id_dsa.pub?

為{幸葍}努か 提交于 2019-11-29 19:41:29
Is one more secure than the other? Mike Pelley id_rsa.pub and id_dsa.pub are the public keys for id_rsa and id_dsa . If you are asking in relation to SSH , id_rsa is an RSA key and can be used with the SSH protocol 1 or 2, whereas id_dsa is a DSA key and can only be used with SSH protocol 2. Both are very secure, but DSA does seem to be the standard these days (assuming all your clients/servers support SSH 2). Update: Since this was written DSA has been shown to be insecure. More information available in the answer below. SSH uses public/private key pairs , so id_rsa is your RSA private key

Unable to load config info from /usr/local/ssl/openssl.cnf on Windows

一笑奈何 提交于 2019-11-29 18:50:48
While using OpenSSL on Windows: openssl genrsa -out privatekey.pem 1024 --> Created successfully openssl req -new -x509 -key privatekey.pem -out publickey.cer -days 365 ----> Showing error message as unable to load config info from /usr/local/ssl/openssl.cnf lame_coder After installing OpenSSL I was required to create a new environment variable: Name: OPENSSL_CONF Value: C:\Program Files\OpenSSL\openssl.cnf In powershell: $env:OPENSSL_CONF = "${env:ProgramFiles}\OpenSSL\openssl.cnf" This value differs from previous installation versions (as seen in a previous edit of this post). Also, don't

Cracking short RSA keys

天涯浪子 提交于 2019-11-29 18:43:47
Given the following RSA keys, how does one go about determining what the values of p and q are? Public Key: (10142789312725007, 5) Private Key: (10142789312725007, 8114231289041741) Your teacher gave you: Public Key: (10142789312725007, 5) which means n = 10142789312725007 e = 5 where n is the modulus and e is the public exponent. In addition, you're given Private Key: (10142789312725007, 8114231289041741) meaning that d = 8114231289041741 where d is the decryption exponent that should remain secret. You can "break" RSA by knowing how to factor "n" into its "p" and "q" prime factors: n = p * q

Issues with OpenSSL on PHP - different behaviour for different versions

筅森魡賤 提交于 2019-11-29 15:42:49
(This question was originally posted on ServerFault - I have deleted it there and moved it here.) I have a development machine running PHP 5.3.5 and a production machine running PHP 5.3.8. The following code runs on the development machine: <?php $key = "-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC0x+2RiQ+LCZNAUcl/Ecf1NrTr lhjOiHaVC+w/y+UJevqVcDstD22OJGwT13B9T47OuQG9BmzcZQYLcShUMhVD/Owu 9+8PcK51EnBd0lym6+z/WixpnqfQonyKiqq5ytmYKUlUv39J8QQUI2geyvY9VpWS wyNcFUs7wPl2zsLCPQIDAQAB -----END PUBLIC KEY-----"; $data = "Hello, world!"; $key1 = openssl_get_publickey($key); print_r (

How do I encode an unmanaged<SecKey> to base64 to send to another server?

此生再无相见时 提交于 2019-11-29 15:30:39
I'm trying to use key pair encryption to validate identity between my app and my PHP server. To do this I need to send the public key over to the server after I generate it in my app. if let pubKey = NSData(base64EncodedData: publicKey, options: NSDataBase64DecodingOptions.allZeros)! { println(pubKey) } publicKey is of type Unmanaged<SecKey> . The error I'm getting in the above code is: Extra argument 'base64EncodedData' in call How would I do this? Is there a better way? Edit: This is how the keypair is generated: var publicKeyPtr, privateKeyPtr: Unmanaged<SecKey>? let parameters = [ String

exchange public/private key in PKCS#1 OAEP encryption/decryption

不想你离开。 提交于 2019-11-29 13:33:36
问题 I only have some very rudimentary theoretical knowledge about RSA. While reading different sources about how to use it in practice, it seemed that PKCS#1 OAEP would be a good thing. For a test implementation, I use Python with PyCrypto. E.g. this is an example using PKCS#1 OAEP. Encrypting using the public key and then decrypting using the private key works fine. E.g. the public can send some data to person X with the private key. From my basic understanding of how RSA works, I thought that I

Read KeyPair's publickey in RSA OpenSSH format?

岁酱吖の 提交于 2019-11-29 12:43:55
I’ve created a KeyPair in Java by doing the following: KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); keyPairGenerator.initialize(1024, new SecureRandom()); KeyPair keyPair = keyPairGenerator.generateKeyPair(); How do I get the publicKey from keyPair in the RSA OpenSSH format that begins with “-----BEGIN” ? Here is a quick hack which I haven't tested. This requires Java 6 or greater. For more information see the following RFCs: RFC 4716 RFC 4253 RFC 4251 import java.io.*; import java.math.BigInteger; import java.nio.*; import java.nio.charset.Charset; import java