Ejemplo n.º 1
0
            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;
            }
Ejemplo n.º 2
0
 public Anonymous_C7(Consumer.Anonymous_C1  paramouter_Anonymous_C1)
 {
     this.outer_Anonymous_C1 = paramouter_Anonymous_C1;
 }
Ejemplo n.º 3
0
        /// <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_C0 (callerOnPlainText_7, encryptedPayloadBlob_5, onError_1), onError_1);
        }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 5
0
 public Anonymous_C13(Consumer.Anonymous_C4  paramouter_Anonymous_C4)
 {
     this.outer_Anonymous_C4 = paramouter_Anonymous_C4;
 }
Ejemplo n.º 6
0
            public Anonymous_C6(Consumer paramouter_Consumer,
						Consumer.OnConsumeComplete  onConsumeComplete_0, net.named_data.jndn.encrypt.EncryptError.OnError  onError_1)
            {
                this.onConsumeComplete = onConsumeComplete_0;
                    this.onError = onError_1;
                    this.outer_Consumer = paramouter_Consumer;
            }
Ejemplo n.º 7
0
        /// <summary>
        /// Express an Interest to fetch the content packet with contentName, and
        /// decrypt it, fetching keys as needed.
        /// </summary>
        ///
        /// <param name="contentName">The name of the content packet.</param>
        /// <param name="onConsumeComplete_0">contentData is the fetched Data packet and result is the decrypted plain text Blob. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onError_1">better error handling the callback should catch and properly handle any exceptions.</param>
        public void consume(Name contentName,
				Consumer.OnConsumeComplete  onConsumeComplete_0, net.named_data.jndn.encrypt.EncryptError.OnError  onError_1)
        {
            Interest interest_2 = new Interest(contentName);

            // Prepare the callback functions.
            OnData onData_3 = new Consumer.Anonymous_C6 (this, onConsumeComplete_0, onError_1);

            OnTimeout onTimeout = new Consumer.Anonymous_C5 (this, interest_2, onData_3, onError_1);

            // Express the Interest.
            try {
                face_.expressInterest(interest_2, onData_3, onTimeout);
            } catch (IOException ex) {
                try {
                    onError_1.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.IOException,
                            "expressInterest error: " + ex.Message);
                } catch (Exception exception) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception);
                }
            }
        }
Ejemplo n.º 8
0
 public Anonymous_C11(Consumer.Anonymous_C3  paramouter_Anonymous_C3)
 {
     this.outer_Anonymous_C3 = paramouter_Anonymous_C3;
 }
Ejemplo n.º 9
0
            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);
            }
Ejemplo n.º 10
0
 /// <summary>
 /// Call friend.setConsumerFriendAccess to pass an instance of
 /// a FriendAccess class to allow a friend class to call private methods.
 /// </summary>
 ///
 /// <param name="friend">Therefore, only a friend class gets an implementation of FriendAccess.</param>
 public static void setFriendAccess(Consumer.Friend  friend)
 {
     if (friend
                     .GetType().FullName
             .equals("src.net.named_data.jndn.tests.integration_tests.TestGroupConsumer")) {
         friend.setConsumerFriendAccess(new Consumer.FriendAccessImpl ());
     }
 }
Ejemplo n.º 11
0
            public abstract void decrypt(Blob encryptedBlob, Blob keyBits,
					Consumer.OnPlainText  onPlainText_0, net.named_data.jndn.encrypt.EncryptError.OnError  onError_1);
Ejemplo n.º 12
0
                public Anonymous_C17(Consumer.Anonymous_C6  paramouter_Anonymous_C6,
										Data contentData_0)
                {
                    this.contentData = contentData_0;
                                    this.outer_Anonymous_C6 = paramouter_Anonymous_C6;
                }
Ejemplo n.º 13
0
 public Anonymous_C16(Consumer.Anonymous_C6  paramouter_Anonymous_C6)
 {
     this.outer_Anonymous_C6 = paramouter_Anonymous_C6;
 }
Ejemplo n.º 14
0
            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;
            }
Ejemplo n.º 15
0
        /// <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>
        internal static 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().toString());
                } catch (Exception ex_8) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", ex_8);
                }
            }
        }
Ejemplo n.º 16
0
 public Anonymous_C9(Consumer.Anonymous_C2  paramouter_Anonymous_C2)
 {
     this.outer_Anonymous_C2 = paramouter_Anonymous_C2;
 }
Ejemplo n.º 17
0
        /// <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, dKeyName_3,
                        cKeyEncryptedContent_2);

                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);
                    }
                }
            }
        }
Ejemplo n.º 18
0
            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;
            }
Ejemplo n.º 19
0
        /// <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_4 = new Interest(interestName);

                // Prepare the callback functions.
                OnData onData_5 = new Consumer.Anonymous_C4 (this, cKeyName_3, onError_1, onPlainText_0,
                        dataEncryptedContent_2);

                OnTimeout onTimeout = new Consumer.Anonymous_C3 (this, onData_5, onError_1, interest_4);

                // 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);
                    }
                }
            }
        }
Ejemplo n.º 20
0
            public Anonymous_C5(Consumer paramouter_Consumer, Interest interest_0,
						OnData onData_1, net.named_data.jndn.encrypt.EncryptError.OnError  onError_2)
            {
                this.interest = interest_0;
                    this.onData = onData_1;
                    this.onError = onError_2;
                    this.outer_Consumer = paramouter_Consumer;
            }
Ejemplo n.º 21
0
 public Anonymous_C15(Consumer.Anonymous_C5  paramouter_Anonymous_C5)
 {
     this.outer_Anonymous_C5 = paramouter_Anonymous_C5;
 }