encryption-asymmetric

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

Generate EC Diffie-Hellman public and private key pair

放肆的年华 提交于 2019-12-22 09:35:55
问题 I need to generate an EC Diffie Hellman key pair. I am using the secp256r1 named curve, and OpenSSL. This is what I have with me so far: unsigned char *ecdh(size_t *secret_len) { EVP_PKEY_CTX *pctx, *kctx; EVP_PKEY_CTX *ctx; unsigned char *secret; EVP_PKEY *pkey = NULL, *peerkey, *params = NULL; /* NB: assumes pkey, peerkey have been already set up */ /* Create the context for parameter generation */ if(NULL == (pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL))) printf("Error in EC key

Opening an RSA private key from Ruby

自古美人都是妖i 提交于 2019-12-22 05:09:08
问题 I think I know how to create custom encrypted RSA keys, but how can I read one encrypted like ssh-keygen does? I know I can do this: OpenSSL::PKey::RSA.new(File.read('private_key')) But then OpenSSL asks me for the passphrase... How can I pass it to OpenSSL as a parameter? And, how can I create one compatible to the ones generated by ssh-keygen? I do something like this to create private encrypted keys: pass = '123456' key = OpenSSL::PKey::RSA.new(1024) key = "0000000000000000#{key.to_der}" c

Seckey from public key string from server in Swift

大城市里の小女人 提交于 2019-12-21 05:10:27
问题 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 =

JWT Keys - Asymmetric and Symmetric

偶尔善良 提交于 2019-12-21 03:52:47
问题 I understand the difference between symmetric and asymmetric keys. I understand that the keys are used to calculate the signature and then verify them. However diving a little deeper, I'd like to understand a bit more which I'm having trouble finding online. Are the keys given to the consumers to verify the contents? Wouldn't that give consumers the ability to change the JWT contents if symmetric keys are used? When asymmetric keys are used is the signature calculated with the private or

How to encrypt and decrypt plain text with a RSA keys in Go?

[亡魂溺海] 提交于 2019-12-20 10:22:18
问题 I am trying to write a utility program which encrypts and decrypts plain text files using a RSA key pair. The RSA keys were generated with ssh-keygen and are stored in .ssh, as usual. I am having trouble understanding how to do that with the Go language crypto and crypto/rsa packages? The documentation on those is a little sparse (even more so because I am new to encryption) and there are very few examples. I checked the rsa_test.go file for any clues, but it only confused me more. In short I

Java asymmetric encryption: preferred way to store public/private keys

纵然是瞬间 提交于 2019-12-20 08:30:20
问题 This code generates a pair of public/private keys: KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA"); keyGen.initialize(1024); KeyPair keypair = keyGen.genKeyPair(); PrivateKey privateKey = keypair.getPrivate(); PublicKey publicKey = keypair.getPublic(); What I'd like to know is how do you usually store the public key: Option 1: store the bytes byte[] privateKeyBytes = privateKey.getEncoded(); byte[] publicKeyBytes = publicKey.getEncoded(); // ... write to file // convert bytes

Flexiprovider - How to encrypt/de with formatted keypair

房东的猫 提交于 2019-12-18 18:31:28
问题 Im using flexiprovider to encrypt/de with asymmetric algorithm based on Elliptic Curve following this tutorial. With a little modification, i'm gonna convert the public and the private key into Base64 for personal purpose (like storing into the database or text file). I'm also looking at this question and the answer is refer to this thread. But my code are running for dekstop not in android device, android and dekstop version in java i think is a really big difference (just for clean up my

Javascript asymmetric encryption and authentication

对着背影说爱祢 提交于 2019-12-18 17:32:16
问题 Some of the guys here are developing an application which incorporates some 'secure areas' accessible by logging in. In the past, the login form and subsequent 'secure' pages were all plain text transmitted over http, as it's an application that goes out for use on shared servers where there is little chance of being able to use SSL (think WordPress and the like). Most people just shrugged their shoulders as that's all they expected - it's hardly a national bank. We are now thinking of

BadPaddingException: invalid ciphertext

南楼画角 提交于 2019-12-18 13:50:11
问题 I would like some help as this is my first time in coding cryptography code. The encryption code appears to be working correctly, but the decryption throws an error. The error I get is: de.flexiprovider.api.exceptions.BadPaddingException: invalid ciphertext in the decrypt function towards the end of the code, which is marked as a comment // ERROR THROWN HERE! .............................. I have included all the imports, please excuse this, as thought it maybe relevant to the issue. Any help