Skip to content

Commit

Permalink
Merge pull request #66 from crocs-muni/cleanup
Browse files Browse the repository at this point in the history
Cleanup + fix Kasumi
  • Loading branch information
Bender250 authored Apr 13, 2018
2 parents 71f7cdd + caca7f9 commit 852f964
Show file tree
Hide file tree
Showing 152 changed files with 1,431 additions and 1,450 deletions.
13 changes: 13 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
BasedOnStyle: LLVM
AccessModifierOffset: -4
AllowShortFunctionsOnASingleLine: Inline
BinPackArguments: false
BinPackParameters: false
BreakConstructorInitializersBeforeComma: true
ContinuationIndentWidth: 4
ColumnLimit: 100
IndentWidth: 4
NamespaceIndentation: None
PointerAlignment: Right
...
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ if (BUILD_testsuite)
testsuite/hash_streams_tests.cc
testsuite/stream_ciphers_streams_tests.cc
testsuite/block_streams_tests.cc
testsuite/test-utils/test_streams
testsuite/test-utils/hash_test_case
testsuite/test-utils/stream_ciphers_test_case
testsuite/test-utils/block_test_case
testsuite/test-utils/common_functions
testsuite/test-utils/test_case.h)
testsuite/test_utils/test_streams
testsuite/test_utils/hash_test_case
testsuite/test_utils/stream_ciphers_test_case
testsuite/test_utils/block_test_case
testsuite/test_utils/common_functions
testsuite/test_utils/test_case.h)

target_compile_definitions(testsuite PUBLIC "TEST_STREAM=1")

file(COPY testsuite/test-resources DESTINATION resources)
file(COPY testsuite/test_resources DESTINATION resources)

# Standard linking to gtest stuff.
target_link_libraries(testsuite gtest gtest_main)
Expand Down
20 changes: 10 additions & 10 deletions generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <pcg/pcg_random.hpp>

#include <fstream>
#include <sstream>
#include <iomanip>
#include <sstream>

static std::ifstream open_config_file(const std::string path) {
std::ifstream file(path);
Expand All @@ -16,9 +16,9 @@ static std::ifstream open_config_file(const std::string path) {
return file;
}

static std::string out_name(json const& config) {
auto fname_it = config.find("file-name");
if (fname_it != config.end()){
static std::string out_name(json const &config) {
auto fname_it = config.find("file_name");
if (fname_it != config.end()) {
return *fname_it;
}

Expand All @@ -31,32 +31,32 @@ static std::string out_name(json const& config) {
std::string a = config_ref.at("algorithm");
ss << a << "_r";
ss << std::setw(2) << std::setfill('0') << std::size_t(config_ref.at("round"));
ss << "_b" << config_ref.at("block-size");
ss << "_b" << config_ref.at("block_size");
ss << ".bin";
return ss.str();
}

generator::generator(const std::string config)
: generator(open_config_file(config)) {}

generator::generator(json const& config)
generator::generator(json const &config)
: _config(config)
, _seed(seed::create(config.at("seed")))
, _tv_count(config.at("tv-count"))
, _tv_count(config.at("tv_count"))
, _o_file_name(out_name(config)) {

seed_seq_from<pcg32> main_seeder(_seed);

_stream_a = make_stream(config.at("stream"), main_seeder, std::size_t(config.at("tv-size")));
_stream_a = make_stream(config.at("stream"), main_seeder, std::size_t(config.at("tv_size")));
}

void generator::generate() {

auto stdout_it = _config.find("stdout");
std::unique_ptr<std::ostream> ofstream_ptr;
std::ostream * o_file = nullptr;
std::ostream *o_file = nullptr;

if (stdout_it == _config.end() || stdout_it->get<bool>() == false){
if (stdout_it == _config.end() || stdout_it->get<bool>() == false) {
ofstream_ptr = std::make_unique<std::ofstream>(_o_file_name, std::ios::binary);
o_file = ofstream_ptr.get();
} else {
Expand Down
14 changes: 7 additions & 7 deletions generator.h
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#pragma once

#include "stream.h"
#include <memory>
#include <iostream>
#include <fstream>
#include <eacirc-core/json.h>
#include <eacirc-core/seed.h>
#include <fstream>
#include <iostream>
#include <memory>

struct generator {
generator(const std::string cofig);

generator(std::istream& config)
generator(std::istream &config)
: generator(json::parse(config)) {}

generator(std::istream&& config)
generator(std::istream &&config)
: generator(json::parse(config)) {}

generator(json&& config)
generator(json &&config)
: generator(config) {}

generator(json const& config);
generator(json const &config);

void generate();

Expand Down
6 changes: 3 additions & 3 deletions main.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "generator.h"
#include <eacirc-core/version.h>
#include <eacirc-core/cmd.h>
#include <eacirc-core/logger.h>
#include <eacirc-core/version.h>
#include <limits>

void test_environment() {
Expand All @@ -21,7 +21,7 @@ static cmd<config> options{{"-h", "--help", "display help message", &config::hel
{"-v", "--version", "display program version", &config::version},
{"-c", "--config", "specify the config file to load", &config::config}};

int main(const int argc, const char** argv) try {
int main(const int argc, const char **argv) try {
auto cfg = options.parse(make_view(argv, argc));

if (cfg.help) {
Expand All @@ -38,7 +38,7 @@ int main(const int argc, const char** argv) try {
}

return 0;
} catch (std::exception& e) {
} catch (std::exception &e) {
logger::error(e.what());
return 1;
}
12 changes: 4 additions & 8 deletions stream.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include <eacirc-core/json.h>
#include <eacirc-core/view.h>
#include <eacirc-core/dataset.h>
#include <eacirc-core/json.h>
#include <eacirc-core/logger.h>
#include <eacirc-core/view.h>
#include <vector>

using value_type = std::uint8_t;
Expand All @@ -15,13 +15,9 @@ struct stream {

virtual vec_cview next() = 0;

vec_cview get_data() const {
return make_cview(_data);
}
vec_cview get_data() const { return make_cview(_data); }

void set_data(vec_cview data) {
std::copy(data.begin(), data.end(), _data.begin());
}
void set_data(vec_cview data) { std::copy(data.begin(), data.end(), _data.begin()); }

std::size_t osize() const { return _osize; }

Expand Down
Loading

0 comments on commit 852f964

Please sign in to comment.