|
30 | 30 | #include "ccid/ccid.h"
|
31 | 31 | #include "otp.h"
|
32 | 32 | #include "do.h"
|
| 33 | +#ifdef MBEDTLS_EDDSA_C |
33 | 34 | #include "mbedtls/eddsa.h"
|
| 35 | +#endif |
34 | 36 |
|
35 | 37 | uint8_t PICO_PRODUCT = 3;
|
36 | 38 |
|
@@ -573,10 +575,13 @@ int load_private_key_ecdsa(mbedtls_ecp_keypair *ctx, file_t *fkey, bool use_dek)
|
573 | 575 | return PICOKEY_EXEC_ERROR;
|
574 | 576 | }
|
575 | 577 | mbedtls_platform_zeroize(kdata, sizeof(kdata));
|
| 578 | +#ifdef MBEDTLS_EDDSA_C |
576 | 579 | if (ctx->grp.id == MBEDTLS_ECP_DP_ED25519) {
|
577 | 580 | r = mbedtls_ecp_point_edwards(&ctx->grp, &ctx->Q, &ctx->d, random_gen, NULL);
|
578 | 581 | }
|
579 |
| - else { |
| 582 | + else |
| 583 | +#endif |
| 584 | + { |
580 | 585 | r = mbedtls_ecp_mul(&ctx->grp, &ctx->Q, &ctx->d, &ctx->grp.G, random_gen, NULL);
|
581 | 586 | }
|
582 | 587 | if (r != 0) {
|
@@ -623,9 +628,11 @@ mbedtls_ecp_group_id get_ec_group_id_from_attr(const uint8_t *algo, size_t algo_
|
623 | 628 | else if (memcmp(algorithm_attr_x448 + 2, algo, algo_len) == 0) {
|
624 | 629 | return MBEDTLS_ECP_DP_CURVE448;
|
625 | 630 | }
|
| 631 | +#ifdef MBEDTLS_EDDSA_C |
626 | 632 | else if (memcmp(algorithm_attr_ed25519 + 2, algo, algo_len) == 0) {
|
627 | 633 | return MBEDTLS_ECP_DP_ED25519;
|
628 | 634 | }
|
| 635 | +#endif |
629 | 636 | return MBEDTLS_ECP_DP_NONE;
|
630 | 637 | }
|
631 | 638 |
|
@@ -744,10 +751,13 @@ int ecdsa_sign(mbedtls_ecp_keypair *ctx,
|
744 | 751 | size_t *out_len) {
|
745 | 752 |
|
746 | 753 | int r = 0;
|
| 754 | +#ifdef MBEDTLS_EDDSA_C |
747 | 755 | if (ctx->grp.id == MBEDTLS_ECP_DP_ED25519) {
|
748 | 756 | r = mbedtls_eddsa_write_signature(ctx, data, data_len, out, 64, out_len, MBEDTLS_EDDSA_PURE, NULL, 0, random_gen, NULL);
|
749 | 757 | }
|
750 |
| - else { |
| 758 | + else |
| 759 | +#endif |
| 760 | + { |
751 | 761 | mbedtls_mpi ri, si;
|
752 | 762 | mbedtls_mpi_init(&ri);
|
753 | 763 | mbedtls_mpi_init(&si);
|
|
0 commit comments