mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
mbedtls: adapt to deprecated api in 2.7
This commit is contained in:
parent
4c299ad4a8
commit
36620a2ffe
1 changed files with 19 additions and 9 deletions
|
@ -23,6 +23,16 @@
|
|||
*/
|
||||
#include "libwebsockets.h"
|
||||
|
||||
#if defined(LWS_WITH_MBEDTLS)
|
||||
#include <mbedtls/version.h>
|
||||
|
||||
#if (MBEDTLS_VERSION_NUMBER >= 0x02070000)
|
||||
#define MBA(fn) fn##_ret
|
||||
#else
|
||||
#define MBA(fn) fn
|
||||
#endif
|
||||
#endif
|
||||
|
||||
size_t
|
||||
lws_genhash_size(int type)
|
||||
{
|
||||
|
@ -47,15 +57,15 @@ lws_genhash_init(struct lws_genhash_ctx *ctx, int type)
|
|||
switch (ctx->type) {
|
||||
case LWS_GENHASH_TYPE_SHA1:
|
||||
mbedtls_sha1_init(&ctx->u.sha1);
|
||||
mbedtls_sha1_starts(&ctx->u.sha1);
|
||||
MBA(mbedtls_sha1_starts)(&ctx->u.sha1);
|
||||
break;
|
||||
case LWS_GENHASH_TYPE_SHA256:
|
||||
mbedtls_sha256_init(&ctx->u.sha256);
|
||||
mbedtls_sha256_starts(&ctx->u.sha256, 0);
|
||||
MBA(mbedtls_sha256_starts)(&ctx->u.sha256, 0);
|
||||
break;
|
||||
case LWS_GENHASH_TYPE_SHA512:
|
||||
mbedtls_sha512_init(&ctx->u.sha512);
|
||||
mbedtls_sha512_starts(&ctx->u.sha512, 0);
|
||||
MBA(mbedtls_sha512_starts)(&ctx->u.sha512, 0);
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
|
@ -95,13 +105,13 @@ lws_genhash_update(struct lws_genhash_ctx *ctx, const void *in, size_t len)
|
|||
#if defined(LWS_WITH_MBEDTLS)
|
||||
switch (ctx->type) {
|
||||
case LWS_GENHASH_TYPE_SHA1:
|
||||
mbedtls_sha1_update(&ctx->u.sha1, in, len);
|
||||
MBA(mbedtls_sha1_update)(&ctx->u.sha1, in, len);
|
||||
break;
|
||||
case LWS_GENHASH_TYPE_SHA256:
|
||||
mbedtls_sha256_update(&ctx->u.sha256, in, len);
|
||||
MBA(mbedtls_sha256_update)(&ctx->u.sha256, in, len);
|
||||
break;
|
||||
case LWS_GENHASH_TYPE_SHA512:
|
||||
mbedtls_sha512_update(&ctx->u.sha512, in, len);
|
||||
MBA(mbedtls_sha512_update)(&ctx->u.sha512, in, len);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
|
@ -117,15 +127,15 @@ lws_genhash_destroy(struct lws_genhash_ctx *ctx, void *result)
|
|||
#if defined(LWS_WITH_MBEDTLS)
|
||||
switch (ctx->type) {
|
||||
case LWS_GENHASH_TYPE_SHA1:
|
||||
mbedtls_sha1_finish(&ctx->u.sha1, result);
|
||||
MBA(mbedtls_sha1_finish)(&ctx->u.sha1, result);
|
||||
mbedtls_sha1_free(&ctx->u.sha1);
|
||||
break;
|
||||
case LWS_GENHASH_TYPE_SHA256:
|
||||
mbedtls_sha256_finish(&ctx->u.sha256, result);
|
||||
MBA(mbedtls_sha256_finish)(&ctx->u.sha256, result);
|
||||
mbedtls_sha256_free(&ctx->u.sha256);
|
||||
break;
|
||||
case LWS_GENHASH_TYPE_SHA512:
|
||||
mbedtls_sha512_finish(&ctx->u.sha512, result);
|
||||
MBA(mbedtls_sha512_finish)(&ctx->u.sha512, result);
|
||||
mbedtls_sha512_free(&ctx->u.sha512);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue