Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

crypto.h

Go to the documentation of this file.
00001 /* 00002 * Asterisk -- A telephony toolkit for Linux. 00003 * 00004 * Provide cryptographic signature routines 00005 * 00006 * Copyright (C) 1999, Mark Spencer 00007 * 00008 * Mark Spencer <markster@linux-support.net> 00009 * 00010 * This program is free software, distributed under the terms of 00011 * the GNU General Public License 00012 */ 00013 00014 #ifndef _ASTERISK_CRYPTO_H 00015 #define _ASTERISK_CRYPTO_H 00016 00017 #include <asterisk/channel.h> 00018 #include <asterisk/file.h> 00019 00020 #if defined(__cplusplus) || defined(c_plusplus) 00021 extern "C" { 00022 #endif 00023 00024 #define AST_KEY_PUBLIC (1 << 0) 00025 #define AST_KEY_PRIVATE (1 << 1) 00026 00027 struct ast_key; 00028 00029 //! Retrieve a key 00030 /*! 00031 * \param name of the key we are retrieving 00032 * \param int type of key (AST_KEY_PUBLIC or AST_KEY_PRIVATE) 00033 * 00034 * Returns the key on success or NULL on failure 00035 */ 00036 extern struct ast_key *ast_key_get(char *key, int type); 00037 00038 //! Initialize keys (that is, retrieve pass codes for all private keys) 00039 /*! 00040 * \param fd a file descriptor for I/O for passwords 00041 * 00042 */ 00043 extern int ast_key_init(int fd); 00044 00045 //! Check the authenticity of a message signature using a given public key 00046 /*! 00047 * \param key a public key to use to verify 00048 * \param msg the message that has been signed 00049 * \param sig the proposed valid signature in mime64-like encoding 00050 * 00051 * Returns 0 if the signature is valid, or -1 otherwise 00052 * 00053 */ 00054 extern int ast_check_signature(struct ast_key *key, char *msg, char *sig); 00055 00056 /*! 00057 * \param key a private key to use to create the signature 00058 * \param msg the message to sign 00059 * \param sig a pointer to a buffer of at least 256 bytes in which the 00060 * mime64-like encoded signature will be stored 00061 * 00062 * Returns 0 on success or -1 on failure. 00063 * 00064 */ 00065 extern int ast_sign(struct ast_key *key, char *msg, char *sig); 00066 00067 #if defined(__cplusplus) || defined(c_plusplus) 00068 } 00069 #endif 00070 00071 #endif

Generated on Sat Jun 12 16:40:57 2004 for Asterisk by doxygen 1.3.7