Skip to content

Commit 682901e

Browse files
committed
return MP_VAL if n < 0. remove check for max int value
remove comment
1 parent 0ef8541 commit 682901e

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

wolfcrypt/src/hpke.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,12 @@ static int I2OSP(int n, int w, byte* out)
101101
{
102102
int i;
103103

104-
if (w <= 0 || w > 32) {
104+
if (w <= 0 || w > 32 || n < 0) {
105105
return MP_VAL;
106106
}
107107

108108
/* if width is less than int max check that n is less than w bytes max */
109-
/* if width is greater than int max check that n is less than int max */
110-
if ((w < 4 && n > ((1 << (w * 8)) - 1)) || (w >= 4 && n > 0x7fffffff)) {
109+
if (w < 4 && n > ((1 << (w * 8)) - 1)) {
111110
return MP_VAL;
112111
}
113112

0 commit comments

Comments
 (0)