]> Git Repo - haraka-avx512.git/blame - haraka.h
run
[haraka-avx512.git] / haraka.h
CommitLineData
23e3fea5 1
2/*
3The MIT License (MIT)
4
5Copyright (c) 2016 kste
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25Optimized Implementations for Haraka256 and Haraka512
26*/
27#ifndef HARAKA_H_
28#define HARAKA_H_
29#include "immintrin.h"
30#include "aes.h"
31#define NUMROUNDS 5
32
33#ifdef _WIN32
34typedef unsigned long long u64;
35#else
36typedef unsigned long u64;
37#endif
38typedef __m512i u512;
39
40extern u512 rc[10];
41u512 MIX_4;
42#define LOAD(src) _mm512_load_epi32((u512 *)(src))
43#define STORE(dest,src) _mm512_store_epi32((u512 *)(dest),src)
44/*
45#define AES2(s0, s1, rci) \
46 s0 = _mm_aesenc_si128(s0, rc[rci]); \
47 s1 = _mm_aesenc_si128(s1, rc[rci + 1]); \
48 s0 = _mm_aesenc_si128(s0, rc[rci + 2]); \
49 s1 = _mm_aesenc_si128(s1, rc[rci + 3]);
50
51#define AES2_4x(s0, s1, s2, s3, rci) \
52 AES2(s0[0], s0[1], rci); \
53 AES2(s1[0], s1[1], rci); \
54 AES2(s2[0], s2[1], rci); \
55 AES2(s3[0], s3[1], rci);
56
57#define AES2_8x(s0, s1, s2, s3, s4, s5, s6, s7, rci) \
58 AES2_4x(s0, s1, s2, s3, rci); \
59 AES2_4x(s4, s5, s6, s7, rci);
60*/
61#define AES4(s, rci)\
62 s = aes2(aes2(s,rc[rci]),rc[rci+1])
63
64#define AES4_zero(s, rci)\
65 s = aes2(aes2(s,rc0[rci]),rc0[rci+1])
66
1df53243 67#define AES4_4x(s, rci) \
23e3fea5 68 AES4(s[0], rci); \
69 AES4(s[1], rci); \
70 AES4(s[2], rci); \
71 AES4(s[3], rci);
72
73#define AES4_8x(s0, s1, rci) \
74 AES4_4x(s0, rci); \
75 AES4_4x(s1, rci);
76
77//#define MIX2(s0, s1) \
78 tmp = _mm_unpacklo_epi32(s0, s1); \
79 s1 = _mm_unpackhi_epi32(s0, s1); \
80 s0 = tmp;
81
82
2733a776 83#define MIX4(s) \
84 s = _mm512_permutexvar_epi32 (MIX_4, s);
85
86#define TRUNCSTORE(out, s) \
23e3fea5 87 *(u64*)(out) = *(((u64*)&s + 1)); \
88 *(u64*)(out + 8) = *(((u64*)&s + 3)); \
89 *(u64*)(out + 16) = *(((u64*)&s + 4)); \
90 *(u64*)(out + 24) = *(((u64*)&s + 6));
91void load_constants();
42472fbc 92int test_implementations();
23e3fea5 93
94/*
95void haraka256(unsigned char *out, const unsigned char *in);
96void haraka256_keyed(unsigned char *out, const unsigned char *in, const u128 *rc);
97void haraka256_4x(unsigned char *out, const unsigned char *in);
98void haraka256_8x(unsigned char *out, const unsigned char *in);
99*/
100void haraka512(unsigned char *out, const unsigned char *in);
101void haraka512_zero(unsigned char *out, const unsigned char *in);
102//void haraka512_keyed(unsigned char *out, const unsigned char *in, const u128 *rc);
1df53243 103void haraka512_4x(unsigned char *out, const unsigned char *in);
104void haraka512_8x(unsigned char *out, const unsigned char *in);
23e3fea5 105
106#endif
107
This page took 0.033649 seconds and 4 git commands to generate.