Topic: 'wc_ecc_get_generator' is not compiled and cannot be used

I downloaded and installed wolfssl-5.5.4 according to the document. I want to use the wc_ecc_get_generator() function in ecc.h. When compiling, I found undefined reference to 'wc_ecc_get_generator()'. I use command 'nm libwolfssl.so | grep wc_ecc_get_generator' in the /usr/local/lib ,found that there is no such function in the .so file.Some other functions in ecc.h can be used, but this function cannot, what is the solution? i just want to get the elliptic curve generator of ecc_point type.Is there any way to replace this function to achieve it?Thank you very much

#include <iostream>
#include <string>
#include <unistd.h>
#include <wolfssl/options.h>
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/ssl.h>
#include <wolfssl/wolfcrypt/types.h>
#include <wolfssl/wolfcrypt/random.h>
#include <wolfssl/wolfcrypt/ecc.h>
#include <wolfssl/wolfcrypt/sp_int.h>
#include <wolfssl/wolfcrypt/integer.h>
#include <wolfssl/wolfcrypt/wolfmath.h>
using namespace std;
int main(){
ecc_key key;
WC_RNG rng;
wc_ecc_init(&key);
wc_InitRng(&rng);
int curveId = ECC_SECP521R1;
int keySize = wc_ecc_get_curve_size_from_id(curveId);
int ret = wc_ecc_make_key_ex(&rng, keySize, &key, curveId);
if (ret != MP_OKAY) {
// error handling
}
ecc_point point = key.pubkey;
ecc_point point1 ;
int err = 1;
err = wc_ecc_get_generator(&point1,curveId);
printf("%d\n",err);
err = 1;
err = wc_ecc_cmp_point(&point,&point1);
printf("%d\n",err);
return 0
}

Share

Re: 'wc_ecc_get_generator' is not compiled and cannot be used

Hi Wangzihao,

The `wc_ecc_get_generator` is wrapped with the `OPENSSL_EXTRA`. Make sure when building you include `./configure --enable-opensslextra`.

However normally someone would export the private or public key using a different function after a make_key. See `wc_ecc_export_x963`, `wc_ecc_export_private_only`, `wc_ecc_export_point_der`, `wc_ecc_export_public_raw`, etc.


Thanks,
David Garske, wolfSSL

Share

Re: 'wc_ecc_get_generator' is not compiled and cannot be used

Hi,David Garske,
    This method is useful, but when compiling the wc_ecc_curve_load() function, a warning"no previous procrytotype" is given.Is this normal? I will pay attention to the compilation problem next time, thank you very much

Share

Re: 'wc_ecc_get_generator' is not compiled and cannot be used

Hi Wangzihao,

Can you share the build settings you are using to compile wolfSSL (like the ./configure or user_settings.h)?

Thanks,
David Garske, wolfSSL

Share

Re: 'wc_ecc_get_generator' is not compiled and cannot be used

Hi,David Garske,
        I used this command

./configure  --enable-opensslextra --enable-ecc --enable-ecccustcurves CFLAGS="-DWOLFSSL_TEST_CERT -DWOLFSSL_DER_TO_PEM -DHAVE_ECC_KOBLITZ -DWOLFSSL_PUBLIC_MP " && make && sudo make install

        Thank you very much.
        Wangzihao

Share