Wed Aug 7 17:16:03 2019

Asterisk developer's documentation


crypto.h File Reference

Provide cryptographic signature routines. More...

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

Go to the source code of this file.

Defines

#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

 AST_OPTIONAL_API (int, ast_crypto_loaded,(void),{return 0;})
 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;})
 AES decrypt data.
 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;})
 AES encrypt data.
 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;})
 Set a decryption key.
 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;})
 Set an encryption key.
 AST_OPTIONAL_API (int, ast_decrypt_bin,(unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key),{return-1;})
 Decrypt a message using a given private key.
 AST_OPTIONAL_API (int, ast_encrypt_bin,(unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key),{return-1;})
 Encrypt a message using a given private key.
 AST_OPTIONAL_API (int, ast_sign_bin,(struct ast_key *key, const char *msg, int msglen, unsigned char *sig),{return-1;})
 Sign a message signature using a given private key.
 AST_OPTIONAL_API (int, ast_sign,(struct ast_key *key, char *msg, char *sig),{return-1;})
 Sign a message signature using a given private key.
 AST_OPTIONAL_API (int, ast_check_signature_bin,(struct ast_key *key, const char *msg, int msglen, const unsigned char *sig),{return-1;})
 Check the authenticity of a message signature using a given public key.
 AST_OPTIONAL_API (int, ast_check_signature,(struct ast_key *key, const char *msg, const char *sig),{return-1;})
 Check the authenticity of a message signature using a given public key.
 AST_OPTIONAL_API (struct ast_key *, ast_key_get,(const char *key, int type),{return NULL;})
 Retrieve a key.

Detailed Description

Provide cryptographic signature routines.

Definition in file crypto.h.


Define Documentation

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

Typedef Documentation

typedef AES_KEY ast_aes_decrypt_key

Definition at line 36 of file crypto.h.

typedef AES_KEY ast_aes_encrypt_key

Definition at line 35 of file crypto.h.


Function Documentation

AST_OPTIONAL_API ( int  ,
ast_crypto_loaded  ,
(void)   
)
AST_OPTIONAL_API ( void  ,
ast_aes_decrypt  ,
(const unsigned char *in, unsigned char *out, const ast_aes_decrypt_key *ctx)   
)

AES decrypt data.

Parameters:
in encrypted data
out pointer to a buffer to hold the decrypted output
ctx address of an aes encryption context filled in with ast_aes_set_decrypt_key
AST_OPTIONAL_API ( void  ,
ast_aes_encrypt  ,
(const unsigned char *in, unsigned char *out, const ast_aes_encrypt_key *ctx)   
)

AES encrypt data.

Parameters:
in data to be encrypted
out pointer to a buffer to hold the encrypted output
ctx address of an aes encryption context filled in with ast_aes_set_encrypt_key
AST_OPTIONAL_API ( int  ,
ast_aes_set_decrypt_key  ,
(const unsigned char *key, ast_aes_decrypt_key *ctx)   
)

Set a decryption key.

Parameters:
key a 16 char key
ctx address of an aes encryption context
Return values:
0 success
nonzero failure
AST_OPTIONAL_API ( int  ,
ast_aes_set_encrypt_key  ,
(const unsigned char *key, ast_aes_encrypt_key *ctx)   
)

Set an encryption key.

Parameters:
key a 16 char key
ctx address of an aes encryption context
Return values:
0 success
nonzero failure
AST_OPTIONAL_API ( int  ,
ast_decrypt_bin  ,
(unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key)   
)

Decrypt a message using a given private key.

Parameters:
key a private key to use to decrypt
src the message to decrypt
srclen the length of the message to decrypt
dst a pointer to a buffer of at least srclen bytes in which the decrypted answer will be stored
Return values:
length of dencrypted data on success.
-1 on failure.
AST_OPTIONAL_API ( int  ,
ast_encrypt_bin  ,
(unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key)   
)

Encrypt a message using a given private key.

Parameters:
key a private key to use to encrypt
src the message to encrypt
srclen the length of the message to encrypt
dst a pointer to a buffer of at least srclen * 1.5 bytes in which the encrypted answer will be stored
Return values:
length of encrypted data on success.
-1 on failure.
AST_OPTIONAL_API ( int  ,
ast_sign_bin  ,
(struct ast_key *key, const char *msg, int msglen, unsigned char *sig)   
)

Sign a message signature using a given private key.

Parameters:
key a private key to use to create the signature
msg the message to sign
sig a pointer to a buffer of at least 128 bytes in which the raw encoded signature will be stored
Return values:
0 on success.
-1 on failure.
AST_OPTIONAL_API ( int  ,
ast_sign  ,
(struct ast_key *key, char *msg, char *sig)   
)

Sign a message signature using a given private key.

Parameters:
key a private key to use to create the signature
msg the message to sign
sig a pointer to a buffer of at least 256 bytes in which the mime64-like encoded signature will be stored
Return values:
0 on success.
-1 on failure.
AST_OPTIONAL_API ( int  ,
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.

Parameters:
key a public key to use to verify
msg the message that has been signed
sig the proposed valid signature in raw binary representation
Return values:
0 if the signature is valid.
-1 otherwise.
AST_OPTIONAL_API ( int  ,
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.

Parameters:
key a public key to use to verify
msg the message that has been signed
sig the proposed valid signature in mime64-like encoding
Return values:
0 if the signature is valid.
-1 otherwise.
AST_OPTIONAL_API ( struct ast_key ,
ast_key_get  ,
(const char *key, int type)   
)

Retrieve a key.

Parameters:
name of the key we are retrieving
int type of key (AST_KEY_PUBLIC or AST_KEY_PRIVATE)
Return values:
the key on success.
NULL on failure.

Generated on 7 Aug 2019 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1