Sat Aug 6 00:39:28 2011

Asterisk developer's documentation


crypto.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2005, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@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  * \brief Provide cryptographic signature routines
00021  */
00022 
00023 #ifndef _ASTERISK_CRYPTO_H
00024 #define _ASTERISK_CRYPTO_H
00025 
00026 #if defined(__cplusplus) || defined(c_plusplus)
00027 extern "C" {
00028 #endif
00029 
00030 #define AST_KEY_PUBLIC  (1 << 0)
00031 #define AST_KEY_PRIVATE (1 << 1)
00032 
00033 struct ast_key;
00034 
00035 /*! \brief Retrieve a key
00036  * \param name of the key we are retrieving
00037  * \param int type of key (AST_KEY_PUBLIC or AST_KEY_PRIVATE)
00038  *
00039  * Returns the key on success or NULL on failure
00040  */
00041 extern struct ast_key *(*ast_key_get)(const char *key, int type);
00042 
00043 /*! \brief Check the authenticity of a message signature using a given public key
00044  * \param key a public key to use to verify
00045  * \param msg the message that has been signed
00046  * \param sig the proposed valid signature in mime64-like encoding
00047  *
00048  * Returns 0 if the signature is valid, or -1 otherwise
00049  *
00050  */
00051 extern int (*ast_check_signature)(struct ast_key *key, const char *msg, const char *sig);
00052 
00053 /*! \brief Check the authenticity of a message signature using a given public key
00054  * \param key a public key to use to verify
00055  * \param msg the message that has been signed
00056  * \param sig the proposed valid signature in raw binary representation
00057  *
00058  * Returns 0 if the signature is valid, or -1 otherwise
00059  *
00060  */
00061 extern int (*ast_check_signature_bin)(struct ast_key *key, const char *msg, int msglen, const unsigned char *sig);
00062 
00063 /*!
00064  * \param key a private key to use to create the signature
00065  * \param msg the message to sign
00066  * \param sig a pointer to a buffer of at least 256 bytes in which the
00067  * mime64-like encoded signature will be stored
00068  *
00069  * Returns 0 on success or -1 on failure.
00070  *
00071  */
00072 extern int (*ast_sign)(struct ast_key *key, char *msg, char *sig);
00073 
00074 /*!
00075  * \param key a private key to use to create the signature
00076  * \param msg the message to sign
00077  * \param sig a pointer to a buffer of at least 128 bytes in which the
00078  * raw encoded signature will be stored
00079  *
00080  * Returns 0 on success or -1 on failure.
00081  *
00082  */
00083 extern int (*ast_sign_bin)(struct ast_key *key, const char *msg, int msglen, unsigned char *sig);
00084 
00085 /*!
00086  * \param key a private key to use to encrypt
00087  * \param src the message to encrypt
00088  * \param srclen the length of the message to encrypt
00089  * \param dst a pointer to a buffer of at least srclen * 1.5 bytes in which the encrypted
00090  * answer will be stored
00091  *
00092  * Returns length of encrypted data on success or -1 on failure.
00093  *
00094  */
00095 extern int (*ast_encrypt_bin)(unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key);
00096 
00097 /*!
00098  * \param key a private key to use to decrypt
00099  * \param src the message to decrypt
00100  * \param srclen the length of the message to decrypt
00101  * \param dst a pointer to a buffer of at least srclen bytes in which the decrypted
00102  * answer will be stored
00103  *
00104  * Returns length of decrypted data on success or -1 on failure.
00105  *
00106  */
00107 extern int (*ast_decrypt_bin)(unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key);
00108 #if defined(__cplusplus) || defined(c_plusplus)
00109 }
00110 #endif
00111 
00112 #endif /* _ASTERISK_CRYPTO_H */

Generated on Sat Aug 6 00:39:28 2011 for Asterisk - the Open Source PBX by  doxygen 1.4.7