HI for ECDH can I use the HAs256 algorithm. I have gone through the inside DS and written this piece of code and it worked also. But here how can U sesha256 ,when i used i am getting the error. How can i use here sha256?
int alen = 0; int blen = 0; int aout = 0; int bout = 0; static const int KDF1_SHA1_len = 20; unsigned char *abuf = NULL; unsigned char *bbuf = NULL; EC_KEY *ecdh = NULL; EC_KEY *ecdh2 = NULL; //Generate Public // ecdh = EC_KEY_new_by_curve_name(NID_secp521r1); // ecdh2 = EC_KEY_new_by_curve_name(NID_secp521r1); ecdh = EC_KEY_new_by_curve_name((NID_sect163k1)); ecdh2 = EC_KEY_new_by_curve_name(NID_sect163k1); EC_KEY_generate_key(ecdh); EC_KEY_generate_key(ecdh2); alen = KDF1_SHA1_len; abuf = (unsigned char *) OPENSSL_malloc (alen); aout = ECDH_compute_key(abuf, alen, EC_KEY_get0_public_key(ecdh2), ecdh, KDF1_SHA1); printf("aout is %d\n",aout); blen = KDF1_SHA1_len; bbuf = (unsigned char *)OPENSSL_malloc(blen); bout = ECDH_compute_key(bbuf, blen, EC_KEY_get0_public_key(ecdh), ecdh2, KDF1_SHA1); On 17 December 2012 20:15, jeetendra gangele <gangele...@gmail.com> wrote: > I need to use ECDH to derive the shared key using public and private key > given. > > > > On 17 December 2012 18:56, jeetendra gangele <gangele...@gmail.com> wrote: >> Thanks for ur help . >> >> >> Can you guide me how can I use ECDH for exachnaging of the secret key. >> I have to implement in two phases. >> 1.i have private key of 256 bit lenght need to get phase i1 value wx,wy >> 2.In second I have phase1 value and private key and need to get secret >> key or public key. >> >> >> >> Thanks >> >> >> On 17 December 2012 13:55, Dave Thompson <dthomp...@prinpay.com> wrote: >>>> From: owner-openssl-us...@openssl.org On Behalf Of jeetendra gangele >>>> Sent: Monday, 17 December, 2012 02:48 >>> >>>> Yes i am talking about signature. >>>> ECDSA_SIG this ouptput structure will have r and s componet >>>> of 28 bytes each. [for 224-bit curve] >>>> So if I merge both r and s I will get 56 bytes right? >>>> These will not have any padding information?. >>>> >>> The struct points to two bignums, which use an internal >>> format; openssl can put what it likes in there. >>> If you get the (near-trivial) encoding as big-endian btyes >>> using BN_bn2bin, *that* does not have padding or overhead. >>> >>> Note that the numbers in an ECDSA signature are effectively >>> uniform random up to the field order, so they will *rarely* >>> be *smaller* than the keysize (here, less then 28 bytes). >>> If you want *fixed* 28 bytes each, *you* will need to pad. >>> >>> (I forgot to allow for this in my earlier reply. The ASN.1 >>> encoding can be less than 62 bytes in these cases.) >>> >>> ______________________________________________________________________ >>> OpenSSL Project http://www.openssl.org >>> User Support Mailing List openssl-users@openssl.org >>> Automated List Manager majord...@openssl.org ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org