Adjust policies to accomodate dsk and ksk signing
diff --git a/src/contact-manager.cpp b/src/contact-manager.cpp
index 2f7536b..9bd8ca2 100644
--- a/src/contact-manager.cpp
+++ b/src/contact-manager.cpp
@@ -55,16 +55,16 @@
Ptr<Keychain> keychain = Ptr<Keychain>(new Keychain(identityManager, policyManager, encryptionManager));
policyManager->addVerificationPolicyRule(Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^([^<DNS>]*)<DNS><PROFILE>",
- "^([^<KEY>]*)<KEY>(<>*)<><ID-CERT>",
+ "^([^<KEY>]*)<KEY>(<>*)[<ksk-.*><dsk-.*>]<ID-CERT>$",
"==", "\\1", "\\1\\2", true)));
policyManager->addVerificationPolicyRule(Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^([^<PROFILE-CERT>]*)<PROFILE-CERT>",
- "^([^<KEY>]*)<KEY>(<>*<ksk-.*>)<ID-CERT>",
+ "^([^<KEY>]*)<KEY>(<>*<ksk-.*>)<ID-CERT>$",
"==", "\\1", "\\1\\2", true)));
policyManager->addVerificationPolicyRule(Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^([^<KEY>]*)<KEY>(<>*)<ksk-.*><ID-CERT>",
- "^([^<KEY>]*)<KEY><dsk-.*><ID-CERT>",
+ "^([^<KEY>]*)<KEY><dsk-.*><ID-CERT>$",
">", "\\1\\2", "\\1", true)));
policyManager->addVerificationPolicyRule(Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^([^<KEY>]*)<KEY><dsk-.*><ID-CERT>",
- "^([^<KEY>]*)<KEY>(<>*)<ksk-.*><ID-CERT>",
+ "^([^<KEY>]*)<KEY>(<>*)<ksk-.*><ID-CERT>$",
"==", "\\1", "\\1\\2", true)));
policyManager->addSigningPolicyRule(Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^([^<DNS>]*)<DNS><PROFILE>",
@@ -118,6 +118,7 @@
void
ContactManager::updateProfileData(const Name& identity)
{
+ _LOG_DEBUG("updateProfileData: " << identity.toUri());
// Get current profile;
Ptr<Profile> newProfile = m_contactStorage->getSelfProfile(identity);
if(NULL == newProfile)
@@ -198,15 +199,27 @@
Ptr<ProfileData> profileData = Ptr<ProfileData>(new ProfileData(identity, profile));
identityManager->signByCertificate(*profileData, certificateName);
- Ptr<security::IdentityCertificate> dskCert = identityManager->getCertificate(certificateName);
- Ptr<const signature::Sha256WithRsa> dskCertSig = DynamicCast<const signature::Sha256WithRsa>(dskCert->getSignature());
- // HACK! KSK certificate should be retrieved from network.
- _LOG_DEBUG("keyLocator: " << dskCertSig->getKeyLocator().getKeyName());
- Name keyName = security::IdentityCertificate::certificateNameToPublicKeyName(dskCertSig->getKeyLocator().getKeyName());
- _LOG_DEBUG("keyName: " << keyName.toUri());
- Name kskCertName = identityManager->getPublicStorage()->getDefaultCertificateNameForKey(keyName);
- _LOG_DEBUG("ksk cert name: " << kskCertName);
- Ptr<security::IdentityCertificate> kskCert = identityManager->getCertificate(kskCertName);
+ Ptr<security::IdentityCertificate> signingCert = identityManager->getCertificate(certificateName);
+ Name signingKeyName = security::IdentityCertificate::certificateNameToPublicKeyName(signingCert->getName(), true);
+
+ Ptr<security::IdentityCertificate> kskCert;
+ if(signingKeyName.get(-1).toUri().substr(0,4) == string("dsk-"))
+ {
+ Ptr<const signature::Sha256WithRsa> dskCertSig = DynamicCast<const signature::Sha256WithRsa>(signingCert->getSignature());
+ // HACK! KSK certificate should be retrieved from network.
+ _LOG_DEBUG("keyLocator: " << dskCertSig->getKeyLocator().getKeyName());
+ Name keyName = security::IdentityCertificate::certificateNameToPublicKeyName(dskCertSig->getKeyLocator().getKeyName());
+ _LOG_DEBUG("keyName: " << keyName.toUri());
+ Name kskCertName = identityManager->getPublicStorage()->getDefaultCertificateNameForKey(keyName);
+ _LOG_DEBUG("ksk cert name: " << kskCertName);
+ kskCert = identityManager->getCertificate(kskCertName);
+
+ }
+ else
+ {
+ kskCert = signingCert;
+ _LOG_DEBUG("ksk cert name: " << kskCert->getName().toUri());
+ }
vector<string> endorseList;
Profile::const_iterator it = profile.begin();