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
95667ed1
Commit
95667ed1
authored
Jul 13, 2019
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🚧
Add an empty watermarking function
parent
adbbc308
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
128 additions
and
0 deletions
+128
-0
test2.wast
example/test2.wast
+32
-0
CMakeLists.txt
src/CMakeLists.txt
+1
-0
OperandSwappingWatermarker.cpp
src/kyut/watermarker/OperandSwappingWatermarker.cpp
+16
-0
OperandSwappingWatermarker.hpp
src/kyut/watermarker/OperandSwappingWatermarker.hpp
+31
-0
CMakeLists.txt
test/CMakeLists.txt
+1
-0
test_OperandSwappingWatermarker.cpp
test/kyut/watermarker/test_OperandSwappingWatermarker.cpp
+47
-0
No files found.
example/test2.wast
0 → 100644
View file @
95667ed1
(module
(export "f1" (func $f1))
(export "f2" (func $f2))
(export "f3" (func $f3))
(func $f1 (result i32)
(i32.add
(i32.const 1)
(i32.const 2)
)
)
(func $f2 (result i32)
(i32.add
(i32.add
(i32.const 1)
(i32.const 2)
)
(i32.const 3)
)
)
(func $f3 (result i32)
(i32.add
(i32.add
(i32.const 1)
(i32.const 2)
)
(i32.add
(i32.const 4)
(i32.const 3)
)
)
)
)
src/CMakeLists.txt
View file @
95667ed1
add_library
(
kyut
add_library
(
kyut
kyut/watermarker/FunctionOrderingWatermarker.cpp
kyut/watermarker/FunctionOrderingWatermarker.cpp
kyut/watermarker/OperandSwappingWatermarker.cpp
)
)
target_link_libraries
(
kyut
target_link_libraries
(
kyut
...
...
src/kyut/watermarker/OperandSwappingWatermarker.cpp
0 → 100644
View file @
95667ed1
#include "OperandSwappingWatermarker.hpp"
namespace
kyut
::
watermarker
{
std
::
size_t
embedOperandSwapping
(
wasm
::
Module
&
module
,
CircularBitStreamReader
&
stream
)
{
(
void
)
module
;
(
void
)
stream
;
return
0
;
}
std
::
size_t
extractOperandSwapping
(
wasm
::
Module
&
module
,
BitStreamWriter
&
stream
)
{
(
void
)
module
;
(
void
)
stream
;
return
0
;
}
}
// namespace kyut::watermarker
src/kyut/watermarker/OperandSwappingWatermarker.hpp
0 → 100644
View file @
95667ed1
#ifndef INCLUDE_kyut_watermark_OperandSwappingWatermarker_hpp
#define INCLUDE_kyut_watermark_OperandSwappingWatermarker_hpp
#include <wasm.h>
namespace
kyut
{
class
BitStreamWriter
;
class
CircularBitStreamReader
;
}
// namespace kyut
namespace
kyut
::
watermarker
{
/**
* @brief Embed watermarks by operand swapping.
*
* @param module A reference to the WebAssembly module in which watermarks will be embedded.
* @param stream Input stream containing watermarks to embed.
* @return Number of watermark bits embedded in the module.
*/
std
::
size_t
embedOperandSwapping
(
wasm
::
Module
&
module
,
CircularBitStreamReader
&
stream
);
/**
* @brief Extract watermarks by operand swapping.
*
* @param module A reference to the WebAssembly module with embedded watermarks.
* @param stream Output stream to save the watermarks.
* @return Number of watermark bits extracted from the module.
*/
std
::
size_t
extractOperandSwapping
(
wasm
::
Module
&
module
,
BitStreamWriter
&
stream
);
}
// namespace kyut::watermarker
#endif // INCLUDE_kyut_watermark_OperandSwappingWatermarker_hpp
test/CMakeLists.txt
View file @
95667ed1
...
@@ -3,6 +3,7 @@ add_executable(test_kyut
...
@@ -3,6 +3,7 @@ add_executable(test_kyut
kyut/test_CircularBitStreamReader.cpp
kyut/test_CircularBitStreamReader.cpp
kyut/test_BitStreamWriter.cpp
kyut/test_BitStreamWriter.cpp
kyut/watermarker/test_FunctionOrderingWatermarker.cpp
kyut/watermarker/test_FunctionOrderingWatermarker.cpp
kyut/watermarker/test_OperandSwappingWatermarker.cpp
)
)
target_compile_definitions
(
test_kyut
target_compile_definitions
(
test_kyut
...
...
test/kyut/watermarker/test_OperandSwappingWatermarker.cpp
0 → 100644
View file @
95667ed1
#include <kyut/watermarker/OperandSwappingWatermarker.hpp>
#include <boost/test/unit_test.hpp>
#include <wasm-io.h>
#include <kyut/BitStreamWriter.hpp>
#include <kyut/CircularBitStreamReader.hpp>
#ifndef KYUT_TEST_SOURCE_DIR
#define KYUT_TEST_SOURCE_DIR "."
#endif
BOOST_AUTO_TEST_SUITE
(
kyut
)
BOOST_AUTO_TEST_SUITE
(
watermarker
)
BOOST_AUTO_TEST_CASE
(
embed_operand_swapping
)
{
wasm
::
Module
module
;
wasm
::
ModuleReader
{}.
read
(
KYUT_TEST_SOURCE_DIR
"/example/test2.wast"
,
module
);
BOOST_REQUIRE_EQUAL
(
module
.
functions
.
size
(),
std
::
size_t
{
3
});
BOOST_REQUIRE_EQUAL
(
module
.
functions
[
0
]
->
name
,
"f1"
);
BOOST_REQUIRE_EQUAL
(
module
.
functions
[
1
]
->
name
,
"f2"
);
BOOST_REQUIRE_EQUAL
(
module
.
functions
[
2
]
->
name
,
"f3"
);
// Embed 0b0000'00
{
CircularBitStreamReader
s
{{
0
b0000
'
0000
}};
const
auto
numBitsEmbedded
=
embedOperandSwapping
(
module
,
s
);
BOOST_REQUIRE_EQUAL
(
numBitsEmbedded
,
std
::
size_t
{
6
});
BOOST_REQUIRE_EQUAL
(
module
.
functions
.
size
(),
std
::
size_t
{
3
});
BOOST_REQUIRE_EQUAL
(
module
.
functions
[
0
]
->
name
,
"f1"
);
BOOST_REQUIRE_EQUAL
(
module
.
functions
[
1
]
->
name
,
"f2"
);
BOOST_REQUIRE_EQUAL
(
module
.
functions
[
2
]
->
name
,
"f3"
);
// f1
{
const
auto
bin
=
module
.
functions
[
0
]
->
body
->
cast
<
wasm
::
Binary
>
();
BOOST_REQUIRE_EQUAL
(
bin
->
left
->
cast
<
wasm
::
Const
>
()
->
value
.
geti32
(),
1
);
BOOST_REQUIRE_EQUAL
(
bin
->
right
->
cast
<
wasm
::
Const
>
()
->
value
.
geti32
(),
2
);
}
}
}
BOOST_AUTO_TEST_SUITE_END
()
BOOST_AUTO_TEST_SUITE_END
()
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