modernise: use trailing return type
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
46e5048788
commit
8c1dfea06e
|
@ -12,7 +12,7 @@ struct G_state{
|
|||
unsigned __int128 ctr;
|
||||
};
|
||||
|
||||
tuple<G_state, unsigned __int128> reseed(G_state G, const string& s){
|
||||
auto reseed(G_state G, const string& s) -> std::tuple<G_state, unsigned __int128> {
|
||||
unsigned __int128 ctr;
|
||||
// TODO(me): conctatenate the key with seed
|
||||
G.k = do_sha(G.ctr);
|
||||
|
@ -20,7 +20,7 @@ tuple<G_state, unsigned __int128> reseed(G_state G, const string& s){
|
|||
return {G, ctr};
|
||||
}
|
||||
|
||||
int64_t do_sha(int64_t key_with_seed){
|
||||
auto do_sha(int64_t key_with_seed) -> int64_t {
|
||||
/* do sha256 */
|
||||
int64_t shastring = key_with_seed + 1;
|
||||
return shastring;
|
||||
|
@ -33,7 +33,7 @@ G_state *initialize_generator(){
|
|||
return G;
|
||||
};
|
||||
|
||||
string do_crypto(int64_t k, unsigned __int128 ctr){
|
||||
auto do_crypto(int64_t k, unsigned __int128 ctr) -> string {
|
||||
/* this function calls the block cipher
|
||||
* returns a string of k*(16 bytes);
|
||||
do whatever atm */
|
||||
|
@ -43,7 +43,7 @@ string do_crypto(int64_t k, unsigned __int128 ctr){
|
|||
}
|
||||
|
||||
/* lacking objects, we have to return both the state and the string */
|
||||
tuple<string, G_state> generate_blocks(G_state G, int k_blocks){
|
||||
auto generate_blocks(G_state G, int k_blocks) -> tuple<string, G_state> {
|
||||
assert (G.ctr!=0);
|
||||
string r = "";
|
||||
for (int i = 0; i < k_blocks; ++i) {
|
||||
|
@ -54,7 +54,7 @@ tuple<string, G_state> generate_blocks(G_state G, int k_blocks){
|
|||
}
|
||||
|
||||
/* n is number of random bytes to generate */
|
||||
tuple<string, G_state> generate_random_data(G_state G, uint n){
|
||||
auto generate_random_data(G_state G, uint n) -> tuple<string, G_state> {
|
||||
string r = "";
|
||||
if (n < 0){
|
||||
/* this should not be possible */
|
||||
|
|
10
generator.h
10
generator.h
|
@ -10,15 +10,15 @@ struct G_state;
|
|||
/* initializes generator */
|
||||
G_state *initialize_generator();
|
||||
|
||||
std::string do_crypto(int64_t k, unsigned __int128 ctr);
|
||||
auto do_crypto(int64_t k, unsigned __int128 ctr) -> std::string;
|
||||
|
||||
std::tuple<G_state, unsigned __int128> reseed(G_state G, const std::string& s);
|
||||
auto reseed(G_state G, const std::string& s) -> std::tuple<G_state, unsigned __int128>;
|
||||
|
||||
int64_t do_sha(int64_t key_with_seed);
|
||||
auto do_sha(int64_t key_with_seed) -> int64_t;
|
||||
|
||||
std::tuple<std::string, G_state> generate_blocks(G_state G, int k_blocks);
|
||||
auto generate_blocks(G_state G, int k_blocks) -> std::tuple<std::string, G_state>;
|
||||
|
||||
/* returns output of 0 <= n <= 2^20 bytes */
|
||||
std::tuple<std::string, G_state> generate_random_data(G_state G, int n);
|
||||
auto generate_random_data(G_state G, int n) -> std::tuple<std::string, G_state>;
|
||||
|
||||
#endif//FORTUNA_GENERATOR_H
|
||||
|
|
Reference in New Issue