mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-30 13:13:44 +00:00
Fix #1908
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sodium.h>
|
||||
#include <mbedtls/version.h>
|
||||
#include <mbedtls/md5.h>
|
||||
|
||||
#include "base64.h"
|
||||
@@ -102,7 +103,19 @@ crypto_md5(const unsigned char *d, size_t n, unsigned char *md)
|
||||
if (md == NULL) {
|
||||
md = m;
|
||||
}
|
||||
#if MBEDTLS_VERSION_NUMBER >= 0x02070000
|
||||
mbedtls_md5_context md5;
|
||||
mbedtls_md5_init(&md5);
|
||||
if (mbedtls_md5_starts_ret(&md5) != 0)
|
||||
FATAL("Failed to initialize MD5 context");
|
||||
if (mbedtls_md5_update_ret(&md5, d, n) != 0)
|
||||
FATAL("Failed to update MD5 sum");
|
||||
if (mbedtls_md5_finish_ret(&md5, md) != 0)
|
||||
FATAL("Failed to generate MD5 hash");
|
||||
mbedtls_md5_free(&md5);
|
||||
#else
|
||||
mbedtls_md5(d, n, md);
|
||||
#endif
|
||||
return md;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user