Branch data Line data Source code
1 : : /* 2 : : * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 : : * 4 : : * Licensed under the Apache License, Version 2.0 (the "License"). 5 : : * You may not use this file except in compliance with the License. 6 : : * A copy of the License is located at 7 : : * 8 : : * http://aws.amazon.com/apache2.0 9 : : * 10 : : * or in the "license" file accompanying this file. This file is distributed 11 : : * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 : : * express or implied. See the License for the specific language governing 13 : : * permissions and limitations under the License. 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 : 0 : { 23 : 0 : return true; 24 : 0 : } 25 : : 26 : : static int s2n_stream_cipher_null_endecrypt(struct s2n_session_key *key, struct s2n_blob *in, struct s2n_blob *out) 27 : 127390 : { 28 [ - + ][ # # ]: 127390 : S2N_ERROR_IF(out->size < in->size, S2N_ERR_SIZE_MISMATCH); 29 : : 30 [ - + ]: 127390 : if (in->data != out->data) { 31 [ # # ][ # # ]: 0 : POSIX_CHECKED_MEMCPY(out->data, in->data, out->size); [ # # ] 32 : 0 : } 33 : 127390 : return 0; 34 : 127390 : } 35 : : 36 : : static S2N_RESULT s2n_stream_cipher_null_get_key(struct s2n_session_key *key, struct s2n_blob *in) 37 : 0 : { 38 : 0 : return S2N_RESULT_OK; 39 : 0 : } 40 : : 41 : : static S2N_RESULT s2n_stream_cipher_null_destroy_key(struct s2n_session_key *key) 42 : 4386 : { 43 : 4386 : return S2N_RESULT_OK; 44 : 4386 : } 45 : : 46 : : static S2N_RESULT s2n_stream_cipher_null_init(struct s2n_session_key *key) 47 : 0 : { 48 : 0 : return S2N_RESULT_OK; 49 : 0 : } 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 : : };