Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Macros | Typedefs | Functions
crypto.h File Reference

Provide cryptographic signature routines. More...

#include "asterisk/optional_api.h"
#include "asterisk/logger.h"

Go to the source code of this file.

Data Structures

struct  aes_key
 

Macros

#define AST_CRYPTO_AES_BLOCKSIZE   128
 
#define AST_CRYPTO_RSA_KEY_BITS   1024
 
#define AST_KEY_PRIVATE   (1 << 1)
 
#define AST_KEY_PUBLIC   (1 << 0)
 

Typedefs

typedef struct aes_key ast_aes_decrypt_key
 
typedef struct aes_key ast_aes_encrypt_key
 

Functions

static void __dtor__ast_aes_decrypt (void)
 
static void __dtor__ast_aes_encrypt (void)
 
static void __dtor__ast_aes_set_decrypt_key (void)
 
static void __dtor__ast_aes_set_encrypt_key (void)
 
static void __dtor__ast_check_signature (void)
 
static void __dtor__ast_check_signature_bin (void)
 
static void __dtor__ast_crypto_loaded (void)
 
static void __dtor__ast_crypto_reload (void)
 
static void __dtor__ast_decrypt_bin (void)
 
static void __dtor__ast_encrypt_bin (void)
 
static void __dtor__ast_key_get (void)
 
static void __dtor__ast_sign (void)
 
static void __dtor__ast_sign_bin (void)
 
static void __init__ast_aes_decrypt (void)
 
static void __init__ast_aes_encrypt (void)
 
static void __init__ast_aes_set_decrypt_key (void)
 
static void __init__ast_aes_set_encrypt_key (void)
 
static void __init__ast_check_signature (void)
 
static void __init__ast_check_signature_bin (void)
 
static void __init__ast_crypto_loaded (void)
 
static void __init__ast_crypto_reload (void)
 
static void __init__ast_decrypt_bin (void)
 
static void __init__ast_encrypt_bin (void)
 
static void __init__ast_key_get (void)
 
static void __init__ast_sign (void)
 
static void __init__ast_sign_bin (void)
 
static int __stub__ast_aes_decrypt (const unsigned char *in, unsigned char *out, const ast_aes_decrypt_key *key)
 AES decrypt data. More...
 
static int __stub__ast_aes_encrypt (const unsigned char *in, unsigned char *out, const ast_aes_encrypt_key *key)
 AES encrypt data. More...
 
static int __stub__ast_aes_set_decrypt_key (const unsigned char *key, ast_aes_decrypt_key *ctx)
 Set a decryption key. More...
 
static int __stub__ast_aes_set_encrypt_key (const unsigned char *key, ast_aes_encrypt_key *ctx)
 Set an encryption key. More...
 
static int __stub__ast_check_signature (struct ast_key *key, const char *msg, const char *sig)
 Check the authenticity of a message signature using a given public key. More...
 
static int __stub__ast_check_signature_bin (struct ast_key *key, const char *msg, int msglen, const unsigned char *dsig)
 Check the authenticity of a message signature using a given public key. More...
 
static int __stub__ast_crypto_loaded (void)
 
static int __stub__ast_crypto_reload (void)
 
static int __stub__ast_decrypt_bin (unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key)
 Decrypt a message using a given private key. More...
 
static int __stub__ast_encrypt_bin (unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key)
 Encrypt a message using a given private key. More...
 
static struct ast_key__stub__ast_key_get (const char *kname, int ktype)
 Retrieve a key. More...
 
static int __stub__ast_sign (struct ast_key *key, char *msg, char *sig)
 Sign a message signature using a given private key. More...
 
static int __stub__ast_sign_bin (struct ast_key *key, const char *msg, int msglen, unsigned char *dsig)
 Sign a message signature using a given private key. More...
 
static attribute_unused typeof (__stub__ast_key_get)*ast_key_get
 
static attribute_unused typeof (__stub__ast_check_signature)*ast_check_signature
 
static attribute_unused typeof (__stub__ast_check_signature_bin)*ast_check_signature_bin
 
static attribute_unused typeof (__stub__ast_sign)*ast_sign
 
static attribute_unused typeof (__stub__ast_sign_bin)*ast_sign_bin
 
static attribute_unused typeof (__stub__ast_encrypt_bin)*ast_encrypt_bin
 
static attribute_unused typeof (__stub__ast_decrypt_bin)*ast_decrypt_bin
 
static attribute_unused typeof (__stub__ast_aes_set_encrypt_key)*ast_aes_set_encrypt_key
 
static attribute_unused typeof (__stub__ast_aes_set_decrypt_key)*ast_aes_set_decrypt_key
 
static attribute_unused typeof (__stub__ast_aes_encrypt)*ast_aes_encrypt
 
static attribute_unused typeof (__stub__ast_aes_decrypt)*ast_aes_decrypt
 
static attribute_unused typeof (__stub__ast_crypto_loaded)*ast_crypto_loaded
 
static attribute_unused typeof (__stub__ast_crypto_reload)*ast_crypto_reload
 

Detailed Description

Provide cryptographic signature routines.

Definition in file crypto.h.

Function Documentation

static int __stub__ast_aes_decrypt ( const unsigned char *  in,
unsigned char *  out,
const ast_aes_decrypt_key key 
)
static

AES decrypt data.

Parameters
inencrypted data
outpointer to a buffer to hold the decrypted output
keypointer to the ast_aes_decrypt_key to use for decryption
Return values
<=0 failure
otherwisenumber of bytes in output buffer

Definition at line 185 of file crypto.h.

185 { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n");return -1; });
static int __stub__ast_aes_encrypt ( const unsigned char *  in,
unsigned char *  out,
const ast_aes_encrypt_key key 
)
static

AES encrypt data.

Parameters
indata to be encrypted
outpointer to a buffer to hold the encrypted output
keypointer to the ast_aes_encrypt_key to use for encryption
Return values
<=0 failure
otherwisenumber of bytes in output buffer

Definition at line 173 of file crypto.h.

173 { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n");return -1; });
static int __stub__ast_aes_set_decrypt_key ( const unsigned char *  key,
ast_aes_decrypt_key ctx 
)
static

Set a decryption key.

Parameters
keya 16 char key
ctxaddress of an aes encryption context
Return values
0success
nonzerofailure

Definition at line 161 of file crypto.h.

161 { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n"); return -1; });
static int __stub__ast_aes_set_encrypt_key ( const unsigned char *  key,
ast_aes_encrypt_key ctx 
)
static

Set an encryption key.

Parameters
keya 16 char key
ctxaddress of an aes encryption context
Return values
0success
nonzerofailure

Definition at line 149 of file crypto.h.

149 { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n"); return -1; });
static int __stub__ast_check_signature ( struct ast_key key,
const char *  msg,
const char *  sig 
)
static

Check the authenticity of a message signature using a given public key.

Parameters
keya public key to use to verify
msgthe message that has been signed
sigthe proposed valid signature in mime64-like encoding
Return values
0if the signature is valid.
-1otherwise.

Definition at line 69 of file crypto.h.

69 { return -1; });
static int __stub__ast_check_signature_bin ( struct ast_key key,
const char *  msg,
int  msglen,
const unsigned char *  dsig 
)
static

Check the authenticity of a message signature using a given public key.

Parameters
keya public key to use to verify
msgthe message that has been signed
msglen
dsigthe proposed valid signature in raw binary representation
Return values
0if the signature is valid.
-1otherwise.

Definition at line 82 of file crypto.h.

82 { return -1; });
static int __stub__ast_decrypt_bin ( unsigned char *  dst,
const unsigned char *  src,
int  srclen,
struct ast_key key 
)
static

Decrypt a message using a given private key.

Parameters
dsta pointer to a buffer of at least srclen bytes in which the decrypted
srcthe message to decrypt
srclenthe length of the message to decrypt
keya private key to use to decrypt answer will be stored
Return values
lengthof decrypted data on success.
-1on failure.

Definition at line 137 of file crypto.h.

137 { return -1; });
static int __stub__ast_encrypt_bin ( unsigned char *  dst,
const unsigned char *  src,
int  srclen,
struct ast_key key 
)
static

Encrypt a message using a given private key.

Parameters
dsta pointer to a buffer of at least srclen * 1.5 bytes in which the encrypted
srcthe message to encrypt
srclenthe length of the message to encrypt
keya private key to use to encrypt answer will be stored
Return values
lengthof encrypted data on success.
-1on failure.

Definition at line 123 of file crypto.h.

123 { return -1; });
static struct ast_key* __stub__ast_key_get ( const char *  kname,
int  ktype 
)
static

Retrieve a key.

Parameters
knameName of the key we are retrieving
ktypeIntger type of key (AST_KEY_PUBLIC or AST_KEY_PRIVATE)
Return values
thekey on success.
NULLon failure.

Definition at line 57 of file crypto.h.

57 { return NULL; });
static int __stub__ast_sign ( struct ast_key key,
char *  msg,
char *  sig 
)
static

Sign a message signature using a given private key.

Parameters
keya private key to use to create the signature
msgthe message to sign
siga pointer to a buffer of at least 256 bytes in which the mime64-like encoded signature will be stored
Return values
0on success.
-1on failure.

Definition at line 95 of file crypto.h.

95 { return -1; });
static int __stub__ast_sign_bin ( struct ast_key key,
const char *  msg,
int  msglen,
unsigned char *  dsig 
)
static

Sign a message signature using a given private key.

Parameters
keya private key to use to create the signature
msgthe message to sign
msglen
dsiga pointer to a buffer of at least 128 bytes in which the raw encoded signature will be stored
Return values
0on success.
-1on failure.

Definition at line 109 of file crypto.h.

109 { return -1; });