From 682901e32e7d1b58ab46aa0ea119aaee28da2a8a Mon Sep 17 00:00:00 2001 From: Ruby Martin Date: Tue, 3 Mar 2026 09:00:45 -0700 Subject: [PATCH] return MP_VAL if n < 0. remove check for max int value remove comment --- wolfcrypt/src/hpke.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/wolfcrypt/src/hpke.c b/wolfcrypt/src/hpke.c index e7b15db0a4..8879079f64 100644 --- a/wolfcrypt/src/hpke.c +++ b/wolfcrypt/src/hpke.c @@ -101,13 +101,12 @@ static int I2OSP(int n, int w, byte* out) { int i; - if (w <= 0 || w > 32) { + if (w <= 0 || w > 32 || n < 0) { return MP_VAL; } /* if width is less than int max check that n is less than w bytes max */ - /* if width is greater than int max check that n is less than int max */ - if ((w < 4 && n > ((1 << (w * 8)) - 1)) || (w >= 4 && n > 0x7fffffff)) { + if (w < 4 && n > ((1 << (w * 8)) - 1)) { return MP_VAL; }