Debian Codegraph @

crypto_kem/8192128pcf/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 two_e[ 1 + SYS_N/8 ] = {2};
25 unsigned char *e = two_e + 1;
26 unsigned char one_ec[ 1 + SYS_N/8 + (SYND_BYTES + 32) ] = {1};
27
28 //
29
30 pke_encrypt(c, pk, e);
31
32 crypto_hash_32b(c + SYND_BYTES, two_e, sizeof(two_e));
33
34 memcpy(one_ec + 1, e, SYS_N/8);
35 memcpy(one_ec + 1 + SYS_N/8, c, SYND_BYTES + 32);
36
37 crypto_hash_32b(key, one_ec, sizeof(one_ec));
38
39 return 0;
40 }
41