mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-07-12 04:18:09 +02:00
Minor SPNEGO structures refactoring
This commit is contained in:
parent
4ac83f6d97
commit
14cae2a68c
3 changed files with 9 additions and 14 deletions
|
@ -36,14 +36,17 @@ namespace SMBLibrary.Authentication
|
|||
int objectIdentifierLength = DerEncodingHelper.ReadLength(tokenBytes, ref offset);
|
||||
byte[] objectIdentifier = ByteReader.ReadBytes(tokenBytes, ref offset, objectIdentifierLength);
|
||||
if (ByteUtils.AreByteArraysEqual(objectIdentifier, SPNEGOIdentifier))
|
||||
{
|
||||
tag = ByteReader.ReadByte(tokenBytes, ref offset);
|
||||
if (tag == SimpleProtectedNegotiationTokenInit.NegTokenInitTag)
|
||||
{
|
||||
return new SimpleProtectedNegotiationTokenInit(tokenBytes, offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tag == SimpleProtectedNegotiationTokenResponse.NegTokenRespTag)
|
||||
{
|
||||
offset--;
|
||||
return new SimpleProtectedNegotiationTokenResponse(tokenBytes, offset);
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -32,16 +32,12 @@ namespace SMBLibrary.Authentication
|
|||
|
||||
public List<TokenInitEntry> Tokens = new List<TokenInitEntry>();
|
||||
|
||||
/// <param name="offset">The offset following the NegTokenInit tag</param>
|
||||
public SimpleProtectedNegotiationTokenInit(byte[] buffer, int offset)
|
||||
{
|
||||
byte tag = ByteReader.ReadByte(buffer, ref offset);
|
||||
if (tag != NegTokenInitTag)
|
||||
{
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
int constructionLength = DerEncodingHelper.ReadLength(buffer, ref offset);
|
||||
int sequenceEndOffset = offset + constructionLength;
|
||||
tag = ByteReader.ReadByte(buffer, ref offset);
|
||||
byte tag = ByteReader.ReadByte(buffer, ref offset);
|
||||
if (tag != (byte)DerEncodingTag.Sequence)
|
||||
{
|
||||
throw new InvalidDataException();
|
||||
|
|
|
@ -44,16 +44,12 @@ namespace SMBLibrary.Authentication
|
|||
{
|
||||
}
|
||||
|
||||
/// <param name="offset">The offset following the NegTokenResp tag</param>
|
||||
public SimpleProtectedNegotiationTokenResponse(byte[] buffer, int offset)
|
||||
{
|
||||
byte tag = ByteReader.ReadByte(buffer, ref offset);
|
||||
if (tag != NegTokenRespTag)
|
||||
{
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
int constuctionLength = DerEncodingHelper.ReadLength(buffer, ref offset);
|
||||
int sequenceEndOffset = offset + constuctionLength;
|
||||
tag = ByteReader.ReadByte(buffer, ref offset);
|
||||
byte tag = ByteReader.ReadByte(buffer, ref offset);
|
||||
if (tag != (byte)DerEncodingTag.Sequence)
|
||||
{
|
||||
throw new InvalidDataException();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue