26 (
char *out,
size_t outlen,
const unsigned char *in,
size_t inlen,
29 static char const hex_lower[] =
"0123456789abcdef";
30 static char const hex_upper[] =
"0123456789ABCDEF";
31 const char *hex_chars = upper_case ? hex_upper : hex_lower;
33 if (outlen < (inlen * 2U + 1U)) {
39 unsigned char ch = *in++;
40 out[posn++] = hex_chars[(ch >> 4) & 0x0F];
41 out[posn++] = hex_chars[ch & 0x0F];
49 (
unsigned char *out,
size_t outlen,
const char *in,
size_t inlen)
58 if (ch >=
'0' && ch <=
'9') {
60 }
else if (ch >=
'a' && ch <=
'f') {
61 digit = ch -
'a' + 10;
62 }
else if (ch >=
'A' && ch <=
'F') {
63 digit = ch -
'A' + 10;
64 }
else if (ch ==
' ' || ch ==
'\t' || ch ==
'\r' || ch ==
'\n' ||
65 ch ==
'\f' || ch ==
'\v') {
74 out[posn++] = value | digit;
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.
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.
System utilities of use to applications that use ASCON.