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
d6dc6169
Commit
d6dc6169
authored
Jul 19, 2019
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display number of bits embedded or extracted
parent
49bcfa57
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
15 deletions
+15
-15
CircularBitStreamReader.hpp
src/kyut/CircularBitStreamReader.hpp
+2
-4
pisn.cpp
src/pisn.cpp
+4
-4
snpi.cpp
src/snpi.cpp
+2
-0
test_CircularBitStreamReader.cpp
test/kyut/test_CircularBitStreamReader.cpp
+7
-7
No files found.
src/kyut/CircularBitStreamReader.hpp
View file @
d6dc6169
...
@@ -44,10 +44,8 @@ namespace kyut {
...
@@ -44,10 +44,8 @@ namespace kyut {
return
false
;
return
false
;
}
}
const
auto
pos
=
pos_read_
;
const
auto
pos
=
pos_read_
++
;
pos_read_
=
(
pos_read_
+
1
)
%
(
data_
.
size
()
*
8
);
return
((
data_
[
pos
/
8
%
data_
.
size
()]
<<
(
pos
%
8
))
&
0x80
)
!=
0
;
return
((
data_
[
pos
/
8
]
<<
(
pos
%
8
))
&
0x80
)
!=
0
;
}
}
std
::
uint64_t
read
(
std
::
size_t
countBits
)
{
std
::
uint64_t
read
(
std
::
size_t
countBits
)
{
...
...
src/pisn.cpp
View file @
d6dc6169
...
@@ -24,18 +24,18 @@ int main(int argc, char *argv[]) {
...
@@ -24,18 +24,18 @@ int main(int argc, char *argv[]) {
// Embed watermarks
// Embed watermarks
kyut
::
BitStreamWriter
stream
;
kyut
::
BitStreamWriter
stream
;
std
::
size_t
numBits
;
if
(
method
==
"opswap"
)
{
if
(
method
==
"opswap"
)
{
numBits
=
kyut
::
watermarker
::
extractOperandSwapping
(
module
,
stream
);
kyut
::
watermarker
::
extractOperandSwapping
(
module
,
stream
);
}
else
if
(
method
==
"funcord"
)
{
}
else
if
(
method
==
"funcord"
)
{
numBits
=
kyut
::
watermarker
::
extractFunctionOrdering
(
module
,
stream
,
10
);
kyut
::
watermarker
::
extractFunctionOrdering
(
module
,
stream
,
10
);
}
else
{
}
else
{
throw
std
::
runtime_error
{
fmt
::
format
(
"unknown embedding method: {}"
,
method
)};
throw
std
::
runtime_error
{
fmt
::
format
(
"unknown embedding method: {}"
,
method
)};
}
}
// Output watermarks extracted
// Output watermarks extracted
std
::
cout
<<
stream
.
dataAsString
();
fmt
::
print
(
"{}"
,
stream
.
dataAsString
());
fmt
::
print
(
std
::
cerr
,
"{} bits extracted
\n
"
,
stream
.
tell
());
}
catch
(
const
wasm
::
ParseException
&
e
)
{
}
catch
(
const
wasm
::
ParseException
&
e
)
{
e
.
dump
(
std
::
cerr
);
e
.
dump
(
std
::
cerr
);
...
...
src/snpi.cpp
View file @
d6dc6169
...
@@ -36,6 +36,8 @@ int main(int argc, char *argv[]) {
...
@@ -36,6 +36,8 @@ int main(int argc, char *argv[]) {
// Output the result
// Output the result
wasm
::
ModuleWriter
{}.
writeText
(
module
,
""
);
wasm
::
ModuleWriter
{}.
writeText
(
module
,
""
);
fmt
::
print
(
std
::
cerr
,
"{} bits embedded
\n
"
,
stream
->
tell
());
}
catch
(
const
wasm
::
ParseException
&
e
)
{
}
catch
(
const
wasm
::
ParseException
&
e
)
{
e
.
dump
(
std
::
cerr
);
e
.
dump
(
std
::
cerr
);
...
...
test/kyut/test_CircularBitStreamReader.cpp
View file @
d6dc6169
...
@@ -27,15 +27,15 @@ BOOST_AUTO_TEST_CASE(read_bit) {
...
@@ -27,15 +27,15 @@ BOOST_AUTO_TEST_CASE(read_bit) {
BOOST_REQUIRE_EQUAL
(
reader
.
tell
(),
std
::
size_t
{
7
});
BOOST_REQUIRE_EQUAL
(
reader
.
tell
(),
std
::
size_t
{
7
});
BOOST_REQUIRE_EQUAL
(
reader
.
readBit
(),
true
);
BOOST_REQUIRE_EQUAL
(
reader
.
readBit
(),
true
);
BOOST_REQUIRE_EQUAL
(
reader
.
tell
(),
std
::
size_t
{
0
});
BOOST_REQUIRE_EQUAL
(
reader
.
tell
(),
std
::
size_t
{
8
});
BOOST_REQUIRE_EQUAL
(
reader
.
readBit
(),
true
);
BOOST_REQUIRE_EQUAL
(
reader
.
readBit
(),
true
);
BOOST_REQUIRE_EQUAL
(
reader
.
tell
(),
std
::
size_t
{
1
});
BOOST_REQUIRE_EQUAL
(
reader
.
tell
(),
std
::
size_t
{
9
});
BOOST_REQUIRE_EQUAL
(
reader
.
readBit
(),
false
);
BOOST_REQUIRE_EQUAL
(
reader
.
readBit
(),
false
);
BOOST_REQUIRE_EQUAL
(
reader
.
tell
(),
std
::
size_t
{
2
});
BOOST_REQUIRE_EQUAL
(
reader
.
tell
(),
std
::
size_t
{
10
});
BOOST_REQUIRE_EQUAL
(
reader
.
readBit
(),
false
);
BOOST_REQUIRE_EQUAL
(
reader
.
readBit
(),
false
);
BOOST_REQUIRE_EQUAL
(
reader
.
tell
(),
std
::
size_t
{
3
});
BOOST_REQUIRE_EQUAL
(
reader
.
tell
(),
std
::
size_t
{
11
});
BOOST_REQUIRE_EQUAL
(
reader
.
readBit
(),
false
);
BOOST_REQUIRE_EQUAL
(
reader
.
readBit
(),
false
);
BOOST_REQUIRE_EQUAL
(
reader
.
tell
(),
std
::
size_t
{
4
});
BOOST_REQUIRE_EQUAL
(
reader
.
tell
(),
std
::
size_t
{
12
});
}
}
BOOST_AUTO_TEST_CASE
(
read
)
{
BOOST_AUTO_TEST_CASE
(
read
)
{
...
@@ -53,10 +53,10 @@ BOOST_AUTO_TEST_CASE(read) {
...
@@ -53,10 +53,10 @@ BOOST_AUTO_TEST_CASE(read) {
BOOST_REQUIRE_EQUAL
(
reader
.
tell
(),
std
::
size_t
{
16
});
BOOST_REQUIRE_EQUAL
(
reader
.
tell
(),
std
::
size_t
{
16
});
BOOST_REQUIRE_EQUAL
(
reader
.
read
(
16
),
std
::
uint64_t
{
0xcdef
});
BOOST_REQUIRE_EQUAL
(
reader
.
read
(
16
),
std
::
uint64_t
{
0xcdef
});
BOOST_REQUIRE_EQUAL
(
reader
.
tell
(),
std
::
size_t
{
0
});
BOOST_REQUIRE_EQUAL
(
reader
.
tell
(),
std
::
size_t
{
32
});
BOOST_REQUIRE_EQUAL
(
reader
.
read
(
24
),
std
::
uint64_t
{
0x89abcd
});
BOOST_REQUIRE_EQUAL
(
reader
.
read
(
24
),
std
::
uint64_t
{
0x89abcd
});
BOOST_REQUIRE_EQUAL
(
reader
.
tell
(),
std
::
size_t
{
24
});
BOOST_REQUIRE_EQUAL
(
reader
.
tell
(),
std
::
size_t
{
56
});
}
}
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