aboutsummaryrefslogtreecommitdiffstats
path: root/utils.c
diff options
context:
space:
mode:
authordvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2009-09-03 16:57:35 +0000
committerdvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2009-09-03 16:57:35 +0000
commitd27c458125a3412ca561ec38f6415588c9a9cdaa (patch)
treeba1b5449db44a3b9e545a2ad13d9ac2bbe5c3822 /utils.c
parent18edad800c797bc030a8d53e86b925d85f5e49b4 (diff)
Merge code associated with AST-2009-006
(closes issue #12912) Reported by: rathaus Tested by: tilghman, russell, dvossel, dbrooks git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@215958 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index 7dc020c83..a284a937d 100644
--- a/utils.c
+++ b/utils.c
@@ -45,6 +45,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"
@@ -297,6 +298,24 @@ void ast_md5_hash(char *output, char *input)
ptr += sprintf(ptr, "%2.2x", digest[x]);
}
+/*! \brief 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;