#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
const unsigned char *
data;
size_t len, posn;
if (argc < 2) {
fprintf(stderr, "Usage: %s \"text to be hashed\"\n", argv[0]);
return 1;
}
data = (
const unsigned char *)(argv[1]);
len = strlen(argv[1]);
static unsigned char const iv[8] = {
0x00, 0x40, 0x0c, 0x04, 0x00, 0x00, 0x01, 0x00
};
for (posn = 0; (posn + 8) <= len; posn += 8) {
}
static unsigned char const pad[1] = {0x80};
unsigned char hash[32];
for (posn = 0; posn < 32; ++posn)
printf("%02x", hash[posn]);
printf("\n");
unsigned char hash2[32];
if (memcmp(hash, hash2, 32) != 0) {
printf("Hash value is incorrect!");
return 1;
}
return 0;
}
ASCON-HASH and ASCON-HASHA hash algorithms.
void ascon_hasha(unsigned char *out, const unsigned char *in, size_t inlen)
Hashes a block of input data with ASCON-HASHA.
Direct access to the ASCON permutation primitive.
#define ascon_permute12(state)
Permutes the ASCON state with 12 rounds of the permutation.
void ascon_free(ascon_state_t *state)
Frees an ASCON permutation state and attempts to destroy any sensitive material.
void ascon_overwrite_bytes(ascon_state_t *state, const uint8_t *data, unsigned offset, unsigned size)
Overwrites existing bytes in the ASCON state.
void ascon_extract_bytes(const ascon_state_t *state, uint8_t *data, unsigned offset, unsigned size)
Extracts bytes from the ASCON state.
void ascon_add_bytes(ascon_state_t *state, const uint8_t *data, unsigned offset, unsigned size)
Adds bytes to the ASCON state by XOR'ing them with existing bytes.
void ascon_init(ascon_state_t *state)
Initializes the words of the ASCON permutation state to zero.
#define ascon_permute8(state)
Permutes the ASCON state with 8 rounds of the permutation.
ascon_state_t state
[snippet_key]
unsigned char data[8]
[snippet_key]
Structure of the internal state of the ASCON permutation.