Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
audiowmark
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
audiowmark
Commits
e585040c
Commit
e585040c
authored
Jan 05, 2019
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow inlining random number generator most of the time.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
946a4524
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
19 deletions
+22
-19
TODO
src/TODO
+0
-1
random.cc
src/random.cc
+12
-17
random.hh
src/random.hh
+10
-1
No files found.
src/TODO
View file @
e585040c
key:
- multiple values per block
- avoid reroll in up_down generation
- move shuffle function to Random class
...
...
src/random.cc
View file @
e585040c
...
...
@@ -102,28 +102,23 @@ Random::get_start_counter (uint64_t seed, Stream stream)
return
cipher_text
;
}
uint64_t
Random
::
operator
()
()
void
Random
::
refill_buffer
()
{
if
(
buffer_pos
==
buffer
.
size
())
{
const
size_t
block_size
=
256
;
unsigned
char
zeros
[
block_size
]
=
{
0
,
};
unsigned
char
cipher_text
[
block_size
];
const
size_t
block_size
=
256
;
unsigned
char
zeros
[
block_size
]
=
{
0
,
};
unsigned
char
cipher_text
[
block_size
];
gcry_error_t
gcry_ret
=
gcry_cipher_encrypt
(
aes_ctr_cipher
,
cipher_text
,
block_size
,
zeros
,
block_size
);
die_on_error
(
"gcry_cipher_encrypt"
,
gcry_ret
);
gcry_error_t
gcry_ret
=
gcry_cipher_encrypt
(
aes_ctr_cipher
,
cipher_text
,
block_size
,
zeros
,
block_size
);
die_on_error
(
"gcry_cipher_encrypt"
,
gcry_ret
);
// print ("AES OUT", {cipher_text, cipher_text + block_size});
// print ("AES OUT", {cipher_text, cipher_text + block_size});
buffer
.
clear
();
for
(
size_t
i
=
0
;
i
<
block_size
;
i
+=
8
)
buffer
.
push_back
(
uint64_from_buffer
(
cipher_text
+
i
));
buffer
.
clear
();
for
(
size_t
i
=
0
;
i
<
block_size
;
i
+=
8
)
buffer
.
push_back
(
uint64_from_buffer
(
cipher_text
+
i
));
buffer_pos
=
0
;
}
assert
(
buffer_pos
<
buffer
.
size
());
return
buffer
[
buffer_pos
++
];
buffer_pos
=
0
;
}
void
...
...
src/random.hh
View file @
e585040c
...
...
@@ -26,7 +26,16 @@ private:
public
:
Random
(
uint64_t
seed
,
Stream
stream
);
~
Random
();
uint64_t
operator
()();
uint64_t
operator
()()
{
if
(
buffer_pos
==
buffer
.
size
())
refill_buffer
();
return
buffer
[
buffer_pos
++
];
}
void
refill_buffer
();
static
void
set_global_test_key
(
uint64_t
seed
);
static
void
load_global_key
(
const
std
::
string
&
key_file
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment