diff --git a/SMBLibrary/SMB2/SMB2Cryptography.cs b/SMBLibrary/SMB2/SMB2Cryptography.cs index b88d855..93b9839 100644 --- a/SMBLibrary/SMB2/SMB2Cryptography.cs +++ b/SMBLibrary/SMB2/SMB2Cryptography.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Tal Aloni . All rights reserved. +/* Copyright (C) 2020-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, @@ -107,6 +107,18 @@ namespace SMBLibrary.SMB2 return AesCcm.DecryptAndAuthenticate(key, aesCcmNonce, encryptedMessage, associatedData, transformHeader.Signature); } + public static byte[] ComputeHash(HashAlgorithm hashAlgorithm, byte[] buffer) + { + if (hashAlgorithm == HashAlgorithm.SHA512) + { + return SHA512.Create().ComputeHash(buffer); + } + else + { + throw new NotSupportedException($"Hash algorithm {hashAlgorithm} is not supported"); + } + } + private static SMB2TransformHeader CreateTransformHeader(byte[] nonce, int originalMessageLength, ulong sessionID) { byte[] nonceWithPadding = new byte[SMB2TransformHeader.NonceLength];