From 9a4a8a10f2d6b31c59a35b8e9507c38918b06ae9 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Sun, 14 Jul 2024 21:31:17 +0200 Subject: [PATCH] Corrected RSA block size --- lib/CloudConnector/src/CloudConnector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/CloudConnector/src/CloudConnector.cpp b/lib/CloudConnector/src/CloudConnector.cpp index 19e897d2..7c0ead9f 100644 --- a/lib/CloudConnector/src/CloudConnector.cpp +++ b/lib/CloudConnector/src/CloudConnector.cpp @@ -419,7 +419,7 @@ void CloudConnector::update(AmsData& data, EnergyAccounting& ea) { } memset(encryptedBuffer, 0, rsa->len); - int maxlen = rsa->len - 42; + int maxlen = rsa->len - 11; // 11 should be the correct padding size for PKCS1 udp.beginPacket(config.hostname,7443); for(int i = 0; i < pos; i += maxlen) { int ret = mbedtls_rsa_pkcs1_encrypt(rsa, mbedtls_ctr_drbg_random, &ctr_drbg, MBEDTLS_RSA_PUBLIC, maxlen, (unsigned char*) (clearBuffer+i), encryptedBuffer);