Indent
This commit is contained in:
parent
9626d7af59
commit
32a084222a
@ -8,10 +8,11 @@
|
||||
#include "private/common.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include "stream_chacha20_vec.h"
|
||||
#include "../stream_chacha20.h"
|
||||
#include "stream_chacha20_vec.h"
|
||||
|
||||
#if (defined(HAVE_EMMINTRIN_H) && defined(HAVE_TMMINTRIN_H) && defined(__GNUC__))
|
||||
#if (defined(HAVE_EMMINTRIN_H) && defined(HAVE_TMMINTRIN_H) && \
|
||||
defined(__GNUC__))
|
||||
|
||||
#pragma GCC target("sse2")
|
||||
#pragma GCC target("ssse3")
|
||||
@ -30,7 +31,8 @@ typedef unsigned int vec __attribute__ ((vector_size(16)));
|
||||
#endif
|
||||
#define ONE (vec) _mm_set_epi32(0, 0, 0, 1)
|
||||
#define LOAD(m) (vec) _mm_loadu_si128((const __m128i *) (const void *) (m))
|
||||
# define LOAD_ALIGNED(m) (vec) _mm_load_si128((const __m128i *) (const void *) (m))
|
||||
#define LOAD_ALIGNED(m) \
|
||||
(vec) _mm_load_si128((const __m128i *) (const void *) (m))
|
||||
#define STORE(m, r) _mm_storeu_si128((__m128i *) (void *) (m), (__m128i)(r))
|
||||
#define ROTV1(x) (vec) _mm_shuffle_epi32((__m128i) x, _MM_SHUFFLE(0, 3, 2, 1))
|
||||
#define ROTV2(x) (vec) _mm_shuffle_epi32((__m128i) x, _MM_SHUFFLE(1, 0, 3, 2))
|
||||
@ -105,12 +107,7 @@ chacha_ivsetup(chacha_ctx *ctx, const uint8_t *iv, uint64_t ic)
|
||||
memcpy(&iv_low, iv, 4);
|
||||
memcpy(&iv_high, iv + 4, 4);
|
||||
{
|
||||
const vec s3 = {
|
||||
(uint32_t) ic,
|
||||
(uint32_t) (ic >> 32),
|
||||
iv_low,
|
||||
iv_high
|
||||
};
|
||||
const vec s3 = { (uint32_t) ic, (uint32_t)(ic >> 32), iv_low, iv_high };
|
||||
ctx->s3 = s3;
|
||||
}
|
||||
}
|
||||
@ -118,12 +115,9 @@ chacha_ivsetup(chacha_ctx *ctx, const uint8_t *iv, uint64_t ic)
|
||||
static void
|
||||
chacha_ietf_ivsetup(chacha_ctx *ctx, const uint8_t *iv, uint32_t ic)
|
||||
{
|
||||
const vec s3 = {
|
||||
ic,
|
||||
((const uint32_t *) (const void *) iv)[0],
|
||||
const vec s3 = { ic, ((const uint32_t *) (const void *) iv)[0],
|
||||
((const uint32_t *) (const void *) iv)[1],
|
||||
((const uint32_t *) (const void *) iv)[2]
|
||||
};
|
||||
((const uint32_t *) (const void *) iv)[2] };
|
||||
ctx->s3 = s3;
|
||||
}
|
||||
|
||||
@ -138,8 +132,9 @@ static void
|
||||
chacha_encrypt_bytes(chacha_ctx *ctx, const uint8_t *in, uint8_t *out,
|
||||
unsigned long long inlen)
|
||||
{
|
||||
CRYPTO_ALIGN(16) unsigned chacha_const[]
|
||||
= { 0x61707865, 0x3320646E, 0x79622D32, 0x6B206574 };
|
||||
CRYPTO_ALIGN(16)
|
||||
unsigned chacha_const[] = { 0x61707865, 0x3320646E, 0x79622D32,
|
||||
0x6B206574 };
|
||||
uint32_t * op = (uint32_t *) (void *) out;
|
||||
const uint32_t * ip = (const uint32_t *) (const void *) in;
|
||||
vec s0, s1, s2, s3;
|
||||
@ -228,7 +223,6 @@ chacha_encrypt_bytes(chacha_ctx *ctx, const uint8_t *in, uint8_t *out,
|
||||
for (i = CHACHA_RNDS / 2; i; i--) {
|
||||
DQROUND_VECTORS(v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
if (inlen >= 16) {
|
||||
STORE(op + 0, LOAD(ip + 0) ^ REVV_BE(v0 + s0));
|
||||
if (inlen >= 32) {
|
||||
@ -252,8 +246,8 @@ chacha_encrypt_bytes(chacha_ctx *ctx, const uint8_t *in, uint8_t *out,
|
||||
}
|
||||
|
||||
static int
|
||||
stream_vec(unsigned char *c, unsigned long long clen,
|
||||
const unsigned char *n, const unsigned char *k)
|
||||
stream_vec(unsigned char *c, unsigned long long clen, const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
{
|
||||
struct chacha_ctx ctx;
|
||||
|
||||
@ -291,8 +285,7 @@ stream_ietf_vec(unsigned char *c, unsigned long long clen,
|
||||
|
||||
static int
|
||||
stream_vec_xor_ic(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n, uint64_t ic,
|
||||
unsigned long long mlen, const unsigned char *n, uint64_t ic,
|
||||
const unsigned char *k)
|
||||
{
|
||||
struct chacha_ctx ctx;
|
||||
@ -310,9 +303,8 @@ stream_vec_xor_ic(unsigned char *c, const unsigned char *m,
|
||||
|
||||
static int
|
||||
stream_ietf_vec_xor_ic(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n, uint32_t ic,
|
||||
const unsigned char *k)
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
uint32_t ic, const unsigned char *k)
|
||||
{
|
||||
struct chacha_ctx ctx;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user