e_null.c revision 225736
1223013Sdim/* crypto/evp/e_null.c */
2223013Sdim/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3223013Sdim * All rights reserved.
4223013Sdim *
5223013Sdim * This package is an SSL implementation written
6223013Sdim * by Eric Young (eay@cryptsoft.com).
7223013Sdim * The implementation was written so as to conform with Netscapes SSL.
8223013Sdim *
9223013Sdim * This library is free for commercial and non-commercial use as long as
10223013Sdim * the following conditions are aheared to.  The following conditions
11223013Sdim * apply to all code found in this distribution, be it the RC4, RSA,
12223013Sdim * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13223013Sdim * included with this distribution is covered by the same copyright terms
14223013Sdim * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15223013Sdim *
16249423Sdim * Copyright remains Eric Young's, and as such any Copyright notices in
17226633Sdim * the code are not to be removed.
18226633Sdim * If this package is used in a product, Eric Young should be given attribution
19223013Sdim * as the author of the parts of the library used.
20223013Sdim * This can be in the form of a textual message at program startup or
21223013Sdim * in documentation (online or textual) provided with the package.
22223013Sdim *
23223013Sdim * Redistribution and use in source and binary forms, with or without
24223013Sdim * modification, are permitted provided that the following conditions
25223013Sdim * are met:
26223013Sdim * 1. Redistributions of source code must retain the copyright
27223013Sdim *    notice, this list of conditions and the following disclaimer.
28223013Sdim * 2. Redistributions in binary form must reproduce the above copyright
29223013Sdim *    notice, this list of conditions and the following disclaimer in the
30263508Sdim *    documentation and/or other materials provided with the distribution.
31263508Sdim * 3. All advertising materials mentioning features or use of this software
32243830Sdim *    must display the following acknowledgement:
33223013Sdim *    "This product includes cryptographic software written by
34223013Sdim *     Eric Young (eay@cryptsoft.com)"
35223013Sdim *    The word 'cryptographic' can be left out if the rouines from the library
36223013Sdim *    being used are not cryptographic related :-).
37223013Sdim * 4. If you include any Windows specific code (or a derivative thereof) from
38263508Sdim *    the apps directory (application code) you must include an acknowledgement:
39263508Sdim *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40223013Sdim *
41243830Sdim * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42243830Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43223013Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44243830Sdim * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45243830Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46223013Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47223013Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48223013Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49223013Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50223013Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51223013Sdim * SUCH DAMAGE.
52223013Sdim *
53223013Sdim * The licence and distribution terms for any publically available version or
54263508Sdim * derivative of this code cannot be changed.  i.e. this code cannot simply be
55263508Sdim * copied and put under another distribution licence
56223013Sdim * [including the GNU Public Licence.]
57243830Sdim */
58243830Sdim
59223013Sdim#include <stdio.h>
60243830Sdim#include "cryptlib.h"
61243830Sdim#include <openssl/evp.h>
62223013Sdim#include <openssl/objects.h>
63223013Sdim
64223013Sdimstatic int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
65223013Sdim	const unsigned char *iv,int enc);
66223013Sdimstatic int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
67223013Sdim	const unsigned char *in, unsigned int inl);
68223013Sdimstatic const EVP_CIPHER n_cipher=
69223013Sdim	{
70223013Sdim	NID_undef,
71223013Sdim	1,0,0,
72243830Sdim	EVP_CIPH_FLAG_FIPS,
73223013Sdim	null_init_key,
74263508Sdim	null_cipher,
75263508Sdim	NULL,
76223013Sdim	0,
77243830Sdim	NULL,
78243830Sdim	NULL,
79223013Sdim	NULL,
80243830Sdim	NULL
81243830Sdim	};
82223013Sdim
83243830Sdimconst EVP_CIPHER *EVP_enc_null(void)
84243830Sdim	{
85243830Sdim	return(&n_cipher);
86223013Sdim	}
87223013Sdim
88223013Sdimstatic int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
89223013Sdim	     const unsigned char *iv, int enc)
90223013Sdim	{
91263508Sdim	/*	memset(&(ctx->c),0,sizeof(ctx->c));*/
92263508Sdim	return 1;
93263508Sdim	}
94223013Sdim
95243830Sdimstatic int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
96243830Sdim	     const unsigned char *in, unsigned int inl)
97223013Sdim	{
98223013Sdim	if (in != out)
99223013Sdim		memcpy((char *)out,(const char *)in,(size_t)inl);
100223013Sdim	return 1;
101223013Sdim	}
102223013Sdim
103223013Sdim