| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#include "crypto/s2n_cipher.h" |
| 17 |
#include "error/s2n_errno.h" |
| 18 |
#include "utils/s2n_blob.h" |
| 19 |
#include "utils/s2n_safety.h" |
| 20 |
|
| 21 |
static bool s2n_stream_cipher_null_available(void) |
| 22 |
{ |
| 23 |
return true; |
| 24 |
} |
| 25 |
|
| 26 |
static int s2n_stream_cipher_null_endecrypt(struct s2n_session_key *key, struct s2n_blob *in, struct s2n_blob *out) |
| 27 |
{ |
| 28 |
S2N_ERROR_IF(out->size < in->size, S2N_ERR_SIZE_MISMATCH); |
| 29 |
|
| 30 |
if (in->data != out->data) { |
| 31 |
POSIX_CHECKED_MEMCPY(out->data, in->data, out->size); |
| 32 |
} |
| 33 |
return 0; |
| 34 |
} |
| 35 |
|
| 36 |
static S2N_RESULT s2n_stream_cipher_null_get_key(struct s2n_session_key *key, struct s2n_blob *in) |
| 37 |
{ |
| 38 |
return S2N_RESULT_OK; |
| 39 |
} |
| 40 |
|
| 41 |
static S2N_RESULT s2n_stream_cipher_null_destroy_key(struct s2n_session_key *key) |
| 42 |
{ |
| 43 |
return S2N_RESULT_OK; |
| 44 |
} |
| 45 |
|
| 46 |
static S2N_RESULT s2n_stream_cipher_null_init(struct s2n_session_key *key) |
| 47 |
{ |
| 48 |
return S2N_RESULT_OK; |
| 49 |
} |
| 50 |
|
| 51 |
const struct s2n_cipher s2n_null_cipher = { |
| 52 |
.type = S2N_STREAM, |
| 53 |
.key_material_size = 0, |
| 54 |
.io.stream = { |
| 55 |
.decrypt = s2n_stream_cipher_null_endecrypt, |
| 56 |
.encrypt = s2n_stream_cipher_null_endecrypt }, |
| 57 |
.is_available = s2n_stream_cipher_null_available, |
| 58 |
.init = s2n_stream_cipher_null_init, |
| 59 |
.set_encryption_key = s2n_stream_cipher_null_get_key, |
| 60 |
.set_decryption_key = s2n_stream_cipher_null_get_key, |
| 61 |
.destroy_key = s2n_stream_cipher_null_destroy_key, |
| 62 |
}; |