public-key-encryption

How to Export Private Key For ECDiffieHellmanCng

旧城冷巷雨未停 提交于 2019-12-01 06:16:30
I am trying to export the keys from a new instance of a ECDiffieHellmanCng object so I can create an instance of it later with the same keys. But I am getting an error when trying to export it. //Create new ECDiffieHellmanCng which automatically creates new keys var ecdh = new ECDiffieHellmanCng(); //Export the keys var privateKey = ecdh.Key.Export(CngKeyBlobFormat.EccPrivateBlob); I am getting a CryptographicException when I call the Export method with the message " The requested operation is not supported. " After putting some breakpoints in the code it looks like it is throwing the

How to replicate hash_hmac('sha256', $key, $secret_key) function in Swift 4?

一笑奈何 提交于 2019-12-01 06:02:24
问题 I've tried generating the hash_hmac('sha256', $key, $secret_key) php function equivalent in Swift 4 without success, after using libraries like CommonCrypto, CryptoSwift. I need these function for API authentication, using Alamofire library, which is a great library. Since i use Swift 4 the compatibility with other Swift libraries is not so good. Even with CryptoSwift which has the latest version(0.7.1) for Swift 4 i still get a lot of compatibility errors likes enter image description here

Reading a PKCS#1 or SPKI public key in Java without libraries

一个人想着一个人 提交于 2019-12-01 05:38:47
问题 I need to use a public key to verify some data in Java, but I can't seem to format the key in such a way that Java can use without third-party plugins. I'm generating the key with Node.js's crypto library, which gives me the option of PKCS#1 or SPKI , and either .pem or .der file format. I've heard that Java doesn't support PKCS#1 out-of-the box, and pretty much every other answer on StackOverflow recommends using BouncyCastle or similar, but in my case, I am writing an SDK, and simply cannot

Use previously generated private key in ECIES

醉酒当歌 提交于 2019-12-01 04:51:43
问题 I wan to encrypt /decrypt data using ECIES , I am using cryptopp for this. AutoSeededRandomPool prng; //get private key generated ECIES<ECP>::Decryptor d0(prng, ASN1::secp256r1()); PrintPrivateKey(d0.GetKey()); //get public key ECIES<ECP>::Encryptor e0(d0); PrintPublicKey(e0.GetKey()); //encrypt the message string em0; // encrypted message StringSource ss1 (message, true, new PK_EncryptorFilter(prng, e0, new StringSink(em0) ) ); //decrypt the message string dm0; // decrypted message

OpenSSL RSA: Unable to encrypt/decrypt messages longer than 16 bytes

心已入冬 提交于 2019-12-01 04:20:38
I'm working on a simple program that uses OpenSSL to do basic RSA encryption and decryption. It is working fine for small messages (<16 bytes), but fails for anything over that. I understand that a limitation of public key cryptography is that you cannot encrypt anything longer than the key size. In my case, I'm using a 1024bit key, so I should have 128bytes to work with (maybe slightly less due to padding), correct? If so, that's not what I'm experiencing. Here's the output from my program with 15 bytes: Generating RSA keypair...done. Message to encrypt: 0123456789ABCDE 16 bytes encrypted

OpenSSL RSA: Unable to encrypt/decrypt messages longer than 16 bytes

大憨熊 提交于 2019-12-01 02:29:58
问题 I'm working on a simple program that uses OpenSSL to do basic RSA encryption and decryption. It is working fine for small messages (<16 bytes), but fails for anything over that. I understand that a limitation of public key cryptography is that you cannot encrypt anything longer than the key size. In my case, I'm using a 1024bit key, so I should have 128bytes to work with (maybe slightly less due to padding), correct? If so, that's not what I'm experiencing. Here's the output from my program

How to establish a secure connection by using Synapse?

浪尽此生 提交于 2019-11-30 18:51:50
I'm testing Synapse and want to know how can I establish a secure connection. I noticed it supports SSL, but I'm not sure whether it suits my needs. I don't have a certificate from CA. I just want to encrypt all data between my server program and client program. Sure, I can encrypt the data myself before sending out. But if SSL can encrypt the data, maybe I can just use it. From what I know, SSL is for "encryption" and "authentication". What I need is only "encryption". Is it possible with Synapse? UPDATE: Thanks for helping from daemon_x and the author of Synapse, Lukas Gebauer, I think I

RSA Encryption output size

心不动则不痛 提交于 2019-11-30 17:34:39
What is RSA encryption output size when using 2048 bit key (using pkcs1padding). Is it always 256 bytes independent of input size? how can i calculate it for other key sizes? Yes , it is. The output-size should always equals the size of the Modulus (part of the key), so: 2048 bit Modulus -> 2048 bit output 1024 bit Modulus -> 1024 bit output ... If it is not, there exist numerous attacks on RSA , see here for basic information about that. So to guarantee that the output is 2048 bit even when the input to encrypt is, let's say 7 , a padding must always be applied! The output (as integer) of

ECC Encryption and Decryption in Java

南笙酒味 提交于 2019-11-30 16:45:49
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 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 scheme for RSA encryption as well, most of the time. As you can see you can use this directly as a Cipher using

Encryption and decryption error 0x0407106B using OpenSSL

可紊 提交于 2019-11-30 15:20:55
问题 I'm writing a routine in C that reads a base64 string with the public key and proceeds to encrypt a string. I also test the same string's decryption but I'm getting error 0x0407106B when trying to do the decoding: $ openssl errstr 0x0407106B error:0407106B:rsa routines:RSA_padding_check_PKCS1_type_2:block type is not 02 Here's the code #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include <openssl/rsa.h> #include <openssl/engine.h> //#define PADDING RSA_PKCS1