From 6ff8bb11774c51fd341b7699a3938fd894995fbf Mon Sep 17 00:00:00 2001 From: vnugent Date: Thu, 25 Apr 2024 17:45:42 -0400 Subject: refactor: Finish support and testing for mbedtls --- src/noscrypt.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/noscrypt.c') diff --git a/src/noscrypt.c b/src/noscrypt.c index 00684b8..fac3dfb 100644 --- a/src/noscrypt.c +++ b/src/noscrypt.c @@ -21,10 +21,10 @@ #include "noscrypt.h" #include "nc-util.h" -#include "crypto/nc-crypto.h" +#include "nc-crypto.h" -#include -#include +#include +#include /* * Local macro for secure zero buffer fill @@ -768,19 +768,30 @@ NC_EXPORT NCResult NC_CC NCEncrypt( CHECK_INVALID_ARG(args->hmacKeyOut32, 3) CHECK_ARG_RANGE(args->dataSize, NIP44_MIN_ENC_MESSAGE_SIZE, NIP44_MAX_ENC_MESSAGE_SIZE, 3) + switch(args->version) + { + case NC_ENC_VERSION_NIP44: + break; /* Allow nip44 */ + + /* At the moment nip04 compatability is not supported */ + case NC_ENC_VERSION_NIP04: + default: + return E_VERSION_NOT_SUPPORTED; + } + /* Compute the shared point */ if ((result = _computeSharedSecret(ctx, sk, pk, &sharedSecret)) != NC_SUCCESS) { goto Cleanup; } - + /* Compute the conversation key from secret and pubkic keys */ if ((result = _computeConversationKey(ctx, &sharedSecret, &conversationKey)) != NC_SUCCESS) { goto Cleanup; } - result = _encryptEx(ctx, &conversationKey, args->hmacKeyOut32, args); + result = _encryptEx(ctx, &conversationKey, args->hmacKeyOut32, args); Cleanup: /* Clean up sensitive data */ -- cgit