of "c" and "ctr", the latter resembles "counter" sound more
This commit is contained in:
parent
7eef4f2951
commit
88414b445d
|
@ -7,30 +7,30 @@ using namespace std;
|
|||
|
||||
struct G_state{
|
||||
long k;
|
||||
long c;
|
||||
long ctr;
|
||||
};
|
||||
|
||||
G_state *initialize_generator(){
|
||||
auto G = new G_state;
|
||||
G->k = 0;
|
||||
G->c = 0;
|
||||
G->ctr = 0;
|
||||
return G;
|
||||
};
|
||||
|
||||
string do_crypto(long k, long c){
|
||||
string do_crypto(long k, long ctr){
|
||||
/* this function calls the block cipher
|
||||
do whatever atm */
|
||||
k = 0;
|
||||
c = 0;
|
||||
ctr = 0;
|
||||
return "";
|
||||
}
|
||||
|
||||
G_state generate_blocks(G_state G, int k_blocks){
|
||||
assert (G.c!=0);
|
||||
assert (G.ctr!=0);
|
||||
string r = "";
|
||||
for (int i = 0; i < k_blocks; ++i) {
|
||||
r += do_crypto(G.k, G.c);
|
||||
G.c += 1;
|
||||
r += do_crypto(G.k, G.ctr);
|
||||
G.ctr += 1;
|
||||
}
|
||||
return G;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ string generate_random_data(G_state G, uint n){
|
|||
}
|
||||
/* do magic to compute r
|
||||
* r ← first-n-bytes(GenerateBlocks(G, ceil(n/16) )) */
|
||||
string rr = to_string(generate_blocks(G,ceil(n/16)).c);
|
||||
string rr = to_string(generate_blocks(G,ceil(n/16)).ctr);
|
||||
r = rr.substr(0,n);
|
||||
return r;
|
||||
};
|
||||
|
|
|
@ -9,7 +9,7 @@ struct G_state;
|
|||
/* initializes generator */
|
||||
G_state *initialize_generator();
|
||||
|
||||
std::string do_crypto(long k, long c);
|
||||
std::string do_crypto(long k, long ctr);
|
||||
|
||||
G_state generate_blocks(G_state G, int k_blocks);
|
||||
|
||||
|
|
Reference in New Issue