ASCON Suite
Functions
ascon-hex.c File Reference
#include <ascon/utility.h>

Go to the source code of this file.

Functions

int ascon_bytes_to_hex (char *out, size_t outlen, const unsigned char *in, size_t inlen, int upper_case)
 Converts an array of bytes into a hexadecimal string. More...
 
int ascon_bytes_from_hex (unsigned char *out, size_t outlen, const char *in, size_t inlen)
 Converts a hexadecimal string into an array of bytes. More...
 

Function Documentation

◆ ascon_bytes_from_hex()

int ascon_bytes_from_hex ( unsigned char *  out,
size_t  outlen,
const char *  in,
size_t  inlen 
)

Converts a hexadecimal string into an array of bytes.

Parameters
outPoints to the buffer to receive the output bytes.
outlenMaximum number of bytes in the output buffer.
inPoints to the input hexadecimal string to convert.
inlenNumber of characters in the input string to convert.
Returns
The number of bytes written to out. Returns -1 if there is something wrong with the parameters such as outlen not being large enough or invalid characters in the input string.

Both uppercase and lowercase hexadecimal characters are recognized. Whitespace characters are ignored. All other characters are invalid.

Definition at line 48 of file ascon-hex.c.

◆ ascon_bytes_to_hex()

int ascon_bytes_to_hex ( char *  out,
size_t  outlen,
const unsigned char *  in,
size_t  inlen,
int  upper_case 
)

Converts an array of bytes into a hexadecimal string.

Parameters
outPoints to the buffer to receive the output string.
outlenMaximum number of characters in the out buffer, which should be at least inlen * 2 + 1 in length.
inPoints to the input byte array to convert into hexadecimal.
inlenNumber of bytes to be converted.
upper_caseUse uppercase hexadecimal letters if non-zero; or use lowercase hexadecimal letters if zero.
Returns
The number of characters written to out, excluding the terminating NUL. Returns -1 if there is something wrong with the parameters such as outlen not being large enough.

The result out buffer will be NUL-terminated except when the function returns -1.

Definition at line 25 of file ascon-hex.c.