Debian Codegraph @

crypto_core/weightsntrup1277/ref/weight.c

raw
1 // 20250302 djb: port to -Wc++-compat
2 // 20240812 djb: more cryptoint usage
3 #include "crypto_core.h"
4
5 #include "crypto_int8.h"
6 #include "crypto_int16.h"
7 #define int8 crypto_int8
8 #define int16 crypto_int16
9 #include "crypto_encode_int16.h"
10
11 #include "params.h"
12
13 /* out = little-endian weight of bottom bits of in */
14 void crypto_core(unsigned char *outbytes,const unsigned char *inbytes,const unsigned char *kbytes,const unsigned char *cbytes)
15 {
16 int8 *in = (int8 *) inbytes;
17 int16 weight = 0;
18 int i;
19
20 for (i = 0;i < p;++i) weight += crypto_int8_bottombit_01(in[i]);
21 crypto_encode_int16(outbytes,&weight);
22 }