Skip to content

Commit 1365ad3

Browse files
authored
Merge pull request #1 from crocs-muni/dev
eSTREAM finalists round reduced and polished
2 parents 46cdff8 + a580377 commit 1365ad3

File tree

11 files changed

+34
-344
lines changed

11 files changed

+34
-344
lines changed

main.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int main(const int argc, const char** argv) try {
2525
auto cfg = options.parse(make_view(argv, argc));
2626

2727
if (cfg.help) {
28-
std::cout << "Usage: eacirc [options]" << std::endl;
28+
std::cout << "Usage: eacirc-streams [options]" << std::endl;
2929

3030
options.print(std::cout);
3131
} else if (cfg.version) {

streams/block/ciphers/common_fun.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,35 @@
22

33
#include <cstdint>
44

5+
#if defined(__APPLE__) || defined(_WIN32)
6+
#define __BIG_ENDIAN 0x1000
7+
#define __LITTLE_ENDIAN 0x0001
8+
#define __BYTE_ORDER __LITTLE_ENDIAN
9+
#else
10+
#include <endian.h>
11+
#endif
12+
513
namespace block {
614

715
std::uint32_t u8_to_u32_copy(const uint8_t* in) {
16+
#if __BYTE_ORDER == __BIG_ENDIAN
817
return std::uint32_t((in[0] << 24) + (in[1] << 16) + (in[2] << 8) + in[3]);
18+
#elif __BYTE_ORDER == __LITTLE_ENDIAN
19+
return std::uint32_t((in[3] << 24) + (in[2] << 16) + (in[1] << 8) + in[0]);
20+
#endif
921
}
1022

1123
void u32_to_u8_copy(uint8_t* out, const uint32_t in) {
24+
#if __BYTE_ORDER == __BIG_ENDIAN
1225
out[0] = uint8_t((in >> 24) & 0xFF);
1326
out[1] = uint8_t((in >> 16) & 0xFF);
1427
out[2] = uint8_t((in >> 8) & 0xFF);
1528
out[3] = uint8_t(in & 0xFF);
29+
#elif __BYTE_ORDER == __LITTLE_ENDIAN
30+
out[3] = uint8_t((in >> 24) & 0xFF);
31+
out[2] = uint8_t((in >> 16) & 0xFF);
32+
out[1] = uint8_t((in >> 8) & 0xFF);
33+
out[0] = uint8_t(in & 0xFF);
34+
#endif
1635
}
17-
1836
}

streams/estream/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ add_library(estream STATIC EXCLUDE_FROM_ALL
1313
ciphers/wg/ecrypt-sync.h
1414
ciphers/tsc-4/ecrypt-sync.h
1515
ciphers/trivium/ecrypt-sync.h
16-
ciphers/tea/ecrypt-sync.h
1716
ciphers/sosemanuk/ecrypt-sync.h
1817
ciphers/sosemanuk/sosemanuk.h
1918
ciphers/sfinks/ecrypt-sync.h
@@ -70,7 +69,6 @@ add_library(estream STATIC EXCLUDE_FROM_ALL
7069
ciphers/zk-crypt/zk-crypt-v3.cpp
7170
ciphers/wg/wg.cpp
7271
ciphers/tsc-4/tsc-4.cpp
73-
ciphers/tea/tea.cpp
7472
ciphers/sosemanuk/sosemanuk.cpp
7573
ciphers/sfinks/sfinks.cpp
7674
ciphers/salsa20/salsa20.cpp

streams/estream/ciphers/dragon/ecrypt-sync.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ class ECRYPT_Dragon : public estream_interface {
103103

104104
public:
105105
/* Mandatory functions */
106+
ECRYPT_Dragon(int rounds)
107+
: estream_interface(rounds) {}
106108

107109
/*
108110
* Key and message independent initialization. This function will be

streams/estream/ciphers/ffcsr/ecrypt-sync.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class ECRYPT_FFCSR : public estream_interface {
6565
FFCSR_ctx _ctx;
6666

6767
public:
68+
ECRYPT_FFCSR(int rounds)
69+
: estream_interface(rounds) {}
6870
/* Mandatory functions */
6971

7072
/*

streams/estream/ciphers/hc-128/ecrypt-sync.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ class ECRYPT_HC128 : public estream_interface {
101101

102102
public:
103103
/* Mandatory functions */
104-
ECRYPT_HC128(int rounds)
105-
: estream_interface(rounds) {}
104+
106105
/*
107106
* Key and message independent initialization. This function will be
108107
* called once when the program starts (e.g., to build expanded S-box

streams/estream/ciphers/rabbit/ecrypt-sync.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ class ECRYPT_Rabbit : public estream_interface {
7272
RABBIT_ctx _ctx;
7373

7474
public:
75+
ECRYPT_Rabbit(int rounds)
76+
: estream_interface(rounds) {}
7577
/* Mandatory functions */
7678

7779
/*

streams/estream/ciphers/rabbit/rabbit.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void ECRYPT_Rabbit::ECRYPT_keysetup(const u8* key, u32 keysize, u32 ivsize) {
130130
ctx->master_ctx.carry = 0;
131131

132132
/* Iterate the system four times */
133-
for (i = 0; i < 4; i++)
133+
for (i = 0; (i < 4 && i < _rounds); i++)
134134
RABBIT_next_state(&(ctx->master_ctx));
135135

136136
/* Modify the counters */
@@ -175,7 +175,7 @@ void ECRYPT_Rabbit::ECRYPT_ivsetup(const u8* iv) {
175175
ctx->work_ctx.carry = ctx->master_ctx.carry;
176176

177177
/* Iterate the system four times */
178-
for (i = 0; i < 4; i++)
178+
for (i = 0; (i < 4 && i < _rounds); i++)
179179
RABBIT_next_state(&(ctx->work_ctx));
180180
}
181181

streams/estream/ciphers/tea/ecrypt-sync.h

Lines changed: 0 additions & 260 deletions
This file was deleted.

0 commit comments

Comments
 (0)