From 40f1ba7e330cf7d178ed7fd7a2a48a0324577cc3 Mon Sep 17 00:00:00 2001 From: Hayden Roche Date: Thu, 13 Oct 2022 16:18:20 -0700 Subject: [PATCH] Fix output length bug in SP non-blocking ECC shared secret gen. This was incorrectly being set to 32 for P-384/521 due to a bug in the SP gen script. --- wolfcrypt/src/sp_arm32.c | 4 ++-- wolfcrypt/src/sp_arm64.c | 4 ++-- wolfcrypt/src/sp_armthumb.c | 4 ++-- wolfcrypt/src/sp_c32.c | 4 ++-- wolfcrypt/src/sp_c64.c | 4 ++-- wolfcrypt/src/sp_cortexm.c | 4 ++-- wolfcrypt/src/sp_x86_64.c | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/wolfcrypt/src/sp_arm32.c b/wolfcrypt/src/sp_arm32.c index a37f13383..c44616d55 100644 --- a/wolfcrypt/src/sp_arm32.c +++ b/wolfcrypt/src/sp_arm32.c @@ -92096,7 +92096,7 @@ int sp_ecc_secret_gen_384_nb(sp_ecc_ctx_t* sp_ctx, const mp_int* priv, &ctx->point, &ctx->point, ctx->k, 1, 1, heap); if (err == MP_OKAY) { sp_384_to_bin_12(ctx->point.x, out); - *outLen = 32; + *outLen = 48; } break; } @@ -119525,7 +119525,7 @@ int sp_ecc_secret_gen_521_nb(sp_ecc_ctx_t* sp_ctx, const mp_int* priv, &ctx->point, &ctx->point, ctx->k, 1, 1, heap); if (err == MP_OKAY) { sp_521_to_bin_17(ctx->point.x, out); - *outLen = 32; + *outLen = 66; } break; } diff --git a/wolfcrypt/src/sp_arm64.c b/wolfcrypt/src/sp_arm64.c index e8753e0a1..d7c313383 100644 --- a/wolfcrypt/src/sp_arm64.c +++ b/wolfcrypt/src/sp_arm64.c @@ -65863,7 +65863,7 @@ int sp_ecc_secret_gen_384_nb(sp_ecc_ctx_t* sp_ctx, const mp_int* priv, &ctx->point, &ctx->point, ctx->k, 1, 1, heap); if (err == MP_OKAY) { sp_384_to_bin_6(ctx->point.x, out); - *outLen = 32; + *outLen = 48; } break; } @@ -110869,7 +110869,7 @@ int sp_ecc_secret_gen_521_nb(sp_ecc_ctx_t* sp_ctx, const mp_int* priv, &ctx->point, &ctx->point, ctx->k, 1, 1, heap); if (err == MP_OKAY) { sp_521_to_bin_9(ctx->point.x, out); - *outLen = 32; + *outLen = 66; } break; } diff --git a/wolfcrypt/src/sp_armthumb.c b/wolfcrypt/src/sp_armthumb.c index 1ec5f38b5..a56b47be5 100644 --- a/wolfcrypt/src/sp_armthumb.c +++ b/wolfcrypt/src/sp_armthumb.c @@ -115081,7 +115081,7 @@ int sp_ecc_secret_gen_384_nb(sp_ecc_ctx_t* sp_ctx, const mp_int* priv, &ctx->point, &ctx->point, ctx->k, 1, 1, heap); if (err == MP_OKAY) { sp_384_to_bin_12(ctx->point.x, out); - *outLen = 32; + *outLen = 48; } break; } @@ -129544,7 +129544,7 @@ int sp_ecc_secret_gen_521_nb(sp_ecc_ctx_t* sp_ctx, const mp_int* priv, &ctx->point, &ctx->point, ctx->k, 1, 1, heap); if (err == MP_OKAY) { sp_521_to_bin_17(ctx->point.x, out); - *outLen = 32; + *outLen = 66; } break; } diff --git a/wolfcrypt/src/sp_c32.c b/wolfcrypt/src/sp_c32.c index 14e446fd3..846be62f6 100644 --- a/wolfcrypt/src/sp_c32.c +++ b/wolfcrypt/src/sp_c32.c @@ -33221,7 +33221,7 @@ int sp_ecc_secret_gen_384_nb(sp_ecc_ctx_t* sp_ctx, const mp_int* priv, &ctx->point, &ctx->point, ctx->k, 1, 1, heap); if (err == MP_OKAY) { sp_384_to_bin_15(ctx->point.x, out); - *outLen = 32; + *outLen = 48; } break; } @@ -41321,7 +41321,7 @@ int sp_ecc_secret_gen_521_nb(sp_ecc_ctx_t* sp_ctx, const mp_int* priv, &ctx->point, &ctx->point, ctx->k, 1, 1, heap); if (err == MP_OKAY) { sp_521_to_bin_21(ctx->point.x, out); - *outLen = 32; + *outLen = 66; } break; } diff --git a/wolfcrypt/src/sp_c64.c b/wolfcrypt/src/sp_c64.c index 46c0f99a8..971543824 100644 --- a/wolfcrypt/src/sp_c64.c +++ b/wolfcrypt/src/sp_c64.c @@ -33569,7 +33569,7 @@ int sp_ecc_secret_gen_384_nb(sp_ecc_ctx_t* sp_ctx, const mp_int* priv, &ctx->point, &ctx->point, ctx->k, 1, 1, heap); if (err == MP_OKAY) { sp_384_to_bin_7(ctx->point.x, out); - *outLen = 32; + *outLen = 48; } break; } @@ -40989,7 +40989,7 @@ int sp_ecc_secret_gen_521_nb(sp_ecc_ctx_t* sp_ctx, const mp_int* priv, &ctx->point, &ctx->point, ctx->k, 1, 1, heap); if (err == MP_OKAY) { sp_521_to_bin_9(ctx->point.x, out); - *outLen = 32; + *outLen = 66; } break; } diff --git a/wolfcrypt/src/sp_cortexm.c b/wolfcrypt/src/sp_cortexm.c index 5b7af1168..4dd112b00 100644 --- a/wolfcrypt/src/sp_cortexm.c +++ b/wolfcrypt/src/sp_cortexm.c @@ -30337,7 +30337,7 @@ int sp_ecc_secret_gen_384_nb(sp_ecc_ctx_t* sp_ctx, const mp_int* priv, &ctx->point, &ctx->point, ctx->k, 1, 1, heap); if (err == MP_OKAY) { sp_384_to_bin_12(ctx->point.x, out); - *outLen = 32; + *outLen = 48; } break; } @@ -38801,7 +38801,7 @@ int sp_ecc_secret_gen_521_nb(sp_ecc_ctx_t* sp_ctx, const mp_int* priv, &ctx->point, &ctx->point, ctx->k, 1, 1, heap); if (err == MP_OKAY) { sp_521_to_bin_17(ctx->point.x, out); - *outLen = 32; + *outLen = 66; } break; } diff --git a/wolfcrypt/src/sp_x86_64.c b/wolfcrypt/src/sp_x86_64.c index 0cabbe643..67c8a23de 100644 --- a/wolfcrypt/src/sp_x86_64.c +++ b/wolfcrypt/src/sp_x86_64.c @@ -49849,7 +49849,7 @@ int sp_ecc_secret_gen_384_nb(sp_ecc_ctx_t* sp_ctx, const mp_int* priv, &ctx->point, &ctx->point, ctx->k, 1, 1, heap); if (err == MP_OKAY) { sp_384_to_bin_6(ctx->point.x, out); - *outLen = 32; + *outLen = 48; } break; } @@ -90894,7 +90894,7 @@ int sp_ecc_secret_gen_521_nb(sp_ecc_ctx_t* sp_ctx, const mp_int* priv, &ctx->point, &ctx->point, ctx->k, 1, 1, heap); if (err == MP_OKAY) { sp_521_to_bin_9(ctx->point.x, out); - *outLen = 32; + *outLen = 66; } break; }