Naive: how to generate EC public key from EC private key?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 18, 2016 at 06:59:36PM +0000, Blumenthal, Uri - 0553 - MITLL wrote:

> Answered my own question: should use EVP_PKEY_bits(pkey) instead.

That's not the right way to determine the curve id.

> >How do I determine what curve the above key is on?

For that you need to determine the EVP_PKEY algorithm type:

	int type = EVP_PKEY_base_id(pkey);

	if (type == EVP_PKEY_EC) {
	    EC_KEY *key = EVP_PKEY_get0_EC_KEY(pkey);
	    EC_GROUP *group = EC_KEY_get0_group(key);

	    /* Use that group to generate more points */
	}

So you don't need code to specifically identify the group, but if
you want to constrain the supported groups:

	switch (EC_GROUP_get_curve_name(group)) {
	case NID_undef:
	default:
	    /* Unknown or not named group */

	case NID_X9_62_prime256v1:
	    /* P-256 */
	    ...

	case NID_secp384r1:
	    /* P-384 */

	    ...
	}

-- 
	Viktor.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux