public Anonymous_C3(Consumer.OnPlainText callerOnPlainText_0, net.named_data.jndn.encrypt.EncryptError.OnError onError_1, Blob encryptedPayloadBlob_2) { this.callerOnPlainText = callerOnPlainText_0; this.onError = onError_1; this.encryptedPayloadBlob = encryptedPayloadBlob_2; }
/// <summary> /// Decrypt cKeyData. /// </summary> /// /// <param name="cKeyData">The C-KEY data packet.</param> /// <param name="onPlainText_0"></param> /// <param name="onError_1">This calls onError.onError(errorCode, message) for an error.</param> internal void decryptCKey(Data cKeyData, Consumer.OnPlainText onPlainText_0, net.named_data.jndn.encrypt.EncryptError.OnError onError_1) { // Get the encrypted content. Blob cKeyContent = cKeyData.getContent(); EncryptedContent cKeyEncryptedContent_2 = new EncryptedContent(); try { cKeyEncryptedContent_2.wireDecode(cKeyContent); } catch (EncodingException ex) { try { onError_1.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.InvalidEncryptedFormat, ex.Message); } catch (Exception exception) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception); } return; } Name eKeyName = cKeyEncryptedContent_2.getKeyLocator().getKeyName(); Name dKeyName_3 = eKeyName.getPrefix(-3); dKeyName_3.append(net.named_data.jndn.encrypt.algo.Encryptor.NAME_COMPONENT_D_KEY).append( eKeyName.getSubName(-2)); // Check if the decryption key is already in the store. Blob dKey = (Blob)ILOG.J2CsMapping.Collections.Collections.Get(dKeyMap_, dKeyName_3); if (dKey != null) { decrypt(cKeyEncryptedContent_2, dKey, onPlainText_0, onError_1); } else { // Get the D-Key Data. Name interestName = new Name(dKeyName_3); interestName.append(net.named_data.jndn.encrypt.algo.Encryptor.NAME_COMPONENT_FOR).append( consumerName_); Interest interest_4 = new Interest(interestName); // Prepare the callback functions. OnData onData_5 = new Consumer.Anonymous_C2(this, onError_1, onPlainText_0, cKeyEncryptedContent_2, dKeyName_3); OnTimeout onTimeout = new Consumer.Anonymous_C1(this, interest_4, onData_5, onError_1); // Express the Interest. try { face_.expressInterest(interest_4, onData_5, onTimeout); } catch (IOException ex_6) { try { onError_1.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.IOException, "expressInterest error: " + ex_6.Message); } catch (Exception exception_7) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception_7); } } } }
public Anonymous_C4(Consumer paramouter_Consumer, Consumer.OnPlainText onPlainText_0, Name dKeyName_1, net.named_data.jndn.encrypt.EncryptError.OnError onError_2, EncryptedContent cKeyEncryptedContent_3) { this.onPlainText = onPlainText_0; this.dKeyName = dKeyName_1; this.onError = onError_2; this.cKeyEncryptedContent = cKeyEncryptedContent_3; this.outer_Consumer = paramouter_Consumer; }
public Anonymous_C5(Consumer paramouter_Consumer, EncryptedContent dataEncryptedContent_0, net.named_data.jndn.encrypt.EncryptError.OnError onError_1, Consumer.OnPlainText onPlainText_2, Name cKeyName_3) { this.dataEncryptedContent = dataEncryptedContent_0; this.onError = onError_1; this.onPlainText = onPlainText_2; this.cKeyName = cKeyName_3; this.outer_Consumer = paramouter_Consumer; }
/// <summary> /// Decrypt the data packet. /// </summary> /// /// <param name="data">The data packet.</param> /// <param name="onPlainText_0"></param> /// <param name="onError_1">This calls onError.onError(errorCode, message) for an error.</param> internal void decryptContent(Data data, Consumer.OnPlainText onPlainText_0, net.named_data.jndn.encrypt.EncryptError.OnError onError_1) { // Get the encrypted content. EncryptedContent dataEncryptedContent_2 = new EncryptedContent(); try { dataEncryptedContent_2.wireDecode(data.getContent()); } catch (EncodingException ex) { try { onError_1.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.InvalidEncryptedFormat, ex.Message); } catch (Exception exception) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception); } return; } Name cKeyName_3 = dataEncryptedContent_2.getKeyLocator().getKeyName(); // Check if the content key is already in the store. Blob cKey = (Blob)ILOG.J2CsMapping.Collections.Collections.Get(cKeyMap_, cKeyName_3); if (cKey != null) { decrypt(dataEncryptedContent_2, cKey, onPlainText_0, onError_1); } else { // Retrieve the C-KEY Data from the network. Name interestName = new Name(cKeyName_3); interestName.append(net.named_data.jndn.encrypt.algo.Encryptor.NAME_COMPONENT_FOR) .append(groupName_); Interest interest_4 = new Interest(interestName); // Prepare the callback functions. OnData onData_5 = new Consumer.Anonymous_C4(this, cKeyName_3, dataEncryptedContent_2, onPlainText_0, onError_1); OnTimeout onTimeout = new Consumer.Anonymous_C3(this, onError_1, interest_4, onData_5); // Express the Interest. try { face_.expressInterest(interest_4, onData_5, onTimeout); } catch (IOException ex_6) { try { onError_1.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.IOException, "expressInterest error: " + ex_6.Message); } catch (Exception exception_7) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception_7); } } } }
/// <summary> /// Decode encryptedBlob as an EncryptedContent and decrypt using keyBits. /// </summary> /// /// <param name="encryptedBlob">The encoded EncryptedContent to decrypt.</param> /// <param name="keyBits">The key value.</param> /// <param name="onPlainText_0"></param> /// <param name="onError_1">This calls onError.onError(errorCode, message) for an error.</param> private static void decrypt(Blob encryptedBlob, Blob keyBits, Consumer.OnPlainText onPlainText_0, net.named_data.jndn.encrypt.EncryptError.OnError onError_1) { EncryptedContent encryptedContent = new EncryptedContent(); try { encryptedContent.wireDecode(encryptedBlob); } catch (EncodingException ex) { try { onError_1.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.InvalidEncryptedFormat, ex.Message); } catch (Exception exception) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception); } return; } decrypt(encryptedContent, keyBits, onPlainText_0, onError_1); }
/// <summary> /// Decrypt the data packet. /// </summary> /// /// <param name="data">The data packet. This does not verify the packet.</param> /// <param name="onPlainText_0"></param> /// <param name="onError_1">This calls onError.onError(errorCode, message) for an error.</param> internal void decryptContent(Data data, Consumer.OnPlainText onPlainText_0, net.named_data.jndn.encrypt.EncryptError.OnError onError_1) { // Get the encrypted content. EncryptedContent dataEncryptedContent_2 = new EncryptedContent(); try { dataEncryptedContent_2.wireDecode(data.getContent()); } catch (EncodingException ex) { try { onError_1.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.InvalidEncryptedFormat, ex.Message); } catch (Exception exception) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception); } return; } Name cKeyName_3 = dataEncryptedContent_2.getKeyLocator().getKeyName(); // Check if the content key is already in the store. Blob cKey = (Blob)ILOG.J2CsMapping.Collections.Collections.Get(cKeyMap_, cKeyName_3); if (cKey != null) { decrypt(dataEncryptedContent_2, cKey, onPlainText_0, onError_1); } else { // Retrieve the C-KEY Data from the network. Name interestName = new Name(cKeyName_3); interestName.append(net.named_data.jndn.encrypt.algo.Encryptor.NAME_COMPONENT_FOR) .append(groupName_); Interest interest = new Interest(interestName); sendInterest(interest, 1, cKeyLink_, new Consumer.Anonymous_C5(this, dataEncryptedContent_2, onError_1, onPlainText_0, cKeyName_3), onError_1); } }
public override void decrypt(Blob encryptedBlob, Blob keyBits, Consumer.OnPlainText onPlainText_0, net.named_data.jndn.encrypt.EncryptError.OnError onError_1) { net.named_data.jndn.encrypt.Consumer.decrypt(encryptedBlob, keyBits, onPlainText_0, onError_1); }
public abstract void decrypt(Blob encryptedBlob, Blob keyBits, Consumer.OnPlainText onPlainText_0, net.named_data.jndn.encrypt.EncryptError.OnError onError_1);
/// <summary> /// Decrypt dKeyData. /// </summary> /// /// <param name="dKeyData">The D-KEY data packet.</param> /// <param name="onPlainText_0"></param> /// <param name="onError_1">This calls onError.onError(errorCode, message) for an error.</param> internal void decryptDKey(Data dKeyData, Consumer.OnPlainText onPlainText_0, net.named_data.jndn.encrypt.EncryptError.OnError onError_1) { // Get the encrypted content. Blob dataContent = dKeyData.getContent(); // Process the nonce. // dataContent is a sequence of the two EncryptedContent. EncryptedContent encryptedNonce = new EncryptedContent(); try { encryptedNonce.wireDecode(dataContent); } catch (EncodingException ex) { try { onError_1.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.InvalidEncryptedFormat, ex.Message); } catch (Exception exception) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception); } return; } Name consumerKeyName = encryptedNonce.getKeyLocator().getKeyName(); // Get consumer decryption key. Blob consumerKeyBlob; try { consumerKeyBlob = getDecryptionKey(consumerKeyName); } catch (ConsumerDb.Error ex_2) { try { onError_1.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.NoDecryptKey, "Database error: " + ex_2.Message); } catch (Exception exception_3) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception_3); } return; } if (consumerKeyBlob.size() == 0) { try { onError_1.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.NoDecryptKey, "The desired consumer decryption key in not in the database"); } catch (Exception exception_4) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception_4); } return; } // Process the D-KEY. // Use the size of encryptedNonce to find the start of encryptedPayload. ByteBuffer encryptedPayloadBuffer = dataContent.buf().duplicate(); encryptedPayloadBuffer.position(encryptedNonce.wireEncode().size()); Blob encryptedPayloadBlob_5 = new Blob(encryptedPayloadBuffer, false); if (encryptedPayloadBlob_5.size() == 0) { try { onError_1.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.InvalidEncryptedFormat, "The data packet does not satisfy the D-KEY packet format"); } catch (Exception ex_6) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", ex_6); } return; } // Decrypt the D-KEY. Consumer.OnPlainText callerOnPlainText_7 = onPlainText_0; decrypt(encryptedNonce, consumerKeyBlob, new Consumer.Anonymous_C3(callerOnPlainText_7, onError_1, encryptedPayloadBlob_5), onError_1); }
/// <summary> /// Decrypt encryptedContent using keyBits. /// </summary> /// /// <param name="encryptedContent">The EncryptedContent to decrypt.</param> /// <param name="keyBits">The key value.</param> /// <param name="onPlainText_0"></param> /// <param name="onError_1">This calls onError.onError(errorCode, message) for an error.</param> static internal void decrypt(EncryptedContent encryptedContent, Blob keyBits, Consumer.OnPlainText onPlainText_0, net.named_data.jndn.encrypt.EncryptError.OnError onError_1) { Blob payload = encryptedContent.getPayload(); if (encryptedContent.getAlgorithmType() == net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.AesCbc) { // Prepare the parameters. EncryptParams decryptParams = new EncryptParams( net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.AesCbc); decryptParams.setInitialVector(encryptedContent.getInitialVector()); // Decrypt the content. Blob content; try { content = net.named_data.jndn.encrypt.algo.AesAlgorithm.decrypt(keyBits, payload, decryptParams); } catch (Exception ex) { try { onError_1.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.InvalidEncryptedFormat, ex.Message); } catch (Exception exception) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception); } return; } try { onPlainText_0.onPlainText(content); } catch (Exception ex_2) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onPlainText", ex_2); } } else if (encryptedContent.getAlgorithmType() == net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.RsaOaep) { // Prepare the parameters. EncryptParams decryptParams_3 = new EncryptParams( net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.RsaOaep); // Decrypt the content. Blob content_4; try { content_4 = net.named_data.jndn.encrypt.algo.RsaAlgorithm.decrypt(keyBits, payload, decryptParams_3); } catch (Exception ex_5) { try { onError_1.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.InvalidEncryptedFormat, ex_5.Message); } catch (Exception exception_6) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception_6); } return; } try { onPlainText_0.onPlainText(content_4); } catch (Exception ex_7) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onPlainText", ex_7); } } else { try { onError_1.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.UnsupportedEncryptionScheme, "" + encryptedContent.getAlgorithmType()); } catch (Exception ex_8) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", ex_8); } } }
public Anonymous_C4(Consumer paramouter_Consumer, Name cKeyName_0, net.named_data.jndn.encrypt.EncryptError.OnError onError_1, Consumer.OnPlainText onPlainText_2, EncryptedContent dataEncryptedContent_3) { this.cKeyName = cKeyName_0; this.onError = onError_1; this.onPlainText = onPlainText_2; this.dataEncryptedContent = dataEncryptedContent_3; this.outer_Consumer = paramouter_Consumer; }
public Anonymous_C2(Consumer paramouter_Consumer, net.named_data.jndn.encrypt.EncryptError.OnError onError_0, Consumer.OnPlainText onPlainText_1, Name dKeyName_2, EncryptedContent cKeyEncryptedContent_3) { this.onError = onError_0; this.onPlainText = onPlainText_1; this.dKeyName = dKeyName_2; this.cKeyEncryptedContent = cKeyEncryptedContent_3; this.outer_Consumer = paramouter_Consumer; }
public Anonymous_C0(Consumer.OnPlainText callerOnPlainText_0, Blob encryptedPayloadBlob_1, net.named_data.jndn.encrypt.EncryptError.OnError onError_2) { this.callerOnPlainText = callerOnPlainText_0; this.encryptedPayloadBlob = encryptedPayloadBlob_1; this.onError = onError_2; }