ASCON Suite
Namespaces | Typedefs | Functions
utility.h File Reference

System utilities of use to applications that use ASCON. More...

#include <stddef.h>
#include <vector>
#include <string.h>
#include <string>

Go to the source code of this file.

Namespaces

 ascon
 

Typedefs

typedef std::vector< unsigned char > ascon::byte_array
 C++ type for an array of bytes. More...
 

Functions

void ascon_clean (void *buf, unsigned size)
 Cleans a buffer that contains sensitive material. More...
 
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...
 

Detailed Description

System utilities of use to applications that use ASCON.

Definition in file utility.h.

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.

◆ ascon_clean()

void ascon_clean ( void *  buf,
unsigned  size 
)

Cleans a buffer that contains sensitive material.

Parameters
bufPoints to the buffer to clear.
sizeSize of the buffer to clear in bytes.
Examples
asconcrypt/asconcrypt.c, and permutation/encrypt/main.c.

Definition at line 38 of file ascon-clean.c.