encoding: Fixing Block (and as a result Name) encoding bugs
As of this commit, all non-const operations on Block will call resetWire
to remove all references to the wire, so it will be recreated next time
"encode" method is called. Also, all getter methods now have only const
versions and non-const access to the internal data structure is
prohibited.
Change-Id: If4b485dd62541d9d4d168a44490068e4deff56c1
diff --git a/src/security/signature-sha256-with-rsa.hpp b/src/security/signature-sha256-with-rsa.hpp
index b59c765..cfcef90 100644
--- a/src/security/signature-sha256-with-rsa.hpp
+++ b/src/security/signature-sha256-with-rsa.hpp
@@ -33,8 +33,8 @@
throw Signature::Error("Incorrect signature type");
info_.parse();
- Block::element_iterator i = info_.find(Tlv::KeyLocator);
- if (i != info_.getAll().end())
+ Block::element_const_iterator i = info_.find(Tlv::KeyLocator);
+ if (i != info_.elements_end())
{
keyLocator_.wireDecode(*i);
}
diff --git a/src/security/validator.cpp b/src/security/validator.cpp
index 8b1c17f..7979120 100644
--- a/src/security/validator.cpp
+++ b/src/security/validator.cpp
@@ -144,11 +144,8 @@
try{
const Block &nameBlock = interestName.wireEncode();
- if(nameBlock.getAll().size() != interestName.size()) //HACK!! we should change it when Name::Component is changed to derive from Block.
- const_cast<Block&>(nameBlock).parse();
-
- Signature sig((++nameBlock.getAll().rbegin())->blockFromValue(),
- (nameBlock.getAll().rbegin())->blockFromValue());
+ Signature sig((++nameBlock.elements().rbegin())->blockFromValue(),
+ (nameBlock.elements().rbegin())->blockFromValue());
switch(sig.getType()){
case Signature::Sha256WithRsa:
@@ -156,7 +153,7 @@
SignatureSha256WithRsa sigSha256Rsa(sig);
return verifySignature(nameBlock.value(),
- nameBlock.value_size() - (nameBlock.getAll().rbegin())->size(),
+ nameBlock.value_size() - (nameBlock.elements().rbegin())->size(),
sigSha256Rsa, key);
}
default: