| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#include "crypto/s2n_stream_cipher_null.c" |
| 17 |
|
| 18 |
#include "api/s2n.h" |
| 19 |
#include "s2n_test.h" |
| 20 |
|
| 21 |
int main(int argc, char **argv) |
| 22 |
{ |
| 23 |
BEGIN_TEST(); |
| 24 |
EXPECT_SUCCESS(s2n_disable_tls13_in_test()); |
| 25 |
|
| 26 |
|
| 27 |
{ |
| 28 |
uint8_t array[9] = { 0 }; |
| 29 |
struct s2n_blob in = { 0 }; |
| 30 |
EXPECT_SUCCESS(s2n_blob_init(&in, array, 9)); |
| 31 |
struct s2n_blob out = { 0 }; |
| 32 |
EXPECT_SUCCESS(s2n_blob_init(&out, array, 9)); |
| 33 |
struct s2n_session_key session_key = { 0 }; |
| 34 |
EXPECT_SUCCESS(s2n_stream_cipher_null_endecrypt(&session_key, &in, &out)); |
| 35 |
}; |
| 36 |
|
| 37 |
|
| 38 |
{ |
| 39 |
uint8_t array[9] = { 0 }; |
| 40 |
struct s2n_blob in = { 0 }; |
| 41 |
EXPECT_SUCCESS(s2n_blob_init(&in, array, 9)); |
| 42 |
struct s2n_blob out = { 0 }; |
| 43 |
EXPECT_SUCCESS(s2n_blob_init(&out, array, 8)); |
| 44 |
struct s2n_session_key session_key = { 0 }; |
| 45 |
EXPECT_FAILURE(s2n_stream_cipher_null_endecrypt(&session_key, &in, &out)); |
| 46 |
}; |
| 47 |
|
| 48 |
|
| 49 |
{ |
| 50 |
uint8_t in_array[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 51 |
uint8_t out_array[9] = { 0 }; |
| 52 |
struct s2n_blob in = { 0 }; |
| 53 |
EXPECT_SUCCESS(s2n_blob_init(&in, in_array, 9)); |
| 54 |
struct s2n_blob out = { 0 }; |
| 55 |
EXPECT_SUCCESS(s2n_blob_init(&out, out_array, 9)); |
| 56 |
EXPECT_BYTEARRAY_NOT_EQUAL(in_array, out_array, out.size); |
| 57 |
struct s2n_session_key session_key = { 0 }; |
| 58 |
EXPECT_SUCCESS(s2n_stream_cipher_null_endecrypt(&session_key, &in, &out)); |
| 59 |
EXPECT_BYTEARRAY_EQUAL(in_array, out_array, out.size); |
| 60 |
}; |
| 61 |
|
| 62 |
|
| 63 |
{ |
| 64 |
EXPECT_TRUE(s2n_stream_cipher_null_available()); |
| 65 |
}; |
| 66 |
|
| 67 |
|
| 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 |
|
| 75 |
{ |
| 76 |
struct s2n_session_key session_key = { 0 }; |
| 77 |
EXPECT_OK(s2n_stream_cipher_null_destroy_key(&session_key)); |
| 78 |
}; |
| 79 |
|
| 80 |
|
| 81 |
{ |
| 82 |
struct s2n_session_key session_key = { 0 }; |
| 83 |
EXPECT_OK(s2n_stream_cipher_null_init(&session_key)); |
| 84 |
}; |
| 85 |
|
| 86 |
END_TEST(); |
| 87 |
} |