aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-10-16 03:08:58 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-10-16 03:08:58 +0000
commit53996e84464de3aa908053e9a480e238b11b86e5 (patch)
treedd9324a8de3f54f72ab9c785deed1bfaf6a8244b /res
parente62d1e4e3353d38d85e2d4fcc98648b540890081 (diff)
Make crypto loading optional
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6797 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rwxr-xr-xres/res_crypto.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/res/res_crypto.c b/res/res_crypto.c
index 8c5eb51b1..006238c2d 100755
--- a/res/res_crypto.c
+++ b/res/res_crypto.c
@@ -129,7 +129,7 @@ static int pw_cb(char *buf, int size, int rwflag, void *userdata)
return -1;
}
-struct ast_key *ast_key_get(char *kname, int ktype)
+static struct ast_key *__ast_key_get(const char *kname, int ktype)
{
struct ast_key *key;
ast_mutex_lock(&keylock);
@@ -314,7 +314,7 @@ static char *binary(int y, int len)
#endif
-int ast_sign_bin(struct ast_key *key, char *msg, int msglen, unsigned char *dsig)
+static int __ast_sign_bin(struct ast_key *key, const char *msg, int msglen, unsigned char *dsig)
{
unsigned char digest[20];
unsigned int siglen = 128;
@@ -345,7 +345,7 @@ int ast_sign_bin(struct ast_key *key, char *msg, int msglen, unsigned char *dsig
}
-extern int ast_decrypt_bin(unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key)
+static int __ast_decrypt_bin(unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key)
{
int res;
int pos = 0;
@@ -371,7 +371,7 @@ extern int ast_decrypt_bin(unsigned char *dst, const unsigned char *src, int src
return pos;
}
-extern int ast_encrypt_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)
{
int res;
int bytes;
@@ -399,7 +399,7 @@ extern int ast_encrypt_bin(unsigned char *dst, const unsigned char *src, int src
return pos;
}
-int ast_sign(struct ast_key *key, char *msg, char *sig)
+static int __ast_sign(struct ast_key *key, char *msg, char *sig)
{
unsigned char dsig[128];
int siglen = sizeof(dsig);
@@ -412,7 +412,7 @@ int ast_sign(struct ast_key *key, char *msg, char *sig)
}
-int ast_check_signature_bin(struct ast_key *key, char *msg, int msglen, unsigned char *dsig)
+static int __ast_check_signature_bin(struct ast_key *key, const char *msg, int msglen, const unsigned char *dsig)
{
unsigned char digest[20];
int res;
@@ -428,7 +428,7 @@ int ast_check_signature_bin(struct ast_key *key, char *msg, int msglen, unsigned
SHA1((unsigned char *)msg, msglen, digest);
/* Verify signature */
- res = RSA_verify(NID_sha1, digest, sizeof(digest), dsig, 128, key->rsa);
+ res = RSA_verify(NID_sha1, digest, sizeof(digest), (unsigned char *)dsig, 128, key->rsa);
if (!res) {
ast_log(LOG_DEBUG, "Key failed verification: %s\n", key->name);
@@ -438,7 +438,7 @@ int ast_check_signature_bin(struct ast_key *key, char *msg, int msglen, unsigned
return 0;
}
-int ast_check_signature(struct ast_key *key, char *msg, char *sig)
+static int __ast_check_signature(struct ast_key *key, const char *msg, const char *sig)
{
unsigned char dsig[128];
int res;
@@ -571,6 +571,15 @@ static int crypto_init(void)
ERR_load_crypto_strings();
ast_cli_register(&cli_show_keys);
ast_cli_register(&cli_init_keys);
+
+ /* Install ourselves into stubs */
+ ast_key_get = __ast_key_get;
+ ast_check_signature = __ast_check_signature;
+ ast_check_signature_bin = __ast_check_signature_bin;
+ ast_sign = __ast_sign;
+ ast_sign_bin = __ast_sign_bin;
+ ast_encrypt_bin = __ast_encrypt_bin;
+ ast_decrypt_bin = __ast_decrypt_bin;
return 0;
}