#include "asterisk.h"
#include <sys/types.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/logger.h"
#include "asterisk/say.h"
#include "asterisk/module.h"
#include "asterisk/options.h"
#include "asterisk/crypto.h"
#include "asterisk/md5.h"
#include "asterisk/cli.h"
#include "asterisk/io.h"
#include "asterisk/lock.h"
#include "asterisk/utils.h"
Go to the source code of this file.
Data Structures | |
struct | ast_key |
Defines | |
#define | KEY_NEEDS_PASSCODE (1 << 16) |
Functions | |
static int | __ast_check_signature (struct ast_key *key, const char *msg, const char *sig) |
static int | __ast_check_signature_bin (struct ast_key *key, const char *msg, int msglen, const unsigned char *dsig) |
static int | __ast_decrypt_bin (unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key) |
static int | __ast_encrypt_bin (unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key) |
static struct ast_key * | __ast_key_get (const char *kname, int ktype) |
static int | __ast_sign (struct ast_key *key, char *msg, char *sig) |
static int | __ast_sign_bin (struct ast_key *key, const char *msg, int msglen, unsigned char *dsig) |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | crypto_init (void) |
static void | crypto_load (int ifd, int ofd) |
static int | init_keys (int fd, int argc, char *argv[]) |
static int | load_module (void) |
static void | md52sum (char *sum, unsigned char *md5) |
static int | pw_cb (char *buf, int size, int rwflag, void *userdata) |
static int | reload (void) |
static int | show_keys (int fd, int argc, char *argv[]) |
static struct ast_key * | try_load_key (char *dir, char *fname, int ifd, int ofd, int *not2) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_BUILDSUM, .description = "Cryptographic Digital Signatures" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "f450f61f60e761b3aa089ebed76ca8a5" , .load = load_module, .unload = unload_module, .reload = reload } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_cli_entry | cli_crypto [] |
static struct ast_cli_entry | cli_init_keys_deprecated |
static struct ast_cli_entry | cli_show_keys_deprecated |
static char | init_keys_usage [] |
static ast_mutex_t | keylock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) |
static struct ast_key * | keys = NULL |
static char | show_key_usage [] |
Definition in file res_crypto.c.
#define KEY_NEEDS_PASSCODE (1 << 16) |
Definition at line 81 of file res_crypto.c.
Referenced by init_keys(), show_keys(), and try_load_key().
static int __ast_check_signature | ( | struct ast_key * | key, | |
const char * | msg, | |||
const char * | sig | |||
) | [static] |
Definition at line 446 of file res_crypto.c.
References ast_base64decode(), ast_check_signature_bin, ast_log(), and LOG_WARNING.
Referenced by crypto_init().
00447 { 00448 unsigned char dsig[128]; 00449 int res; 00450 00451 /* Decode signature */ 00452 res = ast_base64decode(dsig, sig, sizeof(dsig)); 00453 if (res != sizeof(dsig)) { 00454 ast_log(LOG_WARNING, "Signature improper length (expect %d, got %d)\n", (int)sizeof(dsig), (int)res); 00455 return -1; 00456 } 00457 res = ast_check_signature_bin(key, msg, strlen(msg), dsig); 00458 return res; 00459 }
static int __ast_check_signature_bin | ( | struct ast_key * | key, | |
const char * | msg, | |||
int | msglen, | |||
const unsigned char * | dsig | |||
) | [static] |
Definition at line 420 of file res_crypto.c.
References AST_KEY_PUBLIC, ast_log(), ast_key::digest, ast_key::ktype, LOG_DEBUG, LOG_WARNING, ast_key::name, and ast_key::rsa.
Referenced by crypto_init().
00421 { 00422 unsigned char digest[20]; 00423 int res; 00424 00425 if (key->ktype != AST_KEY_PUBLIC) { 00426 /* Okay, so of course you really *can* but for our purposes 00427 we're going to say you can't */ 00428 ast_log(LOG_WARNING, "Cannot check message signature with a private key\n"); 00429 return -1; 00430 } 00431 00432 /* Calculate digest of message */ 00433 SHA1((unsigned char *)msg, msglen, digest); 00434 00435 /* Verify signature */ 00436 res = RSA_verify(NID_sha1, digest, sizeof(digest), (unsigned char *)dsig, 128, key->rsa); 00437 00438 if (!res) { 00439 ast_log(LOG_DEBUG, "Key failed verification: %s\n", key->name); 00440 return -1; 00441 } 00442 /* Pass */ 00443 return 0; 00444 }
static int __ast_decrypt_bin | ( | unsigned char * | dst, | |
const unsigned char * | src, | |||
int | srclen, | |||
struct ast_key * | key | |||
) | [static] |
Definition at line 353 of file res_crypto.c.
References AST_KEY_PRIVATE, ast_log(), ast_key::ktype, LOG_NOTICE, LOG_WARNING, and ast_key::rsa.
Referenced by crypto_init().
00354 { 00355 int res; 00356 int pos = 0; 00357 if (key->ktype != AST_KEY_PRIVATE) { 00358 ast_log(LOG_WARNING, "Cannot decrypt with a public key\n"); 00359 return -1; 00360 } 00361 00362 if (srclen % 128) { 00363 ast_log(LOG_NOTICE, "Tried to decrypt something not a multiple of 128 bytes\n"); 00364 return -1; 00365 } 00366 while(srclen) { 00367 /* Process chunks 128 bytes at a time */ 00368 res = RSA_private_decrypt(128, src, dst, key->rsa, RSA_PKCS1_OAEP_PADDING); 00369 if (res < 0) 00370 return -1; 00371 pos += res; 00372 src += 128; 00373 srclen -= 128; 00374 dst += res; 00375 } 00376 return pos; 00377 }
static int __ast_encrypt_bin | ( | unsigned char * | dst, | |
const unsigned char * | src, | |||
int | srclen, | |||
struct ast_key * | key | |||
) | [static] |
Definition at line 379 of file res_crypto.c.
References AST_KEY_PUBLIC, ast_log(), ast_key::ktype, LOG_NOTICE, LOG_WARNING, and ast_key::rsa.
Referenced by crypto_init().
00380 { 00381 int res; 00382 int bytes; 00383 int pos = 0; 00384 if (key->ktype != AST_KEY_PUBLIC) { 00385 ast_log(LOG_WARNING, "Cannot encrypt with a private key\n"); 00386 return -1; 00387 } 00388 00389 while(srclen) { 00390 bytes = srclen; 00391 if (bytes > 128 - 41) 00392 bytes = 128 - 41; 00393 /* Process chunks 128-41 bytes at a time */ 00394 res = RSA_public_encrypt(bytes, src, dst, key->rsa, RSA_PKCS1_OAEP_PADDING); 00395 if (res != 128) { 00396 ast_log(LOG_NOTICE, "How odd, encrypted size is %d\n", res); 00397 return -1; 00398 } 00399 src += bytes; 00400 srclen -= bytes; 00401 pos += res; 00402 dst += res; 00403 } 00404 return pos; 00405 }
static struct ast_key* __ast_key_get | ( | const char * | kname, | |
int | ktype | |||
) | [static] |
Definition at line 141 of file res_crypto.c.
References ast_mutex_lock(), ast_mutex_unlock(), keylock, keys, ast_key::ktype, ast_key::name, and ast_key::next.
Referenced by crypto_init().
00142 { 00143 struct ast_key *key; 00144 ast_mutex_lock(&keylock); 00145 key = keys; 00146 while(key) { 00147 if (!strcmp(kname, key->name) && 00148 (ktype == key->ktype)) 00149 break; 00150 key = key->next; 00151 } 00152 ast_mutex_unlock(&keylock); 00153 return key; 00154 }
static int __ast_sign | ( | struct ast_key * | key, | |
char * | msg, | |||
char * | sig | |||
) | [static] |
Definition at line 407 of file res_crypto.c.
References ast_base64encode(), and ast_sign_bin.
Referenced by crypto_init().
00408 { 00409 unsigned char dsig[128]; 00410 int siglen = sizeof(dsig); 00411 int res; 00412 res = ast_sign_bin(key, msg, strlen(msg), dsig); 00413 if (!res) 00414 /* Success -- encode (256 bytes max as documented) */ 00415 ast_base64encode(sig, dsig, siglen, 256); 00416 return res; 00417 00418 }
static int __ast_sign_bin | ( | struct ast_key * | key, | |
const char * | msg, | |||
int | msglen, | |||
unsigned char * | dsig | |||
) | [static] |
Definition at line 322 of file res_crypto.c.
References AST_KEY_PRIVATE, ast_log(), ast_key::digest, ast_key::ktype, LOG_WARNING, ast_key::name, and ast_key::rsa.
Referenced by crypto_init().
00323 { 00324 unsigned char digest[20]; 00325 unsigned int siglen = 128; 00326 int res; 00327 00328 if (key->ktype != AST_KEY_PRIVATE) { 00329 ast_log(LOG_WARNING, "Cannot sign with a public key\n"); 00330 return -1; 00331 } 00332 00333 /* Calculate digest of message */ 00334 SHA1((unsigned char *)msg, msglen, digest); 00335 00336 /* Verify signature */ 00337 res = RSA_sign(NID_sha1, digest, sizeof(digest), dsig, &siglen, key->rsa); 00338 00339 if (!res) { 00340 ast_log(LOG_WARNING, "RSA Signature (key %s) failed\n", key->name); 00341 return -1; 00342 } 00343 00344 if (siglen != 128) { 00345 ast_log(LOG_WARNING, "Unexpected signature length %d, expecting %d\n", (int)siglen, (int)128); 00346 return -1; 00347 } 00348 00349 return 0; 00350 00351 }
static void __reg_module | ( | void | ) | [static] |
Definition at line 631 of file res_crypto.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 631 of file res_crypto.c.
static int crypto_init | ( | void | ) | [static] |
Definition at line 587 of file res_crypto.c.
References __ast_check_signature(), __ast_check_signature_bin(), __ast_decrypt_bin(), __ast_encrypt_bin(), __ast_key_get(), __ast_sign(), __ast_sign_bin(), ast_check_signature, ast_check_signature_bin, ast_cli_register_multiple(), ast_decrypt_bin, ast_encrypt_bin, ast_key_get, ast_sign, ast_sign_bin, and cli_crypto.
Referenced by load_module().
00588 { 00589 SSL_library_init(); 00590 ERR_load_crypto_strings(); 00591 ast_cli_register_multiple(cli_crypto, sizeof(cli_crypto) / sizeof(struct ast_cli_entry)); 00592 00593 /* Install ourselves into stubs */ 00594 ast_key_get = __ast_key_get; 00595 ast_check_signature = __ast_check_signature; 00596 ast_check_signature_bin = __ast_check_signature_bin; 00597 ast_sign = __ast_sign; 00598 ast_sign_bin = __ast_sign_bin; 00599 ast_encrypt_bin = __ast_encrypt_bin; 00600 ast_decrypt_bin = __ast_decrypt_bin; 00601 return 0; 00602 }
static void crypto_load | ( | int | ifd, | |
int | ofd | |||
) | [static] |
Definition at line 461 of file res_crypto.c.
References ast_config_AST_KEY_DIR, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_key::delme, free, keylock, keys, ast_key::ktype, last, LOG_DEBUG, LOG_NOTICE, LOG_WARNING, ast_key::name, sla_ringing_trunk::next, ast_key::next, ast_key::rsa, and try_load_key().
Referenced by load_module(), and reload().
00462 { 00463 struct ast_key *key, *nkey, *last; 00464 DIR *dir = NULL; 00465 struct dirent *ent; 00466 int note = 0; 00467 /* Mark all keys for deletion */ 00468 ast_mutex_lock(&keylock); 00469 key = keys; 00470 while(key) { 00471 key->delme = 1; 00472 key = key->next; 00473 } 00474 ast_mutex_unlock(&keylock); 00475 /* Load new keys */ 00476 dir = opendir((char *)ast_config_AST_KEY_DIR); 00477 if (dir) { 00478 while((ent = readdir(dir))) { 00479 try_load_key((char *)ast_config_AST_KEY_DIR, ent->d_name, ifd, ofd, ¬e); 00480 } 00481 closedir(dir); 00482 } else 00483 ast_log(LOG_WARNING, "Unable to open key directory '%s'\n", (char *)ast_config_AST_KEY_DIR); 00484 if (note) { 00485 ast_log(LOG_NOTICE, "Please run the command 'init keys' to enter the passcodes for the keys\n"); 00486 } 00487 ast_mutex_lock(&keylock); 00488 key = keys; 00489 last = NULL; 00490 while(key) { 00491 nkey = key->next; 00492 if (key->delme) { 00493 ast_log(LOG_DEBUG, "Deleting key %s type %d\n", key->name, key->ktype); 00494 /* Do the delete */ 00495 if (last) 00496 last->next = nkey; 00497 else 00498 keys = nkey; 00499 if (key->rsa) 00500 RSA_free(key->rsa); 00501 free(key); 00502 } else 00503 last = key; 00504 key = nkey; 00505 } 00506 ast_mutex_unlock(&keylock); 00507 }
static int init_keys | ( | int | fd, | |
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 539 of file res_crypto.c.
References ast_config_AST_KEY_DIR, ast_copy_string(), ast_key::fn, KEY_NEEDS_PASSCODE, keys, ast_key::ktype, ast_key::next, RESULT_SUCCESS, and try_load_key().
00540 { 00541 struct ast_key *key; 00542 int ign; 00543 char *kn; 00544 char tmp[256] = ""; 00545 00546 key = keys; 00547 while(key) { 00548 /* Reload keys that need pass codes now */ 00549 if (key->ktype & KEY_NEEDS_PASSCODE) { 00550 kn = key->fn + strlen(ast_config_AST_KEY_DIR) + 1; 00551 ast_copy_string(tmp, kn, sizeof(tmp)); 00552 try_load_key((char *)ast_config_AST_KEY_DIR, tmp, fd, fd, &ign); 00553 } 00554 key = key->next; 00555 } 00556 return RESULT_SUCCESS; 00557 }
static int load_module | ( | void | ) | [static] |
Definition at line 610 of file res_crypto.c.
References ast_opt_init_keys, crypto_init(), and crypto_load().
00611 { 00612 crypto_init(); 00613 if (ast_opt_init_keys) 00614 crypto_load(STDIN_FILENO, STDOUT_FILENO); 00615 else 00616 crypto_load(-1, -1); 00617 return 0; 00618 }
static void md52sum | ( | char * | sum, | |
unsigned char * | md5 | |||
) | [static] |
Definition at line 509 of file res_crypto.c.
Referenced by show_keys().
00510 { 00511 int x; 00512 for (x=0;x<16;x++) 00513 sum += sprintf(sum, "%02x", *(md5++)); 00514 }
static int pw_cb | ( | char * | buf, | |
int | size, | |||
int | rwflag, | |||
void * | userdata | |||
) | [static] |
Definition at line 112 of file res_crypto.c.
References ast_hide_password(), AST_KEY_PRIVATE, ast_restore_tty(), ast_key::infd, ast_key::ktype, ast_key::name, and ast_key::outfd.
Referenced by try_load_key().
00113 { 00114 struct ast_key *key = (struct ast_key *)userdata; 00115 char prompt[256]; 00116 int res; 00117 int tmp; 00118 if (key->infd > -1) { 00119 snprintf(prompt, sizeof(prompt), ">>>> passcode for %s key '%s': ", 00120 key->ktype == AST_KEY_PRIVATE ? "PRIVATE" : "PUBLIC", key->name); 00121 if (write(key->outfd, prompt, strlen(prompt)) < 0) { 00122 /* Note that we were at least called */ 00123 key->infd = -2; 00124 return -1; 00125 } 00126 memset(buf, 0, sizeof(buf)); 00127 tmp = ast_hide_password(key->infd); 00128 memset(buf, 0, size); 00129 res = read(key->infd, buf, size); 00130 ast_restore_tty(key->infd, tmp); 00131 if (buf[strlen(buf) -1] == '\n') 00132 buf[strlen(buf) - 1] = '\0'; 00133 return strlen(buf); 00134 } else { 00135 /* Note that we were at least called */ 00136 key->infd = -2; 00137 } 00138 return -1; 00139 }
static int reload | ( | void | ) | [static] |
Definition at line 604 of file res_crypto.c.
References crypto_load().
00605 { 00606 crypto_load(-1, -1); 00607 return 0; 00608 }
static int show_keys | ( | int | fd, | |
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 516 of file res_crypto.c.
References ast_cli(), AST_KEY_PUBLIC, ast_mutex_lock(), ast_mutex_unlock(), ast_key::digest, KEY_NEEDS_PASSCODE, keylock, keys, ast_key::ktype, md52sum(), ast_key::name, ast_key::next, and RESULT_SUCCESS.
00517 { 00518 struct ast_key *key; 00519 char sum[16 * 2 + 1]; 00520 int count_keys = 0; 00521 00522 ast_mutex_lock(&keylock); 00523 key = keys; 00524 ast_cli(fd, "%-18s %-8s %-16s %-33s\n", "Key Name", "Type", "Status", "Sum"); 00525 while(key) { 00526 md52sum(sum, key->digest); 00527 ast_cli(fd, "%-18s %-8s %-16s %-33s\n", key->name, 00528 (key->ktype & 0xf) == AST_KEY_PUBLIC ? "PUBLIC" : "PRIVATE", 00529 key->ktype & KEY_NEEDS_PASSCODE ? "[Needs Passcode]" : "[Loaded]", sum); 00530 00531 key = key->next; 00532 count_keys++; 00533 } 00534 ast_mutex_unlock(&keylock); 00535 ast_cli(fd, "%d known RSA keys.\n", count_keys); 00536 return RESULT_SUCCESS; 00537 }
static struct ast_key* try_load_key | ( | char * | dir, | |
char * | fname, | |||
int | ifd, | |||
int | ofd, | |||
int * | not2 | |||
) | [static] |
Definition at line 156 of file res_crypto.c.
References ast_calloc, ast_copy_string(), AST_KEY_PRIVATE, AST_KEY_PUBLIC, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_opt_init_keys, ast_verbose(), ast_key::delme, ast_key::digest, errno, f, ast_key::fn, ast_key::infd, KEY_NEEDS_PASSCODE, keylock, keys, ast_key::ktype, LOG_DEBUG, LOG_NOTICE, LOG_WARNING, md5(), MD5Final(), MD5Init(), MD5Update(), ast_key::name, ast_key::next, option_debug, option_verbose, ast_key::outfd, pw_cb(), ast_key::rsa, and VERBOSE_PREFIX_3.
Referenced by crypto_load(), and init_keys().
00157 { 00158 int ktype = 0; 00159 char *c = NULL; 00160 char ffname[256]; 00161 unsigned char digest[16]; 00162 FILE *f; 00163 struct MD5Context md5; 00164 struct ast_key *key; 00165 static int notice = 0; 00166 int found = 0; 00167 00168 /* Make sure its name is a public or private key */ 00169 00170 if ((c = strstr(fname, ".pub")) && !strcmp(c, ".pub")) { 00171 ktype = AST_KEY_PUBLIC; 00172 } else if ((c = strstr(fname, ".key")) && !strcmp(c, ".key")) { 00173 ktype = AST_KEY_PRIVATE; 00174 } else 00175 return NULL; 00176 00177 /* Get actual filename */ 00178 snprintf(ffname, sizeof(ffname), "%s/%s", dir, fname); 00179 00180 ast_mutex_lock(&keylock); 00181 key = keys; 00182 while(key) { 00183 /* Look for an existing version already */ 00184 if (!strcasecmp(key->fn, ffname)) 00185 break; 00186 key = key->next; 00187 } 00188 ast_mutex_unlock(&keylock); 00189 00190 /* Open file */ 00191 f = fopen(ffname, "r"); 00192 if (!f) { 00193 ast_log(LOG_WARNING, "Unable to open key file %s: %s\n", ffname, strerror(errno)); 00194 return NULL; 00195 } 00196 MD5Init(&md5); 00197 while(!feof(f)) { 00198 /* Calculate a "whatever" quality md5sum of the key */ 00199 char buf[256]; 00200 memset(buf, 0, 256); 00201 if (fgets(buf, sizeof(buf), f)) { 00202 MD5Update(&md5, (unsigned char *) buf, strlen(buf)); 00203 } 00204 } 00205 MD5Final(digest, &md5); 00206 if (key) { 00207 /* If the MD5 sum is the same, and it isn't awaiting a passcode 00208 then this is far enough */ 00209 if (!memcmp(digest, key->digest, 16) && 00210 !(key->ktype & KEY_NEEDS_PASSCODE)) { 00211 fclose(f); 00212 key->delme = 0; 00213 return NULL; 00214 } else { 00215 /* Preserve keytype */ 00216 ktype = key->ktype; 00217 /* Recycle the same structure */ 00218 found++; 00219 } 00220 } 00221 00222 /* Make fname just be the normal name now */ 00223 *c = '\0'; 00224 if (!key) { 00225 if (!(key = ast_calloc(1, sizeof(*key)))) { 00226 fclose(f); 00227 return NULL; 00228 } 00229 } 00230 /* At this point we have a key structure (old or new). Time to 00231 fill it with what we know */ 00232 /* Gotta lock if this one already exists */ 00233 if (found) 00234 ast_mutex_lock(&keylock); 00235 /* First the filename */ 00236 ast_copy_string(key->fn, ffname, sizeof(key->fn)); 00237 /* Then the name */ 00238 ast_copy_string(key->name, fname, sizeof(key->name)); 00239 key->ktype = ktype; 00240 /* Yes, assume we're going to be deleted */ 00241 key->delme = 1; 00242 /* Keep the key type */ 00243 memcpy(key->digest, digest, 16); 00244 /* Can I/O takes the FD we're given */ 00245 key->infd = ifd; 00246 key->outfd = ofd; 00247 /* Reset the file back to the beginning */ 00248 rewind(f); 00249 /* Now load the key with the right method */ 00250 if (ktype == AST_KEY_PUBLIC) 00251 key->rsa = PEM_read_RSA_PUBKEY(f, NULL, pw_cb, key); 00252 else 00253 key->rsa = PEM_read_RSAPrivateKey(f, NULL, pw_cb, key); 00254 fclose(f); 00255 if (key->rsa) { 00256 if (RSA_size(key->rsa) == 128) { 00257 /* Key loaded okay */ 00258 key->ktype &= ~KEY_NEEDS_PASSCODE; 00259 if (option_verbose > 2) 00260 ast_verbose(VERBOSE_PREFIX_3 "Loaded %s key '%s'\n", key->ktype == AST_KEY_PUBLIC ? "PUBLIC" : "PRIVATE", key->name); 00261 if (option_debug) 00262 ast_log(LOG_DEBUG, "Key '%s' loaded OK\n", key->name); 00263 key->delme = 0; 00264 } else 00265 ast_log(LOG_NOTICE, "Key '%s' is not expected size.\n", key->name); 00266 } else if (key->infd != -2) { 00267 ast_log(LOG_WARNING, "Key load %s '%s' failed\n",key->ktype == AST_KEY_PUBLIC ? "PUBLIC" : "PRIVATE", key->name); 00268 if (ofd > -1) { 00269 ERR_print_errors_fp(stderr); 00270 } else 00271 ERR_print_errors_fp(stderr); 00272 } else { 00273 ast_log(LOG_NOTICE, "Key '%s' needs passcode.\n", key->name); 00274 key->ktype |= KEY_NEEDS_PASSCODE; 00275 if (!notice) { 00276 if (!ast_opt_init_keys) 00277 ast_log(LOG_NOTICE, "Add the '-i' flag to the asterisk command line if you want to automatically initialize passcodes at launch.\n"); 00278 notice++; 00279 } 00280 /* Keep it anyway */ 00281 key->delme = 0; 00282 /* Print final notice about "init keys" when done */ 00283 *not2 = 1; 00284 } 00285 if (found) 00286 ast_mutex_unlock(&keylock); 00287 if (!found) { 00288 ast_mutex_lock(&keylock); 00289 key->next = keys; 00290 keys = key; 00291 ast_mutex_unlock(&keylock); 00292 } 00293 return key; 00294 }
static int unload_module | ( | void | ) | [static] |
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_BUILDSUM, .description = "Cryptographic Digital Signatures" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "f450f61f60e761b3aa089ebed76ca8a5" , .load = load_module, .unload = unload_module, .reload = reload } [static] |
Definition at line 631 of file res_crypto.c.
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 631 of file res_crypto.c.
struct ast_cli_entry cli_crypto[] [static] |
struct ast_cli_entry cli_init_keys_deprecated [static] |
Initial value:
{ { "init", "keys", NULL }, init_keys, NULL, NULL }
Definition at line 572 of file res_crypto.c.
struct ast_cli_entry cli_show_keys_deprecated [static] |
Initial value:
{ { "show", "keys", NULL }, show_keys, NULL, NULL }
Definition at line 567 of file res_crypto.c.
char init_keys_usage[] [static] |
Initial value:
"Usage: keys init\n" " Initializes private keys (by reading in pass code from the user)\n"
Definition at line 563 of file res_crypto.c.
ast_mutex_t keylock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) [static] |
Definition at line 79 of file res_crypto.c.
Referenced by __ast_key_get(), crypto_load(), show_keys(), and try_load_key().
Definition at line 103 of file res_crypto.c.
Referenced by __ast_key_get(), adsi_delete(), adsi_folders(), adsi_login(), adsi_message(), adsi_password(), adsi_status(), adsi_status2(), ast_db_deltree(), ast_db_gettree(), check_auth(), crypto_load(), database_show(), database_showkey(), init_keys(), misdn_set_opt_exec(), reply_digest(), show_keys(), transmit_fake_auth_response(), and try_load_key().
char show_key_usage[] [static] |
Initial value:
"Usage: keys show\n" " Displays information about RSA keys known by Asterisk\n"
Definition at line 559 of file res_crypto.c.