Debian Codegraph @

crypto_kem/6688128f/vec/kem_enc.c

raw
1 // 20230102 djb: rename encrypt() as pke_encrypt()
2 // 20221230 djb: add linker lines
3 // 20221230 djb: split out of operations.c
4
5 // linker define operation_enc
6 // linker use pke_encrypt
7
8 #include "operations.h"
9
10 #include "hash.h"
11 #include "encrypt.h"
12 #include "params.h"
13 #include "util.h"
14
15 #include <stdint.h>
16 #include <string.h>
17
18 int operation_enc(
19 unsigned char *c,
20 unsigned char *key,
21 const unsigned char *pk
22 )
23 {
24 unsigned char e[ SYS_N/8 ];
25 unsigned char one_ec[ 1 + SYS_N/8 + SYND_BYTES ] = {1};
26
27 //
28
29 pke_encrypt(c, pk, e);
30
31 memcpy(one_ec + 1, e, SYS_N/8);
32 memcpy(one_ec + 1 + SYS_N/8, c, SYND_BYTES);
33
34 crypto_hash_32b(key, one_ec, sizeof(one_ec));
35
36 return 0;
37 }
38