/// <summary> /// Parses the packet given as byte array into the current /// class and returns this with the populated parameters. /// </summary> /// <param name="bData">A byte array containing an OpenPGP /// representation of the packet.</param> /// <returns>Returns an AsySessionKeyPacket that containes /// the parsed properties.</returns> /// <remarks>No remarks</remarks> public override Packet ParsePacket(byte[] bData) { if (bData.Length < 10) { throw(new System.ArgumentException("The given Packet is not a valid SessionKey packet!")); } vnVersion = (AsymSessionKeyPacketVersionNumbers)bData[0]; lKeyID = (ulong)bData[1] << 56; lKeyID ^= (ulong)bData[2] << 48; lKeyID ^= (ulong)bData[3] << 40; lKeyID ^= (ulong)bData[4] << 32; lKeyID ^= (ulong)bData[5] << 24; lKeyID ^= (ulong)bData[6] << 16; lKeyID ^= (ulong)bData[7] << 8; lKeyID ^= (ulong)bData[8]; PublicAlgorithm = (AsymAlgorithms)bData[9]; byte[] bMPIs = new byte[bData.Length - 10]; Array.Copy(bData, 10, bMPIs, 0, bMPIs.Length); biEncryptedSessionKey = BigInteger.ParseMPIs(bMPIs); return(this); }
/// <summary> /// Parses the packet given as byte array into the current /// class and returns this with the populated parameters. /// </summary> /// <param name="bData">A byte array containing an OpenPGP /// representation of the packet.</param> /// <returns>Returns an AsySessionKeyPacket that containes /// the parsed properties.</returns> /// <remarks>No remarks</remarks> public override Packet ParsePacket(byte[] bData) { if (bData.Length < 10) { throw(new System.ArgumentException("The given Packet is not a valid SessionKey packet!")); } vnVersion = (AsymSessionKeyPacketVersionNumbers)bData[0]; lKeyID = (ulong)bData[1] << 56; lKeyID ^= (ulong)bData[2] << 48; lKeyID ^= (ulong)bData[3] << 40; lKeyID ^= (ulong)bData[4] << 32; lKeyID ^= (ulong)bData[5] << 24; lKeyID ^= (ulong)bData[6] << 16; lKeyID ^= (ulong)bData[7] << 8; lKeyID ^= (ulong)bData[8]; PublicAlgorithm = (AsymAlgorithms)bData[9]; byte[] bMPIs = new byte[bData.Length - 10]; Array.Copy(bData, 10, bMPIs, 0, bMPIs.Length); biEncryptedSessionKey = BigInteger.ParseMPIs(bMPIs); return this; }