Skip to contentSkip to conversation

crypto: ecdsa - explicitly zeroize pub_key

PATCH In review Vladis Dronov 2 participants 3 messages Apr 14, 2025 – Apr 16, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: ecdsa - explicitly zeroize pub_key

The FIPS standard, as a part of the Sensitive Security Parameter area, requires the FIPS module to provide methods to zeroise all the unprotected SSP (Security Sensitive Parameters), i.e. both the CSP (Critical Security Parameters), and the PSP (Public Security Parameters):

A module shall provide methods to zeroise all unprotected SSPs and key components within the module.

This requirement is mentioned in the section AS09.28 "Sensitive security parameter zeroisation – Levels 1, 2, 3, and 4" of FIPS 140-3 / ISO 19790. This is required for the FIPS certification. Thus, add a public key zeroization to ecdsa_ecc_ctx_deinit().

---
 crypto/ecdsa.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
crypto/ecdsa.c +3 -1
index 117526d15dde..e7f58ad5ac76 100644
@@ -96,10 +96,12 @@ static int ecdsa_ecc_ctx_init(struct ecc_ctx *ctx, unsigned int curve_id)
 	return 0;
 }
 
-
 static void ecdsa_ecc_ctx_deinit(struct ecc_ctx *ctx)
 {
 	ctx->pub_key_set = false;
+
+	memzero_explicit(ctx->x, sizeof(ctx->x));
+	memzero_explicit(ctx->y, sizeof(ctx->y));
 }
 
 static int ecdsa_ecc_ctx_reset(struct ecc_ctx *ctx)
Signature · 1 line
2.49.0
#1 lore raw

Hi,

Quoted 24 lines · Vladis Dronov

The FIPS standard, as a part of the Sensitive Security Parameter area, requires the FIPS module to provide methods to zeroise all the unprotected SSP (Security Sensitive Parameters), i.e. both the CSP (Critical Security Parameters), and the PSP (Public Security Parameters):

A module shall provide methods to zeroise all unprotected SSPs and key components within the module.

This requirement is mentioned in the section AS09.28 "Sensitive security parameter zeroisation – Levels 1, 2, 3, and 4" of FIPS 140-3 / ISO 19790. This is required for the FIPS certification. Thus, add a public key zeroization to ecdsa_ecc_ctx_deinit().

---
 crypto/ecdsa.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
crypto/ecdsa.c +0 -0
index 117526d15dde..e7f58ad5ac76 100644

crypto/ecdsa.c static int ecdsa_ecc_ctx_init(struct ecc_ctx *ctx, unsigned int curve_id) · line 104

Quoted 10 lines
crypto/ecdsa.c +3 -1
@@ -96,10 +96,12 @@ static int ecdsa_ecc_ctx_init(struct ecc_ctx *ctx, unsigned int curve_id)
        return 0;
 }
 
-
 static void ecdsa_ecc_ctx_deinit(struct ecc_ctx *ctx)
 {
        ctx->pub_key_set = false;
+
+       memzero_explicit(ctx->x, sizeof(ctx->x));
+       memzero_explicit(ctx->y, sizeof(ctx->y));

Isn't this already done with crypto_destroy_tfm()? Or am I missing something?

Ignat

Quoted 6 lines
crypto/ecdsa.c +0 -1
 }
 
 static int ecdsa_ecc_ctx_reset(struct ecc_ctx *ctx)
--

2.49.0

#2 lore raw
Quoted 41 lines · Ignat Korchagin

Hi,

Quoted 24 lines · Vladis Dronov

The FIPS standard, as a part of the Sensitive Security Parameter area, requires the FIPS module to provide methods to zeroise all the unprotected SSP (Security Sensitive Parameters), i.e. both the CSP (Critical Security Parameters), and the PSP (Public Security Parameters):

A module shall provide methods to zeroise all unprotected SSPs and key components within the module.

This requirement is mentioned in the section AS09.28 "Sensitive security parameter zeroisation – Levels 1, 2, 3, and 4" of FIPS 140-3 / ISO 19790. This is required for the FIPS certification. Thus, add a public key zeroization to ecdsa_ecc_ctx_deinit().

---
 crypto/ecdsa.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
crypto/ecdsa.c +0 -0
index 117526d15dde..e7f58ad5ac76 100644

crypto/ecdsa.c static int ecdsa_ecc_ctx_init(struct ecc_ctx *ctx, unsigned int curve_id) · line 104

Quoted 10 lines
crypto/ecdsa.c +3 -1
@@ -96,10 +96,12 @@ static int ecdsa_ecc_ctx_init(struct ecc_ctx *ctx, unsigned int curve_id)
        return 0;
 }
 
-
 static void ecdsa_ecc_ctx_deinit(struct ecc_ctx *ctx)
 {
        ctx->pub_key_set = false;
+
+       memzero_explicit(ctx->x, sizeof(ctx->x));
+       memzero_explicit(ctx->y, sizeof(ctx->y));

Isn't this already done with crypto_destroy_tfm()? Or am I missing something?

Quoted 1 line

Ignat

Thank you for your input, Ignat, most appreciated. Indeed, the memory for ecc_ctx is cleared with kfree_sensitive() in crypto_destroy_tfm(), you are right. And people at FIPS LAB seem to be okay with that (for now).

So, please disregard this patch, I'm sorry for the noise.

Best regards,
Vladis

Quoted 8 lines
Quoted 7 lines
crypto/ecdsa.c +0 -1
 }
 
 static int ecdsa_ecc_ctx_reset(struct ecc_ctx *ctx)
--

2.49.0