mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-04 03:20:33 +00:00
Remove built-in AES code and use optional_api instead
Review: https://reviewboard.asterisk.org/r/793/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@278538 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -28,6 +28,16 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include "asterisk/optional_api.h"
|
||||
#include "asterisk/logger.h"
|
||||
|
||||
#ifdef HAVE_CRYPTO
|
||||
#include "openssl/aes.h"
|
||||
typedef AES_KEY ast_aes_encrypt_key;
|
||||
typedef AES_KEY ast_aes_decrypt_key;
|
||||
#else /* !HAVE_CRYPTO */
|
||||
typedef char ast_aes_encrypt_key;
|
||||
typedef char ast_aes_decrypt_key;
|
||||
#endif /* HAVE_CRYPTO */
|
||||
|
||||
#define AST_KEY_PUBLIC (1 << 0)
|
||||
#define AST_KEY_PRIVATE (1 << 1)
|
||||
@@ -122,6 +132,50 @@ AST_OPTIONAL_API(int, ast_encrypt_bin, (unsigned char *dst, const unsigned char
|
||||
*/
|
||||
AST_OPTIONAL_API(int, ast_decrypt_bin, (unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key), { return -1; });
|
||||
|
||||
/*!
|
||||
* \brief Set an encryption key
|
||||
* \param key a 16 char key
|
||||
* \param ctx address of an aes encryption context
|
||||
*
|
||||
* \retval 0 success
|
||||
* \retval nonzero failure
|
||||
*/
|
||||
AST_OPTIONAL_API(int, ast_aes_set_encrypt_key,
|
||||
(const unsigned char *key, ast_aes_encrypt_key *ctx),
|
||||
{ ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n"); return -1; });
|
||||
|
||||
/*!
|
||||
* \brief Set a decryption key
|
||||
* \param key a 16 char key
|
||||
* \param ctx address of an aes encryption context
|
||||
*
|
||||
* \retval 0 success
|
||||
* \retval nonzero failure
|
||||
*/
|
||||
AST_OPTIONAL_API(int, ast_aes_set_decrypt_key,
|
||||
(const unsigned char *key, ast_aes_decrypt_key *ctx),
|
||||
{ ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n"); return -1; });
|
||||
|
||||
/*!
|
||||
* \brief AES encrypt data
|
||||
* \param in data to be encrypted
|
||||
* \param out pointer to a buffer to hold the encrypted output
|
||||
* \param ctx address of an aes encryption context filled in with ast_aes_set_encrypt_key
|
||||
*/
|
||||
AST_OPTIONAL_API(void, ast_aes_encrypt,
|
||||
(const unsigned char *in, unsigned char *out, const ast_aes_encrypt_key *ctx),
|
||||
{ ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n");return; });
|
||||
|
||||
/*!
|
||||
* \brief AES decrypt data
|
||||
* \param in encrypted data
|
||||
* \param out pointer to a buffer to hold the decrypted output
|
||||
* \param ctx address of an aes encryption context filled in with ast_aes_set_decrypt_key
|
||||
*/
|
||||
AST_OPTIONAL_API(void, ast_aes_decrypt,
|
||||
(const unsigned char *in, unsigned char *out, const ast_aes_decrypt_key *ctx),
|
||||
{ ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n");return; });
|
||||
|
||||
AST_OPTIONAL_API(int, ast_crypto_loaded, (void), { return 0; });
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
|
Reference in New Issue
Block a user