Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
dc1f5e9f
Commit
dc1f5e9f
authored
Sep 15, 2013
by
Laurent Alebarde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify test_security_curve.cpp with zmq_z85_encode
parent
d76f3f7c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
34 deletions
+1
-34
test_security_curve.cpp
tests/test_security_curve.cpp
+1
-34
No files found.
tests/test_security_curve.cpp
View file @
dc1f5e9f
...
...
@@ -30,39 +30,6 @@ static char server_secret [] = "JTKVSB%%)wK0E.X)V>+}o?pNmC{O&4W4b!Ni{Lh6";
// size * 5 / 4 bytes long plus 1 byte for the null terminator. Returns
// dest. Size must be a multiple of 4.
// Maps base 256 to base 85
static
char
encoder
[
85
+
1
]
=
{
"0123456789"
"abcdefghij"
"klmnopqrst"
"uvwxyzABCD"
"EFGHIJKLMN"
"OPQRSTUVWX"
"YZ.-:+=^!/"
"*?&<>()[]{"
"}@%$#"
};
static
char
*
Z85_encode
(
char
*
dest
,
uint8_t
*
data
,
size_t
size
)
{
assert
(
size
%
4
==
0
);
unsigned
int
char_nbr
=
0
;
unsigned
int
byte_nbr
=
0
;
uint32_t
value
=
0
;
while
(
byte_nbr
<
size
)
{
// Accumulate value in base 256 (binary)
value
=
value
*
256
+
data
[
byte_nbr
++
];
if
(
byte_nbr
%
4
==
0
)
{
// Output value in base 85
unsigned
int
divisor
=
85
*
85
*
85
*
85
;
while
(
divisor
)
{
dest
[
char_nbr
++
]
=
encoder
[
value
/
divisor
%
85
];
divisor
/=
85
;
}
value
=
0
;
}
}
assert
(
char_nbr
==
size
*
5
/
4
);
dest
[
char_nbr
]
=
0
;
return
dest
;
}
static
void
zap_handler
(
void
*
ctx
)
{
// Create and bind ZAP socket
...
...
@@ -87,7 +54,7 @@ static void zap_handler (void *ctx)
assert
(
size
==
32
);
char
client_key_text
[
41
];
Z
85_encode
(
client_key_text
,
client_key
,
32
);
zmq_z
85_encode
(
client_key_text
,
client_key
,
32
);
assert
(
streq
(
version
,
"1.0"
));
assert
(
streq
(
mechanism
,
"CURVE"
));
...
...
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