aes_ecb.c revision 295016
1140074Spjd/* crypto/aes/aes_ecb.c */
2141993Spjd/* ====================================================================
3140074Spjd * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.
4140074Spjd *
5140074Spjd * Redistribution and use in source and binary forms, with or without
6140074Spjd * modification, are permitted provided that the following conditions
7140074Spjd * are met:
8140074Spjd *
9140074Spjd * 1. Redistributions of source code must retain the above copyright
10140074Spjd *    notice, this list of conditions and the following disclaimer.
11140074Spjd *
12140074Spjd * 2. Redistributions in binary form must reproduce the above copyright
13155174Spjd *    notice, this list of conditions and the following disclaimer in
14140074Spjd *    the documentation and/or other materials provided with the
15140074Spjd *    distribution.
16140074Spjd *
17140074Spjd * 3. All advertising materials mentioning features or use of this
18140074Spjd *    software must display the following acknowledgment:
19140074Spjd *    "This product includes software developed by the OpenSSL Project
20140074Spjd *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21140074Spjd *
22140074Spjd * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23140074Spjd *    endorse or promote products derived from this software without
24140074Spjd *    prior written permission. For written permission, please contact
25140074Spjd *    openssl-core@openssl.org.
26140074Spjd *
27140074Spjd * 5. Products derived from this software may not be called "OpenSSL"
28140074Spjd *    nor may "OpenSSL" appear in their names without prior written
29140074Spjd *    permission of the OpenSSL Project.
30140074Spjd *
31140074Spjd * 6. Redistributions of any form whatsoever must retain the following
32140074Spjd *    acknowledgment:
33140074Spjd *    "This product includes software developed by the OpenSSL Project
34140074Spjd *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35140074Spjd *
36140074Spjd * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37223921Sae * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38140074Spjd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39140074Spjd * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
40140074Spjd * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41140074Spjd * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42140074Spjd * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43140074Spjd * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44219029Snetchild * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45140074Spjd * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46151897Srwatson * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47140074Spjd * OF THE POSSIBILITY OF SUCH DAMAGE.
48140074Spjd * ====================================================================
49140074Spjd *
50140074Spjd */
51140074Spjd
52140074Spjd#ifndef AES_DEBUG
53140074Spjd# ifndef NDEBUG
54140074Spjd#  define NDEBUG
55140074Spjd# endif
56140074Spjd#endif
57140074Spjd#include <assert.h>
58140074Spjd
59140074Spjd#include <openssl/aes.h>
60140074Spjd#include "aes_locl.h"
61140074Spjd
62140074Spjdvoid AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
63140074Spjd                     const AES_KEY *key, const int enc)
64140074Spjd{
65140074Spjd
66140074Spjd    assert(in && out && key);
67140074Spjd    assert((AES_ENCRYPT == enc) || (AES_DECRYPT == enc));
68140074Spjd
69140074Spjd    if (AES_ENCRYPT == enc)
70140074Spjd        AES_encrypt(in, out, key);
71227309Sed    else
72227309Sed        AES_decrypt(in, out, key);
73140074Spjd}
74140074Spjd