mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-07-21 08:45:54 +02:00
GSSAPI: SimpleProtectedNegotiationTokenInit: Extracted GetEncodedMechanismTypeListLength method
This commit is contained in:
parent
dad516b223
commit
2667b5439e
1 changed files with 18 additions and 11 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2017 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
/* Copyright (C) 2017-2024 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
||||||
*
|
*
|
||||||
* You can redistribute this program and/or modify it under the terms of
|
* 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,
|
* the GNU Lesser Public License as published by the Free Software Foundation,
|
||||||
|
@ -102,16 +102,7 @@ namespace SMBLibrary.Authentication.GSSAPI
|
||||||
|
|
||||||
protected virtual int GetTokenFieldsLength()
|
protected virtual int GetTokenFieldsLength()
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = GetEncodedMechanismTypeListLength(MechanismTypeList);
|
||||||
if (MechanismTypeList != null)
|
|
||||||
{
|
|
||||||
int typeListSequenceLength = GetMechanismTypeListSequenceLength(MechanismTypeList);
|
|
||||||
int typeListSequenceLengthFieldSize = DerEncodingHelper.GetLengthFieldSize(typeListSequenceLength);
|
|
||||||
int typeListConstructionLength = 1 + typeListSequenceLengthFieldSize + typeListSequenceLength;
|
|
||||||
int typeListConstructionLengthFieldSize = DerEncodingHelper.GetLengthFieldSize(typeListConstructionLength);
|
|
||||||
int entryLength = 1 + typeListConstructionLengthFieldSize + 1 + typeListSequenceLengthFieldSize + typeListSequenceLength;
|
|
||||||
result += entryLength;
|
|
||||||
}
|
|
||||||
if (MechanismToken != null)
|
if (MechanismToken != null)
|
||||||
{
|
{
|
||||||
int mechanismTokenLengthFieldSize = DerEncodingHelper.GetLengthFieldSize(MechanismToken.Length);
|
int mechanismTokenLengthFieldSize = DerEncodingHelper.GetLengthFieldSize(MechanismToken.Length);
|
||||||
|
@ -229,5 +220,21 @@ namespace SMBLibrary.Authentication.GSSAPI
|
||||||
DerEncodingHelper.WriteLength(buffer, ref offset, mechanismListMIC.Length);
|
DerEncodingHelper.WriteLength(buffer, ref offset, mechanismListMIC.Length);
|
||||||
ByteWriter.WriteBytes(buffer, ref offset, mechanismListMIC);
|
ByteWriter.WriteBytes(buffer, ref offset, mechanismListMIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int GetEncodedMechanismTypeListLength(List<byte[]> mechanismTypeList)
|
||||||
|
{
|
||||||
|
if (mechanismTypeList == null)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int typeListSequenceLength = GetMechanismTypeListSequenceLength(mechanismTypeList);
|
||||||
|
int typeListSequenceLengthFieldSize = DerEncodingHelper.GetLengthFieldSize(typeListSequenceLength);
|
||||||
|
int typeListConstructionLength = 1 + typeListSequenceLengthFieldSize + typeListSequenceLength;
|
||||||
|
int typeListConstructionLengthFieldSize = DerEncodingHelper.GetLengthFieldSize(typeListConstructionLength);
|
||||||
|
return 1 + typeListConstructionLengthFieldSize + 1 + typeListSequenceLengthFieldSize + typeListSequenceLength;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue