aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/src
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2020-03-11 13:42:39 +0000
committerGerrit Code Review <gerrit@fd.io>2020-03-11 13:42:39 +0000
commit0e9fe18eac5ca679dcec2346e42e7fb638acbeee (patch)
tree1f1c65188d2690a15bdb51d1dbe1f6ede676dc57 /libtransport/src
parent642ac16179e8a041f37d749f5bf72512f76fcfae (diff)
parentc564dd5c456de2d27b43cb3888d998e814abba57 (diff)
Merge "[HICN-546] Fix memory leak on producer side"
Diffstat (limited to 'libtransport/src')
-rw-r--r--libtransport/src/security/signer.cc4
-rw-r--r--libtransport/src/security/verifier.cc16
2 files changed, 7 insertions, 13 deletions
diff --git a/libtransport/src/security/signer.cc b/libtransport/src/security/signer.cc
index 314c3ea82..8a56cfa3d 100644
--- a/libtransport/src/security/signer.cc
+++ b/libtransport/src/security/signer.cc
@@ -162,12 +162,10 @@ void Signer::sign(Packet &packet) {
}
CryptoHash hash = hasher.finalize();
-
signature_ = parcSigner_SignDigestNoAlloc(this->signer_, hash.hash_,
packet.getSignature(),
(uint32_t)signature_length_);
PARCBuffer *buffer = parcSignature_GetSignature(signature_);
-
size_t bytes_len = parcBuffer_Remaining(buffer);
if (bytes_len > signature_length_) {
@@ -176,6 +174,8 @@ void Signer::sign(Packet &packet) {
hicn_packet_copy_header(format, &header_copy,
(hicn_header_t *)packet.packet_start_, false);
+
+ parcSignature_Release(&signature_);
}
size_t Signer::getSignatureLength() { return signature_length_; }
diff --git a/libtransport/src/security/verifier.cc b/libtransport/src/security/verifier.cc
index 19796f718..0cfbdc6f9 100644
--- a/libtransport/src/security/verifier.cc
+++ b/libtransport/src/security/verifier.cc
@@ -116,17 +116,10 @@ PARCKeyId *Verifier::addKeyFromCertificate(const std::string &file_name) {
}
int Verifier::verify(const Packet &packet) {
- // to initialize packet.payload_head_
+ // Initialize packet.payload_head_
const_cast<Packet *>(&packet)->separateHeaderPayload();
- bool valid = false;
-
- // initialize packet.payload_head_
- const_cast<Packet *>(&packet)->separateHeaderPayload();
- // header chain points to the IP + TCP hicn header
- // utils::MemBuf *header_chain = packet.header_head_;
- // utils::MemBuf *payload_chain = packet.payload_head_;
- // uint8_t *hicn_packet = header_chain->writableData();
Packet::Format format = packet.getFormat();
+ bool valid = false;
if (!(packet.format_ & HFO_AH)) {
throw errors::MalformedAHPacketException();
@@ -149,11 +142,12 @@ int Verifier::verify(const Packet &packet) {
int ah_payload_len = (int)packet.getSignatureSize();
uint8_t *_signature = packet.getSignature();
uint8_t *signature = new uint8_t[ah_payload_len];
+ std::shared_ptr<CryptoHasher> hasher;
+
// TODO Remove signature copy at this point, by not setting to zero
// the validation payload.
std::memcpy(signature, _signature, ah_payload_len);
- std::shared_ptr<CryptoHasher> hasher;
switch (CryptoSuite(suite)) {
case CryptoSuite::DSA_SHA256:
case CryptoSuite::RSA_SHA256:
@@ -178,7 +172,7 @@ int Verifier::verify(const Packet &packet) {
parcBuffer_Wrap(signature, ah_payload_len, 0, ah_payload_len);
parcBuffer_Rewind(bits);
- /* IF the signature algo is ECDSA, the signature might be shorter than the
+ /* If the signature algo is ECDSA, the signature might be shorter than the
* signature field */
PARCSigningAlgorithm algo = parcCryptoSuite_GetSigningAlgorithm(suite);
while (algo == PARCSigningAlgorithm_ECDSA && parcBuffer_HasRemaining(bits) &&