Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wasm-watermarker
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nagayama15
wasm-watermarker
Commits
8a6f7c11
Verified
Commit
8a6f7c11
authored
Dec 03, 2020
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: rename method name "*-ordering" -> "*-reordering"
parent
5b0c3ad2
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
52 additions
and
52 deletions
+52
-52
Reordering-inl.hpp
lib/kyut/Reordering-inl.hpp
+7
-7
Reordering.hpp
lib/kyut/Reordering.hpp
+6
-6
ExportReordering.hpp
lib/kyut/methods/ExportReordering.hpp
+8
-8
FunctionReordering.hpp
lib/kyut/methods/FunctionReordering.hpp
+8
-8
pisn.cpp
src/pisn.cpp
+7
-7
snpi.cpp
src/snpi.cpp
+7
-7
CMakeLists.txt
test/CMakeLists.txt
+1
-1
test_Reordering.cpp
test/test_Reordering.cpp
+8
-8
No files found.
lib/kyut/
O
rdering-inl.hpp
→
lib/kyut/
Reo
rdering-inl.hpp
View file @
8a6f7c11
#ifndef INCLUDE_kyut_Ordering_inl_hpp
#define INCLUDE_kyut_Ordering_inl_hpp
#include "
O
rdering.hpp"
#include "
Reo
rdering.hpp"
#include <algorithm>
#include "BitStreamWriter.hpp"
...
...
@@ -43,7 +43,7 @@ namespace kyut {
}
template
<
typename
RandomAccessIterator
,
typename
Less
>
inline
std
::
size_t
embed_by_ordering
(
inline
std
::
size_t
embed_by_
re
ordering
(
CircularBitStreamReader
&
r
,
std
::
size_t
chunk_size
,
RandomAccessIterator
begin
,
...
...
@@ -119,7 +119,7 @@ namespace kyut {
}
template
<
typename
RandomAccessIterator
,
typename
Less
>
inline
std
::
size_t
extract_by_ordering
(
inline
std
::
size_t
extract_by_
re
ordering
(
BitStreamWriter
&
w
,
std
::
size_t
chunk_size
,
RandomAccessIterator
begin
,
...
...
@@ -144,23 +144,23 @@ namespace kyut {
}
// namespace detail
template
<
typename
RandomAccessIterator
,
typename
Less
>
inline
std
::
size_t
embed_by_ordering
(
inline
std
::
size_t
embed_by_
re
ordering
(
CircularBitStreamReader
&
r
,
std
::
size_t
chunk_size
,
RandomAccessIterator
begin
,
RandomAccessIterator
end
,
Less
less
)
{
return
detail
::
embed_by_ordering
(
r
,
chunk_size
,
begin
,
end
,
less
);
return
detail
::
embed_by_
re
ordering
(
r
,
chunk_size
,
begin
,
end
,
less
);
}
template
<
typename
RandomAccessIterator
,
typename
Less
>
inline
std
::
size_t
extract_by_ordering
(
inline
std
::
size_t
extract_by_
re
ordering
(
BitStreamWriter
&
w
,
std
::
size_t
chunk_size
,
RandomAccessIterator
begin
,
RandomAccessIterator
end
,
Less
less
)
{
return
detail
::
extract_by_ordering
(
w
,
chunk_size
,
begin
,
end
,
less
);
return
detail
::
extract_by_
re
ordering
(
w
,
chunk_size
,
begin
,
end
,
less
);
}
}
// namespace kyut
...
...
lib/kyut/
O
rdering.hpp
→
lib/kyut/
Reo
rdering.hpp
View file @
8a6f7c11
#ifndef INCLUDE_kyut_
O
rdering_hpp
#define INCLUDE_kyut_
O
rdering_hpp
#ifndef INCLUDE_kyut_
Reo
rdering_hpp
#define INCLUDE_kyut_
Reo
rdering_hpp
#include <cstddef>
...
...
@@ -10,7 +10,7 @@ namespace kyut {
constexpr
std
::
size_t
max_chunk_size
=
20
;
template
<
typename
RandomAccessIterator
,
typename
Less
>
std
::
size_t
embed_by_ordering
(
std
::
size_t
embed_by_
re
ordering
(
CircularBitStreamReader
&
r
,
std
::
size_t
chunk_size
,
RandomAccessIterator
begin
,
...
...
@@ -18,7 +18,7 @@ namespace kyut {
Less
less
);
template
<
typename
RandomAccessIterator
,
typename
Less
>
std
::
size_t
extract_by_ordering
(
std
::
size_t
extract_by_
re
ordering
(
BitStreamWriter
&
w
,
std
::
size_t
chunk_size
,
RandomAccessIterator
begin
,
...
...
@@ -26,6 +26,6 @@ namespace kyut {
Less
less
);
}
// namespace kyut
#include "
O
rdering-inl.hpp"
#include "
Reo
rdering-inl.hpp"
#endif // INCLUDE_kyut_
O
rdering_hpp
#endif // INCLUDE_kyut_
Reo
rdering_hpp
lib/kyut/methods/Export
O
rdering.hpp
→
lib/kyut/methods/Export
Reo
rdering.hpp
View file @
8a6f7c11
#ifndef INCLUDE_kyut_methods_Export
O
rdering_hpp
#define INCLUDE_kyut_methods_Export
O
rdering_hpp
#ifndef INCLUDE_kyut_methods_Export
Reo
rdering_hpp
#define INCLUDE_kyut_methods_Export
Reo
rdering_hpp
#include "../
O
rdering.hpp"
#include "../
Reo
rdering.hpp"
#include "wasm.h"
namespace
kyut
{
...
...
@@ -9,9 +9,9 @@ namespace kyut {
class
BitStreamWriter
;
}
// namespace kyut
namespace
kyut
::
methods
::
export_ordering
{
namespace
kyut
::
methods
::
export_
re
ordering
{
inline
std
::
size_t
embed
(
CircularBitStreamReader
&
r
,
wasm
::
Module
&
module
,
std
::
size_t
chunk_size
)
{
const
auto
size_bits
=
embed_by_ordering
(
const
auto
size_bits
=
embed_by_
re
ordering
(
r
,
chunk_size
,
std
::
begin
(
module
.
exports
),
...
...
@@ -24,7 +24,7 @@ namespace kyut::methods::export_ordering {
}
inline
std
::
size_t
extract
(
BitStreamWriter
&
w
,
wasm
::
Module
&
module
,
std
::
size_t
chunk_size
)
{
const
auto
size_bits
=
extract_by_ordering
(
const
auto
size_bits
=
extract_by_
re
ordering
(
w
,
chunk_size
,
std
::
begin
(
module
.
exports
),
...
...
@@ -35,6 +35,6 @@ namespace kyut::methods::export_ordering {
return
size_bits
;
}
}
// namespace kyut::methods::export_ordering
}
// namespace kyut::methods::export_
re
ordering
#endif // INCLUDE_kyut_methods_Export
O
rdering_hpp
#endif // INCLUDE_kyut_methods_Export
Reo
rdering_hpp
lib/kyut/methods/Function
O
rdering.hpp
→
lib/kyut/methods/Function
Reo
rdering.hpp
View file @
8a6f7c11
#ifndef INCLUDE_kyut_methods_Function
O
rdering_hpp
#define INCLUDE_kyut_methods_Function
O
rdering_hpp
#ifndef INCLUDE_kyut_methods_Function
Reo
rdering_hpp
#define INCLUDE_kyut_methods_Function
Reo
rdering_hpp
#include "../
O
rdering.hpp"
#include "../
Reo
rdering.hpp"
#include "../wasm-ext/Compare.hpp"
namespace
kyut
{
...
...
@@ -9,7 +9,7 @@ namespace kyut {
class
BitStreamWriter
;
}
// namespace kyut
namespace
kyut
::
methods
::
function_ordering
{
namespace
kyut
::
methods
::
function_
re
ordering
{
inline
std
::
size_t
embed
(
CircularBitStreamReader
&
r
,
wasm
::
Module
&
module
,
std
::
size_t
chunk_size
)
{
const
auto
begin
=
std
::
begin
(
module
.
functions
);
const
auto
end
=
std
::
end
(
module
.
functions
);
...
...
@@ -18,7 +18,7 @@ namespace kyut::methods::function_ordering {
return
f
->
body
==
nullptr
;
});
const
auto
size_bits
=
embed_by_ordering
(
const
auto
size_bits
=
embed_by_
re
ordering
(
r
,
chunk_size
,
start
,
...
...
@@ -38,7 +38,7 @@ namespace kyut::methods::function_ordering {
return
f
->
body
==
nullptr
;
});
const
auto
size_bits
=
extract_by_ordering
(
const
auto
size_bits
=
extract_by_
re
ordering
(
w
,
chunk_size
,
start
,
...
...
@@ -49,6 +49,6 @@ namespace kyut::methods::function_ordering {
return
size_bits
;
}
}
// namespace kyut::methods::function_ordering
}
// namespace kyut::methods::function_
re
ordering
#endif // INCLUDE_kyut_methods_Function
O
rdering_hpp
#endif // INCLUDE_kyut_methods_Function
Reo
rdering_hpp
src/pisn.cpp
View file @
8a6f7c11
#include <fmt/printf.h>
#include "cmdline.h"
#include "kyut/methods/Export
O
rdering.hpp"
#include "kyut/methods/Function
O
rdering.hpp"
#include "kyut/methods/Export
Reo
rdering.hpp"
#include "kyut/methods/Function
Reo
rdering.hpp"
#include "wasm-io.h"
namespace
{
...
...
@@ -15,7 +15,7 @@ int main(int argc, char* argv[]) {
options
.
add
(
"help"
,
'h'
,
"Print help message"
);
options
.
add
(
"version"
,
'v'
,
"Print version"
);
options
.
add
<
std
::
string
>
(
"method"
,
'm'
,
"Embedding method (function-
ordering, export-ordering)"
,
true
,
""
,
cmdline
::
oneof
<
std
::
string
>
(
"function-ordering"
,
"export-
ordering"
));
options
.
add
<
std
::
string
>
(
"method"
,
'm'
,
"Embedding method (function-
reordering, export-reordering)"
,
true
,
""
,
cmdline
::
oneof
<
std
::
string
>
(
"function-reordering"
,
"export-re
ordering"
));
options
.
add
<
std
::
size_t
>
(
"chunk-size"
,
'c'
,
"Chunk size [2~20]"
,
false
,
20
,
cmdline
::
range
<
std
::
size_t
>
(
2
,
20
));
options
.
add
<
std
::
string
>
(
"dump"
,
0
,
"Output format (ascii, hex)"
,
false
,
"ascii"
,
cmdline
::
oneof
<
std
::
string
>
(
"ascii"
,
"hex"
));
...
...
@@ -51,10 +51,10 @@ int main(int argc, char* argv[]) {
kyut
::
BitStreamWriter
w
{};
std
::
size_t
size_bits
;
if
(
method
==
"function-ordering"
)
{
size_bits
=
kyut
::
methods
::
function_ordering
::
extract
(
w
,
module
,
chunk_size
);
}
else
if
(
method
==
"export-ordering"
)
{
size_bits
=
kyut
::
methods
::
export_ordering
::
extract
(
w
,
module
,
chunk_size
);
if
(
method
==
"function-
re
ordering"
)
{
size_bits
=
kyut
::
methods
::
function_
re
ordering
::
extract
(
w
,
module
,
chunk_size
);
}
else
if
(
method
==
"export-
re
ordering"
)
{
size_bits
=
kyut
::
methods
::
export_
re
ordering
::
extract
(
w
,
module
,
chunk_size
);
}
else
{
WASM_UNREACHABLE
((
"unknown method: "
+
method
).
c_str
());
}
...
...
src/snpi.cpp
View file @
8a6f7c11
#include <fmt/printf.h>
#include "cmdline.h"
#include "kyut/methods/Export
O
rdering.hpp"
#include "kyut/methods/Function
O
rdering.hpp"
#include "kyut/methods/Export
Reo
rdering.hpp"
#include "kyut/methods/Function
Reo
rdering.hpp"
#include "support/colors.h"
#include "wasm-io.h"
...
...
@@ -17,7 +17,7 @@ int main(int argc, char* argv[]) {
options
.
add
(
"version"
,
'v'
,
"Print version"
);
options
.
add
<
std
::
string
>
(
"output"
,
'o'
,
"Output filename"
,
true
);
options
.
add
<
std
::
string
>
(
"method"
,
'm'
,
"Embedding method (function-
ordering, export-ordering)"
,
true
,
""
,
cmdline
::
oneof
<
std
::
string
>
(
"function-ordering"
,
"export-
ordering"
));
options
.
add
<
std
::
string
>
(
"method"
,
'm'
,
"Embedding method (function-
reordering, export-reordering)"
,
true
,
""
,
cmdline
::
oneof
<
std
::
string
>
(
"function-reordering"
,
"export-re
ordering"
));
options
.
add
<
std
::
string
>
(
"watermark"
,
'w'
,
"Watermark to embed"
,
true
);
options
.
add
<
std
::
size_t
>
(
"chunk-size"
,
'c'
,
"Chunk size [2~20]"
,
false
,
20
,
cmdline
::
range
<
std
::
size_t
>
(
2
,
20
));
...
...
@@ -68,10 +68,10 @@ int main(int argc, char* argv[]) {
kyut
::
CircularBitStreamReader
r
{
watermark
};
std
::
size_t
size_bits
;
if
(
method
==
"function-ordering"
)
{
size_bits
=
kyut
::
methods
::
function_ordering
::
embed
(
r
,
module
,
chunk_size
);
}
else
if
(
method
==
"export-ordering"
)
{
size_bits
=
kyut
::
methods
::
export_ordering
::
embed
(
r
,
module
,
chunk_size
);
if
(
method
==
"function-
re
ordering"
)
{
size_bits
=
kyut
::
methods
::
function_
re
ordering
::
embed
(
r
,
module
,
chunk_size
);
}
else
if
(
method
==
"export-
re
ordering"
)
{
size_bits
=
kyut
::
methods
::
export_
re
ordering
::
embed
(
r
,
module
,
chunk_size
);
}
else
{
WASM_UNREACHABLE
((
"unknown method: "
+
method
).
c_str
());
}
...
...
test/CMakeLists.txt
View file @
8a6f7c11
...
...
@@ -3,7 +3,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/test")
add_executable
(
test_kyut
test_BitStreamWriter.cpp
test_CircularBitStreamReader.cpp
test_
O
rdering.cpp
test_
Reo
rdering.cpp
)
target_link_libraries
(
test_kyut
...
...
test/test_
O
rdering.cpp
→
test/test_
Reo
rdering.cpp
View file @
8a6f7c11
#include "kyut/
O
rdering.hpp"
#include "kyut/
Reo
rdering.hpp"
#include <gtest/gtest.h>
...
...
@@ -11,7 +11,7 @@ namespace {
std
::
string_view
expected_reordered_data
)
{
kyut
::
CircularBitStreamReader
r
{
watermark
};
const
auto
size_bits
=
kyut
::
embed_by_ordering
(
const
auto
size_bits
=
kyut
::
embed_by_
re
ordering
(
r
,
chunk_size
,
std
::
begin
(
data
),
...
...
@@ -23,7 +23,7 @@ namespace {
}
}
// namespace
TEST
(
kyut_
Ordering
,
embed_by_
ordering
)
{
TEST
(
kyut_
Reordering
,
embed_by_re
ordering
)
{
using
namespace
std
::
string_view_literals
;
check_embed
(
"1234"
,
"
\x00
"
sv
,
20
,
4
,
"1234"
);
...
...
@@ -47,7 +47,7 @@ namespace {
std
::
string_view
expected_watermark_extracted
)
{
kyut
::
BitStreamWriter
w
{};
const
auto
size_bits
=
kyut
::
extract_by_ordering
(
const
auto
size_bits
=
kyut
::
extract_by_
re
ordering
(
w
,
chunk_size
,
std
::
begin
(
data
),
...
...
@@ -60,7 +60,7 @@ namespace {
}
}
// namespace
TEST
(
kyut_
Ordering
,
extract_by_
ordering
)
{
TEST
(
kyut_
Reordering
,
extract_by_re
ordering
)
{
using
namespace
std
::
string_view_literals
;
check_extract
(
"1234"
,
20
,
4
,
"
\x00
"
sv
);
...
...
@@ -80,7 +80,7 @@ namespace {
std
::
string_view
expected_watermark_extracted
)
{
kyut
::
CircularBitStreamReader
r
{
watermark_embedding
};
const
auto
size_bits_embedded
=
kyut
::
embed_by_ordering
(
const
auto
size_bits_embedded
=
kyut
::
embed_by_
re
ordering
(
r
,
chunk_size
,
std
::
begin
(
data
),
...
...
@@ -91,7 +91,7 @@ namespace {
kyut
::
BitStreamWriter
w
{};
const
auto
size_bits_extracted
=
kyut
::
extract_by_ordering
(
const
auto
size_bits_extracted
=
kyut
::
extract_by_
re
ordering
(
w
,
chunk_size
,
std
::
begin
(
data
),
...
...
@@ -103,7 +103,7 @@ namespace {
}
}
// namespace
TEST
(
kyut_
O
rdering
,
embed_then_extract
)
{
TEST
(
kyut_
Reo
rdering
,
embed_then_extract
)
{
using
namespace
std
::
string_view_literals
;
check_embed_then_extract
(
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv"
,
"Test"
sv
,
15
,
40
*
3
+
32
,
"TestTestTestTestTes"
sv
);
...
...
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