public-key-encryption

How to Create SeckeyRef from exponent and modulus of Public key and use in SecKeyEncrypt method

本小妞迷上赌 提交于 2019-11-28 22:09:20
Anyone please help in Creating SecKeyRef from Exponent and Modulus being my Public exponent = 010001 and Public Modulus = 008903fb6d15f352ed3b45add3216f632f7139954a5631337aba7d645ed38482e3a810b4db26aab4d1df58c147230f0c75631a3dd0554b50de44e79f4fcf205c89fd3f80e0ff8d16c2e9f56ed3ab177953d54c9c30357d04e677cedd9912906ef8a046d7b0185b7f2022a8e435b0c6ecaef93f089fc3aa3f3677550b5d842046c7 and i want to use this SecKeyEncrypt as public key solved the problem NSData *publicTag=[self PublicKeyItems]; in Generating keypair and calling the method try importing BasicEncodingRules.h and .m in your file -

Encrypting a file with RSA in Python

随声附和 提交于 2019-11-28 16:22:43
问题 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 =

RSA Encryption Decryption in Android

China☆狼群 提交于 2019-11-28 15:23:24
I am implementing a demo for RSA Encryption and Decryption in Android. I can Perform Encryption very well, but In Decryption I get an Exception: >>java.security.InvalidKeyException: unknown key type passed to RSA . KeyPairGenerator kpg; KeyPair kp; PublicKey publicKey; PrivateKey privateKey; byte [] encryptedBytes,decryptedBytes; Cipher cipher,cipher1; String encrypted,decrypted; public String RSAEncrypt (final String plain) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { kpg = KeyPairGenerator.getInstance("RSA");

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

混江龙づ霸主 提交于 2019-11-28 15:15:59
问题 Is one more secure than the other? 回答1: 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

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

我的梦境 提交于 2019-11-28 13:50:59
问题 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 回答1: 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

Whose key is used to encrypt a HTTPS response?

99封情书 提交于 2019-11-28 11:33:07
I have a web server built up relying on HTTPS. So, my server maintains its private key and publish a public key that any clients can use to encrypt their request. Since my server is the only one who has the private key to decrypt any message encryped using server's public key, any request sent this way can be considered secure. However my question is at the response part. When the server sends the response back to the client, whose public key will the server use to encrypt the response message? I assume the server will use client's public key to encrypt the response (by default? or upon

Issues with OpenSSL on PHP - different behaviour for different versions

北城以北 提交于 2019-11-28 09:58:08
问题 (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

How can I convert a private key file from Java into .net x509Certificate2

ε祈祈猫儿з 提交于 2019-11-28 06:16:52
问题 I am writing a .NET client app that consumes a Java web service and need to sign sent requests (related to this other question). I have been supplied with a private.key file (and a .X509 certificate) and a Java source example. The certificate looks like the public key of service, and the private.key is what I use to sign requests. In the Java source, I can see they convert the file to a byte array and pass it into the constructor of the PKCS8EncodedKeySpec class. A bit of googling suggests

Read KeyPair's publickey in RSA OpenSSH format?

假如想象 提交于 2019-11-28 06:07:15
问题 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” ? 回答1: 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

C# How to simply encrypt a text file with a PGP Public Key?

天涯浪子 提交于 2019-11-28 05:55:55
I've researched a bit about how to achieve what I said in the question and found several APIs but most of them look very complicated and since I'm just a noobie in this area I just want a simple method like: public String Encrypt(String message, PublicKey publicKey) Don't know if this can be done? If not then please someone enlighten me another way to achieve this :) Thank you. UPDATE: So far I have only seen that all of the library for OpenPGP encryption require both the public key and private key to do the encrypt while I only want to encrypt with the public key (because I don't have the