mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-04-30 02:37:49 +02:00
SMB2: Added EncryptionCapabilities structure implementation
This commit is contained in:
parent
d847230868
commit
3cf5fcbe93
2 changed files with 56 additions and 0 deletions
46
SMBLibrary/SMB2/Structures/EncryptionCapabilities.cs
Normal file
46
SMBLibrary/SMB2/Structures/EncryptionCapabilities.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
/* Copyright (C) 2024 Tal Aloni <tal.aloni.il@gmail.com>. 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
|
||||
{
|
||||
/// <summary>
|
||||
/// [MS-SMB2] 2.2.3.1.2 SMB2_ENCRYPTION_CAPABILITIES
|
||||
/// </summary>
|
||||
public class EncryptionCapabilities
|
||||
{
|
||||
// ushort CipherCount;
|
||||
public List<CipherAlgorithm> Ciphers = new List<CipherAlgorithm>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
10
SMBLibrary/SMB2/Structures/Enums/CipherAlgorithm.cs
Normal file
10
SMBLibrary/SMB2/Structures/Enums/CipherAlgorithm.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
namespace SMBLibrary.SMB2
|
||||
{
|
||||
public enum CipherAlgorithm : ushort
|
||||
{
|
||||
Aes128Ccm = 0x0001,
|
||||
Aes128Gcm = 0x0002,
|
||||
Aes256Ccm = 0x0003,
|
||||
Aes256Gcm = 0x0004,
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue