/// <summary> /// Encrypt the payload using the symmetric key according to params, and return /// an EncryptedContent. /// </summary> /// /// <param name="payload">The data to encrypt.</param> /// <param name="key">The key value.</param> /// <param name="keyName">The key name for the EncryptedContent key locator.</param> /// <param name="params">The parameters for encryption.</param> /// <returns>A new EncryptedContent.</returns> private static EncryptedContent encryptSymmetric(Blob payload, Blob key, Name keyName, EncryptParams paras) { EncryptAlgorithmType algorithmType = paras.getAlgorithmType(); Blob initialVector = paras.getInitialVector(); KeyLocator keyLocator = new KeyLocator(); keyLocator.setType(net.named_data.jndn.KeyLocatorType.KEYNAME); keyLocator.setKeyName(keyName); if (algorithmType == net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.AesCbc || algorithmType == net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.AesEcb) { if (algorithmType == net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.AesCbc) { if (initialVector.size() != net.named_data.jndn.encrypt.algo.AesAlgorithm.BLOCK_SIZE) { throw new Exception("incorrect initial vector size"); } } Blob encryptedPayload = net.named_data.jndn.encrypt.algo.AesAlgorithm.encrypt(key, payload, paras); EncryptedContent result = new EncryptedContent(); result.setAlgorithmType(algorithmType); result.setKeyLocator(keyLocator); result.setPayload(encryptedPayload); result.setInitialVector(initialVector); return(result); } else { throw new Exception("Unsupported encryption method"); } }
/// <summary> /// Encrypt the payload using the asymmetric key according to params, and /// return an EncryptedContent. /// </summary> /// /// <param name="payload"></param> /// <param name="key">The key value.</param> /// <param name="keyName">The key name for the EncryptedContent key locator.</param> /// <param name="params">The parameters for encryption.</param> /// <returns>A new EncryptedContent.</returns> private static EncryptedContent encryptAsymmetric(Blob payload, Blob key, Name keyName, EncryptParams paras) { EncryptAlgorithmType algorithmType = paras.getAlgorithmType(); KeyLocator keyLocator = new KeyLocator(); keyLocator.setType(net.named_data.jndn.KeyLocatorType.KEYNAME); keyLocator.setKeyName(keyName); if (algorithmType == net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.RsaPkcs || algorithmType == net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.RsaOaep) { Blob encryptedPayload = net.named_data.jndn.encrypt.algo.RsaAlgorithm.encrypt(key, payload, paras); EncryptedContent result = new EncryptedContent(); result.setAlgorithmType(algorithmType); result.setKeyLocator(keyLocator); result.setPayload(encryptedPayload); return(result); } else { throw new Exception("Unsupported encryption method"); } }
/// <summary> /// Set all the fields to indicate unspecified values. /// </summary> /// public void clear() { algorithmType_ = net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.NONE; keyLocator_ = new KeyLocator(); initialVector_ = new Blob(); payload_ = new Blob(); payloadKey_ = new Blob(); }
// TODO: getExtension /// <summary> /// Write a string representation of this certificate to result. /// </summary> /// /// <param name="result">The StringBuffer to write to.</param> public void printCertificate(StringBuilder result) { result.append("Certificate name:\n"); result.append(" ").append(getName().toUri()).append("\n"); result.append("Validity:\n"); result.append(" NotBefore: ") .append(net.named_data.jndn.encrypt.Schedule .toIsoString(getValidityPeriod().getNotBefore())) .append("\n"); result.append(" NotAfter: ") .append(net.named_data.jndn.encrypt.Schedule.toIsoString(getValidityPeriod().getNotAfter())) .append("\n"); // TODO: Print the extension. result.append("Public key bits:\n"); try { result.append(net.named_data.jndn.util.Common.base64Encode(getPublicKey() .getImmutableArray(), true)); } catch (CertificateV2.Error ex) { // No public key. } result.append("Signature Information:\n"); result.append(" Signature Type: "); if (getSignature() is Sha256WithEcdsaSignature) { result.append("SignatureSha256WithEcdsa\n"); } else if (getSignature() is Sha256WithRsaSignature) { result.append("SignatureSha256WithRsa\n"); } else { result.append("<unknown>\n"); } if (net.named_data.jndn.KeyLocator.canGetFromSignature(getSignature())) { result.append(" Key Locator: "); KeyLocator keyLocator = net.named_data.jndn.KeyLocator.getFromSignature(getSignature()); if (keyLocator.getType() == net.named_data.jndn.KeyLocatorType.KEYNAME) { if (keyLocator.getKeyName().equals(getKeyName())) { result.append("Self-Signed "); } result.append("Name=").append(keyLocator.getKeyName().toUri()) .append("\n"); } else { result.append("<no KeyLocator key name>\n"); } } }
/// <summary> /// Create an EncryptedContent as a deep copy of the given object. /// </summary> /// /// <param name="encryptedContent">The other encryptedContent to copy.</param> public EncryptedContent(EncryptedContent encryptedContent) { this.algorithmType_ = default(EncryptAlgorithmType) /* was: null */; this.keyLocator_ = new KeyLocator(); this.initialVector_ = new Blob(); this.payload_ = new Blob(); algorithmType_ = encryptedContent.algorithmType_; keyLocator_ = new KeyLocator(encryptedContent.keyLocator_); initialVector_ = encryptedContent.initialVector_; payload_ = encryptedContent.payload_; }
/// <summary> /// Create an EncryptedContent as a deep copy of the given object. /// </summary> /// /// <param name="encryptedContent">The other encryptedContent to copy.</param> public EncryptedContent(EncryptedContent encryptedContent) { this.algorithmType_ = net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.NONE; this.keyLocator_ = new KeyLocator(); this.initialVector_ = new Blob(); this.payload_ = new Blob(); this.payloadKey_ = new Blob(); algorithmType_ = encryptedContent.algorithmType_; keyLocator_ = new KeyLocator(encryptedContent.keyLocator_); initialVector_ = encryptedContent.initialVector_; payload_ = encryptedContent.payload_; }
public void testBadCertificateName() { Interest interest1 = fixture_.makeCommandInterest(fixture_.identity_); KeyLocator keyLocator = new KeyLocator(); keyLocator.setType(net.named_data.jndn.KeyLocatorType.KEYNAME); keyLocator.setKeyName(new Name("/bad/cert/name")); Sha256WithRsaSignature signatureInfo = new Sha256WithRsaSignature(); signatureInfo.setKeyLocator(keyLocator); setNameComponent(interest1, net.named_data.jndn.security.CommandInterestSigner.POS_SIGNATURE_INFO, net.named_data.jndn.encoding.TlvWireFormat.get().encodeSignatureInfo(signatureInfo)); validateExpectFailure(interest1, "Should fail (bad certificate name)"); }
public void testBadKeyLocatorType() { Interest interest1 = fixture_.makeCommandInterest(fixture_.identity_); KeyLocator keyLocator = new KeyLocator(); keyLocator.setType(net.named_data.jndn.KeyLocatorType.KEY_LOCATOR_DIGEST); keyLocator.setKeyData(new Blob(new int[] { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd })); Sha256WithRsaSignature signatureInfo = new Sha256WithRsaSignature(); signatureInfo.setKeyLocator(keyLocator); setNameComponent(interest1, net.named_data.jndn.security.CommandInterestSigner.POS_SIGNATURE_INFO, net.named_data.jndn.encoding.TlvWireFormat.get().encodeSignatureInfo(signatureInfo)); validateExpectFailure(interest1, "Should fail (bad KeyLocator type)"); }
/// <summary> /// Look in the IdentityStorage or pibImpl for the public key with the name in the /// KeyLocator (if available). If the public key can't be found, return an /// empty Blob. /// </summary> /// /// <param name="keyLocator">The KeyLocator.</param> /// <param name="failureReason"></param> /// <returns>The public key DER or an empty Blob if not found.</returns> private Blob getPublicKeyDer(KeyLocator keyLocator, String[] failureReason) { if (keyLocator.getType() == net.named_data.jndn.KeyLocatorType.KEYNAME && identityStorage_ != null) { Name keyName; try { // Assume the key name is a certificate name. keyName = net.named_data.jndn.security.certificate.IdentityCertificate .certificateNameToPublicKeyName(keyLocator.getKeyName()); } catch (Exception ex) { failureReason[0] = "Cannot get a public key name from the certificate named: " + keyLocator.getKeyName().toUri(); return(new Blob()); } try { // Assume the key name is a certificate name. return(identityStorage_.getKey(keyName)); } catch (SecurityException ex_0) { failureReason[0] = "The identityStorage doesn't have the key named " + keyName.toUri(); return(new Blob()); } } else if (keyLocator.getType() == net.named_data.jndn.KeyLocatorType.KEYNAME && pibImpl_ != null) { try { return(pibImpl_.getKeyBits(keyLocator.getKeyName())); } catch (Pib.Error ex_1) { failureReason[0] = "The pibImpl doesn't have the key named " + keyLocator.getKeyName().toUri(); return(new Blob()); } catch (PibImpl.Error ex_2) { failureReason[0] = "Error getting the key named " + keyLocator.getKeyName().toUri(); return(new Blob()); } } else { // Can't find a key to verify. failureReason[0] = "The signature KeyLocator doesn't have a key name"; return(new Blob()); } }
/// <summary> /// A helper method for getKeyLocatorName. /// </summary> /// private static Name getKeyLocatorNameFromSignature(Signature signatureInfo, ValidationState state) { if (!net.named_data.jndn.KeyLocator.canGetFromSignature(signatureInfo)) { state.fail(new ValidationError(net.named_data.jndn.security.v2.ValidationError.INVALID_KEY_LOCATOR, "KeyLocator is missing")); return(new Name()); } KeyLocator keyLocator = net.named_data.jndn.KeyLocator.getFromSignature(signatureInfo); if (keyLocator.getType() != net.named_data.jndn.KeyLocatorType.KEYNAME) { state.fail(new ValidationError(net.named_data.jndn.security.v2.ValidationError.INVALID_KEY_LOCATOR, "KeyLocator type is not Name")); return(new Name()); } return(keyLocator.getKeyName()); }
/// <summary> /// Look in the IdentityStorage for the public key with the name in the /// KeyLocator (if available). If the public key can't be found, return and /// empty Blob. /// </summary> /// /// <param name="keyLocator">The KeyLocator.</param> /// <returns>The public key DER or an empty Blob if not found.</returns> private Blob getPublicKeyDer(KeyLocator keyLocator) { if (keyLocator.getType() == net.named_data.jndn.KeyLocatorType.KEYNAME && identityStorage_ != null) { try { // Assume the key name is a certificate name. return(identityStorage_ .getKey(net.named_data.jndn.security.certificate.IdentityCertificate .certificateNameToPublicKeyName(keyLocator .getKeyName()))); } catch (SecurityException ex) { // The storage doesn't have the key. return(new Blob()); } } else { // Can't find a key to verify. return(new Blob()); } }
private static Sha256WithRsaSignature generateFakeSignature() { Sha256WithRsaSignature signatureInfo = new Sha256WithRsaSignature(); Name keyLocatorName = new Name("/ndn/site1/KEY/ksk-2516425377094"); KeyLocator keyLocator = new KeyLocator(); keyLocator.setType(net.named_data.jndn.KeyLocatorType.KEYNAME); keyLocator.setKeyName(keyLocatorName); signatureInfo.setKeyLocator(keyLocator); ValidityPeriod period = new ValidityPeriod(); period.setPeriod(net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20141111T050000"), net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20141111T060000")); signatureInfo.setValidityPeriod(period); Blob block2 = new Blob(SIG_VALUE, false); signatureInfo.setSignature(block2); return(signatureInfo); }
public void testSetterGetter() { EncryptedContent content = new EncryptedContent(); Assert.AssertEquals(net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.NONE, content.getAlgorithmType()); Assert.AssertEquals(true, content.getPayload().isNull()); Assert.AssertEquals(true, content.getInitialVector().isNull()); Assert.AssertEquals(net.named_data.jndn.KeyLocatorType.NONE, content.getKeyLocator().getType()); content.setAlgorithmType(net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.RsaOaep); Assert.AssertEquals(net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.RsaOaep, content.getAlgorithmType()); Assert.AssertEquals(true, content.getPayload().isNull()); Assert.AssertEquals(true, content.getInitialVector().isNull()); Assert.AssertEquals(net.named_data.jndn.KeyLocatorType.NONE, content.getKeyLocator().getType()); KeyLocator keyLocator = new KeyLocator(); keyLocator.setType(net.named_data.jndn.KeyLocatorType.KEYNAME); keyLocator.getKeyName().set("/test/key/locator"); content.setKeyLocator(keyLocator); Assert.AssertTrue(content.getKeyLocator().getType() != net.named_data.jndn.KeyLocatorType.NONE); Assert.AssertTrue(content.getKeyLocator().getKeyName() .equals(new Name("/test/key/locator"))); Assert.AssertEquals(true, content.getPayload().isNull()); Assert.AssertEquals(true, content.getInitialVector().isNull()); content.setPayload(new Blob(message, false)); Assert.AssertTrue(content.getPayload().equals(new Blob(message, false))); content.setInitialVector(new Blob(iv, false)); Assert.AssertTrue(content.getInitialVector().equals(new Blob(iv, false))); Blob encoded = content.wireEncode(); Blob contentBlob = new Blob(encrypted, false); Assert.AssertTrue(contentBlob.equals(encoded)); }
benchmarkEncodeDataSeconds (int nIterations, bool useComplex, bool useCrypto, KeyType keyType, Blob[] encoding) { Name name; Blob content; if (useComplex) { // Use a large name and content. name = new Name ("/ndn/ucla.edu/apps/lwndn-test/numbers.txt/%FD%05%05%E8%0C%CE%1D/%00"); StringBuilder contentStream = new StringBuilder(); int count = 1; contentStream.append(count++); while (contentStream.toString().Length < 1115) { contentStream.append(" ").append(count++); } content = new Blob(contentStream.toString()); } else { // Use a small name and content. name = new Name("/test"); content = new Blob("abc"); } Name.Component finalBlockId = new Name.Component(new Blob(new byte[] { (byte)0 })); // Initialize the KeyChain storage in case useCrypto is true. MemoryIdentityStorage identityStorage = new MemoryIdentityStorage(); MemoryPrivateKeyStorage privateKeyStorage = new MemoryPrivateKeyStorage(); KeyChain keyChain = new KeyChain (new IdentityManager(identityStorage, privateKeyStorage), new SelfVerifyPolicyManager(identityStorage)); Name keyName = new Name("/testname/DSK-123"); Name certificateName = keyName.getSubName(0, keyName.size() - 1).append ("KEY").append(keyName.get(-1)).append("ID-CERT").append("0"); privateKeyStorage.setKeyPairForKeyName (keyName, KeyType.RSA, new ByteBuffer(DEFAULT_RSA_PUBLIC_KEY_DER), new ByteBuffer(DEFAULT_RSA_PRIVATE_KEY_DER)); Blob signatureBits = new Blob(new byte[256]); Blob emptyBlob = new Blob(new byte[0]); double start = getNowSeconds(); for (int i = 0; i < nIterations; ++i) { Data data = new Data(name); data.setContent(content); if (useComplex) { data.getMetaInfo().setFreshnessPeriod(30000); data.getMetaInfo().setFinalBlockId(finalBlockId); } if (useCrypto) { // This sets the signature fields. keyChain.sign(data, certificateName); } else { // Imitate IdentityManager.signByCertificate to set up the signature // fields, but don't sign. KeyLocator keyLocator = new KeyLocator(); keyLocator.setType(KeyLocatorType.KEYNAME); keyLocator.setKeyName(certificateName); Sha256WithRsaSignature sha256Signature = (Sha256WithRsaSignature)data.getSignature(); sha256Signature.setKeyLocator(keyLocator); sha256Signature.setSignature(signatureBits); } encoding[0] = data.wireEncode(); } double finish = getNowSeconds(); return(finish - start); }
dumpData(Data data) { Console.Out.WriteLine("name: " + data.getName().toUri()); if (data.getContent().size() > 0) { Console.Out.Write("content (raw): "); var buf = data.getContent().buf(); while (buf.remaining() > 0) { Console.Out.Write((char)buf.get()); } Console.Out.WriteLine(""); Console.Out.WriteLine("content (hex): " + data.getContent().toHex()); } else { Console.Out.WriteLine("content: <empty>"); } if (!(data.getMetaInfo().getType() == ContentType.BLOB)) { Console.Out.Write("metaInfo.type: "); if (data.getMetaInfo().getType() == ContentType.KEY) { Console.Out.WriteLine("KEY"); } else if (data.getMetaInfo().getType() == ContentType.LINK) { Console.Out.WriteLine("LINK"); } else if (data.getMetaInfo().getType() == ContentType.NACK) { Console.Out.WriteLine("NACK"); } else if (data.getMetaInfo().getType() == ContentType.OTHER_CODE) { Console.Out.WriteLine("other code " + data.getMetaInfo().getOtherTypeCode()); } } Console.Out.WriteLine("metaInfo.freshnessPeriod (milliseconds): " + (data.getMetaInfo().getFreshnessPeriod() >= 0 ? "" + data.getMetaInfo().getFreshnessPeriod() : "<none>")); Console.Out.WriteLine("metaInfo.finalBlockId: " + (data.getMetaInfo().getFinalBlockId().getValue().size() > 0 ? data.getMetaInfo().getFinalBlockId().getValue().toHex() : "<none>")); KeyLocator keyLocator = null; if (data.getSignature() is Sha256WithRsaSignature) { var signature = (Sha256WithRsaSignature)data.getSignature(); Console.Out.WriteLine("Sha256WithRsa signature.signature: " + (signature.getSignature().size() > 0 ? signature.getSignature().toHex() : "<none>")); keyLocator = signature.getKeyLocator(); } else if (data.getSignature() is Sha256WithEcdsaSignature) { var signature = (Sha256WithEcdsaSignature)data.getSignature(); Console.Out.WriteLine("Sha256WithEcdsa signature.signature: " + (signature.getSignature().size() > 0 ? signature.getSignature().toHex() : "<none>")); keyLocator = signature.getKeyLocator(); } else if (data.getSignature() is HmacWithSha256Signature) { var signature = (HmacWithSha256Signature)data.getSignature(); Console.Out.WriteLine("HmacWithSha256 signature.signature: " + (signature.getSignature().size() > 0 ? signature.getSignature().toHex() : "<none>")); keyLocator = signature.getKeyLocator(); } else if (data.getSignature() is DigestSha256Signature) { var signature = (DigestSha256Signature)data.getSignature(); Console.Out.WriteLine("DigestSha256 signature.signature: " + (signature.getSignature().size() > 0 ? signature.getSignature().toHex() : "<none>")); } else if (data.getSignature() is GenericSignature) { var signature = (GenericSignature)data.getSignature(); Console.Out.WriteLine("Generic signature.signature: " + (signature.getSignature().size() > 0 ? signature.getSignature().toHex() : "<none>")); Console.Out.WriteLine(" Type code: " + signature.getTypeCode() + " signatureInfo: " + (signature.getSignatureInfoEncoding().size() > 0 ? signature.getSignatureInfoEncoding().toHex() : "<none>")); } if (keyLocator != null) { Console.Out.Write("signature.keyLocator: "); if (keyLocator.getType() == KeyLocatorType.NONE) { Console.Out.WriteLine("<none>"); } else if (keyLocator.getType() == KeyLocatorType.KEY_LOCATOR_DIGEST) { Console.Out.WriteLine("KeyLocatorDigest: " + keyLocator.getKeyData().toHex()); } else if (keyLocator.getType() == KeyLocatorType.KEYNAME) { Console.Out.WriteLine("KeyName: " + keyLocator.getKeyName().toUri()); } else { Console.Out.WriteLine("<unrecognized ndn_KeyLocatorType>"); } } }
public void testConstructor() { // Check default settings. EncryptedContent content = new EncryptedContent(); Assert.AssertEquals(net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.NONE, content.getAlgorithmType()); Assert.AssertEquals(true, content.getPayload().isNull()); Assert.AssertEquals(true, content.getInitialVector().isNull()); Assert.AssertEquals(net.named_data.jndn.KeyLocatorType.NONE, content.getKeyLocator().getType()); // Check an encrypted content with IV. KeyLocator keyLocator = new KeyLocator(); keyLocator.setType(net.named_data.jndn.KeyLocatorType.KEYNAME); keyLocator.getKeyName().set("/test/key/locator"); EncryptedContent rsaOaepContent = new EncryptedContent(); rsaOaepContent.setAlgorithmType(net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.RsaOaep) .setKeyLocator(keyLocator).setPayload(new Blob(message, false)) .setInitialVector(new Blob(iv, false)); Assert.AssertEquals(net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.RsaOaep, rsaOaepContent.getAlgorithmType()); Assert.AssertTrue(rsaOaepContent.getPayload().equals(new Blob(message, false))); Assert.AssertTrue(rsaOaepContent.getInitialVector() .equals(new Blob(iv, false))); Assert.AssertTrue(rsaOaepContent.getKeyLocator().getType() != net.named_data.jndn.KeyLocatorType.NONE); Assert.AssertTrue(rsaOaepContent.getKeyLocator().getKeyName() .equals(new Name("/test/key/locator"))); // Encoding. Blob encryptedBlob = new Blob(encrypted, false); Blob encoded = rsaOaepContent.wireEncode(); Assert.AssertTrue(encryptedBlob.equals(encoded)); // Decoding. EncryptedContent rsaOaepContent2 = new EncryptedContent(); rsaOaepContent2.wireDecode(encryptedBlob); Assert.AssertEquals(net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.RsaOaep, rsaOaepContent2.getAlgorithmType()); Assert.AssertTrue(rsaOaepContent2.getPayload() .equals(new Blob(message, false))); Assert.AssertTrue(rsaOaepContent2.getInitialVector().equals( new Blob(iv, false))); Assert.AssertTrue(rsaOaepContent2.getKeyLocator().getType() != net.named_data.jndn.KeyLocatorType.NONE); Assert.AssertTrue(rsaOaepContent2.getKeyLocator().getKeyName() .equals(new Name("/test/key/locator"))); // Check the no IV case. EncryptedContent rsaOaepContentNoIv = new EncryptedContent(); rsaOaepContentNoIv.setAlgorithmType(net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.RsaOaep) .setKeyLocator(keyLocator).setPayload(new Blob(message, false)); Assert.AssertEquals(net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.RsaOaep, rsaOaepContentNoIv.getAlgorithmType()); Assert.AssertTrue(rsaOaepContentNoIv.getPayload().equals( new Blob(message, false))); Assert.AssertTrue(rsaOaepContentNoIv.getInitialVector().isNull()); Assert.AssertTrue(rsaOaepContentNoIv.getKeyLocator().getType() != net.named_data.jndn.KeyLocatorType.NONE); Assert.AssertTrue(rsaOaepContentNoIv.getKeyLocator().getKeyName() .equals(new Name("/test/key/locator"))); // Encoding. Blob encryptedBlob2 = new Blob(encryptedNoIv, false); Blob encodedNoIV = rsaOaepContentNoIv.wireEncode(); Assert.AssertTrue(encryptedBlob2.equals(encodedNoIV)); // Decoding. EncryptedContent rsaOaepContentNoIv2 = new EncryptedContent(); rsaOaepContentNoIv2.wireDecode(encryptedBlob2); Assert.AssertEquals(net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.RsaOaep, rsaOaepContentNoIv2.getAlgorithmType()); Assert.AssertTrue(rsaOaepContentNoIv2.getPayload().equals( new Blob(message, false))); Assert.AssertTrue(rsaOaepContentNoIv2.getInitialVector().isNull()); Assert.AssertTrue(rsaOaepContentNoIv2.getKeyLocator().getType() != net.named_data.jndn.KeyLocatorType.NONE); Assert.AssertTrue(rsaOaepContentNoIv2.getKeyLocator().getKeyName() .equals(new Name("/test/key/locator"))); }
/// <summary> /// Set the key locator. /// </summary> /// /// <param name="keyLocator"></param> /// <returns>This EncryptedContent so that you can chain calls to update values.</returns> public EncryptedContent setKeyLocator(KeyLocator keyLocator) { keyLocator_ = (keyLocator == null) ? new KeyLocator() : new KeyLocator( keyLocator); return(this); }