mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
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
This commit is contained in:
21
utils.c
21
utils.c
@@ -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;
|
||||
|
Reference in New Issue
Block a user