public-key-encryption

Encrypting string in javascript and decryption in java

夙愿已清 提交于 2019-12-03 16:50:20
I would like to know if someone know any library to do encryption in javascript and decryption in java. I have already tried many API, But getting not not getting same values in java. I want public-private key encryption and hence try to use RSA. Few i have used are: http://www-cs-students.stanford.edu/~tjw/jsbn/ http://ats.oka.nu/titaniumcore/js/crypto/readme.txt http://www.ohdave.com/rsa/ Few thing i checked, javascript breaks string into small chunks and then encrypt them which make cipher text different in java and javascript. I edit javascript code to use string as a whole but didn't

How do I export a public key <SecKey> that was generated using SecKeyGeneratePair to be used on a server?

放肆的年华 提交于 2019-12-03 15:20:37
问题 I generated a keeper using SecKeyGeneratePair. var publicKeyPtr, privateKeyPtr: Unmanaged<SecKey>? let publicKeyParameters: [String: AnyObject] = [ kSecAttrIsPermanent: true, kSecAttrApplicationTag: "com.example.site.public" ] let privateKeyParameters: [String: AnyObject] = [ kSecAttrIsPermanent: true, kSecAttrApplicationTag: "com.example.site.private" ] let parameters: [String: AnyObject] = [ kSecAttrKeyType: kSecAttrKeyTypeRSA, kSecAttrKeySizeInBits: 2048, kSecPublicKeyAttrs

Seckey from public key string from server in Swift

爱⌒轻易说出口 提交于 2019-12-03 15:14:30
I want to encrypt data using RSA , I tried to generate the key in my code and it's working , But what I actually need is to get the public key as a string from server and then use it as Seckey so I can use it to encrypt data using RSA, I tried this code: //KeyString is the string of the key from server let KeyData = (keyString as NSString).dataUsingEncoding(NSUTF8StringEncoding) as NSData! var cert : Unmanaged<SecCertificateRef>!; var policy : Unmanaged<SecPolicy>!; cert = SecCertificateCreateWithData(kCFAllocatorDefault, KeyData); policy = SecPolicyCreateBasicX509(); var status : OSStatus =

ECC algorithm key mismatch

纵然是瞬间 提交于 2019-12-03 14:15:41
问题 I am trying to implement ECC algorithm on Android. I am currently using spongy castle to implement it. The key generation cone snippet is as follows : KeyPairGenerator kpg = null; try { kpg = KeyPairGenerator.getInstance("ECIES");// Do i have to do any changes here? } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } ECGenParameterSpec brainpoolP160R1 = new ECGenParameterSpec("brainpoolP160R1"); try { kpg.initialize(brainpoolP160R1); } catch (InvalidAlgorithmParameterException) { }

RSA Java encryption and Node.js decryption is not working

Deadly 提交于 2019-12-03 12:53:16
问题 I have a system that requires a RSA keypair to be generated in javascript, have the public key then stored in a database at the server side (as a string), then the server side which is in Java will encrypt a string with the stored public key and send it to the client side which will decrypt the string with the private key. I'm using a browsified version of node-rsa on my client browser. First at the client i generate a keypair and export the keys, storing them as strings var NodeRSA = require

Java - Diffie-Hellman Encryption - Wrong Output

Deadly 提交于 2019-12-03 10:14:59
I'm attempting to implement Diffie-Hellman key exchange. I am a little confused with how to use the secret key once generated. As seen in the output, the 2 secret keys are generated using the same prime & base as normal in the key exchange, and trade public keys when generating the secret keys, however they are not outputting the same value as I expected. I'm getting very confused with how to implement this encryption method and would be very grateful for some direction. My overall aim for this is to implement an encrypted SMS Android application. (The screenshot was unable to capture the

How is SSH_AUTH_SOCK setup and used by ssh-agent?

坚强是说给别人听的谎言 提交于 2019-12-03 09:53:53
I have been able to setup the sharing of ssh-agent for public-key authentication after reading https://superuser.com/a/230872/301446 The environment file thus generated has the following contents: SSH_AUTH_SOCK=/tmp/ssh-OwqeSuxmEsQN/agent.4744; export SSH_AUTH_SOCK; SSH_AGENT_PID=8960; export SSH_AGENT_PID; #echo Agent pid 8960; And agent.4744 has: !<socket >24194 s 07DF88C6-E9997283-4C471010-2FE57D77 Would you know how this socket is used by ssh-agent? I can understand that it's used by ssh-agent to share authentication information but exactly how? From here : $SSH_AUTH_SOCK contains the path

Java public private key decryption issue

微笑、不失礼 提交于 2019-12-03 09:39:15
I am trying to encrypt and decrypt a message as mentioned in the below code. Basically I want to encrypt a message with a public key and convert that encrypted message from byte array to String. And decrypt this string into original text. Here are the both methods. Here encryption works fine but decryption fails (error is "Data must start with zero"). I think this is causing because I convert encrypted byte array into String. How do I solve this? (I want to have encrypted byte array as string and use it for decryption) Is there any other approach (with public and private keys) public static

How to implement OpenSSL functionality in Python?

不打扰是莪最后的温柔 提交于 2019-12-03 09:11:33
问题 I would like to encrypt a secret text by public-key and decrypt it by private-key in Python. I can achieve that with the openssl command: echo "secrettext/2011/09/14 22:57:23" | openssl rsautl -encrypt -pubin -inkey public.pem | base64 data.cry base64 -D data.cry | openssl rsautl -decrypt -inkey private.pem How would one implement that in Python? 回答1: Encrypt #!/usr/bin/env python import fileinput from M2Crypto import RSA rsa = RSA.load_pub_key("public.pem") ctxt = rsa.public_encrypt

Which symmetric key algorithm does SSL use?

旧城冷巷雨未停 提交于 2019-12-03 09:03:19
问题 I understand that through SSL, the browser gets the public key of the secured website and through public key encryption rsa algorithm, these 2 establish session key and then continue communication thru some symmetric algorithm, because symmetric key encryption/decryption is faster. Which symmetric key algorithm does SSL use? DES? AES? or something else? 回答1: When the client connects to the server, it negotiates a so-called ciphersuite (combination of encryption, key exchange, authentication