diffie-hellman

How to get AES secret key from DH secret key

这一生的挚爱 提交于 2019-12-20 04:15:22
问题 I have the following code that converts a DH secret key to AES secret key. This used to work until Oracle JRE 8u161 when they started restricting creation of DH keys < 1024 in java.security file. Now, I will get NoSuchAlgorithmException: Unsupported secret key algorithm AES at the last line. PrivateKey privKey = null; PublicKey pubKey = null; PublicKey agreement = null; KeyAgreement keyAgreement = KeyAgreement.getInstance("DH"); keyAgreement.init(privKey); keyAgreement.doPhase(pubKey, false);

How to Export Private Key For ECDiffieHellmanCng

梦想的初衷 提交于 2019-12-19 09:07:16
问题 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

Generate Diffie Hellman Object using npm `threads` module: getPrime is undefined

会有一股神秘感。 提交于 2019-12-13 03:23:09
问题 Using from npm threads library I try to create a diffie hellman in a non-blocking manner using a seperate thread instead of the main one: const spawn = require('threads').spawn; const thread = spawn(function(input, done) { const cryptot = require('crypto'); const dh = cryptot.createDiffieHellman(2048); done({dh}); }); thread.send({p:null, g:null}).on('message', (response) => { console.log(response.dh.getPrime(), response.dh.getGenerator()); thread.kill(); }).on('error', (err)=>{ console.error

ECDH secrets generated by BouncyCastle Java API and by OpenSSL are different

与世无争的帅哥 提交于 2019-12-13 00:09:23
问题 I'm trying to make use of elliptic curve crypto. I need two implementations of the same thing, one in Java and one in C. I'm testing them using two key pairs which were generated using the curve secp256k1 . When I generate the derived secret in Java I always get a different number from what I get from OpenSSL. Java code: /* privateKey and peerPublicKey are generated with the following parameters */ ECParameterSpec paramSpec = ECNamedCurveTable.getParameterSpec("secp256k1"); /* ... */ Provider

Processing BigInteger issues

一个人想着一个人 提交于 2019-12-12 13:04:25
问题 Assume the following Diffie-Hellman info which can also be found on this page 1)P string givenp = "00e655cc9e04f3bebae76ecca77143ef5c4451876615a9f8b4f712b8f3bdf47ee7f717c09bb5b2b66450831367d9dcf85f9f0528bcd5318fb1dab2f23ce77c48b6b7381eed13e80a14cca6b30b5e37ffe53db15e2d6b727a2efcee51893678d50e9a89166a359e574c4c3ca5e59fae79924fe6f186b36a2ebde9bf09fe4de50453"; BigInteger p = new BigInteger(HexToBytesv2(givenp)); 2)G BigInteger g = new BigInteger(2); 3)Merchant private key string

Shared Secret based on Elliptic curve Diffie–Hellman with CommonCrypto

一世执手 提交于 2019-12-12 11:07:42
问题 I am looking for the methods in CommonCrypto to generate the shared secret based on ECDH (Elliptic curve Diffie–Hellman). I can find proprietary implementations like this one https://github.com/surespot/surespot-ios/blob/master/surespot/encryption/EncryptionController.mm but this one is not using CommonCrypto. The method to calculate the shared secret is called sometimes Key Exchange and includes the calculation of the shared secret. Can someone send a link to the right documentation or to an

Can't bridge Elliptic Curve Diffie-Hellman with javascript

我们两清 提交于 2019-12-12 09:17:28
问题 I know this is a very specific question but I tried to exchange keys between php and a client using the Elliptic Curve Diffie-Hellman algorithm (ECDH) based on 2 libraries that seem sound: https://github.com/mdanter/phpecc for the php part and http://www-cs-students.stanford.edu/~tjw/jsbn/ecdh.html for the js part. It seems that the parameters (as can be seen at the second demo) just aren't right for the Mattias Danter library in (1)! What I tried: a. produce Alice public key in php b. take x

C# and PHP ECDH not matching

我只是一个虾纸丫 提交于 2019-12-12 06:58:24
问题 I'm trying to generate a shared secret between a web server running PHP and a C# desktop application. I'm aware of the BouncyCastle library, but I'd prefer not having to use it since it's pretty huge. I'm using phpecc and ECDiffieHellmanCng and trying to generate a shared secret between the two parties but I'm having issues with exporting/importing in C#. It seems phpecc requires der/pem format in order to import a key, and ECDiffieHellmanCng doesn't seem to have any easy way to export in a

String to PublicKey using Diffie-Hellman algorithm

元气小坏坏 提交于 2019-12-11 19:44:40
问题 I have a Public key string (128 bytes byte to hex processed) given by my client. I need to generate shared key using the private key and Public key given by client. I'm getting below exception while converting the String to Public key. I tried decoding/encoding the bytes, no improvement. I have the following code. // This is a sample key. private static final String PUB_KEY = "0DC1B7102DE3F6785A284ABFCA1822A6B59C947B5F2FAAE" +

ECDiffieHellmanPublicKey from ByteArray (using ECDiffieHellman NamedCurves)

孤者浪人 提交于 2019-12-11 19:02:31
问题 I'm working on communication nodejs -> c# server. I need to secure connection between them so I chode ECDiffieHellman as the key exchange mechanism (nodejs supports it). I had some problem with it... Just my lack of knowledge so I've made my lesson and now I can generate and export keys as base64 and nodejs have no problem with accepting c# key but on the other side c# ... won't even take his own key ... error System.Security.Cryptography.CryptographicException: 'The parameter is incorrect.'