diff options
author | Tilghman Lesher <tilghman@meg.abyt.es> | 2006-02-03 22:37:29 +0000 |
---|---|---|
committer | Tilghman Lesher <tilghman@meg.abyt.es> | 2006-02-03 22:37:29 +0000 |
commit | 34bcd0e0b65aef5a30b1b87a1e934a22757f1e5a (patch) | |
tree | 7ee7bba9af76d6bbba703f9f46349e75ac245ab6 /utils.c | |
parent | 193b923925caabbf9d2dcc989f8e2b90e8ed82e1 (diff) |
Bug 6322 - Implementation of SHA1 in Asterisk (plus dialplan function to use it)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@9138 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'utils.c')
-rw-r--r-- | utils.c | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -43,6 +43,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/io.h" #include "asterisk/logger.h" #include "asterisk/md5.h" +#include "asterisk/sha1.h" #include "asterisk/options.h" #include "asterisk/compat.h" @@ -281,7 +282,7 @@ int test_for_thread_safety(void) return(test_errors); /* return 0 on success. */ } -/*! \brief ast_md5_hash: Produce 16 char MD5 hash of value. ---*/ +/*! \brief ast_md5_hash: Produce 32 char MD5 hash of value. ---*/ void ast_md5_hash(char *output, char *input) { struct MD5Context md5; @@ -297,6 +298,24 @@ void ast_md5_hash(char *output, char *input) ptr += sprintf(ptr, "%2.2x", digest[x]); } +/*! \brief ast_sha1_hash: Produce 40 char SHA1 hash of value. ---*/ +void ast_sha1_hash(char *output, char *input) +{ + struct SHA1Context sha; + char *ptr; + int x; + uint8_t Message_Digest[20]; + + SHA1Reset(&sha); + + SHA1Input(&sha, (const unsigned char *) input, strlen(input)); + + SHA1Result(&sha, Message_Digest); + ptr = output; + for (x = 0; x < 20; x++) + ptr += sprintf(ptr, "%2.2x", Message_Digest[x]); +} + int ast_base64decode(unsigned char *dst, const char *src, int max) { int cnt = 0; |