summaryrefslogtreecommitdiff
path: root/p/haskell-cryptonite/debian/patches/more-alignment.patch
diff options
context:
space:
mode:
Diffstat (limited to 'p/haskell-cryptonite/debian/patches/more-alignment.patch')
-rw-r--r--p/haskell-cryptonite/debian/patches/more-alignment.patch144
1 files changed, 53 insertions, 91 deletions
diff --git a/p/haskell-cryptonite/debian/patches/more-alignment.patch b/p/haskell-cryptonite/debian/patches/more-alignment.patch
index c5844c855..01352bcac 100644
--- a/p/haskell-cryptonite/debian/patches/more-alignment.patch
+++ b/p/haskell-cryptonite/debian/patches/more-alignment.patch
@@ -5,7 +5,7 @@ Forwarded: https://github.com/haskell-crypto/cryptonite/pull/175
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/cbits/cryptonite_align.h
+++ b/cbits/cryptonite_align.h
-@@ -34,18 +34,124 @@
+@@ -34,9 +34,34 @@
#define need_alignment(p,n) IS_ALIGNED(p,n)
#endif
@@ -19,6 +19,11 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+ return be64_to_cpu(*((uint64_t *) p));
+}
+
++static inline uint64_t load_le64_aligned(const uint8_t *p)
++{
++ return le64_to_cpu(*((uint64_t *) p));
++}
++
+static inline void store_be32_aligned(uint8_t *p, uint32_t val)
+{
+ *((uint32_t *) p) = cpu_to_be32(val);
@@ -33,21 +38,10 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
{
- return le32_to_cpu(*((uint32_t *) p));
+ return le32_to_cpu(*((uint32_t *) p));
-+}
-+
-+static inline uint64_t load_le64_aligned(const uint8_t *p)
-+{
-+ return le64_to_cpu(*((uint64_t *) p));
-+}
-+
-+static inline void store_le32_aligned(uint8_t *p, uint32_t val)
-+{
-+ *((uint32_t *) p) = cpu_to_le32(val);
-+}
-+
-+static inline void store_le64_aligned(uint8_t *p, uint64_t val)
-+{
-+ *((uint64_t *) p) = cpu_to_le64(val);
+ }
+
+ static inline void store_le32_aligned(uint8_t *dst, const uint32_t v)
+@@ -60,12 +85,83 @@ static inline void store_be64_aligned(ui
}
#ifdef UNALIGNED_ACCESS_OK
@@ -131,7 +125,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+
#endif
- #endif
+ #ifdef UNALIGNED_ACCESS_OK
--- a/cbits/cryptonite_poly1305.c
+++ b/cbits/cryptonite_poly1305.c
@@ -37,11 +37,7 @@
@@ -147,7 +141,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
static void poly1305_do_chunk(poly1305_ctx *ctx, uint8_t *data, int blocks, int final)
{
-@@ -61,11 +57,11 @@
+@@ -61,11 +57,11 @@ static void poly1305_do_chunk(poly1305_c
s1 = r1 * 5; s2 = r2 * 5; s3 = r3 * 5; s4 = r4 * 5;
while (blocks--) {
@@ -164,7 +158,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
d0 = ((uint64_t)h0 * r0) + ((uint64_t)h1 * s4) + ((uint64_t)h2 * s3) + ((uint64_t)h3 * s2) + ((uint64_t)h4 * s1);
d1 = ((uint64_t)h0 * r1) + ((uint64_t)h1 * r0) + ((uint64_t)h2 * s4) + ((uint64_t)h3 * s3) + ((uint64_t)h4 * s2);
-@@ -94,16 +90,16 @@
+@@ -94,16 +90,16 @@ void cryptonite_poly1305_init(poly1305_c
memset(ctx, 0, sizeof(poly1305_ctx));
@@ -193,7 +187,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
}
--- a/cbits/cryptonite_aes.c
+++ b/cbits/cryptonite_aes.c
-@@ -370,7 +370,7 @@
+@@ -370,7 +370,7 @@ void cryptonite_aes_gcm_init(aes_gcm *gc
cryptonite_gf_mul(&gcm->iv, &gcm->h);
}
@@ -202,7 +196,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
}
void cryptonite_aes_gcm_aad(aes_gcm *gcm, uint8_t *input, uint32_t length)
-@@ -399,7 +399,7 @@
+@@ -399,7 +399,7 @@ void cryptonite_aes_gcm_finish(uint8_t *
gcm_ghash_add(gcm, &lblock);
cryptonite_aes_encrypt_block(&lblock, key, &gcm->iv);
@@ -211,7 +205,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
for (i = 0; i < 16; i++) {
tag[i] = gcm->tag.b[i];
-@@ -464,7 +464,7 @@
+@@ -464,7 +464,7 @@ void cryptonite_aes_ocb_init(aes_ocb *oc
memcpy(stretch, ktop.b, 16);
memcpy(tmp.b, ktop.b + 1, 8);
@@ -220,7 +214,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
memcpy(stretch + 16, tmp.b, 8);
/* initialize the encryption offset from stretch */
-@@ -490,22 +490,22 @@
+@@ -490,22 +490,22 @@ void cryptonite_aes_ocb_aad(aes_ocb *ocb
for (i=1; i<= length/16; i++, input=input+16) {
ocb_get_L_i(&tmp, ocb->li, i);
@@ -248,7 +242,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
}
}
-@@ -513,8 +513,8 @@
+@@ -513,8 +513,8 @@ void cryptonite_aes_ocb_finish(uint8_t *
{
block128 tmp;
@@ -259,7 +253,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
cryptonite_aes_encrypt_block((block128 *) tag, key, &tmp);
block128_xor((block128 *) tag, &ocb->sum_aad);
}
-@@ -699,7 +699,7 @@
+@@ -699,7 +699,7 @@ static void ocb_generic_crypt(uint8_t *o
for (i = 1; i <= length/16; i++, input += 16, output += 16) {
/* Offset_i = Offset_{i-1} xor L_{ntz(i)} */
ocb_get_L_i(&tmp, ocb->li, i);
@@ -268,7 +262,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
block128_vxor(&tmp, &ocb->offset_enc, (block128 *) input);
if (encrypt) {
-@@ -716,24 +716,24 @@
+@@ -716,24 +716,24 @@ static void ocb_generic_crypt(uint8_t *o
/* process the last partial block if any */
length = length % 16;
if (length > 0) {
@@ -299,38 +293,6 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
input += length;
}
}
---- a/cbits/cryptonite_keccak.c
-+++ b/cbits/cryptonite_keccak.c
-@@ -25,6 +25,7 @@
- #include <stdint.h>
- #include <string.h>
- #include "cryptonite_bitfn.h"
-+#include "cryptonite_align.h"
- #include "cryptonite_keccak.h"
-
- #define KECCAK_NB_ROUNDS 24
-@@ -124,9 +125,18 @@
- ctx->bufindex = 0;
- }
-
-- /* process as much ctx->bufsz-block */
-- for (; len >= ctx->bufsz; len -= ctx->bufsz, data += ctx->bufsz)
-- keccak_do_chunk(ctx->state, (uint64_t *) data, ctx->bufsz / 8);
-+ if (need_alignment(data, 8)) {
-+ uint64_t tramp[200 - 2 * (224 / 8)];
-+ ASSERT_ALIGNMENT(tramp, 8);
-+ for (; len >= ctx->bufsz; len -= ctx->bufsz, data += ctx->bufsz) {
-+ memcpy(tramp, data, ctx->bufsz);
-+ keccak_do_chunk(ctx->state, tramp, ctx->bufsz / 8);
-+ }
-+ } else {
-+ /* process as much ctx->bufsz-block */
-+ for (; len >= ctx->bufsz; len -= ctx->bufsz, data += ctx->bufsz)
-+ keccak_do_chunk(ctx->state, (uint64_t *) data, ctx->bufsz / 8);
-+ }
-
- /* append data into buf */
- if (len) {
--- a/cbits/cryptonite_md4.c
+++ b/cbits/cryptonite_md4.c
@@ -25,6 +25,7 @@
@@ -341,7 +303,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
#include "cryptonite_md4.h"
void cryptonite_md4_init(struct md4_ctx *ctx)
-@@ -130,9 +131,18 @@
+@@ -130,9 +131,18 @@ void cryptonite_md4_update(struct md4_ct
index = 0;
}
@@ -363,7 +325,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
/* append data into buf */
if (len)
-@@ -157,5 +167,8 @@
+@@ -157,5 +167,8 @@ void cryptonite_md4_finalize(struct md4_
cryptonite_md4_update(ctx, (uint8_t *) &bits, sizeof(bits));
/* output hash */
@@ -383,7 +345,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
#include "cryptonite_md5.h"
void cryptonite_md5_init(struct md5_ctx *ctx)
-@@ -143,9 +144,18 @@
+@@ -143,9 +144,18 @@ void cryptonite_md5_update(struct md5_ct
index = 0;
}
@@ -405,7 +367,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
/* append data into buf */
if (len)
-@@ -157,7 +167,6 @@
+@@ -157,7 +167,6 @@ void cryptonite_md5_finalize(struct md5_
static uint8_t padding[64] = { 0x80, };
uint64_t bits;
uint32_t index, padlen;
@@ -413,7 +375,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
/* add padding and update data with it */
bits = cpu_to_le64(ctx->sz << 3);
-@@ -171,8 +180,8 @@
+@@ -171,8 +180,8 @@ void cryptonite_md5_finalize(struct md5_
cryptonite_md5_update(ctx, (uint8_t *) &bits, sizeof(bits));
/* output hash */
@@ -436,7 +398,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
#include <string.h>
void cryptonite_ripemd160_init(struct ripemd160_ctx *ctx)
-@@ -265,9 +266,20 @@
+@@ -265,9 +266,20 @@ void cryptonite_ripemd160_update(struct
index = 0;
}
@@ -459,7 +421,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
if (len)
memcpy(ctx->buf + index, data, len);
}
-@@ -277,7 +289,6 @@
+@@ -277,7 +289,6 @@ void cryptonite_ripemd160_finalize(struc
static uint8_t padding[64] = { 0x80, };
uint64_t bits;
uint32_t index, padlen;
@@ -467,7 +429,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
/* add padding and update data with it */
bits = cpu_to_le64(ctx->sz << 3);
-@@ -291,9 +302,9 @@
+@@ -291,9 +302,9 @@ void cryptonite_ripemd160_finalize(struc
cryptonite_ripemd160_update(ctx, (uint8_t *) &bits, sizeof(bits));
/* output digest */
@@ -492,7 +454,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
static const uint8_t sigma[16] = "expand 32-byte k";
static const uint8_t tau[16] = "expand 16-byte k";
-@@ -58,11 +59,6 @@
+@@ -58,11 +59,6 @@ static const uint8_t tau[16] = "expand 1
QR (x15,x12,x13,x14); \
}
@@ -504,7 +466,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
static void salsa_core(int rounds, block *out, const cryptonite_salsa_state *in)
{
uint32_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
-@@ -126,34 +122,34 @@
+@@ -126,34 +122,34 @@ void cryptonite_salsa_init_core(cryptoni
const uint8_t *constants = (keylen == 32) ? sigma : tau;
int i;
@@ -567,7 +529,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
#include "cryptonite_salsa.h"
static void blockmix_salsa8(uint32_t *in, uint32_t *out, uint32_t *X, const uint32_t r)
-@@ -49,16 +50,6 @@
+@@ -49,16 +50,6 @@ static inline uint64_t integerify(uint32
return B[(2*r-1) * 16] | (uint64_t)B[(2*r-1) * 16 + 1] << 32;
}
@@ -584,7 +546,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
void cryptonite_scrypt_smix(uint8_t *B, const uint32_t r, const uint64_t N, uint32_t *V, uint32_t *XY)
{
uint32_t *X = XY;
-@@ -69,7 +60,7 @@
+@@ -69,7 +60,7 @@ void cryptonite_scrypt_smix(uint8_t *B,
const int r32 = 32*r;
for (k = 0; k < r32; k++)
@@ -593,7 +555,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
for (i = 0; i < N; i += 2) {
array_copy32(&V[i * r32], X, r32);
blockmix_salsa8(X, Y, Z, r);
-@@ -86,5 +77,5 @@
+@@ -86,5 +77,5 @@ void cryptonite_scrypt_smix(uint8_t *B,
blockmix_salsa8(Y, X, Z, r);
}
for (k = 0; k < r32; k++)
@@ -610,7 +572,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
void cryptonite_sha1_init(struct sha1_ctx *ctx)
{
-@@ -173,9 +174,18 @@
+@@ -173,9 +174,18 @@ void cryptonite_sha1_update(struct sha1_
index = 0;
}
@@ -632,7 +594,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
/* append data into buf */
if (len)
-@@ -187,7 +197,6 @@
+@@ -187,7 +197,6 @@ void cryptonite_sha1_finalize(struct sha
static uint8_t padding[64] = { 0x80, };
uint64_t bits;
uint32_t index, padlen;
@@ -640,7 +602,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
/* add padding and update data with it */
bits = cpu_to_be64(ctx->sz << 3);
-@@ -201,9 +210,9 @@
+@@ -201,9 +210,9 @@ void cryptonite_sha1_finalize(struct sha
cryptonite_sha1_update(ctx, (uint8_t *) &bits, sizeof(bits));
/* output hash */
@@ -665,7 +627,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
void cryptonite_sha224_init(struct sha224_ctx *ctx)
{
-@@ -134,9 +135,18 @@
+@@ -134,9 +135,18 @@ void cryptonite_sha256_update(struct sha
index = 0;
}
@@ -687,7 +649,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
/* append data into buf */
if (len)
-@@ -156,7 +166,6 @@
+@@ -156,7 +166,6 @@ void cryptonite_sha256_finalize(struct s
static uint8_t padding[64] = { 0x80, };
uint64_t bits;
uint32_t i, index, padlen;
@@ -695,7 +657,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
/* cpu -> big endian */
bits = cpu_to_be64(ctx->sz << 3);
-@@ -171,5 +180,5 @@
+@@ -171,5 +180,5 @@ void cryptonite_sha256_finalize(struct s
/* store to digest */
for (i = 0; i < 8; i++)
@@ -712,7 +674,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
static const uint8_t K256_0[2] = { 14, 16, };
static const uint8_t K256_1[2] = { 52, 57, };
-@@ -143,9 +144,18 @@
+@@ -143,9 +144,18 @@ void cryptonite_skein256_update(struct s
ctx->bufindex = 0;
}
@@ -744,7 +706,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
static const uint8_t K512_0[4] = { 46, 36, 19, 37, };
static const uint8_t K512_1[4] = { 33, 27, 14, 42, };
-@@ -161,9 +162,18 @@
+@@ -161,9 +162,18 @@ void cryptonite_skein512_update(struct s
ctx->bufindex = 0;
}
@@ -776,7 +738,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
static const uint64_t t1[256] = {
0x02aab17cf7e90c5eULL,0xac424b03e243a8ecULL,0x72cd5be30dd5fcd3ULL,0x6d019b93f6f97f3aULL,
-@@ -381,9 +382,18 @@
+@@ -381,9 +382,18 @@ void cryptonite_tiger_update(struct tige
index = 0;
}
@@ -798,7 +760,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
/* append data into buf */
if (len)
-@@ -395,7 +405,6 @@
+@@ -395,7 +405,6 @@ void cryptonite_tiger_finalize(struct ti
static uint8_t padding[64] = { 0x01, };
uint64_t bits;
uint32_t index, padlen;
@@ -806,7 +768,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
/* add padding and update data with it */
bits = cpu_to_le64(ctx->sz << 3);
-@@ -409,7 +418,7 @@
+@@ -409,7 +418,7 @@ void cryptonite_tiger_finalize(struct ti
cryptonite_tiger_update(ctx, (uint8_t *) &bits, sizeof(bits));
/* output hash */
@@ -834,7 +796,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
/* XSalsa20 algorithm as described in https://cr.yp.to/snuffle/xsalsa-20081128.pdf */
void cryptonite_xsalsa_init(cryptonite_salsa_context *ctx, uint8_t nb_rounds,
uint32_t keylen, const uint8_t *key,
-@@ -51,8 +47,8 @@
+@@ -51,8 +47,8 @@ void cryptonite_xsalsa_init(cryptonite_s
(x6, x7, x8, x9) is the first 128 bits of a 192-bit nonce
*/
cryptonite_salsa_init_core(&ctx->st, keylen, key, 8, iv);
@@ -845,7 +807,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
/* Compute (z0, z1, . . . , z15) = doubleround ^(r/2) (x0, x1, . . . , x15) */
block hSalsa;
-@@ -73,8 +69,8 @@
+@@ -73,8 +69,8 @@ void cryptonite_xsalsa_init(cryptonite_s
ctx->st.d[12] = hSalsa.d[ 7] - ctx->st.d[ 7];
ctx->st.d[13] = hSalsa.d[ 8] - ctx->st.d[ 8];
ctx->st.d[14] = hSalsa.d[ 9] - ctx->st.d[ 9];
@@ -868,7 +830,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
typedef union {
uint64_t q[2];
-@@ -40,38 +41,71 @@
+@@ -40,38 +41,71 @@ typedef union {
uint8_t b[16];
} block128;
@@ -949,7 +911,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
static inline void block128_inc_be(block128 *b)
--- a/cbits/aes/generic.c
+++ b/cbits/aes/generic.c
-@@ -324,21 +324,22 @@
+@@ -324,21 +324,22 @@ static void create_round_key(uint8_t *ex
static void aes_main(aes_key *key, uint8_t *state)
{
int i = 0;
@@ -979,7 +941,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
}
static void shift_rows_inv(uint8_t *state)
-@@ -374,21 +375,22 @@
+@@ -374,21 +375,22 @@ static void mix_columns_inv(uint8_t *sta
static void aes_main_inv(aes_key *key, uint8_t *state)
{
int i = 0;
@@ -1009,7 +971,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
}
/* Set the block values, for the block:
-@@ -405,26 +407,28 @@
+@@ -405,26 +407,28 @@ static void aes_main_inv(aes_key *key, u
void cryptonite_aes_generic_encrypt_block(aes_block *output, aes_key *key, aes_block *input)
{
@@ -1058,7 +1020,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
#include "cryptonite_sha512.h"
void cryptonite_sha384_init(struct sha512_ctx *ctx)
-@@ -153,9 +154,18 @@
+@@ -153,9 +154,18 @@ void cryptonite_sha512_update(struct sha
index = 0;
}
@@ -1080,7 +1042,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
/* append data into buf */
if (len)
-@@ -175,7 +185,6 @@
+@@ -175,7 +185,6 @@ void cryptonite_sha512_finalize(struct s
static uint8_t padding[128] = { 0x80, };
uint32_t i, index, padlen;
uint64_t bits[2];
@@ -1088,7 +1050,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
/* cpu -> big endian */
bits[0] = cpu_to_be64((ctx->sz[1] << 3 | ctx->sz[0] >> 61));
-@@ -191,7 +200,7 @@
+@@ -191,7 +200,7 @@ void cryptonite_sha512_finalize(struct s
/* store to digest */
for (i = 0; i < 8; i++)