aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/restricted/aws/s2n/pq-crypto/kyber_r2/cbd.c
diff options
context:
space:
mode:
authororivej <orivej@yandex-team.ru>2022-02-10 16:44:49 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:49 +0300
commit718c552901d703c502ccbefdfc3c9028d608b947 (patch)
tree46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/restricted/aws/s2n/pq-crypto/kyber_r2/cbd.c
parente9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff)
downloadydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/restricted/aws/s2n/pq-crypto/kyber_r2/cbd.c')
-rw-r--r--contrib/restricted/aws/s2n/pq-crypto/kyber_r2/cbd.c102
1 files changed, 51 insertions, 51 deletions
diff --git a/contrib/restricted/aws/s2n/pq-crypto/kyber_r2/cbd.c b/contrib/restricted/aws/s2n/pq-crypto/kyber_r2/cbd.c
index b4fc010ca9..4e86526aaa 100644
--- a/contrib/restricted/aws/s2n/pq-crypto/kyber_r2/cbd.c
+++ b/contrib/restricted/aws/s2n/pq-crypto/kyber_r2/cbd.c
@@ -1,51 +1,51 @@
-#include "cbd.h"
-#include "params.h"
-
-#include <stddef.h>
-#include <stdint.h>
-
-/*************************************************
-* Name: load32_littleendian
-*
-* Description: load bytes into a 32-bit integer
-* in little-endian order
-*
-* Arguments: - const uint8_t *x: pointer to input byte array
-*
-* Returns 32-bit unsigned integer loaded from x
-**************************************************/
-static uint32_t load32_littleendian(const uint8_t *x) {
- uint32_t r;
- r = (uint32_t)x[0];
- r |= (uint32_t)x[1] << 8;
- r |= (uint32_t)x[2] << 16;
- r |= (uint32_t)x[3] << 24;
- return r;
-}
-
-/*************************************************
-* Name: cbd
-*
-* Description: Given an array of uniformly random bytes, compute
-* polynomial with coefficients distributed according to
-* a centered binomial distribution with parameter KYBER_ETA
-* specialized for KYBER_ETA=2
-*
-* Arguments: - poly *r: pointer to output polynomial
-* - const uint8_t *buf: pointer to input byte array
-**************************************************/
-void PQCLEAN_KYBER512_CLEAN_cbd(poly *r, const uint8_t *buf) {
- int16_t a, b;
-
- for (size_t i = 0; i < KYBER_N / 8; i++) {
- uint32_t t = load32_littleendian(buf + 4 * i);
- uint32_t d = t & 0x55555555;
- d += (t >> 1) & 0x55555555;
-
- for (size_t j = 0; j < 8; j++) {
- a = (d >> 4 * j) & 0x3;
- b = (d >> (4 * j + 2)) & 0x3;
- r->coeffs[8 * i + j] = a - b;
- }
- }
-}
+#include "cbd.h"
+#include "params.h"
+
+#include <stddef.h>
+#include <stdint.h>
+
+/*************************************************
+* Name: load32_littleendian
+*
+* Description: load bytes into a 32-bit integer
+* in little-endian order
+*
+* Arguments: - const uint8_t *x: pointer to input byte array
+*
+* Returns 32-bit unsigned integer loaded from x
+**************************************************/
+static uint32_t load32_littleendian(const uint8_t *x) {
+ uint32_t r;
+ r = (uint32_t)x[0];
+ r |= (uint32_t)x[1] << 8;
+ r |= (uint32_t)x[2] << 16;
+ r |= (uint32_t)x[3] << 24;
+ return r;
+}
+
+/*************************************************
+* Name: cbd
+*
+* Description: Given an array of uniformly random bytes, compute
+* polynomial with coefficients distributed according to
+* a centered binomial distribution with parameter KYBER_ETA
+* specialized for KYBER_ETA=2
+*
+* Arguments: - poly *r: pointer to output polynomial
+* - const uint8_t *buf: pointer to input byte array
+**************************************************/
+void PQCLEAN_KYBER512_CLEAN_cbd(poly *r, const uint8_t *buf) {
+ int16_t a, b;
+
+ for (size_t i = 0; i < KYBER_N / 8; i++) {
+ uint32_t t = load32_littleendian(buf + 4 * i);
+ uint32_t d = t & 0x55555555;
+ d += (t >> 1) & 0x55555555;
+
+ for (size_t j = 0; j < 8; j++) {
+ a = (d >> 4 * j) & 0x3;
+ b = (d >> (4 * j + 2)) & 0x3;
+ r->coeffs[8 * i + j] = a - b;
+ }
+ }
+}