Skip to content

Commit bd3ee57

Browse files
wafuwafu13maddeleinelrstewart
authored
tests: improve coverage for s2n_stream_cipher_null (#5268)
Co-authored-by: maddeleine <59030281+maddeleine@users.noreply.github.com> Co-authored-by: Lindsay Stewart <slindsay@amazon.com>
1 parent 222bed2 commit bd3ee57

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

tests/unit/s2n_stream_cipher_null_test.c

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ int main(int argc, char **argv)
3030
EXPECT_SUCCESS(s2n_blob_init(&in, array, 9));
3131
struct s2n_blob out = { 0 };
3232
EXPECT_SUCCESS(s2n_blob_init(&out, array, 9));
33-
EXPECT_SUCCESS(s2n_stream_cipher_null_endecrypt(NULL, &in, &out));
33+
struct s2n_session_key session_key = { 0 };
34+
EXPECT_SUCCESS(s2n_stream_cipher_null_endecrypt(&session_key, &in, &out));
3435
};
3536

3637
/* Test that in size > out size fails */
@@ -40,7 +41,8 @@ int main(int argc, char **argv)
4041
EXPECT_SUCCESS(s2n_blob_init(&in, array, 9));
4142
struct s2n_blob out = { 0 };
4243
EXPECT_SUCCESS(s2n_blob_init(&out, array, 8));
43-
EXPECT_FAILURE(s2n_stream_cipher_null_endecrypt(NULL, &in, &out));
44+
struct s2n_session_key session_key = { 0 };
45+
EXPECT_FAILURE(s2n_stream_cipher_null_endecrypt(&session_key, &in, &out));
4446
};
4547

4648
/* Test that in is copied to out when they are different */
@@ -52,9 +54,34 @@ int main(int argc, char **argv)
5254
struct s2n_blob out = { 0 };
5355
EXPECT_SUCCESS(s2n_blob_init(&out, out_array, 9));
5456
EXPECT_BYTEARRAY_NOT_EQUAL(in_array, out_array, out.size);
55-
EXPECT_SUCCESS(s2n_stream_cipher_null_endecrypt(NULL, &in, &out));
57+
struct s2n_session_key session_key = { 0 };
58+
EXPECT_SUCCESS(s2n_stream_cipher_null_endecrypt(&session_key, &in, &out));
5659
EXPECT_BYTEARRAY_EQUAL(in_array, out_array, out.size);
5760
};
5861

62+
/* Test that null cipher is always available */
63+
{
64+
EXPECT_TRUE(s2n_stream_cipher_null_available());
65+
};
66+
67+
/* Test that get_key always returns success */
68+
{
69+
struct s2n_blob in = { 0 };
70+
struct s2n_session_key session_key = { 0 };
71+
EXPECT_OK(s2n_stream_cipher_null_get_key(&session_key, &in));
72+
};
73+
74+
/* Test that destroy_key always returns success */
75+
{
76+
struct s2n_session_key session_key = { 0 };
77+
EXPECT_OK(s2n_stream_cipher_null_destroy_key(&session_key));
78+
};
79+
80+
/* Test that init always returns success */
81+
{
82+
struct s2n_session_key session_key = { 0 };
83+
EXPECT_OK(s2n_stream_cipher_null_init(&session_key));
84+
};
85+
5986
END_TEST();
6087
}

0 commit comments

Comments
 (0)