| Asterisk - The Open Source Telephony Project GIT-master-27fb039
    | 
Asterisk wrapper for crypt(3) More...

Go to the source code of this file.
| Macros | |
| #define | MAX_SALT_LEN 21 | 
| Max length of a salt string. | |
| Functions | |
| char * | ast_crypt (const char *key, const char *salt) | 
| Asterisk wrapper around crypt(3). | |
| char * | ast_crypt_encrypt (const char *key) | 
| Asterisk wrapper around crypt(3) for encrypting passwords. | |
| int | ast_crypt_validate (const char *key, const char *expected) | 
| Asterisk wrapper around crypt(3) for validating passwords. | |
| static int | gen_salt (char *current_salt, size_t maxlen) | 
| Generates a salt to try with crypt. | |
| static char | gen_salt_char (void) | 
| Variables | |
| static char | salt_chars [] | 
Asterisk wrapper for crypt(3)
Definition in file crypt.c.
| #define MAX_SALT_LEN 21 | 
| char * ast_crypt | ( | const char * | key, | 
| const char * | salt | ||
| ) | 
Asterisk wrapper around crypt(3).
The interpretation of the salt (which determines the password hashing algorithm) is system specific. Application code should prefer to use ast_crypt_encrypt() or ast_crypt_validate().
The returned string is heap allocated, and should be freed with ast_free().
| key | User's password to crypt. | 
| salt | Salt to crypt with. | 
| NULL | on error. | 
Definition at line 121 of file crypt.c.
References ast_begins_with(), ast_strdup, and NULL.
Referenced by ast_crypt_encrypt().
| char * ast_crypt_encrypt | ( | const char * | key | ) | 
Asterisk wrapper around crypt(3) for encrypting passwords.
This function will generate a random salt and encrypt the given password.
The returned string is heap allocated, and should be freed with ast_free().
| key | User's password to crypt. | 
| NULL | on error. | 
Definition at line 190 of file crypt.c.
References ast_crypt(), gen_salt(), MAX_SALT_LEN, and NULL.
Referenced by ari_mkpasswd(), and AST_TEST_DEFINE().
| int ast_crypt_validate | ( | const char * | key, | 
| const char * | expected | ||
| ) | 
Asterisk wrapper around crypt(3) for validating passwords.
| key | User's password to validate. | 
| expected | Expected result from crypt. | 
| True | (non-zero) if key matches expected. | 
| False | (zero) if key doesn't match. | 
Definition at line 136 of file crypt.c.
Referenced by ari_conf_validate_user(), and AST_TEST_DEFINE().
| 
 | static | 
Generates a salt to try with crypt.
If given an empty string, will generate a salt for the most secure algorithm to try with crypt(). If given a previously generated salt, the algorithm will be lowered by one level of security.
| [out] | current_salt | Output string in which to generate the salt. This can be an empty string, or the results of a prior gen_salt call. | 
| maxlen | Length of current_salt. | 
Definition at line 72 of file crypt.c.
References gen_salt_char(), MAX_SALT_LEN, and NULL.
Referenced by ast_crypt_encrypt().
| 
 | static | 
Randomly select a character for a salt string
Definition at line 52 of file crypt.c.
References ast_random_double, and salt_chars.
Referenced by gen_salt().
| 
 | static | 
Definition at line 45 of file crypt.c.
Referenced by gen_salt_char().