#include <stdio.h>
#include <string.h>
const unsigned char *m, int len)
{
int posn;
for (posn = 0; (posn + 16) <= len; posn += 16) {
}
if (posn < len) {
}
}
const unsigned char *c, int len)
{
int posn;
for (posn = 0; (posn + 16) <= len; posn += 16) {
}
if (posn < len) {
}
}
int main(int argc, char *argv[])
{
const char *progname = argv[0];
unsigned char buffer[1024];
unsigned char key[32];
int encrypt_mode = 1;
FILE *infile;
FILE *outfile;
int len;
if (argc >= 2 && !strcmp(argv[1], "-d")) {
encrypt_mode = 0;
++argv;
--argc;
}
if (argc < 4) {
fprintf(stderr, "Usage: %s [-d] \"password\" input-file output-file\n", progname);
return 1;
}
if ((infile = fopen(argv[2], "rb")) == NULL) {
perror(argv[1]);
return 1;
}
if ((outfile = fopen(argv[3], "wb")) == NULL) {
perror(argv[2]);
fclose(infile);
return 1;
}
ascon_hash(key, (
const unsigned char *)(argv[1]), strlen(argv[1]));
static unsigned char const iv[8] = {
0x80, 0x40, 0x0c, 0x08, 0xFF, 0xFF, 0xFF, 0xFF
};
while ((len = fread(buffer, 1, sizeof(buffer), infile)) > 0) {
if (encrypt_mode)
encrypt(&
state, buffer, buffer, len);
else
decrypt(&
state, buffer, buffer, len);
fwrite(buffer, 1, len, outfile);
if (len < (int)sizeof(buffer))
break;
}
fclose(infile);
fclose(outfile);
return 0;
}
ASCON-HASH and ASCON-HASHA hash algorithms.
void ascon_hash(unsigned char *out, const unsigned char *in, size_t inlen)
Hashes a block of input data with ASCON-HASH.
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_extract_and_overwrite_bytes(ascon_state_t *state, const uint8_t *input, uint8_t *output, unsigned offset, unsigned size)
Extracts bytes from the ASCON state and XOR's them with input bytes to produce output bytes....
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]
Structure of the internal state of the ASCON permutation.
System utilities of use to applications that use ASCON.
void ascon_clean(void *buf, unsigned size)
Cleans a buffer that contains sensitive material.