FreeRTOS-Plus/ThirdParty/WolfSSL-FIPS-Ready/wolfcrypt/src/asn.c
/* Get the DER/BER encoding of an ASN.1 INTEGER header.
 * Removes the leading zero byte when found.
 *
 * input     Buffer holding DER/BER encoded data.
 * inOutIdx  Current index into buffer to parse.
 * len       The number of bytes in the ASN.1 data (excluding any leading zero).
 * maxIdx    Length of data in buffer.
 * returns BUFFER_E when there is not enough data to parse.
 *         ASN_PARSE_E when the INTEGER tag is not found, length is invalid,
 *         or invalid use of or missing leading zero.
 *         Otherwise, 0 to indicate success.
 */
Get the DER/BER encoding of an ASN.1 INTEGER header.
Removes the leading zero byte when found.

input     Buffer holding DER/BER encoded data.
inOutIdx  Current index into buffer to parse.
len       The number of bytes in the ASN.1 data (excluding any leading zero).
maxIdx    Length of data in buffer.
returns BUFFER_E when there is not enough data to parse.
ASN_PARSE_E when the INTEGER tag is not found, length is invalid,
or invalid use of or missing leading zero.
Otherwise, 0 to indicate success.
Get the DER / BER encoding of an ASN . 1 INTEGER header . Removes the leading zero byte when found . input Buffer holding DER / BER encoded data . inOutIdx Current index into buffer to parse . len The number of bytes in the ASN . 1 data ( excluding any leading zero ) . maxIdx Length of data in buffer . returns BUFFER_E when there is not enough data to parse . ASN_PARSE_E when the INTEGER tag is not found length is invalid or invalid use of or missing leading zero . Otherwise 0 to indicate success .
static int GetASNInt(const byte* input, word32* inOutIdx, int* len,
                     word32 maxIdx)
{
    int    ret;
    ret = GetASNHeader(input, ASN_INTEGER, inOutIdx, len, maxIdx);
    if (ret < 0)
        return ret;
    if (*len > 0) {
        if ((input[*inOutIdx] == 0x00) && (*len > 1)) {
            (*inOutIdx)++;
            (*len)--;
#ifndef WOLFSSL_ASN_INT_LEAD_0_ANY
            if (*len > 0 && (input[*inOutIdx] & 0x80) == 0)
                return ASN_PARSE_E;
#endif
        }
    }
    return 0;
}
static int GetASNInt ( const byte * input , word32 * inOutIdx , int * len , word32 maxIdx ) { int ret ; ret = GetASNHeader ( input , ASN_INTEGER , inOutIdx , len , maxIdx ) ; if ( ret < 0 ) return ret ; if ( * len > 0 ) { if ( ( input [ * inOutIdx ] == 0x00 ) && ( * len > 1 ) ) { ( * inOutIdx ) ++ ; ( * len ) -- ; #ifndef WOLFSSL_ASN_INT_LEAD_0_ANY if ( * len > 0 && ( input [ * inOutIdx ] & 0x80 ) == 0 ) return ASN_PARSE_E ; #endif } } return 0 ; }
Get the DER/BER encoding of an ASN.1 INTEGER header.
Get the DER / BER encoding of an ASN . 1 INTEGER header .
/* remove leading zero, unless there is only one 0x00 byte */