1 // Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include <openssl/cipher.h>
16
17 #include <string.h>
18
19 #include <openssl/nid.h>
20
21 #include "../fipsmodule/cipher/internal.h"
22 #include "../internal.h"
23
24
null_init_key(EVP_CIPHER_CTX * ctx,const uint8_t * key,const uint8_t * iv,int enc)25 static int null_init_key(EVP_CIPHER_CTX *ctx, const uint8_t *key,
26 const uint8_t *iv, int enc) {
27 return 1;
28 }
29
null_cipher(EVP_CIPHER_CTX * ctx,uint8_t * out,const uint8_t * in,size_t in_len)30 static int null_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in,
31 size_t in_len) {
32 if (in != out) {
33 OPENSSL_memcpy(out, in, in_len);
34 }
35 return 1;
36 }
37
38 static const EVP_CIPHER n_cipher = {
39 /*nid=*/NID_undef,
40 /*block_size=*/1,
41 /*key_len=*/0,
42 /*iv_len=*/0,
43 /*ctx_size=*/0,
44 /*flags=*/0,
45 /*init=*/null_init_key,
46 /*cipher=*/null_cipher,
47 /*cleanup=*/nullptr,
48 /*ctrl=*/nullptr,
49 };
50
EVP_enc_null(void)51 const EVP_CIPHER *EVP_enc_null(void) { return &n_cipher; }
52