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
7e8980f5
Commit
7e8980f5
authored
Jan 04, 2019
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement audiowmark gen-key command.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
90a47bf9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
2 deletions
+49
-2
TODO
src/TODO
+6
-0
audiowmark.cc
src/audiowmark.cc
+22
-1
random.cc
src/random.cc
+18
-0
random.hh
src/random.hh
+3
-1
No files found.
src/TODO
View file @
7e8980f5
key:
- --key loading
- multiple values per block
- avoid reroll in up_down generation
- move shuffle function to Random class
possible improvements:
- dynamic bit strength
- mp3 support with libmad
src/audiowmark.cc
View file @
7e8980f5
...
...
@@ -56,6 +56,9 @@ print_usage()
printf
(
" * compute bit error rate for decoding with original file
\n
"
);
printf
(
" audiowmark cmp-delta <input_wav> <watermarked_wav> <message_hex>
\n
"
);
printf
(
"
\n
"
);
printf
(
" * generate 128-bit watermarking key, to be used with --key option
\n
"
);
printf
(
" audiowmark gen-key <key_file>
\n
"
);
printf
(
"
\n
"
);
printf
(
"Global options:
\n
"
);
printf
(
" --frame-size frame size (must be power of 2) [%zd]
\n
"
,
Params
::
frame_size
);
printf
(
" --frames-per-bit number of frames per bit [%d]
\n
"
,
Params
::
frames_per_bit
);
...
...
@@ -884,6 +887,20 @@ get_snr (const string& origfile, const string& wmfile)
return
0
;
}
int
gen_key
(
const
string
&
outfile
)
{
FILE
*
f
=
fopen
(
outfile
.
c_str
(),
"w"
);
if
(
!
f
)
{
fprintf
(
stderr
,
"audiowmark: error writing to file %s
\n
"
,
outfile
.
c_str
());
return
1
;
}
fprintf
(
f
,
"# watermarking key for audiowmark
\n\n
key %s
\n
"
,
Random
::
gen_key
().
c_str
());
fclose
(
f
);
return
0
;
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -928,9 +945,13 @@ main (int argc, char **argv)
{
return
get_watermark_delta
(
argv
[
2
],
argv
[
3
],
argv
[
4
]);
}
else
if
(
op
==
"gen-key"
&&
argc
==
3
)
{
return
gen_key
(
argv
[
2
]);
}
else
{
fprintf
(
stderr
,
"audiowmark: error parsing commandline args
\n
"
);
fprintf
(
stderr
,
"audiowmark: error parsing commandline args
(use audiowmark -h)
\n
"
);
return
1
;
}
}
src/random.cc
View file @
7e8980f5
#include "random.hh"
using
std
::
string
;
static
std
::
vector
<
unsigned
char
>
aes_key
(
16
);
static
constexpr
auto
GCRY_CIPHER
=
GCRY_CIPHER_AES128
;
...
...
@@ -123,3 +125,19 @@ Random::set_global_test_key (uint64_t key)
{
uint64_to_buffer
(
key
,
&
aes_key
[
0
]);
}
std
::
string
Random
::
gen_key
()
{
unsigned
char
key
[
16
];
gcry_randomize
(
key
,
16
,
/* long term key material strength */
GCRY_VERY_STRONG_RANDOM
);
string
s
;
for
(
auto
k
:
key
)
{
char
buffer
[
256
];
sprintf
(
buffer
,
"%02x"
,
k
);
s
+=
buffer
;
}
return
s
;
}
src/random.hh
View file @
7e8980f5
...
...
@@ -5,6 +5,7 @@
#include <stdint.h>
#include <vector>
#include <string>
class
Random
{
...
...
@@ -33,7 +34,8 @@ public:
~
Random
();
uint64_t
operator
()();
static
void
set_global_test_key
(
uint64_t
seed
);
static
void
set_global_test_key
(
uint64_t
seed
);
static
std
::
string
gen_key
();
};
#endif
/* AUDIOWMARK_RANDOM_HH */
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