src/server/util/hashing.h

changeset 589
70ad04769cbf
parent 587
c94800af0490
child 594
36a46311e0f6
--- a/src/server/util/hashing.h	Wed May 28 21:15:49 2025 +0200
+++ b/src/server/util/hashing.h	Thu May 29 15:17:01 2025 +0200
@@ -31,6 +31,7 @@
 
 #define WS_SHA1_DIGEST_LENGTH 20
 #define WS_SHA256_DIGEST_LENGTH 32
+#define WS_SHA512_DIGEST_LENGTH 32
 
 #ifdef __APPLE__
 /* macos */
@@ -39,7 +40,8 @@
 
 #define WS_AES_CTX              CCCryptorRef
 #define WS_SHA1_CTX             CC_SHA1_CTX
-#define WS_SHA_CTX              CC_SHA256_CTX
+#define WS_SHA256_CTX           CC_SHA256_CTX
+#define WS_SHA512_CTX           CC_SHA512_CTX
 
 #include <CommonCrypto/CommonCrypto.h>
 #include <CommonCrypto/CommonDigest.h>
@@ -70,6 +72,7 @@
 #define WS_AES_CTX              WinBCryptCTX
 #define WS_SHA1_CTX             WinBCryptSHACTX
 #define WS_SHA256_CTX           WinBCryptSHACTX
+#define WS_SHA512_CTX           WinBCryptSHACTX
 
 #else
 /* unix/linux */
@@ -82,9 +85,11 @@
 #if OPENSSL_VERSION_NUMBER < 0x30000000L
 #define WS_SHA256_CTX           SHA1_CTX
 #define WS_SHA256_CTX           SHA256_CTX
+#define WS_SHA512_CTX           SHA512_CTX
 #else
 #define WS_SHA1_CTX             EVP_MD_CTX*
 #define WS_SHA256_CTX           EVP_MD_CTX*
+#define WS_SHA512_CTX           EVP_MD_CTX*
 #endif
 
 
@@ -97,6 +102,10 @@
 #define SHA256_Init     SHA256Init
 #define SHA256_Update   SHA256Update
 #define SHA256_Final    SHA256Final
+
+#define SHA512_Init     SHA512Init
+#define SHA512_Update   SHA512Update
+#define SHA512_Final    SHA512Final
 #else
 #include <openssl/sha.h>
 #endif
@@ -113,6 +122,11 @@
 void ws_sha256_update(WS_SHA256_CTX *ctx, const char *data, size_t len);
 void ws_sha256_final(WS_SHA256_CTX *ctx, unsigned char *buf);
 
+int ws_sha512_init(WS_SHA512_CTX *ctx);
+WS_SHA512_CTX* ws_sha512_create(void);
+void ws_sha512_update(WS_SHA512_CTX *ctx, const char *data, size_t len);
+void ws_sha512_final(WS_SHA512_CTX *ctx, unsigned char *buf);
+
 
 #ifdef __cplusplus
 }

mercurial