Skip to content

Commit 69688c2

Browse files
committed
linuxkm ecdsa: fix ecc define guards.
1 parent a626ec2 commit 69688c2

2 files changed

Lines changed: 30 additions & 15 deletions

File tree

linuxkm/lkcapi_ecdsa_glue.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ static int linuxkm_test_ecdsa_nist_driver(const char * driver,
3737
const byte * sig, word32 sig_len,
3838
const byte * hash, word32 hash_len);
3939

40-
#if defined(HAVE_ECC192)
40+
#if defined(LINUXKM_ECC192)
4141
static int ecdsa_nist_p192_loaded = 0;
42-
#endif /* HAVE_ECC192 */
42+
#endif /* LINUXKM_ECC192 */
4343
static int ecdsa_nist_p256_loaded = 0;
4444
static int ecdsa_nist_p384_loaded = 0;
4545
#if defined(HAVE_ECC521)
@@ -60,16 +60,16 @@ static unsigned int km_ecdsa_max_size(struct crypto_akcipher *tfm);
6060
static int km_ecdsa_verify(struct akcipher_request *req);
6161

6262
/* ecdsa_nist_pN callbacks */
63-
#if defined(HAVE_ECC192)
63+
#if defined(LINUXKM_ECC192)
6464
static int km_ecdsa_nist_p192_init(struct crypto_akcipher *tfm);
65-
#endif /* HAVE_ECC192 */
65+
#endif /* LINUXKM_ECC192 */
6666
static int km_ecdsa_nist_p256_init(struct crypto_akcipher *tfm);
6767
static int km_ecdsa_nist_p384_init(struct crypto_akcipher *tfm);
6868
#if defined(HAVE_ECC521)
6969
static int km_ecdsa_nist_p521_init(struct crypto_akcipher *tfm);
7070
#endif /* HAVE_ECC521 */
7171

72-
#if defined(HAVE_ECC192)
72+
#if defined(LINUXKM_ECC192)
7373
static struct akcipher_alg ecdsa_nist_p192 = {
7474
.base.cra_name = "ecdsa-nist-p192",
7575
.base.cra_driver_name = "ecdsa-nist-p192-wolfcrypt",
@@ -82,7 +82,7 @@ static struct akcipher_alg ecdsa_nist_p192 = {
8282
.init = km_ecdsa_nist_p192_init,
8383
.exit = km_ecdsa_exit,
8484
};
85-
#endif /* HAVE_ECC192 */
85+
#endif /* LINUXKM_ECC192 */
8686

8787
static struct akcipher_alg ecdsa_nist_p256 = {
8888
.base.cra_name = "ecdsa-nist-p256",
@@ -145,7 +145,7 @@ static int km_ecdsa_set_pub(struct crypto_akcipher *tfm, const void *key,
145145
ctx = akcipher_tfm_ctx(tfm);
146146

147147
switch (ctx->curve_len) {
148-
#if defined(HAVE_ECC192)
148+
#if defined(LINUXKM_ECC192)
149149
case 24: /* p192 */
150150
#endif
151151
case 32: /* p256 */
@@ -276,12 +276,12 @@ static int km_ecdsa_init(struct crypto_akcipher *tfm, int curve_id)
276276
return 0;
277277
}
278278

279-
#if defined(HAVE_ECC192)
279+
#if defined(LINUXKM_ECC192)
280280
static int km_ecdsa_nist_p192_init(struct crypto_akcipher *tfm)
281281
{
282282
return km_ecdsa_init(tfm, ECC_SECP192R1);
283283
}
284-
#endif /* HAVE_ECC192 */
284+
#endif /* LINUXKM_ECC192 */
285285

286286
static int km_ecdsa_nist_p256_init(struct crypto_akcipher *tfm)
287287
{
@@ -393,7 +393,7 @@ static int km_ecdsa_verify(struct akcipher_request *req)
393393
return err;
394394
}
395395

396-
#if defined(HAVE_ECC192)
396+
#if defined(LINUXKM_ECC192)
397397
static int linuxkm_test_ecdsa_nist_p192(void)
398398
{
399399
int rc = 0;
@@ -443,7 +443,7 @@ static int linuxkm_test_ecdsa_nist_p192(void)
443443

444444
return rc;
445445
}
446-
#endif /* HAVE_ECC192 */
446+
#endif /* LINUXKM_ECC192 */
447447

448448
static int linuxkm_test_ecdsa_nist_p256(void)
449449
{

linuxkm/lkcapi_glue.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4195,7 +4195,22 @@ static int linuxkm_test_aesecb(void) {
41954195
#undef LINUXKM_LKCAPI_REGISTER_ECDSA
41964196
#endif /* HAVE_ECC */
41974197

4198+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 13, 0) && \
4199+
defined(LINUXKM_LKCAPI_REGISTER_ECDSA)
4200+
/**
4201+
* note: ecdsa only supported with linux 6.12 and earlier for now.
4202+
* In linux 6.13, ecdsa changed from a struct akcipher_alg type to
4203+
* struct sig_alg type, and the sign/verify callbacks were removed
4204+
* from akcipher_alg.
4205+
* */
4206+
#undef LINUXKM_LKCAPI_REGISTER_ECDSA
4207+
#endif
4208+
41984209
#if defined(LINUXKM_LKCAPI_REGISTER_ECDSA)
4210+
#if (defined(HAVE_ECC192) || defined(HAVE_ALL_CURVES)) && \
4211+
ECC_MIN_KEY_SZ <= 192
4212+
#define LINUXKM_ECC192
4213+
#endif
41994214
#include "linuxkm/lkcapi_ecdsa_glue.c"
42004215
#endif
42014216

@@ -4284,10 +4299,10 @@ static int linuxkm_lkcapi_register(void)
42844299
#endif
42854300

42864301
#ifdef LINUXKM_LKCAPI_REGISTER_ECDSA
4287-
#if defined(HAVE_ECC192)
4302+
#if defined(LINUXKM_ECC192)
42884303
REGISTER_ALG(ecdsa_nist_p192, crypto_register_akcipher,
42894304
linuxkm_test_ecdsa_nist_p192);
4290-
#endif /* HAVE_ECC192 */
4305+
#endif /* LINUXKM_ECC192 */
42914306

42924307
REGISTER_ALG(ecdsa_nist_p256, crypto_register_akcipher,
42934308
linuxkm_test_ecdsa_nist_p256);
@@ -4352,9 +4367,9 @@ static void linuxkm_lkcapi_unregister(void)
43524367
#endif
43534368

43544369
#ifdef LINUXKM_LKCAPI_REGISTER_ECDSA
4355-
#if defined(HAVE_ECC192)
4370+
#if defined(LINUXKM_ECC192)
43564371
UNREGISTER_ALG(ecdsa_nist_p192, crypto_unregister_akcipher);
4357-
#endif /* HAVE_ECC192 */
4372+
#endif /* LINUXKM_ECC192 */
43584373
UNREGISTER_ALG(ecdsa_nist_p256, crypto_unregister_akcipher);
43594374
UNREGISTER_ALG(ecdsa_nist_p384, crypto_unregister_akcipher);
43604375
#if defined(HAVE_ECC521)

0 commit comments

Comments
 (0)