Debian Codegraph @

crt/s2n/crypto/s2n_stream_cipher_null.c

raw symbols SCIP
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 {
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 };