Topic: EC_POINT_set_compressed_coordinates_GFp() support

Hi,

Is there a support for compressed coordinates for EC points? I found in WolfSSL a function EC_POINT_set_affine_coordinates_GFp(), but there is no EC_POINT_set_compressed_coordinates_GFp() which can be found in OpenSSL.

Also, are there any APIs available to convert the point between compressed and affine form?

For decryption process I'm trying to implement, I get the randomly generated ECDH public key from a device and need to set is as the X9.62 compressed coordinate of a point over GFp for group P-256, assuming 0 as the y-bit.

Thanks

Share

Re: EC_POINT_set_compressed_coordinates_GFp() support

Hi @eyrmin,

Thanks for your question, please checkout the sections of code wrapped by the setting HAVE_COMP_KEY (Short for HAVE COMPRESSED KEY).

Can you tell us a bit about what it is you are working on and which organization you are with? For a more private venue to share this information you can reach us at support [at] wolfssl [dot] com also.

Warm Regards,

K

Re: EC_POINT_set_compressed_coordinates_GFp() support

Hi,

I'm working on reading the ApplePay VAS loyalty passes. I have got the code working fine with OpenSSL but we can't build it for our  payment terminal which is why we tried to achieve the same with WolfSSL as it provides the OpenSSL compatibility layer.

The first step of the algorithm says:
"Set the randomly generated ECDH public key as the X9.62 compressed coordinate of a point over GFp for group P-256 , assuming 0 as the y-bit."

This randomly generated ECDH public key comes from the phone.


Using OpenSSL code, we achieve this with the following code (the only missing piece when using WolfSSL is EC_POINT_set_compressed_coordinates_GFp ):

int message_public_key(size_t message_len, const uint8_t* message, EVP_PKEY *public_key)
{
    int rc;
    if (message_len < ECIES_PUBLIC_KEY_SIZE) {
        rc = 0;
    }
    else {
        BIGNUM *bn = NULL;
        EC_GROUP *group = NULL;
        EC_POINT *ecp = NULL;
        EC_KEY *ephemeral_key = NULL;

        do {
            bn = BN_new();
            BN_bin2bn(message, ECIES_PUBLIC_KEY_SIZE, bn);
            group = EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1);
            ecp = EC_POINT_new(group);
            RC_CHECK(rc = EC_POINT_set_compressed_coordinates_GFp(group, ecp, bn, 0, NULL));
            ephemeral_key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
            RC_CHECK(rc = EC_KEY_set_public_key(ephemeral_key, ecp));
            RC_CHECK(rc = EVP_PKEY_set1_EC_KEY(public_key, ephemeral_key));
        } while (0);

        if (bn) BN_free(bn);
        if (group) EC_GROUP_free(group);
        if (ecp) EC_POINT_free(ecp);
        if (ephemeral_key) EC_KEY_free(ephemeral_key);
    }
    return rc;
}

Share

Re: EC_POINT_set_compressed_coordinates_GFp() support

Kaleb J. Himes wrote:

Thanks for your question, please checkout the sections of code wrapped by the setting HAVE_COMP_KEY (Short for HAVE COMPRESSED KEY).

I'm studying too Apple VAS encryption. I have tried to follow your hint, but I have not understood so much and I have not been able to solve the problem.
It seems to me HAVE_COMP_KEY option affects mainly keys import/export while the function
EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *p, const BIGNUM *x, int y_bit, BN_CTX *ctx)
calculates y value for a given x value (as square roots of x^3 + a*x + b) and then internally calls EC_POINT_set_affine_coordinates()
I'm not able to find some equivalent function within WolfSSL.

Thx,
Abramo

Share

Re: EC_POINT_set_compressed_coordinates_GFp() support

Abulafia,

We have a few separate requests in to add support for EC_POINT_set_compressed_coordinates (not yet available). We tend to work on new feature additions that are not tied to a funded effort in our spare time but as such we don't have a fixed timeline associated with their implementation. If a customer needs a new feature right away they can partner with us on the effort to get it implemented in a finite timeline. If this is a show-stopper for you be sure to contact the business manager for your region. If you are not sure who the business manager would be you can send a general inquiry to facts [at] wolfssl [dot] com to figure out who to connect with for your region.

Warm Regards,

K

Re: EC_POINT_set_compressed_coordinates_GFp() support

Thank you very much for your kind answer !

Share

Re: EC_POINT_set_compressed_coordinates_GFp() support

Thanks