diff --git a/src/internal.c b/src/internal.c index 5796570c..6387a756 100644 --- a/src/internal.c +++ b/src/internal.c @@ -2706,6 +2706,54 @@ static int DoKexInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx) return ret; } + +/* create mpint type + * + * can decrease size of buf by 1 or more if leading bytes are 0's and not needed + * the input argument "sz" gets reset if that is the case. Buffer size is never + * increased. + * + * An example of this would be a buffer of 0053 changed to 53. + * If a padding value is needed then "pad" is set to 1 + * + */ +static int CreateMpint(byte* buf, word32* sz, byte* pad) +{ + word32 i; + + if (buf == NULL || sz == NULL || pad == NULL) { + WLOG(WS_LOG_ERROR, "Internal argument error with CreateMpint"); + return WS_BAD_ARGUMENT; + } + + if (*sz == 0) + return WS_SUCCESS; + + /* check for leading 0's */ + for (i = 0; i < *sz; i++) { + if (buf[i] != 0x00) + break; + } + *pad = (buf[i] & 0x80) ? 1 : 0; + + /* if padding would be needed and have leading 0's already then do not add + * extra 0's */ + if (i > 0 && *pad == 1) { + i = i - 1; + *pad = 0; + } + + /* if i is still greater than 0 then the buffer needs shifted to remove + * leading 0's */ + if (i > 0) { + WMEMMOVE(buf, buf + i, *sz - i); + *sz = *sz - i; + } + + return WS_SUCCESS; +} + + #if !defined(WOLFSSH_NO_DH_GROUP1_SHA1) || \ !defined(WOLFSSH_NO_DH_GROUP14_SHA1) || \ !defined(WOLFSSH_NO_DH_GEX_SHA256) @@ -2839,6 +2887,7 @@ static int DoKexDhInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx) return ret; } + struct wolfSSH_sigKeyBlock { byte useRsa; word32 keySz; diff --git a/src/misc.c b/src/misc.c index f6db6eaf..69a47378 100644 --- a/src/misc.c +++ b/src/misc.c @@ -112,51 +112,6 @@ STATIC INLINE int ConstantCompare(const byte* a, const byte* b, } -/* create mpint type - * - * can decrease size of buf by 1 or more if leading bytes are 0's and not needed - * the input argument "sz" gets reset if that is the case. Buffer size is never - * increased. - * - * An example of this would be a buffer of 0053 changed to 53. - * If a padding value is needed then "pad" is set to 1 - * - */ -STATIC INLINE int CreateMpint(byte* buf, word32* sz, byte* pad) -{ - word32 i; - - if (buf == NULL || sz == NULL || pad == NULL) { - WLOG(WS_LOG_ERROR, "Internal argument error with CreateMpint"); - return WS_BAD_ARGUMENT; - } - - if (*sz == 0) - return WS_SUCCESS; - - /* check for leading 0's */ - for (i = 0; i < *sz; i++) { - if (buf[i] != 0x00) - break; - } - *pad = (buf[i] & 0x80) ? 1 : 0; - - /* if padding would be needed and have leading 0's already then do not add - * extra 0's */ - if (i > 0 && *pad == 1) { - i = i - 1; - *pad = 0; - } - - /* if i is still greater than 0 then the buffer needs shifted to remove - * leading 0's */ - if (i > 0) { - WMEMMOVE(buf, buf + i, *sz - i); - *sz = *sz - i; - } - - return WS_SUCCESS; -} #undef STATIC diff --git a/wolfssh/misc.h b/wolfssh/misc.h index 6b089472..04fa68e6 100644 --- a/wolfssh/misc.h +++ b/wolfssh/misc.h @@ -44,7 +44,6 @@ WOLFSSH_LOCAL void ato32(const byte*, word32*); WOLFSSH_LOCAL void c32toa(word32, byte*); WOLFSSH_LOCAL void ForceZero(const void*, word32); WOLFSSH_LOCAL int ConstantCompare(const byte*, const byte*, word32); -WOLFSSH_LOCAL int CreateMpint(byte*, word32*, byte*); #endif /* NO_INLINE */