eduardsui / tlse

Single C file TLS 1.2/1.3 implementation, using tomcrypt as crypto library
Other
535 stars 87 forks source link

Cannot be built with the current version of libtomcrypt (from Git) #51

Closed Peter2121 closed 3 years ago

Peter2121 commented 4 years ago

Probably, some structures are changed.

In file included from tlssimple.c:11:
./../tlse.c:1984:44: error: member reference type 'ltc_ecc_dp' is not a pointer; did you mean to use '.'?
    if ((err = mp_read_radix(prime, key->dp->prime, 16)) != CRYPT_OK) {
                                    ~~~~~~~^~
                                           .
./../tlse.c:996:67: note: expanded from macro 'mp_read_radix'
#define mp_read_radix(a, b, c)               ltc_mp.read_radix(a, b, c)
                                                                  ^
./../tlse.c:1987:40: error: member reference type 'ltc_ecc_dp' is not a pointer; did you mean to use '.'?
    if ((err = mp_read_radix(b, key->dp->B, 16)) != CRYPT_OK) {
                                ~~~~~~~^~
                                       .
./../tlse.c:996:67: note: expanded from macro 'mp_read_radix'
#define mp_read_radix(a, b, c)               ltc_mp.read_radix(a, b, c)
                                                                  ^
./../tlse.c:2078:10: error: no member named 'idx' in 'ecc_key'
    key->idx = -1;
    ~~~  ^
./../tlse.c:2079:14: error: assigning to 'ltc_ecc_dp' from incompatible type 'const ltc_ecc_set_type *'
    key->dp  = dp;
             ^ ~~
./../tlse.c:2264:10: error: no member named 'idx' in 'ecc_key'
    key->idx = -1;
    ~~~  ^
./../tlse.c:2265:14: error: assigning to 'ltc_ecc_dp' from incompatible type 'const ltc_ecc_set_type *'
    key->dp  = dp;
             ^ ~~

There are some warnings too.

eduardsui commented 4 years ago

Let me check. Thank you for reporting.

eduardsui commented 3 years ago

I think you are right, but in libtomcrypt releases, we have:

/** An ECC key */
typedef struct {
    /** Type of key, PK_PRIVATE or PK_PUBLIC */
    int type;

    /** Index into the ltc_ecc_sets[] for the parameters of this curve; if -1, then this key is using user supplied curve in dp */
    int idx;

    /** pointer to domain parameters; either points to NIST curves (identified by idx >= 0) or user supplied curve */
    const ltc_ecc_set_type *dp;

    /** The public key */
    ecc_point pubkey;

    /** The private key */
    void *k;
} ecc_key;

But indeed, in master branch we have:

/** An ECC key */
typedef struct {
    /** Type of key, PK_PRIVATE or PK_PUBLIC */
    int type;

    /** Structure with domain parameters */
    ltc_ecc_dp dp;

    /** Structure with the public key */
    ecc_point pubkey;

    /** The private key */
    void *k;
} ecc_key;

It should be fairly easy to rewrite this code, but not being an official release, I don't think it is a good ideea to support it. Things may change until the next official release.