diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-08-14 21:28:30 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-08-14 21:28:30 +0000 |
commit | 0be30f736da175c984323e545f26a71aa9d07e89 (patch) | |
tree | fae4e2dc3e578b3c5fcdc795b43080c895067948 /res | |
parent | 37c8c59ba52b2024374715f9853a90e5bb100ed3 (diff) |
Oops, forgot message length
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3608 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rwxr-xr-x | res/res_crypto.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/res/res_crypto.c b/res/res_crypto.c index 87339f292..205a8c5ce 100755 --- a/res/res_crypto.c +++ b/res/res_crypto.c @@ -296,7 +296,7 @@ static char *binary(int y, int len) #endif -int ast_sign_bin(struct ast_key *key, char *msg, unsigned char *dsig) +int ast_sign_bin(struct ast_key *key, char *msg, int msglen, unsigned char *dsig) { unsigned char digest[20]; int siglen = sizeof(dsig); @@ -308,7 +308,7 @@ int ast_sign_bin(struct ast_key *key, char *msg, unsigned char *dsig) } /* Calculate digest of message */ - SHA1((unsigned char *)msg, strlen(msg), digest); + SHA1((unsigned char *)msg, msglen, digest); /* Verify signature */ res = RSA_sign(NID_sha1, digest, sizeof(digest), dsig, &siglen, key->rsa); @@ -332,7 +332,7 @@ int ast_sign(struct ast_key *key, char *msg, char *sig) unsigned char dsig[128]; int siglen = sizeof(dsig); int res; - res = ast_sign_bin(key, msg, dsig); + res = ast_sign_bin(key, msg, strlen(msg), dsig); if (!res) /* Success -- encode (256 bytes max as documented) */ ast_base64encode(sig, dsig, siglen, 256); @@ -340,7 +340,7 @@ int ast_sign(struct ast_key *key, char *msg, char *sig) } -int ast_check_signature_bin(struct ast_key *key, char *msg, unsigned char *dsig) +int ast_check_signature_bin(struct ast_key *key, char *msg, int msglen, unsigned char *dsig) { unsigned char digest[20]; int res; @@ -353,7 +353,7 @@ int ast_check_signature_bin(struct ast_key *key, char *msg, unsigned char *dsig) } /* Calculate digest of message */ - SHA1((unsigned char *)msg, strlen(msg), digest); + SHA1((unsigned char *)msg, msglen, digest); /* Verify signature */ res = RSA_verify(NID_sha1, digest, sizeof(digest), dsig, sizeof(dsig), key->rsa); @@ -377,7 +377,7 @@ int ast_check_signature(struct ast_key *key, char *msg, char *sig) ast_log(LOG_WARNING, "Signature improper length (expect %d, got %d)\n", (int)sizeof(dsig), (int)res); return -1; } - res = ast_check_signature_bin(key, msg, dsig); + res = ast_check_signature_bin(key, msg, strlen(msg), dsig); return res; } |