test_sodium.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MPL-2.0 */
2 
3 #include "testutil.hpp"
4 #include "testutil_unity.hpp"
5 
6 void setUp ()
7 {
8 }
9 
10 void tearDown ()
11 {
12 }
13 
14 // There is no way to test for correctness because of the embedded RNG.
16 {
17  errno = 0;
18  char public_key[41] = {0};
19  char secret_key[41] = {0};
20 
21  const int rc = zmq_curve_keypair (public_key, secret_key);
22 
23 #if defined(ZMQ_HAVE_CURVE)
25 #else
27 #endif
28 }
29 
31 {
32  // These are paired according to hintjens.com/blog:45
33  static const char public_key[] = "Yne@$w-vo<fVvi]a<NY6T1ed:M$fCG*[IaLV{hID";
34  static const char secret_key[] = "D:)Q[IlAW!ahhC2ac:9*A}h:p?([4%wOTJ%JR%cs";
35 
36  errno = 0;
37  char out_public[41] = {0};
38 
39  const int rc = zmq_curve_public (out_public, secret_key);
40 
41 #if defined(ZMQ_HAVE_CURVE)
43  TEST_ASSERT_EQUAL_STRING (public_key, out_public);
44 #else
46  (void) public_key;
47 #endif
48 }
49 
50 // The key length must be evenly divisible by 5 or must fail with EINVAL.
51 void test__zmq_curve_public__invalid__failure (const char *secret_)
52 {
53  errno = 0;
54  char out_public[41] = {0};
55 
56  const int rc = zmq_curve_public (out_public, secret_);
57 
58 #if defined(ZMQ_HAVE_CURVE)
60  TEST_ASSERT_EQUAL_STRING ("", out_public);
61 #else
63 #endif
64 }
65 
67 {
69 }
70 
72 {
74  "0123456789012345678901234567890123456789.");
75 }
76 
77 int main ()
78 {
79  UNITY_BEGIN ();
81 
85 
86  return UNITY_END ();
87 }
TEST_ASSERT_EQUAL_STRING
#define TEST_ASSERT_EQUAL_STRING(expected, actual)
Definition: unity.h:235
ENOTSUP
#define ENOTSUP
Definition: zmq.h:104
UNITY_END
return UNITY_END()
EINVAL
#define EINVAL
Definition: errno.hpp:25
RUN_TEST
#define RUN_TEST(func)
Definition: unity_internals.h:615
errno
int errno
test__zmq_curve_keypair__always__success
void test__zmq_curve_keypair__always__success(void)
Definition: test_sodium.cpp:15
main
int main()
Definition: test_sodium.cpp:77
tearDown
void tearDown()
Definition: test_sodium.cpp:10
zmq_curve_public
ZMQ_EXPORT int zmq_curve_public(char *z85_public_key_, const char *z85_secret_key_)
Definition: zmq_utils.cpp:222
test__zmq_curve_public__valid__success
void test__zmq_curve_public__valid__success()
Definition: test_sodium.cpp:30
testutil_unity.hpp
testutil.hpp
test__zmq_curve_public__invalid__failure
void test__zmq_curve_public__invalid__failure(const char *secret_)
Definition: test_sodium.cpp:51
setUp
void setUp()
Definition: test_sodium.cpp:6
void
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
test__zmq_curve_public__invalid__failure_short
void test__zmq_curve_public__invalid__failure_short()
Definition: test_sodium.cpp:66
zmq_curve_keypair
ZMQ_EXPORT int zmq_curve_keypair(char *z85_public_key_, char *z85_secret_key_)
Definition: zmq_utils.cpp:190
UNITY_BEGIN
UNITY_BEGIN()
TEST_ASSERT_FAILURE_ERRNO
#define TEST_ASSERT_FAILURE_ERRNO(error_code, expr)
Definition: testutil_unity.hpp:95
test__zmq_curve_public__invalid__failure_long
void test__zmq_curve_public__invalid__failure_long()
Definition: test_sodium.cpp:71
TEST_ASSERT_SUCCESS_ERRNO
#define TEST_ASSERT_SUCCESS_ERRNO(expr)
Definition: proxy_thr.cpp:47


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:59