public void onData(Interest ckInterest, Data ckData) { try { contentKey.pendingInterest = 0; // TODO: Verify that the key is legitimate. Name[] kdkPrefix = new Name[1]; Name[] kdkIdentityName = new Name[1]; Name[] kdkKeyName = new Name[1]; if (!DecryptorV2.extractKdkInfoFromCkName(ckData.getName(), ckInterest.getName(), onError, kdkPrefix, kdkIdentityName, kdkKeyName)) { // The error has already been reported. return; } // Check if the KDK already exists. PibIdentity kdkIdentity = null; try { kdkIdentity = outer_DecryptorV2.internalKeyChain_.getPib() .getIdentity(kdkIdentityName[0]); } catch (Pib.Error ex) { } if (kdkIdentity != null) { PibKey kdkKey = null; try { kdkKey = kdkIdentity .getKey(kdkKeyName[0]); } catch (Pib.Error ex_0) { } if (kdkKey != null) { // The KDK was already fetched and imported. net.named_data.jndn.encrypt.DecryptorV2.logger_.log( ILOG.J2CsMapping.Util.Logging.Level.INFO, "KDK {0} already exists, so directly using it to decrypt the CK", kdkKeyName); outer_DecryptorV2.decryptCkAndProcessPendingDecrypts( contentKey, ckData, kdkKeyName[0], onError); return; } } outer_DecryptorV2.fetchKdk(contentKey, kdkPrefix[0], ckData, onError, net.named_data.jndn.encrypt.EncryptorV2.N_RETRIES); } catch (Exception ex_1) { onError.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.General, "Error in fetchCk onData: " + ex_1); } }
public void onData(Interest kdkInterest, Data kdkData) { contentKey.pendingInterest = 0; // TODO: Verify that the key is legitimate. bool isOk = outer_DecryptorV2.decryptAndImportKdk(kdkData, onError); if (!isOk) { return; } // This way of getting the kdkKeyName is a bit hacky. Name kdkKeyName = kdkPrefix.getPrefix(-2) .append("KEY").append(kdkPrefix.get(-1)); outer_DecryptorV2.decryptCkAndProcessPendingDecrypts(contentKey, ckData, kdkKeyName, onError); }