diff --git a/SMBLibrary/SMB2/Structures/EncryptionCapabilities.cs b/SMBLibrary/SMB2/Structures/EncryptionCapabilities.cs new file mode 100644 index 0000000..cdd3585 --- /dev/null +++ b/SMBLibrary/SMB2/Structures/EncryptionCapabilities.cs @@ -0,0 +1,46 @@ +/* Copyright (C) 2024 Tal Aloni . All rights reserved. + * + * You can redistribute this program and/or modify it under the terms of + * the GNU Lesser Public License as published by the Free Software Foundation, + * either version 3 of the License, or (at your option) any later version. + */ +using System.Collections.Generic; +using Utilities; + +namespace SMBLibrary.SMB2 +{ + /// + /// [MS-SMB2] 2.2.3.1.2 SMB2_ENCRYPTION_CAPABILITIES + /// + public class EncryptionCapabilities + { + // ushort CipherCount; + public List Ciphers = new List(); + + public EncryptionCapabilities() + { + } + + public EncryptionCapabilities(byte[] buffer, int offset) + { + ushort cipherCount = LittleEndianConverter.ToUInt16(buffer, offset); + for (int index = 0; index < cipherCount; index++) + { + Ciphers.Add((CipherAlgorithm)LittleEndianConverter.ToUInt16(buffer, offset + index * 2)); + } + } + + public byte[] GetBytes() + { + int length = 2 * Ciphers.Count * 2; + byte[] buffer = new byte[length]; + LittleEndianWriter.WriteUInt16(buffer, 0, (ushort)Ciphers.Count); + for (int index = 0; index < Ciphers.Count; index++) + { + LittleEndianWriter.WriteUInt16(buffer, 2 + index * 2, (ushort)Ciphers[index]); + } + + return buffer; + } + } +} diff --git a/SMBLibrary/SMB2/Structures/Enums/CipherAlgorithm.cs b/SMBLibrary/SMB2/Structures/Enums/CipherAlgorithm.cs new file mode 100644 index 0000000..a9da60f --- /dev/null +++ b/SMBLibrary/SMB2/Structures/Enums/CipherAlgorithm.cs @@ -0,0 +1,10 @@ +namespace SMBLibrary.SMB2 +{ + public enum CipherAlgorithm : ushort + { + Aes128Ccm = 0x0001, + Aes128Gcm = 0x0002, + Aes256Ccm = 0x0003, + Aes256Gcm = 0x0004, + } +}