epoc32/include/stdapis/openssl/aes.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 0 061f57f2323e
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
/* crypto/aes/aes.h -*- mode:C; c-file-style: "eay" -*- */
williamr@2
     2
/* ====================================================================
williamr@2
     3
 * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.
williamr@2
     4
 *
williamr@2
     5
 * Redistribution and use in source and binary forms, with or without
williamr@2
     6
 * modification, are permitted provided that the following conditions
williamr@2
     7
 * are met:
williamr@2
     8
 *
williamr@2
     9
 * 1. Redistributions of source code must retain the above copyright
williamr@2
    10
 *    notice, this list of conditions and the following disclaimer. 
williamr@2
    11
 *
williamr@2
    12
 * 2. Redistributions in binary form must reproduce the above copyright
williamr@2
    13
 *    notice, this list of conditions and the following disclaimer in
williamr@2
    14
 *    the documentation and/or other materials provided with the
williamr@2
    15
 *    distribution.
williamr@2
    16
 *
williamr@2
    17
 * 3. All advertising materials mentioning features or use of this
williamr@2
    18
 *    software must display the following acknowledgment:
williamr@2
    19
 *    "This product includes software developed by the OpenSSL Project
williamr@2
    20
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
williamr@2
    21
 *
williamr@2
    22
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
williamr@2
    23
 *    endorse or promote products derived from this software without
williamr@2
    24
 *    prior written permission. For written permission, please contact
williamr@2
    25
 *    openssl-core@openssl.org.
williamr@2
    26
 *
williamr@2
    27
 * 5. Products derived from this software may not be called "OpenSSL"
williamr@2
    28
 *    nor may "OpenSSL" appear in their names without prior written
williamr@2
    29
 *    permission of the OpenSSL Project.
williamr@2
    30
 *
williamr@2
    31
 * 6. Redistributions of any form whatsoever must retain the following
williamr@2
    32
 *    acknowledgment:
williamr@2
    33
 *    "This product includes software developed by the OpenSSL Project
williamr@2
    34
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
williamr@2
    35
 *
williamr@2
    36
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
williamr@2
    37
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
williamr@2
    38
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
williamr@2
    39
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
williamr@2
    40
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
williamr@2
    41
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
williamr@2
    42
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
williamr@2
    43
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
williamr@2
    44
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
williamr@2
    45
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
williamr@2
    46
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
williamr@2
    47
 * OF THE POSSIBILITY OF SUCH DAMAGE.
williamr@2
    48
 * ====================================================================
williamr@2
    49
 *
williamr@2
    50
 */
williamr@2
    51
 /*
williamr@2
    52
 © Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
williamr@2
    53
 */
williamr@2
    54
williamr@2
    55
williamr@2
    56
#ifndef HEADER_AES_H
williamr@2
    57
#define HEADER_AES_H
williamr@2
    58
williamr@2
    59
#if (defined(__SYMBIAN32__) && !defined(SYMBIAN))
williamr@2
    60
#define SYMBIAN
williamr@2
    61
#endif
williamr@2
    62
williamr@2
    63
#include <openssl/opensslconf.h>
williamr@2
    64
#ifdef SYMBIAN
williamr@2
    65
#include <e32def.h>
williamr@2
    66
#endif
williamr@2
    67
#ifdef OPENSSL_NO_AES
williamr@2
    68
#error AES is disabled.
williamr@2
    69
#endif
williamr@2
    70
williamr@2
    71
#define AES_ENCRYPT	1
williamr@2
    72
#define AES_DECRYPT	0
williamr@2
    73
williamr@2
    74
/* Because array size can't be a const in C, the following two are macros.
williamr@2
    75
   Both sizes are in bytes. */
williamr@2
    76
#define AES_MAXNR 14
williamr@2
    77
#define AES_BLOCK_SIZE 16
williamr@2
    78
williamr@2
    79
#ifdef  __cplusplus
williamr@2
    80
extern "C" {
williamr@2
    81
#endif
williamr@2
    82
williamr@2
    83
/* This should be a hidden type, but EVP requires that the size be known */
williamr@2
    84
struct aes_key_st {
williamr@2
    85
#ifdef AES_LONG
williamr@2
    86
    unsigned long rd_key[4 *(AES_MAXNR + 1)];
williamr@2
    87
#else
williamr@2
    88
    unsigned int rd_key[4 *(AES_MAXNR + 1)];
williamr@2
    89
#endif
williamr@2
    90
    int rounds;
williamr@2
    91
};
williamr@2
    92
typedef struct aes_key_st AES_KEY;
williamr@2
    93
williamr@2
    94
williamr@2
    95
IMPORT_C const char *AES_options(void);
williamr@2
    96
williamr@2
    97
IMPORT_C int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
williamr@2
    98
	AES_KEY *key);
williamr@2
    99
IMPORT_C int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
williamr@2
   100
	AES_KEY *key);
williamr@2
   101
williamr@2
   102
IMPORT_C void AES_encrypt(const unsigned char *in, unsigned char *out,
williamr@2
   103
	const AES_KEY *key);
williamr@2
   104
IMPORT_C void AES_decrypt(const unsigned char *in, unsigned char *out,
williamr@2
   105
	const AES_KEY *key);
williamr@2
   106
williamr@2
   107
IMPORT_C void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
williamr@2
   108
	const AES_KEY *key, const int enc);
williamr@2
   109
IMPORT_C void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
williamr@2
   110
	const unsigned long length, const AES_KEY *key,
williamr@2
   111
	unsigned char *ivec, const int enc);
williamr@2
   112
IMPORT_C void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
williamr@2
   113
	const unsigned long length, const AES_KEY *key,
williamr@2
   114
	unsigned char *ivec, int *num, const int enc);
williamr@2
   115
IMPORT_C void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
williamr@2
   116
	const unsigned long length, const AES_KEY *key,
williamr@2
   117
	unsigned char *ivec, int *num, const int enc);
williamr@2
   118
IMPORT_C void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
williamr@2
   119
	const unsigned long length, const AES_KEY *key,
williamr@2
   120
	unsigned char *ivec, int *num, const int enc);
williamr@2
   121
IMPORT_C void AES_cfbr_encrypt_block(const unsigned char *in,unsigned char *out,
williamr@2
   122
			    const int nbits,const AES_KEY *key,
williamr@2
   123
			    unsigned char *ivec,const int enc);
williamr@2
   124
IMPORT_C void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
williamr@2
   125
	const unsigned long length, const AES_KEY *key,
williamr@2
   126
	unsigned char *ivec, int *num);
williamr@2
   127
IMPORT_C void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
williamr@2
   128
	const unsigned long length, const AES_KEY *key,
williamr@2
   129
	unsigned char ivec[AES_BLOCK_SIZE],
williamr@2
   130
	unsigned char ecount_buf[AES_BLOCK_SIZE],
williamr@2
   131
	unsigned int *num);
williamr@2
   132
williamr@2
   133
#ifdef  __cplusplus
williamr@2
   134
}
williamr@2
   135
#endif
williamr@2
   136
williamr@2
   137
#endif /* !HEADER_AES_H */