1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-23 20:15:19 -07:00

Remove unused implementations.

This commit is contained in:
Frank Denis 2013-03-11 15:14:52 -07:00
parent f62f5ceb04
commit 12c4bee782
6 changed files with 0 additions and 385 deletions

View File

@ -1,4 +0,0 @@
#define CRYPTO_OUTPUTBYTES 32
#define CRYPTO_INPUTBYTES 16
#define CRYPTO_KEYBYTES 32
#define CRYPTO_CONSTBYTES 16

View File

@ -1,135 +0,0 @@
/*
version 20080912
D. J. Bernstein
Public domain.
*/
#include "crypto_core.h"
#define ROUNDS 20
typedef unsigned int uint32;
static uint32 rotate(uint32 u,int c)
{
return (u << c) | (u >> (32 - c));
}
static uint32 load_littleendian(const unsigned char *x)
{
return
(uint32) (x[0]) \
| (((uint32) (x[1])) << 8) \
| (((uint32) (x[2])) << 16) \
| (((uint32) (x[3])) << 24)
;
}
static void store_littleendian(unsigned char *x,uint32 u)
{
x[0] = u; u >>= 8;
x[1] = u; u >>= 8;
x[2] = u; u >>= 8;
x[3] = u;
}
int crypto_core(
unsigned char *out,
const unsigned char *in,
const unsigned char *k,
const unsigned char *c
)
{
uint32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
uint32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
int i;
j0 = x0 = load_littleendian(c + 0);
j1 = x1 = load_littleendian(k + 0);
j2 = x2 = load_littleendian(k + 4);
j3 = x3 = load_littleendian(k + 8);
j4 = x4 = load_littleendian(k + 12);
j5 = x5 = load_littleendian(c + 4);
j6 = x6 = load_littleendian(in + 0);
j7 = x7 = load_littleendian(in + 4);
j8 = x8 = load_littleendian(in + 8);
j9 = x9 = load_littleendian(in + 12);
j10 = x10 = load_littleendian(c + 8);
j11 = x11 = load_littleendian(k + 16);
j12 = x12 = load_littleendian(k + 20);
j13 = x13 = load_littleendian(k + 24);
j14 = x14 = load_littleendian(k + 28);
j15 = x15 = load_littleendian(c + 12);
for (i = ROUNDS;i > 0;i -= 2) {
x4 ^= rotate( x0+x12, 7);
x8 ^= rotate( x4+ x0, 9);
x12 ^= rotate( x8+ x4,13);
x0 ^= rotate(x12+ x8,18);
x9 ^= rotate( x5+ x1, 7);
x13 ^= rotate( x9+ x5, 9);
x1 ^= rotate(x13+ x9,13);
x5 ^= rotate( x1+x13,18);
x14 ^= rotate(x10+ x6, 7);
x2 ^= rotate(x14+x10, 9);
x6 ^= rotate( x2+x14,13);
x10 ^= rotate( x6+ x2,18);
x3 ^= rotate(x15+x11, 7);
x7 ^= rotate( x3+x15, 9);
x11 ^= rotate( x7+ x3,13);
x15 ^= rotate(x11+ x7,18);
x1 ^= rotate( x0+ x3, 7);
x2 ^= rotate( x1+ x0, 9);
x3 ^= rotate( x2+ x1,13);
x0 ^= rotate( x3+ x2,18);
x6 ^= rotate( x5+ x4, 7);
x7 ^= rotate( x6+ x5, 9);
x4 ^= rotate( x7+ x6,13);
x5 ^= rotate( x4+ x7,18);
x11 ^= rotate(x10+ x9, 7);
x8 ^= rotate(x11+x10, 9);
x9 ^= rotate( x8+x11,13);
x10 ^= rotate( x9+ x8,18);
x12 ^= rotate(x15+x14, 7);
x13 ^= rotate(x12+x15, 9);
x14 ^= rotate(x13+x12,13);
x15 ^= rotate(x14+x13,18);
}
x0 += j0;
x1 += j1;
x2 += j2;
x3 += j3;
x4 += j4;
x5 += j5;
x6 += j6;
x7 += j7;
x8 += j8;
x9 += j9;
x10 += j10;
x11 += j11;
x12 += j12;
x13 += j13;
x14 += j14;
x15 += j15;
x0 -= load_littleendian(c + 0);
x5 -= load_littleendian(c + 4);
x10 -= load_littleendian(c + 8);
x15 -= load_littleendian(c + 12);
x6 -= load_littleendian(in + 0);
x7 -= load_littleendian(in + 4);
x8 -= load_littleendian(in + 8);
x9 -= load_littleendian(in + 12);
store_littleendian(out + 0,x0);
store_littleendian(out + 4,x5);
store_littleendian(out + 8,x10);
store_littleendian(out + 12,x15);
store_littleendian(out + 16,x6);
store_littleendian(out + 20,x7);
store_littleendian(out + 24,x8);
store_littleendian(out + 28,x9);
return 0;
}

View File

@ -1,15 +0,0 @@
#ifndef crypto_core_H
#define crypto_core_H
#include "crypto_core_hsalsa20.h"
#define crypto_core crypto_core_hsalsa20
#define crypto_core_OUTPUTBYTES crypto_core_hsalsa20_OUTPUTBYTES
#define crypto_core_INPUTBYTES crypto_core_hsalsa20_INPUTBYTES
#define crypto_core_KEYBYTES crypto_core_hsalsa20_KEYBYTES
#define crypto_core_CONSTBYTES crypto_core_hsalsa20_CONSTBYTES
#define crypto_core_PRIMITIVE "hsalsa20"
#define crypto_core_IMPLEMENTATION crypto_core_hsalsa20_IMPLEMENTATION
#define crypto_core_VERSION crypto_core_hsalsa20_VERSION
#endif

View File

@ -1,2 +0,0 @@
#define CRYPTO_STATEBYTES 32
#define CRYPTO_BLOCKBYTES 64

View File

@ -1,228 +0,0 @@
#include "crypto_hashblocks.h"
typedef unsigned int uint32;
static uint32 load_bigendian(const unsigned char *x)
{
return
(uint32) (x[3]) \
| (((uint32) (x[2])) << 8) \
| (((uint32) (x[1])) << 16) \
| (((uint32) (x[0])) << 24)
;
}
static void store_bigendian(unsigned char *x,uint32 u)
{
x[3] = u; u >>= 8;
x[2] = u; u >>= 8;
x[1] = u; u >>= 8;
x[0] = u;
}
#define SHR(x,c) ((x) >> (c))
#define ROTR(x,c) (((x) >> (c)) | ((x) << (32 - (c))))
#define Ch(x,y,z) ((x & y) ^ (~x & z))
#define Maj(x,y,z) ((x & y) ^ (x & z) ^ (y & z))
#define Sigma0(x) (ROTR(x, 2) ^ ROTR(x,13) ^ ROTR(x,22))
#define Sigma1(x) (ROTR(x, 6) ^ ROTR(x,11) ^ ROTR(x,25))
#define sigma0(x) (ROTR(x, 7) ^ ROTR(x,18) ^ SHR(x, 3))
#define sigma1(x) (ROTR(x,17) ^ ROTR(x,19) ^ SHR(x,10))
#define M(w0,w14,w9,w1) w0 += sigma1(w14) + w9 + sigma0(w1);
#define EXPAND \
M(w0 ,w14,w9 ,w1 ) \
M(w1 ,w15,w10,w2 ) \
M(w2 ,w0 ,w11,w3 ) \
M(w3 ,w1 ,w12,w4 ) \
M(w4 ,w2 ,w13,w5 ) \
M(w5 ,w3 ,w14,w6 ) \
M(w6 ,w4 ,w15,w7 ) \
M(w7 ,w5 ,w0 ,w8 ) \
M(w8 ,w6 ,w1 ,w9 ) \
M(w9 ,w7 ,w2 ,w10) \
M(w10,w8 ,w3 ,w11) \
M(w11,w9 ,w4 ,w12) \
M(w12,w10,w5 ,w13) \
M(w13,w11,w6 ,w14) \
M(w14,w12,w7 ,w15) \
M(w15,w13,w8 ,w0 )
#define F(r0,r1,r2,r3,r4,r5,r6,r7,w,k) \
r7 += Sigma1(r4) + Ch(r4,r5,r6) + k + w; \
r3 += r7; \
r7 += Sigma0(r0) + Maj(r0,r1,r2);
#define G(r0,r1,r2,r3,r4,r5,r6,r7,i) \
F(r0,r1,r2,r3,r4,r5,r6,r7,w0 ,round[i + 0]) \
F(r7,r0,r1,r2,r3,r4,r5,r6,w1 ,round[i + 1]) \
F(r6,r7,r0,r1,r2,r3,r4,r5,w2 ,round[i + 2]) \
F(r5,r6,r7,r0,r1,r2,r3,r4,w3 ,round[i + 3]) \
F(r4,r5,r6,r7,r0,r1,r2,r3,w4 ,round[i + 4]) \
F(r3,r4,r5,r6,r7,r0,r1,r2,w5 ,round[i + 5]) \
F(r2,r3,r4,r5,r6,r7,r0,r1,w6 ,round[i + 6]) \
F(r1,r2,r3,r4,r5,r6,r7,r0,w7 ,round[i + 7]) \
F(r0,r1,r2,r3,r4,r5,r6,r7,w8 ,round[i + 8]) \
F(r7,r0,r1,r2,r3,r4,r5,r6,w9 ,round[i + 9]) \
F(r6,r7,r0,r1,r2,r3,r4,r5,w10,round[i + 10]) \
F(r5,r6,r7,r0,r1,r2,r3,r4,w11,round[i + 11]) \
F(r4,r5,r6,r7,r0,r1,r2,r3,w12,round[i + 12]) \
F(r3,r4,r5,r6,r7,r0,r1,r2,w13,round[i + 13]) \
F(r2,r3,r4,r5,r6,r7,r0,r1,w14,round[i + 14]) \
F(r1,r2,r3,r4,r5,r6,r7,r0,w15,round[i + 15])
static const uint32 round[64] = {
0x428a2f98
, 0x71374491
, 0xb5c0fbcf
, 0xe9b5dba5
, 0x3956c25b
, 0x59f111f1
, 0x923f82a4
, 0xab1c5ed5
, 0xd807aa98
, 0x12835b01
, 0x243185be
, 0x550c7dc3
, 0x72be5d74
, 0x80deb1fe
, 0x9bdc06a7
, 0xc19bf174
, 0xe49b69c1
, 0xefbe4786
, 0x0fc19dc6
, 0x240ca1cc
, 0x2de92c6f
, 0x4a7484aa
, 0x5cb0a9dc
, 0x76f988da
, 0x983e5152
, 0xa831c66d
, 0xb00327c8
, 0xbf597fc7
, 0xc6e00bf3
, 0xd5a79147
, 0x06ca6351
, 0x14292967
, 0x27b70a85
, 0x2e1b2138
, 0x4d2c6dfc
, 0x53380d13
, 0x650a7354
, 0x766a0abb
, 0x81c2c92e
, 0x92722c85
, 0xa2bfe8a1
, 0xa81a664b
, 0xc24b8b70
, 0xc76c51a3
, 0xd192e819
, 0xd6990624
, 0xf40e3585
, 0x106aa070
, 0x19a4c116
, 0x1e376c08
, 0x2748774c
, 0x34b0bcb5
, 0x391c0cb3
, 0x4ed8aa4a
, 0x5b9cca4f
, 0x682e6ff3
, 0x748f82ee
, 0x78a5636f
, 0x84c87814
, 0x8cc70208
, 0x90befffa
, 0xa4506ceb
, 0xbef9a3f7
, 0xc67178f2
} ;
int crypto_hashblocks(unsigned char *statebytes,const unsigned char *in,unsigned long long inlen)
{
uint32 state[8];
uint32 r0;
uint32 r1;
uint32 r2;
uint32 r3;
uint32 r4;
uint32 r5;
uint32 r6;
uint32 r7;
r0 = load_bigendian(statebytes + 0); state[0] = r0;
r1 = load_bigendian(statebytes + 4); state[1] = r1;
r2 = load_bigendian(statebytes + 8); state[2] = r2;
r3 = load_bigendian(statebytes + 12); state[3] = r3;
r4 = load_bigendian(statebytes + 16); state[4] = r4;
r5 = load_bigendian(statebytes + 20); state[5] = r5;
r6 = load_bigendian(statebytes + 24); state[6] = r6;
r7 = load_bigendian(statebytes + 28); state[7] = r7;
while (inlen >= 64) {
uint32 w0 = load_bigendian(in + 0);
uint32 w1 = load_bigendian(in + 4);
uint32 w2 = load_bigendian(in + 8);
uint32 w3 = load_bigendian(in + 12);
uint32 w4 = load_bigendian(in + 16);
uint32 w5 = load_bigendian(in + 20);
uint32 w6 = load_bigendian(in + 24);
uint32 w7 = load_bigendian(in + 28);
uint32 w8 = load_bigendian(in + 32);
uint32 w9 = load_bigendian(in + 36);
uint32 w10 = load_bigendian(in + 40);
uint32 w11 = load_bigendian(in + 44);
uint32 w12 = load_bigendian(in + 48);
uint32 w13 = load_bigendian(in + 52);
uint32 w14 = load_bigendian(in + 56);
uint32 w15 = load_bigendian(in + 60);
G(r0,r1,r2,r3,r4,r5,r6,r7,0)
EXPAND
G(r0,r1,r2,r3,r4,r5,r6,r7,16)
EXPAND
G(r0,r1,r2,r3,r4,r5,r6,r7,32)
EXPAND
G(r0,r1,r2,r3,r4,r5,r6,r7,48)
r0 += state[0];
r1 += state[1];
r2 += state[2];
r3 += state[3];
r4 += state[4];
r5 += state[5];
r6 += state[6];
r7 += state[7];
state[0] = r0;
state[1] = r1;
state[2] = r2;
state[3] = r3;
state[4] = r4;
state[5] = r5;
state[6] = r6;
state[7] = r7;
in += 64;
inlen -= 64;
}
store_bigendian(statebytes + 0,state[0]);
store_bigendian(statebytes + 4,state[1]);
store_bigendian(statebytes + 8,state[2]);
store_bigendian(statebytes + 12,state[3]);
store_bigendian(statebytes + 16,state[4]);
store_bigendian(statebytes + 20,state[5]);
store_bigendian(statebytes + 24,state[6]);
store_bigendian(statebytes + 28,state[7]);
return 0;
}

View File

@ -1 +0,0 @@
Daniel J. Bernstein