lib_hash_drbg/src/sha256.c
/*
 * Hash a hex string using SHA256, as a single function call
 *  Similar to sha256(), but takes a hex string as input rather than a byte array
 *
 *  Note that while sha256() always completes its operation, and has no return value
 *   while sha256_hex() may return with an error (if the input is too large).
 *
 * Parameters:
 * 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
 * char* hash_string - 65 byte output buffer to hold the hash result in hex
 *
 * Return code:
 * -1 - hexstring is too long
 *  1 - Ok
 */
Hash a hex string using SHA256, as a single function call
Similar to sha256(), but takes a hex string as input rather than a byte array

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

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
char* hash_string - 65 byte output buffer to hold the hash result in hex

Return code:
-1 - hexstring is too long
1 - Ok
Hash a hex string using SHA256 as a single function call Similar to sha256 () but takes a hex string as input rather than a byte array Note that while sha256 () always completes its operation and has no return value while sha256_hex () may return with an error ( if the input is too large ) . 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 char * hash_string - 65 byte output buffer to hold the hash result in hex Return code : - 1 - hexstring is too long 1 - Ok
int
sha256_hex(const char* hex, uint32_t length, char* hash_string)
{
    SHA256_CTX context;
    uint8_t    hash_bytes[32];
    int        result;
    sha256_init(&context);
    result = sha256_update_hex(&context, hex, length);
    if (result != -1) {
        sha256_finalize(&context, hash_bytes);
    }
    bytes_to_hex (hash_bytes, 32, hash_string, 65);
    return result;
}
int sha256_hex ( const char * hex , uint32_t length , char * hash_string ) { SHA256_CTX context ; uint8_t hash_bytes [ 32 ] ; int result ; sha256_init ( & context ) ; result = sha256_update_hex ( & context , hex , length ) ; if ( result != -1 ) { sha256_finalize ( & context , hash_bytes ) ; } bytes_to_hex ( hash_bytes , 32 , hash_string , 65 ) ; return result ; }
Hash a hex string using SHA256, as a single function call
  Similar to sha256(), but takes a hex string as input rather than a byte array
Hash a hex string using SHA256 as a single function call Similar to sha256 () but takes a hex string as input rather than a byte array
/*
     * Too much input data will result in an error
     */