Thu Apr 28 2011 16:56:39

Asterisk developer's documentation


aes.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 20075, Digium, Inc.
00005  *
00006  * Kevin P. Fleming <kpfleming@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  * Wrappers for AES encryption/decryption
00021  *
00022  * \author Kevin P. Fleming <kpfleming@digium.com>
00023  *
00024  * These wrappers provided a generic interface to either the
00025  * AES methods provided by OpenSSL's crypto library, or the
00026  * AES implementation included with Asterisk.
00027  */
00028 
00029 #ifndef _ASTERISK_AES_H
00030 #define _ASTERISK_AES_H
00031 
00032 #ifdef HAVE_CRYPTO
00033 
00034 /* Use the OpenSSL crypto library */
00035 #include "openssl/aes.h"
00036 
00037 typedef AES_KEY ast_aes_encrypt_key;
00038 typedef AES_KEY ast_aes_decrypt_key;
00039 
00040 #define ast_aes_encrypt_key(key, context) AES_set_encrypt_key(key, 128, context)
00041 
00042 #define ast_aes_decrypt_key(key, context) AES_set_decrypt_key(key, 128, context)
00043 
00044 #define ast_aes_encrypt(in, out, context) AES_encrypt(in, out, context)
00045 
00046 #define ast_aes_decrypt(in, out, context) AES_decrypt(in, out, context)
00047 
00048 #else /* !HAVE_CRYPTO */
00049 
00050 /* Use the included AES implementation */
00051 
00052 #define AES_128
00053 #include "aes_internal.h"
00054 
00055 typedef aes_encrypt_ctx ast_aes_encrypt_key;
00056 typedef aes_decrypt_ctx ast_aes_decrypt_key;
00057 
00058 #define ast_aes_encrypt_key(key, context) aes_encrypt_key128(key, context)
00059 
00060 #define ast_aes_decrypt_key(key, context) aes_decrypt_key128(key, context)
00061 
00062 #define ast_aes_encrypt(in, out, context) aes_encrypt(in, out, context)
00063 
00064 #define ast_aes_decrypt(in, out, context) aes_decrypt(in, out, context)
00065 
00066 #endif /* !HAVE_CRYPTO */
00067 
00068 #endif /* _ASTERISK_AES_H */