Bug fix in extended armor.

This commit is contained in:
Adam Ierymenko 2024-09-26 20:13:10 -04:00
parent 96ba1079b2
commit 1e679cc94d
No known key found for this signature in database
GPG Key ID: C8877CF2D7A5D7F3
4 changed files with 6 additions and 3 deletions

View File

@ -10,8 +10,7 @@
* of this software will be governed by version 2.0 of the Apache License.
*/
#include <prometheus/histogram.h>
#include <prometheus/simpleapi.h>
#include "Metrics.hpp"
namespace prometheus {
namespace simpleapi {

View File

@ -12,6 +12,7 @@
#ifndef METRICS_H_
#define METRICS_H_
#include <prometheus/gauge.h>
#include <prometheus/histogram.h>
#include <prometheus/simpleapi.h>

View File

@ -1162,6 +1162,7 @@ void Packet::armor(const void* key, bool encryptPayload, bool extendedArmor, con
AES::CTR aesCtr(cipher);
aesCtr.init(data, 0, data + ZT_PACKET_IDX_EXTENDED_ARMOR_START);
aesCtr.crypt(data + ZT_PACKET_IDX_EXTENDED_ARMOR_START, size() - ZT_PACKET_IDX_EXTENDED_ARMOR_START);
aesCtr.finish();
this->append(ephemeralKeyPair.pub.data, ZT_ECC_EPHEMERAL_PUBLIC_KEY_LEN);
}
@ -1184,7 +1185,8 @@ bool Packet::dearmor(const void* key, const AES aesKeys[2], const Identity& iden
AES cipher(ephemeralSymmetric);
AES::CTR aesCtr(cipher);
aesCtr.init(data, 0, data + ZT_PACKET_IDX_EXTENDED_ARMOR_START);
aesCtr.crypt(data + ZT_PACKET_IDX_EXTENDED_ARMOR_START, size() - ZT_PACKET_IDX_EXTENDED_ARMOR_START);
aesCtr.crypt(data + ZT_PACKET_IDX_EXTENDED_ARMOR_START, (size() - ZT_PACKET_IDX_EXTENDED_ARMOR_START) - ZT_ECC_EPHEMERAL_PUBLIC_KEY_LEN);
aesCtr.finish();
this->setSize(size() - ZT_ECC_EPHEMERAL_PUBLIC_KEY_LEN);

View File

@ -25,6 +25,7 @@
#include "Switch.hpp"
#include "Trace.hpp"
#include "Utils.hpp"
#include "Switch.hpp"
namespace ZeroTier {