FreeRTOS-Plus/ThirdParty/WolfSSL-FIPS-Ready/wolfcrypt/src/asn.c
/* Set the DER/BER encoding of the ASN.1 BIT_STRING with a 16-bit value.
 *
 * val         16-bit value to encode.
 * output      Buffer to write into.
 * returns the number of bytes added to the buffer.
 */
Set the DER/BER encoding of the ASN.1 BIT_STRING with a 16-bit value.
val         16-bit value to encode.
output      Buffer to write into.
returns the number of bytes added to the buffer.
Set the DER / BER encoding of the ASN . 1 BIT_STRING with a 16 - bit value . val 16 - bit value to encode . output Buffer to write into . returns the number of bytes added to the buffer .
static word32 SetBitString16Bit(word16 val, byte* output)
{
    word32 idx;
    int    len;
    byte   lastByte;
    byte   unusedBits = 0;
    if ((val >> 8) != 0) {
        len = 2;
        lastByte = (byte)(val >> 8);
    }
    else {
        len = 1;
        lastByte = (byte)val;
    }
    while (((lastByte >> unusedBits) & 0x01) == 0x00)
        unusedBits++;
    idx = SetBitString(len, unusedBits, output);
    output[idx++] = (byte)val;
    if (len > 1)
        output[idx++] = (byte)(val >> 8);
    return idx;
}
static word32 SetBitString16Bit ( word16 val , byte * output ) { word32 idx ; int len ; byte lastByte ; byte unusedBits = 0 ; if ( ( val >> 8 ) != 0 ) { len = 2 ; lastByte = ( byte ) ( val >> 8 ) ; } else { len = 1 ; lastByte = ( byte ) val ; } while ( ( ( lastByte >> unusedBits ) & 0x01 ) == 0x00 ) unusedBits ++ ; idx = SetBitString ( len , unusedBits , output ) ; output [ idx ++ ] = ( byte ) val ; if ( len > 1 ) output [ idx ++ ] = ( byte ) ( val >> 8 ) ; return idx ; }
Set the DER/BER encoding of the ASN.1 BIT_STRING with a 16-bit value.
Set the DER / BER encoding of the ASN . 1 BIT_STRING with a 16 - bit value .