ecdh

ECDH with key in Android Key Store

安稳与你 提交于 2020-01-02 10:18:29
问题 I'm developping an Android App that generates an EC Asymetric key. When my app gets connected to a device, they exchange their public key. They then use ECDH to establish a shared secret. This shared secret is then used to derive an AES session key. All this is working fine. I'm now working on the storage of the asymetric key. I wanted to put it in the Android KeyStore but I don't see how I can then do the ECDH operation. The key in the key store can be used to sign, decrypt or encrypt but I

SecKeyCopyKeyExchangeResult() function return an error, “kSecKeyKeyExchangeParameterRequestedSize is missing”

☆樱花仙子☆ 提交于 2019-12-25 01:41:10
问题 I'm using Xcode11 Beta as IDE and Swift. Below is my code, my code can work well on Xcode10.3, but it can't work on Xcode11. When I call the function SecKeyCopyKeyExchangeResult(), the stack always return an error, "kSecKeyKeyExchangeParameterRequestedSize is missing", but it's okay on Xcode10.3. I checked Apple Developer portal, haven't any clue on it. ` func main() { testECDH() } private func testECDH(){ generateKeyPair() let alicePublicKey = getPublicKey() let alicePrivateKey =

How do I get ECDH keypair in Android 9.0 pie?

房东的猫 提交于 2019-12-24 20:45:50
问题 I want to get ECDH keypair (Public key and Private key). This method is not working in Android 9.0 pie, because Security provider "BC" , "SC" is removed from this version. I tried below method KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC", "BC"); SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); keyGen.initialize(256, random); KeyFactory kaif = KeyFactory.getInstance("EC", "BC"); KeyPair pair = keyGen.generateKeyPair(); PrivateKey privateKey = pair.getPrivate();

Protection of an ECC Key in an Android Application

≡放荡痞女 提交于 2019-12-23 03:57:11
问题 I have done an Android Application using an ECC Key pair. When I have developed it last year, I wanted to create the ECC key in the Android Keystore. Unfortunately, this ECC key is used to generate a session key thanks to ECDH, and ECDH is not supported by Android Keystore (this is what I have been said here: ECDH with key in Android Key Store ) I have followed the recommendations: I have created an AES key in the Android KeyStore and I have used it to encrypt the ECC key before storing it in

What should the length of public key on ECDH be?

喜你入骨 提交于 2019-12-13 20:22:21
问题 I am working on a project. Implemented ECDH with C++(Botan library) now I am trying to implement ECDH on Android app and I will try to connect Android to Windows and will check if the shared secret keys are identical. My problem is related to Java implementation, it generates a longer public key than I expected. As far as I know or learn from here, If it is a 256-bit curve (secp256k1), keys will be: Public: 32 bytes * 2 + 1 = 65 (uncompressed) Private: 32 bytes // Generate ephemeral ECDH

How to import a bitcoin private key to BigInteger?

好久不见. 提交于 2019-12-13 07:59:03
问题 I use the following codes to try to import a bitcoin private key and compute the public key. The computed ECPublicKey is not equal to bitcoinPublicKey. How to correct? string bitcoinPrivateKeyStr = "cVnb9S9GgHxsBxfaApvGnWvfwqXRYdV8f1Q2CkQeBa4EsWTNmsGS"; BitcoinSecret bs = new BitcoinSecret(bitcoinPrivateKeyStr); byte[] bitcoinPrivateKeyBytes = bs.PrivateKey.ToBytes(); byte[] bitcoinPublicKeybytes = bs.PubKey.Decompress().ToBytes(); X9ECParameters curve = SecNamedCurves.GetByName("secp256k1");

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.'

Encryption in swift using Diffie Hellman key exchange and an elliptic curve encryption

倖福魔咒の 提交于 2019-12-11 06:24:35
问题 I've been trying to encrypt and decrypt a string in swift using a Diffie Hellman key exchange and an elliptic curve encryption. Following is the code that I followed. SWIFT Code : let attributes: [String: Any] = [kSecAttrKeySizeInBits as String: 256, kSecAttrKeyType as String: kSecAttrKeyTypeEC, kSecPrivateKeyAttrs as String: [kSecAttrIsPermanent as String: false]] var error: Unmanaged<CFError>? if #available(iOS 10.0, *) { **// Step 1: Generating the Public & Private Key** guard let

ECDH with key in Android Key Store

家住魔仙堡 提交于 2019-12-06 13:16:52
I'm developping an Android App that generates an EC Asymetric key. When my app gets connected to a device, they exchange their public key. They then use ECDH to establish a shared secret. This shared secret is then used to derive an AES session key. All this is working fine. I'm now working on the storage of the asymetric key. I wanted to put it in the Android KeyStore but I don't see how I can then do the ECDH operation. The key in the key store can be used to sign, decrypt or encrypt but I don't see the possibility to do ECDH operation. Is it possible? While browsing SO, I have seen this