elliptic-curve

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

java.lang.IllegalArgumentException: string curve25519 not an OID bouncycastle 1.52

亡梦爱人 提交于 2019-12-21 05:40:53
问题 I'm trying to generate a key pair using the /java bouncy castle 1.52 implementation for curve 25519 what gives me java.lang.IllegalArgumentException: string curve25519 not an OID Here is my code: public KeyPair generateKeys() throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("curve25519"); KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", "BC"); g.initialize(ecSpec, new

Points calculated using this elliptic curve point multiplication do not lie on the curve and this class brings Arithmetic exception

余生颓废 提交于 2019-12-21 03:18:07
问题 I get stack on my error of point multiplication using standard projective coordinates. I don't know what i missed but the multiplied points do not lie on the curve and some times it outputs something like Arithmetic Exception: integer is not invertible. public class ECPointArthimetic { EllipticCurve ec; private BigInteger x; private BigInteger y; private BigInteger z; private BigInteger zinv; private BigInteger one = BigInteger.ONE; private BigInteger zero = BigInteger.ZERO; private boolean

.NET implementation (libraries) of elliptic curve cryptography

半腔热情 提交于 2019-12-20 17:37:33
问题 Please can you suggest any implementation of elliptical curve cryptography to be used on .NET platform? Also if you have used them, can you tell me the recommended curves that should be used? [EDIT] As @FatCat mentioned, its implementation is available in .NET framework 3.5 but that is only available on windows vista. Can you please suggest another way/library to use it? 回答1: Check out the Bouncy Castle library for C#, it has ECDH and ECDSA. 回答2: The .NET Framework already includes Diffie

Codes to generate a public key in an elliptic curve algorithm using a given private key

给你一囗甜甜゛ 提交于 2019-12-20 11:33:25
问题 I need to implement ECC (Elliptic Curve Cryptography) algorithm using jdk 1.7. I tried using bouncy castle, sunEC, but all of them gave errors and errors. My target is to generate an elliptic curve using the private key, I will be given to the system. Thus, I need to get a accurate code to generate a public key using a given private key using jdk1.7. The IDE I use is ecllipse. And I need to know, what are the other parameters I should be given other than a private key? Is it enough to provide

Using openssh public key (ecdsa-sha2-nistp256) with Java Security

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 04:47:27
问题 Is there a Java library/example to read an openssh format ecdsa public key to a JCE PublicKey in Java? I want to use EC for JWT . The format I'm trying to read is as per authorized_keys, or Github API (e.g. https://api.github.com/users/davidcarboni/keys): ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBK8hPtB72/sfYgNw1WTska2DNOJFx+QhUxuV6OLINSD2ty+6gxcM8yZrvMqWdMePGRb2cGh8L/0bGOk+64IQ/pM= I've found this answer, which is fine for RSA and DSS: Using public key from

Using openssh public key (ecdsa-sha2-nistp256) with Java Security

自闭症网瘾萝莉.ら 提交于 2019-12-20 04:47:18
问题 Is there a Java library/example to read an openssh format ecdsa public key to a JCE PublicKey in Java? I want to use EC for JWT . The format I'm trying to read is as per authorized_keys, or Github API (e.g. https://api.github.com/users/davidcarboni/keys): ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBK8hPtB72/sfYgNw1WTska2DNOJFx+QhUxuV6OLINSD2ty+6gxcM8yZrvMqWdMePGRb2cGh8L/0bGOk+64IQ/pM= I've found this answer, which is fine for RSA and DSS: Using public key from

Java compact representation of ECC PublicKey

爱⌒轻易说出口 提交于 2019-12-19 03:33:03
问题 java.security.PublicKey#getEncoded() returns X509 representation of key which in case of ECC adds a lot of overhead compared to raw ECC values. I'd like to be able to convert PublicKey to byte array (and vice versa) in most compact representation (i.e. as small byte chunk as possible). KeyType (ECC) and concrete curve type are known in advance so information about them do not need to be encoded. Solution can use Java API, BouncyCastle or any other custom code/library (as long as license does

Java compact representation of ECC PublicKey

China☆狼群 提交于 2019-12-19 03:32:12
问题 java.security.PublicKey#getEncoded() returns X509 representation of key which in case of ECC adds a lot of overhead compared to raw ECC values. I'd like to be able to convert PublicKey to byte array (and vice versa) in most compact representation (i.e. as small byte chunk as possible). KeyType (ECC) and concrete curve type are known in advance so information about them do not need to be encoded. Solution can use Java API, BouncyCastle or any other custom code/library (as long as license does

How do I obtain the public key from an ECDSA private key in OpenSSL?

霸气de小男生 提交于 2019-12-17 16:25:15
问题 I am providing this sample application to show my problem #include <stdio.h> #include <stdlib.h> #include <openssl/ec.h> #include <openssl/bn.h> int main() { EC_KEY *pkey = NULL; EC_POINT *pub_key = NULL; const EC_GROUP *group = NULL; BIGNUM start; BIGNUM *res; BN_CTX *ctx; BN_init(&start); ctx = BN_CTX_new(); res = &start; BN_hex2bn(&res,"3D79F601620A6D05DB7FED883AB8BCD08A9101B166BC60166869DA5FC08D936E"); pkey = EC_KEY_new_by_curve_name(NID_secp256k1); group = EC_KEY_get0_group(pkey); pub