| Asterisk - The Open Source Telephony Project GIT-master-27fb039
    | 
Provide cryptographic signature routines. More...


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 | |
| int AST_OPTIONAL_API_NAME() | ast_aes_decrypt (const unsigned char *in, unsigned char *out, const ast_aes_decrypt_key *key) | 
| AES decrypt data. | |
| int AST_OPTIONAL_API_NAME() | ast_aes_encrypt (const unsigned char *in, unsigned char *out, const ast_aes_encrypt_key *key) | 
| AES encrypt data. | |
| int AST_OPTIONAL_API_NAME() | ast_aes_set_decrypt_key (const unsigned char *key, ast_aes_decrypt_key *ctx) | 
| Set a decryption key. | |
| int AST_OPTIONAL_API_NAME() | ast_aes_set_encrypt_key (const unsigned char *key, ast_aes_encrypt_key *ctx) | 
| Set an encryption key. | |
| int AST_OPTIONAL_API_NAME() | 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. | |
| int AST_OPTIONAL_API_NAME() | 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. | |
| int AST_OPTIONAL_API_NAME() | ast_crypto_loaded (void) | 
| int AST_OPTIONAL_API_NAME() | ast_crypto_reload (void) | 
| int AST_OPTIONAL_API_NAME() | ast_decrypt_bin (unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key) | 
| Decrypt a message using a given private key. | |
| int AST_OPTIONAL_API_NAME() | ast_encrypt_bin (unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key) | 
| Encrypt a message using a given private key. | |
| struct ast_key *AST_OPTIONAL_API_NAME() | ast_key_get (const char *kname, int ktype) | 
| Retrieve a key. | |
| int AST_OPTIONAL_API_NAME() | ast_sign (struct ast_key *key, char *msg, char *sig) | 
| Sign a message signature using a given private key. | |
| int AST_OPTIONAL_API_NAME() | ast_sign_bin (struct ast_key *key, const char *msg, int msglen, unsigned char *dsig) | 
| Sign a message signature using a given private key. | |
Provide cryptographic signature routines.
Definition in file crypto.h.
| typedef struct aes_key ast_aes_decrypt_key | 
| typedef struct aes_key ast_aes_encrypt_key | 
| int AST_OPTIONAL_API_NAME() ast_aes_decrypt | ( | const unsigned char * | in, | 
| unsigned char * | out, | ||
| const ast_aes_decrypt_key * | key | ||
| ) | 
AES decrypt data.
| in | encrypted data | 
| out | pointer to a buffer to hold the decrypted output | 
| key | pointer to the ast_aes_decrypt_key to use for decryption | 
| <= | 0 failure | 
| otherwise | number of bytes in output buffer | 
Definition at line 790 of file res_crypto.c.
References AST_CRYPTO_AES_BLOCKSIZE, ast_log, evp_cipher_aes_decrypt(), in, LOG_ERROR, and out.
Referenced by aes_helper(), AST_TEST_DEFINE(), decrypt_memcpy(), and memcpy_decrypt().
| int AST_OPTIONAL_API_NAME() ast_aes_encrypt | ( | const unsigned char * | in, | 
| unsigned char * | out, | ||
| const ast_aes_encrypt_key * | key | ||
| ) | 
AES encrypt data.
| in | data to be encrypted | 
| out | pointer to a buffer to hold the encrypted output | 
| key | pointer to the ast_aes_encrypt_key to use for encryption | 
| <= | 0 failure | 
| otherwise | number of bytes in output buffer | 
Definition at line 749 of file res_crypto.c.
References AST_CRYPTO_AES_BLOCKSIZE, ast_log, evp_cipher_aes_encrypt(), in, LOG_ERROR, and out.
Referenced by aes_helper(), AST_TEST_DEFINE(), encrypt_memcpy(), and memcpy_encrypt().
| int AST_OPTIONAL_API_NAME() ast_aes_set_decrypt_key | ( | const unsigned char * | key, | 
| ast_aes_decrypt_key * | ctx | ||
| ) | 
Set a decryption key.
| key | a 16 char key | 
| ctx | address of an aes encryption context | 
| 0 | success | 
| nonzero | failure | 
Definition at line 709 of file res_crypto.c.
References AST_CRYPTO_AES_BLOCKSIZE, and NULL.
Referenced by aes_helper(), AST_TEST_DEFINE(), build_ecx_key(), build_encryption_keys(), check_key(), socket_process_helper(), and update_key().
| int AST_OPTIONAL_API_NAME() ast_aes_set_encrypt_key | ( | const unsigned char * | key, | 
| ast_aes_encrypt_key * | ctx | ||
| ) | 
Set an encryption key.
| key | a 16 char key | 
| ctx | address of an aes encryption context | 
| 0 | success | 
| nonzero | failure | 
Definition at line 700 of file res_crypto.c.
References AST_CRYPTO_AES_BLOCKSIZE, and NULL.
Referenced by aes_helper(), AST_TEST_DEFINE(), build_ecx_key(), check_key(), and update_key().
| int AST_OPTIONAL_API_NAME() 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.
| key | a public key to use to verify | 
| msg | the message that has been signed | 
| sig | the proposed valid signature in mime64-like encoding | 
| 0 | if the signature is valid. | 
| -1 | otherwise. | 
Check the authenticity of a message signature using a given public key.
Definition at line 673 of file res_crypto.c.
References ast_base64decode(), ast_check_signature_bin(), ast_log, and LOG_WARNING.
Referenced by authenticate_verify(), and register_verify().
| int AST_OPTIONAL_API_NAME() 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.
| key | a public key to use to verify | 
| msg | the message that has been signed | 
| msglen | |
| dsig | the proposed valid signature in raw binary representation | 
| 0 | if the signature is valid. | 
| -1 | otherwise. | 
Check the authenticity of a message signature using a given public key.
Definition at line 634 of file res_crypto.c.
References ast_debug, AST_KEY_PUBLIC, ast_log, ast_key::digest, evp_pkey_verify(), ast_key::ktype, LOG_ERROR, LOG_WARNING, ast_key::name, NULL, and ast_key::pkey.
Referenced by ast_check_signature(), AST_TEST_DEFINE(), and check_key().
| int AST_OPTIONAL_API_NAME() ast_crypto_loaded | ( | void | ) | 
Definition at line 689 of file res_crypto.c.
Referenced by AST_TEST_DEFINE().
| int AST_OPTIONAL_API_NAME() ast_crypto_reload | ( | void | ) | 
Definition at line 694 of file res_crypto.c.
References crypto_load().
Referenced by AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), and AST_TEST_DEFINE().
| int AST_OPTIONAL_API_NAME() ast_decrypt_bin | ( | unsigned char * | dst, | 
| const unsigned char * | src, | ||
| int | srclen, | ||
| struct ast_key * | key | ||
| ) | 
Decrypt a message using a given private key.
| dst | a pointer to a buffer of at least srclen bytes in which the decrypted | 
| src | the message to decrypt | 
| srclen | the length of the message to decrypt | 
| key | a private key to use to decrypt answer will be stored | 
| length | of decrypted data on success. | 
| -1 | on failure. | 
Decrypt a message using a given private key.
Definition at line 472 of file res_crypto.c.
References AST_KEY_PRIVATE, ast_log, evp_pkey_decrypt(), ast_key::ktype, LOG_NOTICE, LOG_WARNING, and ast_key::pkey.
Referenced by AST_TEST_DEFINE(), and check_key().
| int AST_OPTIONAL_API_NAME() ast_encrypt_bin | ( | unsigned char * | dst, | 
| const unsigned char * | src, | ||
| int | srclen, | ||
| struct ast_key * | key | ||
| ) | 
Encrypt a message using a given private key.
| dst | a pointer to a buffer of at least srclen * 1.5 bytes in which the encrypted | 
| src | the message to encrypt | 
| srclen | the length of the message to encrypt | 
| key | a private key to use to encrypt answer will be stored | 
| length | of encrypted data on success. | 
| -1 | on failure. | 
Encrypt a message using a given private key.
Definition at line 549 of file res_crypto.c.
References AST_KEY_PUBLIC, ast_log, evp_pkey_encrypt(), ast_key::ktype, LOG_NOTICE, LOG_WARNING, ast_key::pkey, and RSA_PKCS1_OAEP_PADDING_SIZE.
Referenced by AST_TEST_DEFINE(), and update_key().
| struct ast_key *AST_OPTIONAL_API_NAME() ast_key_get | ( | const char * | kname, | 
| int | ktype | ||
| ) | 
Retrieve a key.
| kname | Name of the key we are retrieving | 
| ktype | Intger type of key (AST_KEY_PUBLIC or AST_KEY_PRIVATE) | 
| the | key on success. | 
| NULL | on failure. | 
Retrieve a key.
Definition at line 149 of file res_crypto.c.
References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_key::ktype, ast_key::list, and ast_key::name.
Referenced by AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), authenticate(), authenticate_verify(), check_key(), register_verify(), and update_key().
| int AST_OPTIONAL_API_NAME() ast_sign | ( | struct ast_key * | key, | 
| char * | msg, | ||
| char * | sig | ||
| ) | 
Sign a message signature using a given private key.
| 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 | 
| 0 | on success. | 
| -1 | on failure. | 
Sign a message signature using a given private key.
Definition at line 584 of file res_crypto.c.
References ast_base64encode(), and ast_sign_bin().
Referenced by authenticate().
| int AST_OPTIONAL_API_NAME() ast_sign_bin | ( | struct ast_key * | key, | 
| const char * | msg, | ||
| int | msglen, | ||
| unsigned char * | dsig | ||
| ) | 
Sign a message signature using a given private key.
| key | a private key to use to create the signature | 
| msg | the message to sign | 
| msglen | |
| dsig | a pointer to a buffer of at least 128 bytes in which the raw encoded signature will be stored | 
| 0 | on success. | 
| -1 | on failure. | 
Sign a message signature using a given private key.
Definition at line 390 of file res_crypto.c.
References AST_KEY_PRIVATE, ast_log, ast_key::digest, evp_pkey_sign(), ast_key::ktype, LOG_ERROR, LOG_WARNING, ast_key::name, NULL, and ast_key::pkey.
Referenced by ast_sign(), AST_TEST_DEFINE(), and update_key().