mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-04-30 10:47:48 +02:00
SMB2Cryptography: Added ComputeHash method
This commit is contained in:
parent
76c1ffa981
commit
d847230868
1 changed files with 13 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2020 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
||||
/* Copyright (C) 2020-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,
|
||||
|
@ -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];
|
||||
|
|
Loading…
Add table
Reference in a new issue