lib_hash_drbg/src/sha256.c
/*
 * Update the sha256 context with the input data as a hex string
 *  Convert the input hex string to a byte array and call sha256_update.
 *
 *  A maximum of MAX_SIZE bytes (2*MAX_SIZE hex characters) may be hashed with a single call
 *  although multiples calls may be made
 *
 *  Note that while sha256_update() always completes its operation, and has no return value
 *   while sha256_update_hex() may return with an error (if the input is too large).
 *
 * Parameters:
 * SHA256_CTX* context - structure holding the sha256 context
 * uint8_t* hex        - input hex data buffer to be hashed
 * uint32_t length     - size of input data buffer, which may be longer than the hex string inside
 *
 * Return code:
 * -1 - hexstring is too long
 *  1 - Ok
 */
Update the sha256 context with the input data as a hex string
Convert the input hex string to a byte array and call sha256_update.

A maximum of MAX_SIZE bytes (2*MAX_SIZE hex characters) may be hashed with a single call
although multiples calls may be made

Note that while sha256_update() always completes its operation, and has no return value
while sha256_update_hex() may return with an error (if the input is too large).

SHA256_CTX* context - structure holding the sha256 context
uint8_t* hex        - input hex data buffer to be hashed
uint32_t length     - size of input data buffer, which may be longer than the hex string inside

Return code:
-1 - hexstring is too long
1 - Ok
Update the sha256 context with the input data as a hex string Convert the input hex string to a byte array and call sha256_update . A maximum of MAX_SIZE bytes ( 2 * MAX_SIZE hex characters ) may be hashed with a single call although multiples calls may be made Note that while sha256_update () always completes its operation and has no return value while sha256_update_hex () may return with an error ( if the input is too large ) . SHA256_CTX * context - structure holding the sha256 context uint8_t * hex - input hex data buffer to be hashed uint32_t length - size of input data buffer which may be longer than the hex string inside Return code : - 1 - hexstring is too long 1 - Ok
int
sha256_update_hex(SHA256_CTX* context, const char* hex, uint32_t length)
{
    uint8_t data[MAX_SIZE];  
    int    datalen;  
    datalen = hex_to_bytes(hex, length, data, MAX_SIZE);
    if (datalen == -1) {
        return -1;
    }
    sha256_update(context, data, datalen);
    return 1;
}
int sha256_update_hex ( SHA256_CTX * context , const char * hex , uint32_t length ) { uint8_t data [ MAX_SIZE ] ; int datalen ; datalen = hex_to_bytes ( hex , length , data , MAX_SIZE ) ; if ( datalen == -1 ) { return -1 ; } sha256_update ( context , data , datalen ) ; return 1 ; }
Update the sha256 context with the input data as a hex string
  Convert the input hex string to a byte array and call sha256_update.
Update the sha256 context with the input data as a hex string Convert the input hex string to a byte array and call sha256_update .
/* at most 100,000 bytes mat be contained in the hex buffer */ /* amount of data in hex string */ /*
     * Convert input hex string to a byte array
     *  If the input hex string is too long, return an error
     */