Skip to content

Commit e82d6e3

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

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

wolfcrypt/src/hpke.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ 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 */
109109
/* 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)) {
110+
if (w < 4 && n > ((1 << (w * 8)) - 1)) {
111111
return MP_VAL;
112112
}
113113

0 commit comments

Comments
 (0)