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

Provide cryptographic signature routines. More...

#include "asterisk/optional_api.h"
#include "asterisk/logger.h"
#include "openssl/aes.h"
Include dependency graph for crypto.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define AST_KEY_PRIVATE   (1 << 1)
 
#define AST_KEY_PUBLIC   (1 << 0)
 

Typedefs

typedef AES_KEY ast_aes_decrypt_key
 
typedef 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_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_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 void __stub__ast_aes_decrypt (const unsigned char *in, unsigned char *out, const ast_aes_decrypt_key *ctx)
 AES decrypt data. More...
 
static void __stub__ast_aes_encrypt (const unsigned char *in, unsigned char *out, const ast_aes_encrypt_key *ctx)
 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 *sig)
 Check the authenticity of a message signature using a given public key. More...
 
static int __stub__ast_crypto_loaded (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 *key, int type)
 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 *sig)
 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
 

Detailed Description

Provide cryptographic signature routines.

Definition in file crypto.h.

Macro Definition Documentation

◆ AST_KEY_PRIVATE

#define AST_KEY_PRIVATE   (1 << 1)

◆ AST_KEY_PUBLIC

#define AST_KEY_PUBLIC   (1 << 0)

Typedef Documentation

◆ ast_aes_decrypt_key

typedef AES_KEY ast_aes_decrypt_key

Definition at line 36 of file crypto.h.

◆ ast_aes_encrypt_key

typedef AES_KEY ast_aes_encrypt_key

Definition at line 35 of file crypto.h.

Function Documentation

◆ __dtor__ast_aes_decrypt()

static void __dtor__ast_aes_decrypt ( void  )
static

Definition at line 179 of file crypto.h.

179 { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n");return; });
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42

◆ __dtor__ast_aes_encrypt()

static void __dtor__ast_aes_encrypt ( void  )
static

Definition at line 169 of file crypto.h.

169 { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n");return; });
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42

◆ __dtor__ast_aes_set_decrypt_key()

static void __dtor__ast_aes_set_decrypt_key ( void  )
static

Definition at line 159 of file crypto.h.

159 { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n"); return -1; });
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42

◆ __dtor__ast_aes_set_encrypt_key()

static void __dtor__ast_aes_set_encrypt_key ( void  )
static

Definition at line 147 of file crypto.h.

147 { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n"); return -1; });
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42

◆ __dtor__ast_check_signature()

static void __dtor__ast_check_signature ( void  )
static

Definition at line 67 of file crypto.h.

67 { return -1; });

◆ __dtor__ast_check_signature_bin()

static void __dtor__ast_check_signature_bin ( void  )
static

Definition at line 80 of file crypto.h.

80 { return -1; });

◆ __dtor__ast_crypto_loaded()

static void __dtor__ast_crypto_loaded ( void  )
static

Definition at line 181 of file crypto.h.

181 { return 0; });

◆ __dtor__ast_decrypt_bin()

static void __dtor__ast_decrypt_bin ( void  )
static

Definition at line 135 of file crypto.h.

135 { return -1; });

◆ __dtor__ast_encrypt_bin()

static void __dtor__ast_encrypt_bin ( void  )
static

Definition at line 121 of file crypto.h.

121 { return -1; });

◆ __dtor__ast_key_get()

static void __dtor__ast_key_get ( void  )
static

Definition at line 55 of file crypto.h.

55 { return NULL; });
#define NULL
Definition: resample.c:96

◆ __dtor__ast_sign()

static void __dtor__ast_sign ( void  )
static

Definition at line 93 of file crypto.h.

93 { return -1; });

◆ __dtor__ast_sign_bin()

static void __dtor__ast_sign_bin ( void  )
static

Definition at line 107 of file crypto.h.

107 { return -1; });

◆ __init__ast_aes_decrypt()

static void __init__ast_aes_decrypt ( void  )
static

Definition at line 179 of file crypto.h.

179 { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n");return; });
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42

◆ __init__ast_aes_encrypt()

static void __init__ast_aes_encrypt ( void  )
static

Definition at line 169 of file crypto.h.

169 { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n");return; });
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42

◆ __init__ast_aes_set_decrypt_key()

static void __init__ast_aes_set_decrypt_key ( void  )
static

Definition at line 159 of file crypto.h.

159 { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n"); return -1; });
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42

◆ __init__ast_aes_set_encrypt_key()

static void __init__ast_aes_set_encrypt_key ( void  )
static

Definition at line 147 of file crypto.h.

147 { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n"); return -1; });
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42

◆ __init__ast_check_signature()

static void __init__ast_check_signature ( void  )
static

Definition at line 67 of file crypto.h.

67 { return -1; });

◆ __init__ast_check_signature_bin()

static void __init__ast_check_signature_bin ( void  )
static

Definition at line 80 of file crypto.h.

80 { return -1; });

◆ __init__ast_crypto_loaded()

static void __init__ast_crypto_loaded ( void  )
static

Definition at line 181 of file crypto.h.

181 { return 0; });

◆ __init__ast_decrypt_bin()

static void __init__ast_decrypt_bin ( void  )
static

Definition at line 135 of file crypto.h.

135 { return -1; });

◆ __init__ast_encrypt_bin()

static void __init__ast_encrypt_bin ( void  )
static

Definition at line 121 of file crypto.h.

121 { return -1; });

◆ __init__ast_key_get()

static void __init__ast_key_get ( void  )
static

Definition at line 55 of file crypto.h.

55 { return NULL; });
#define NULL
Definition: resample.c:96

◆ __init__ast_sign()

static void __init__ast_sign ( void  )
static

Definition at line 93 of file crypto.h.

93 { return -1; });

◆ __init__ast_sign_bin()

static void __init__ast_sign_bin ( void  )
static

Definition at line 107 of file crypto.h.

107 { return -1; });

◆ __stub__ast_aes_decrypt()

static void __stub__ast_aes_decrypt ( const unsigned char *  in,
unsigned char *  out,
const ast_aes_decrypt_key ctx 
)
static

AES decrypt data.

Parameters
inencrypted data
outpointer to a buffer to hold the decrypted output
ctxaddress of an aes encryption context filled in with ast_aes_set_decrypt_key

Definition at line 179 of file crypto.h.

References ast_log, and LOG_WARNING.

179 { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n");return; });
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42

◆ __stub__ast_aes_encrypt()

static void __stub__ast_aes_encrypt ( const unsigned char *  in,
unsigned char *  out,
const ast_aes_encrypt_key ctx 
)
static

AES encrypt data.

Parameters
indata to be encrypted
outpointer to a buffer to hold the encrypted output
ctxaddress of an aes encryption context filled in with ast_aes_set_encrypt_key

Definition at line 169 of file crypto.h.

References ast_aes_decrypt(), ast_log, AST_OPTIONAL_API, and LOG_WARNING.

169 { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n");return; });
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42

◆ __stub__ast_aes_set_decrypt_key()

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 159 of file crypto.h.

References ast_aes_encrypt(), ast_log, AST_OPTIONAL_API, in, LOG_WARNING, and out.

159 { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n"); return -1; });
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42

◆ __stub__ast_aes_set_encrypt_key()

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 147 of file crypto.h.

References ast_aes_set_decrypt_key(), ast_log, AST_OPTIONAL_API, and LOG_WARNING.

147 { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n"); return -1; });
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42

◆ __stub__ast_check_signature()

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 67 of file crypto.h.

67 { return -1; });

◆ __stub__ast_check_signature_bin()

static int __stub__ast_check_signature_bin ( struct ast_key key,
const char *  msg,
int  msglen,
const unsigned 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
msglen
sigthe proposed valid signature in raw binary representation
Return values
0if the signature is valid.
-1otherwise.

Definition at line 80 of file crypto.h.

80 { return -1; });

◆ __stub__ast_crypto_loaded()

static int __stub__ast_crypto_loaded ( void  )
static

Definition at line 181 of file crypto.h.

181 { return 0; });

◆ __stub__ast_decrypt_bin()

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

Definition at line 135 of file crypto.h.

References ast_aes_set_encrypt_key(), and AST_OPTIONAL_API.

135 { return -1; });

◆ __stub__ast_encrypt_bin()

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

Definition at line 121 of file crypto.h.

121 { return -1; });

◆ __stub__ast_key_get()

static struct ast_key* __stub__ast_key_get ( const char *  key,
int  type 
)
static

Retrieve a key.

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

Definition at line 55 of file crypto.h.

References NULL.

55 { return NULL; });
#define NULL
Definition: resample.c:96

◆ __stub__ast_sign()

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 93 of file crypto.h.

93 { return -1; });

◆ __stub__ast_sign_bin()

static int __stub__ast_sign_bin ( struct ast_key key,
const char *  msg,
int  msglen,
unsigned 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
msglen
siga 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 107 of file crypto.h.

107 { return -1; });

◆ typeof() [1/12]

static attribute_unused typeof ( __stub__ast_key_get  )
static

◆ typeof() [2/12]

static attribute_unused typeof ( __stub__ast_check_signature  )
static

◆ typeof() [3/12]

◆ typeof() [4/12]

static attribute_unused typeof ( __stub__ast_sign  )
static

◆ typeof() [5/12]

static attribute_unused typeof ( __stub__ast_sign_bin  )
static

◆ typeof() [6/12]

static attribute_unused typeof ( __stub__ast_encrypt_bin  )
static

◆ typeof() [7/12]

static attribute_unused typeof ( __stub__ast_decrypt_bin  )
static

◆ typeof() [8/12]

◆ typeof() [9/12]

◆ typeof() [10/12]

static attribute_unused typeof ( __stub__ast_aes_encrypt  )
static

◆ typeof() [11/12]

static attribute_unused typeof ( __stub__ast_aes_decrypt  )
static

◆ typeof() [12/12]

static attribute_unused typeof ( __stub__ast_crypto_loaded  )
static