e_null.c revision 109998
179543Sru/* crypto/evp/e_null.c */
2151497Sru/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3151497Sru * All rights reserved.
469626Sru *
5151497Sru * This package is an SSL implementation written
6151497Sru * by Eric Young (eay@cryptsoft.com).
7151497Sru * The implementation was written so as to conform with Netscapes SSL.
869626Sru *
969626Sru * This library is free for commercial and non-commercial use as long as
1069626Sru * the following conditions are aheared to.  The following conditions
1169626Sru * apply to all code found in this distribution, be it the RC4, RSA,
1269626Sru * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
1369626Sru * included with this distribution is covered by the same copyright terms
1469626Sru * except that the holder is Tim Hudson (tjh@cryptsoft.com).
1569626Sru *
1669626Sru * Copyright remains Eric Young's, and as such any Copyright notices in
1769626Sru * the code are not to be removed.
1869626Sru * If this package is used in a product, Eric Young should be given attribution
1969626Sru * as the author of the parts of the library used.
20114402Sru * This can be in the form of a textual message at program startup or
2169626Sru * in documentation (online or textual) provided with the package.
22114402Sru *
23114402Sru * Redistribution and use in source and binary forms, with or without
24114402Sru * modification, are permitted provided that the following conditions
2569626Sru * are met:
26114402Sru * 1. Redistributions of source code must retain the copyright
27114402Sru *    notice, this list of conditions and the following disclaimer.
2855839Sasmodai * 2. Redistributions in binary form must reproduce the above copyright
2955839Sasmodai *    notice, this list of conditions and the following disclaimer in the
30114402Sru *    documentation and/or other materials provided with the distribution.
31114402Sru * 3. All advertising materials mentioning features or use of this software
32114402Sru *    must display the following acknowledgement:
3355839Sasmodai *    "This product includes cryptographic software written by
3455839Sasmodai *     Eric Young (eay@cryptsoft.com)"
3569626Sru *    The word 'cryptographic' can be left out if the rouines from the library
3669626Sru *    being used are not cryptographic related :-).
37114402Sru * 4. If you include any Windows specific code (or a derivative thereof) from
38114402Sru *    the apps directory (application code) you must include an acknowledgement:
39114402Sru *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
4055839Sasmodai *
4169626Sru * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
4255839Sasmodai * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4375584Sru * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4455839Sasmodai * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45104862Sru * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4655839Sasmodai * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4755839Sasmodai * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48104862Sru * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4955839Sasmodai * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5075584Sru * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5175584Sru * SUCH DAMAGE.
5275584Sru *
5375584Sru * The licence and distribution terms for any publically available version or
54104862Sru * derivative of this code cannot be changed.  i.e. this code cannot simply be
5575584Sru * copied and put under another distribution licence
5675584Sru * [including the GNU Public Licence.]
57104862Sru */
5875584Sru
5955839Sasmodai#include <stdio.h>
60114402Sru#include "cryptlib.h"
61114402Sru#include <openssl/evp.h>
62114402Sru#include <openssl/objects.h>
6355839Sasmodai
6455839Sasmodaistatic int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
6575584Sru	const unsigned char *iv,int enc);
6675584Srustatic int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
67151497Sru	const unsigned char *in, unsigned int inl);
68151497Srustatic const EVP_CIPHER n_cipher=
69151497Sru	{
7055839Sasmodai	NID_undef,
7175584Sru	1,0,0,
72151497Sru	0,
7355839Sasmodai	null_init_key,
7455839Sasmodai	null_cipher,
7569626Sru	NULL,
76114402Sru	0,
77114402Sru	NULL,
78114402Sru	NULL,
7969626Sru	NULL
8069626Sru	};
8169626Sru
8269626Sruconst EVP_CIPHER *EVP_enc_null(void)
83151497Sru	{
84151497Sru	return(&n_cipher);
85114402Sru	}
8655839Sasmodai
8775584Srustatic int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
88151497Sru	     const unsigned char *iv, int enc)
89151497Sru	{
90151497Sru	/*	memset(&(ctx->c),0,sizeof(ctx->c));*/
9175584Sru	return 1;
9275584Sru	}
9375584Sru
94114402Srustatic int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
9575584Sru	     const unsigned char *in, unsigned int inl)
9669626Sru	{
9769626Sru	if (in != out)
9869626Sru		memcpy((char *)out,(char *)in,(int)inl);
99114402Sru	return 1;
10069626Sru	}
10169626Sru
10269626Sru