Tamas Ban | a71bc97 | 2024-09-16 13:57:38 +0200 | [diff] [blame] | 1 | From 91cbc7bff52d51030c3163f30bc0e86333554ece Mon Sep 17 00:00:00 2001 |
| 2 | From: David Vincze <david.vincze@arm.com> |
| 3 | Date: Mon, 25 Nov 2024 14:29:04 +0000 |
| 4 | Subject: [PATCH] Remove unused EdDSA calls to help reduce code size |
| 5 | |
| 6 | With the help of dead-code elimination and actual code removal |
| 7 | in this patch it's possible to skip the complete EdDSA algorithm |
| 8 | support from the build process. |
| 9 | |
| 10 | Remove EdDSA from sign verifier as it does not need to be covered |
| 11 | by the tests. Remove it from the code so the build does not depend |
| 12 | on it. |
| 13 | |
| 14 | --- |
| 15 | src/t_cose_sign1_sign.c | 13 ------------- |
| 16 | src/t_cose_sign1_verify.c | 8 -------- |
| 17 | 2 files changed, 21 deletions(-) |
| 18 | |
| 19 | diff --git a/src/t_cose_sign1_sign.c b/src/t_cose_sign1_sign.c |
| 20 | index ea0713e..fdf8efd 100644 |
| 21 | --- a/src/t_cose_sign1_sign.c |
| 22 | +++ b/src/t_cose_sign1_sign.c |
| 23 | @@ -37,17 +37,10 @@ t_cose_sign1_sign_init(struct t_cose_sign1_sign_ctx *me, |
| 24 | // TODO: Translate any more options flags? |
| 25 | t_cose_sign_sign_init(&(me->me2), option_flags | T_COSE_OPT_MESSAGE_TYPE_SIGN1); |
| 26 | |
| 27 | - if(cose_algorithm_id == T_COSE_ALGORITHM_EDDSA) { |
| 28 | - t_cose_signature_sign_eddsa_init(&(me->signer.eddsa)); |
| 29 | - t_cose_sign_add_signer(&(me->me2), |
| 30 | - t_cose_signature_sign_from_eddsa(&(me->signer.eddsa))); |
| 31 | - } else |
| 32 | - { |
| 33 | t_cose_signature_sign_main_init(&(me->signer.general), |
| 34 | me->cose_algorithm_id); |
| 35 | t_cose_sign_add_signer(&(me->me2), |
| 36 | t_cose_signature_sign_from_main(&(me->signer.general))); |
| 37 | - } |
| 38 | } |
| 39 | |
| 40 | |
| 41 | @@ -58,15 +51,9 @@ t_cose_sign1_set_signing_key(struct t_cose_sign1_sign_ctx *me, |
| 42 | { |
| 43 | me->signing_key = signing_key; /* Used by make test message */ |
| 44 | me->kid = kid; /* Used by make test message */ |
| 45 | - if(me->cose_algorithm_id == T_COSE_ALGORITHM_EDDSA) { |
| 46 | - t_cose_signature_sign_eddsa_set_signing_key(&(me->signer.eddsa), |
| 47 | - signing_key, |
| 48 | - kid); |
| 49 | - } else { |
| 50 | t_cose_signature_sign_main_set_signing_key(&(me->signer.general), |
| 51 | signing_key, |
| 52 | kid); |
| 53 | - } |
| 54 | } |
| 55 | |
| 56 | |
| 57 | diff --git a/src/t_cose_sign1_verify.c b/src/t_cose_sign1_verify.c |
| 58 | index 0614bb0..a3fc221 100644 |
| 59 | --- a/src/t_cose_sign1_verify.c |
| 60 | +++ b/src/t_cose_sign1_verify.c |
| 61 | @@ -34,10 +34,6 @@ t_cose_sign1_verify_init(struct t_cose_sign1_verify_ctx *me, |
| 62 | t_cose_signature_verify_main_init(&(me->main_verifier)); |
| 63 | t_cose_sign_add_verifier(&(me->me2), |
| 64 | t_cose_signature_verify_from_main(&(me->main_verifier))); |
| 65 | - |
| 66 | - t_cose_signature_verify_eddsa_init(&(me->eddsa_verifier), option_flags); |
| 67 | - t_cose_sign_add_verifier(&(me->me2), |
| 68 | - t_cose_signature_verify_from_eddsa(&(me->eddsa_verifier))); |
| 69 | } |
| 70 | |
| 71 | |
| 72 | @@ -49,10 +45,6 @@ t_cose_sign1_set_verification_key(struct t_cose_sign1_verify_ctx *me, |
| 73 | * until decoding the input. There is only one key in t_cose_sign1(). |
| 74 | * Also, t_cose_sign1 didn't do any kid matching, so it is NULL here. |
| 75 | */ |
| 76 | - t_cose_signature_verify_eddsa_set_key(&(me->eddsa_verifier), |
| 77 | - verification_key, |
| 78 | - // TODO: should this be NULL? |
| 79 | - NULL_Q_USEFUL_BUF_C); |
| 80 | t_cose_signature_verify_main_set_key(&(me->main_verifier), |
| 81 | verification_key, |
| 82 | NULL_Q_USEFUL_BUF_C); |
| 83 | -- |
| 84 | 2.34.1 |