Commit e7029870 authored by jan.koester's avatar jan.koester
Browse files

test

parent fcf4fdb5
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -3432,8 +3432,11 @@ namespace netplus {
        }

        // GCM record payload: explicit_nonce(8) + ciphertext + tag(16)
        if (payload.size() < 8 + 16)
            throwSSL(NetException::Error, "GCM record too short");
        if (payload.size() < 8 + 16) {
            NetException e;
            e[NetException::Error] << "tls: GCM record too short";
            throw e;
        }

        const uint8_t* explicit_nonce = payload.data();
        size_t ct_len = payload.size() - 8 - 16;
@@ -3459,8 +3462,11 @@ namespace netplus {
        uint8_t tag_copy[16];
        std::memcpy(tag_copy, tag, 16);

        if (!aes_recv->aes_gcm_decrypt(nonce, aad, 13, ct, ct_len, tag_copy, plaintext.data()))
            throwSSL(NetException::Error, "GCM tag verification failed");
        if (!aes_recv->aes_gcm_decrypt(nonce, aad, 13, ct, ct_len, tag_copy, plaintext.data())) {
            NetException e;
            e[NetException::Error] << "tls: GCM tag verification failed";
            throw e;
        }

        recv_seq++;
        return plaintext;
@@ -3491,7 +3497,9 @@ namespace netplus {
        const uint16_t ver = 0x0303;

        if (!aes) {
            throwSSL(NetException::Error, "sendTLS12RecordGCM: AES cipher not initialized");
            NetException e;
            e[NetException::Error] << "tls: sendTLS12RecordGCM: AES cipher not initialized";
            throw e;
        }

        // Build nonce: implicit_iv(4) || explicit_nonce(8) = 12 bytes