Brunet.Security.SecurityDataMessage.Encrypt C# (CSharp) Method

Encrypt() public method

Encrypts the packet given a SymmetricEncryption.
public Encrypt ( SymmetricEncryption se ) : void
se SymmetricEncryption
return void
    public void Encrypt(SymmetricEncryption se) {
      byte[] to_encrypt = new byte[4 + _data.Length + _signature.Length];
      int pos = 0;
      NumberSerializer.WriteInt(_data.Length, to_encrypt, pos);
      pos += 4;
      _data.CopyTo(to_encrypt, pos);
      pos += _data.Length;
      _signature.CopyTo(to_encrypt, pos);
      _encrypted_data = se.EncryptData(to_encrypt);
      _update_icpacket = true;
    }

Usage Example

Example #1
0
        /// <summary>First signs the data and then encrypts it.</summary>
        /// <param name="UnecryptedData">The data to sign and encrypt.</param>
        /// <returns>The signed and encrypted data.</returns>
        public void SignAndEncrypt(SecurityDataMessage sdm)
        {
            if (_closed)
            {
                throw new Exception("SecurityHandler: closed");
            }
            // Get the sequence id and increment the counter
            int seqid = ++_last_outgoing_seqid;

            // We ask for an update at the half life and every 1000 packets thereafter
            if (seqid == HALF_LIFE || (seqid > HALF_LIFE && seqid % 1000 == 0))
            {
                if (Update != null)
                {
                    Update(Epoch, EventArgs.Empty);
                }
            }

            sdm.Seqid = seqid;
            sdm.Epoch = Epoch;
            sdm.Sign(_outgoing_auth);
            sdm.Encrypt(_encryptor);
        }
All Usage Examples Of Brunet.Security.SecurityDataMessage::Encrypt