]> granicus.if.org Git - libevent/commitdiff
Fix conflict with SHA1 function from openssl
authorDmitry Ilyin <dima@doty.ru>
Wed, 14 Sep 2022 10:33:13 +0000 (13:33 +0300)
committerAzat Khuzhin <a3at.mail@gmail.com>
Wed, 14 Sep 2022 20:10:55 +0000 (23:10 +0300)
sha1.c
sha1.h
ws.c

diff --git a/sha1.c b/sha1.c
index 33ca1dfbe2dd6f9b80b0632b57604c044a2d77b3..da159ab79ebb8fae0a48eb92a08f213137daa4c8 100644 (file)
--- a/sha1.c
+++ b/sha1.c
@@ -60,9 +60,18 @@ A million repetitions of "a"
     z += (w ^ x ^ y) + blk(i) + 0xCA62C1D6 + rol(v, 5);                        \
     w = rol(w, 30);
 
+static void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
+
+static void SHA1Init(SHA1_CTX *context);
+
+static void SHA1Update(SHA1_CTX *context, const unsigned char *data, uint32_t len);
+
+static void SHA1Final(unsigned char digest[20], SHA1_CTX *context);
+
+
 /* Hash a single 512-bit block. This is the core of the algorithm. */
 
-void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]) {
+static void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]) {
     uint32_t a, b, c, d, e;
 
     typedef union {
@@ -184,7 +193,7 @@ void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]) {
 
 /* SHA1Init - Initialize new context */
 
-void SHA1Init(SHA1_CTX *context) {
+static void SHA1Init(SHA1_CTX *context) {
     /* SHA1 initialization constants */
     context->state[0] = 0x67452301;
     context->state[1] = 0xEFCDAB89;
@@ -196,7 +205,7 @@ void SHA1Init(SHA1_CTX *context) {
 
 /* Run your data through this. */
 
-void SHA1Update(SHA1_CTX *context, const unsigned char *data, uint32_t len) {
+static void SHA1Update(SHA1_CTX *context, const unsigned char *data, uint32_t len) {
     uint32_t i;
 
     uint32_t j;
@@ -220,7 +229,7 @@ void SHA1Update(SHA1_CTX *context, const unsigned char *data, uint32_t len) {
 
 /* Add padding and return the message digest. */
 
-void SHA1Final(unsigned char digest[20], SHA1_CTX *context) {
+static void SHA1Final(unsigned char digest[20], SHA1_CTX *context) {
     unsigned i;
 
     unsigned char finalcount[8];
@@ -267,7 +276,7 @@ void SHA1Final(unsigned char digest[20], SHA1_CTX *context) {
     memset(&finalcount, '\0', sizeof(finalcount));
 }
 
-void SHA1(char *hash_out, const char *str, int len) {
+void builtin_SHA1(char *hash_out, const char *str, int len) {
     SHA1_CTX ctx;
     int ii;
 
diff --git a/sha1.h b/sha1.h
index 1accbc779fcf88f678843852da83f7b3f06d4311..2e7469cd2ea1303310deb7b3fd4318d63303f6fe 100644 (file)
--- a/sha1.h
+++ b/sha1.h
@@ -15,14 +15,6 @@ typedef struct {
     unsigned char buffer[64];
 } SHA1_CTX;
 
-void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
-
-void SHA1Init(SHA1_CTX *context);
-
-void SHA1Update(SHA1_CTX *context, const unsigned char *data, uint32_t len);
-
-void SHA1Final(unsigned char digest[20], SHA1_CTX *context);
-
-void SHA1(char *hash_out, const char *str, int len);
+void builtin_SHA1(char *hash_out, const char *str, int len);
 
 #endif /* SHA1_H */
diff --git a/ws.c b/ws.c
index fa8891565b5aa6b18fe2e097fca23a7ef489c581..8c9314daa2d157ed6fb39d38923ee7ea24cd0082 100644 (file)
--- a/ws.c
+++ b/ws.c
@@ -140,7 +140,7 @@ ws_gen_accept_key(const char *ws_key, char out[32])
 
        snprintf(buf, sizeof(buf), "%s" WS_UUID, ws_key);
 
-       SHA1(digest, buf, strlen(buf));
+       builtin_SHA1(digest, buf, strlen(buf));
        Base64encode(out, digest, sizeof(digest));
        return out;
 }