Browse Source

[mod_auth] use SHA1_Init,Update,Final

wolfSSL does not provide the SHA1() convenience function,
so use stepwise funcs SHA1_Init(), SHA1_Update(), SHA1_Final()
personal/stbuehler/fix-fdevent
Glenn Strauss 3 years ago
parent
commit
e9f223d35e
  1. 8
      src/algo_sha1.c
  2. 4
      src/algo_sha1.h
  3. 5
      src/mod_authn_file.c

8
src/algo_sha1.c

@ -170,12 +170,4 @@ void SHA1_Final(sha1_byte digest[SHA1_DIGEST_LENGTH], SHA_CTX *context) {
memset(&finalcount, 0, 8);
}
unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md) {
SHA_CTX ctx;
SHA1_Init(&ctx);
SHA1_Update(&ctx, d, (unsigned int)n);
SHA1_Final(md, &ctx);
return md;
}
#endif

4
src/algo_sha1.h

@ -67,14 +67,10 @@ typedef struct _SHA_CTX {
void SHA1_Init(SHA_CTX *context);
void SHA1_Update(SHA_CTX *context, const sha1_byte *data, unsigned int len);
void SHA1_Final(sha1_byte digest[SHA1_DIGEST_LENGTH], SHA_CTX *context);
/*(added for lighttpd)*/
unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);
#else
void SHA1_Init();
void SHA1_Update();
void SHA1_Final();
/*(added for lighttpd)*/
unsigned char *SHA1();
#endif
#ifdef __cplusplus

5
src/mod_authn_file.c

@ -595,8 +595,11 @@ static void apr_md5_encode(const char *pw, const char *salt, char *result, size_
static void apr_sha_encode(const char *pw, char *result, size_t nbytes) {
unsigned char digest[20];
size_t base64_written;
SHA_CTX sha1;
SHA1((const unsigned char*) pw, strlen(pw), digest);
SHA1_Init(&sha1);
SHA1_Update(&sha1, (const unsigned char *) pw, strlen(pw));
SHA1_Final(digest, &sha1);
memset(result, 0, nbytes);

Loading…
Cancel
Save