Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pcap-Net
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Pcap-Net
Commits
cf09203f
Commit
cf09203f
authored
Feb 28, 2015
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Calculate KeyTag for DNS resource records DNSKEY and KEY.
parent
4aa021c3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
46 additions
and
8 deletions
+46
-8
OfflinePacketDeviceTests.cs
...tNet/src/PcapDotNet.Core.Test/OfflinePacketDeviceTests.cs
+1
-2
WiresharkDatagramComparerDns.cs
.../src/PcapDotNet.Core.Test/WiresharkDatagramComparerDns.cs
+2
-2
WiresharkDatagramComparerVLanTaggedFrame.cs
...Net.Core.Test/WiresharkDatagramComparerVLanTaggedFrame.cs
+5
-2
DataSegment.cs
PcapDotNet/src/PcapDotNet.Packets/DataSegment.cs
+6
-1
DnsResourceDataDnsKey.cs
...pDotNet.Packets/Dns/ResourceData/DnsResourceDataDnsKey.cs
+14
-0
DnsResourceDataKey.cs
...PcapDotNet.Packets/Dns/ResourceData/DnsResourceDataKey.cs
+17
-0
IpV4Datagram.cs
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Datagram.cs
+1
-1
No files found.
PcapDotNet/src/PcapDotNet.Core.Test/OfflinePacketDeviceTests.cs
View file @
cf09203f
...
...
@@ -82,8 +82,7 @@ namespace PcapDotNet.Core.Test
[
TestMethod
]
public
void
OpenOfflineMultipleTimesUnicode
()
{
// TODO: Fix so we can go beyond 509 when using unicode filenames.
// See http://www.winpcap.org/pipermail/winpcap-bugs/2012-December/001547.html
// TODO: Fix so we can go beyond 509 when using unicode filenames. See http://www.winpcap.org/pipermail/winpcap-bugs/2012-December/001547.html
TestOpenMultipleTimes
(
100
,
@"דמפ.pcap"
);
}
...
...
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkDatagramComparerDns.cs
View file @
cf09203f
...
...
@@ -684,7 +684,7 @@ namespace PcapDotNet.Core.Test
case
"dns.key.key_id"
:
dataField
.
AssertNoFields
();
// TODO: Calculate key tag.
dataField
.
AssertShowDecimal
(
keyData
.
KeyTag
);
break
;
case
"dns.key.public_key"
:
...
...
@@ -1373,8 +1373,8 @@ namespace PcapDotNet.Core.Test
break
;
case
"dns.dnskey.key_id"
:
// TODO: Calculate key tag.
dataField
.
AssertNoFields
();
dataField
.
AssertShowDecimal
(
dnsKeyData
.
KeyTag
);
break
;
case
"dns.dnskey.public_key"
:
...
...
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkDatagramComparerVLanTaggedFrame.cs
View file @
cf09203f
...
...
@@ -40,8 +40,11 @@ namespace PcapDotNet.Core.Test
case
"vlan.len"
:
field
.
AssertShowDecimal
((
ushort
)
vLanTaggedFrameDatagram
.
EtherType
);
field
.
AssertNumFields
(
1
);
field
.
Fields
().
First
().
AssertName
(
"_ws.expert"
);
if
(
field
.
Fields
().
Any
())
{
field
.
AssertNumFields
(
1
);
field
.
Fields
().
First
().
AssertName
(
"_ws.expert"
);
}
break
;
case
"vlan.trailer"
:
...
...
PcapDotNet/src/PcapDotNet.Packets/DataSegment.cs
View file @
cf09203f
...
...
@@ -332,6 +332,11 @@ namespace PcapDotNet.Packets
return
Buffer
.
ReadIpV6Address
(
StartOffset
+
offset
,
endianity
);
}
internal
uint
Sum16Bits
()
{
return
Sum16Bits
(
Buffer
,
StartOffset
,
Length
);
}
/// <summary>
/// Converts the given 16 bits sum to a checksum.
/// Sums the two 16 bits in the 32 bits value and if the result is bigger than a 16 bits value repeat.
...
...
@@ -339,7 +344,7 @@ namespace PcapDotNet.Packets
/// </summary>
/// <param name="sum"></param>
/// <returns></returns>
protected
static
ushort
Sum16BitsToChecksum
(
uint
sum
)
internal
static
ushort
Sum16BitsToChecksum
(
uint
sum
)
{
// Take only 16 bits out of the 32 bit sum and add up the carrier.
// if the results overflows - do it again.
...
...
PcapDotNet/src/PcapDotNet.Packets/Dns/ResourceData/DnsResourceDataDnsKey.cs
View file @
cf09203f
...
...
@@ -117,6 +117,20 @@ namespace PcapDotNet.Packets.Dns
/// </summary>
public
DataSegment
PublicKey
{
get
;
private
set
;
}
public
ushort
KeyTag
{
get
{
if
(
Algorithm
==
DnsAlgorithm
.
RsaMd5
)
return
PublicKey
.
ReadUShort
(
PublicKey
.
Length
-
3
,
Endianity
.
Big
);
ushort
flags
=
BitSequence
.
Merge
((
byte
)(
ZoneKey
?
Mask
.
ZoneKey
:
0
),
(
byte
)((
Revoke
?
Mask
.
Revoke
:
0
)
|
(
SecureEntryPoint
?
Mask
.
SecureEntryPoint
:
0
)));
ushort
protocolAndAlgorithm
=
BitSequence
.
Merge
(
Protocol
,
(
byte
)
Algorithm
);
uint
sum
=
(
uint
)(
flags
+
protocolAndAlgorithm
+
PublicKey
.
Sum16Bits
());
return
(
ushort
)(
sum
+
(
sum
>>
16
));
}
}
/// <summary>
/// Two DnsResourceDataDnsKey are equal iff their zone key, revoke, secure entry point, protocol, algorithm and public key fields are equal.
/// </summary>
...
...
PcapDotNet/src/PcapDotNet.Packets/Dns/ResourceData/DnsResourceDataKey.cs
View file @
cf09203f
...
...
@@ -208,6 +208,23 @@ namespace PcapDotNet.Packets.Dns
/// </summary>
public
DataSegment
PublicKey
{
get
;
private
set
;
}
public
ushort
KeyTag
{
get
{
if
(
Algorithm
==
DnsAlgorithm
.
RsaMd5
)
return
PublicKey
.
ReadUShort
(
PublicKey
.
Length
-
3
,
Endianity
.
Big
);
ushort
flags
=
BitSequence
.
Merge
((
byte
)((
AuthenticationProhibited
?
Mask
.
AuthenticationProhibited
:
0
)
|
(
ConfidentialityProhibited
?
Mask
.
ConfidentialityProhibited
:
0
)
|
(
Experimental
?
Mask
.
Experimental
:
0
)
|
(
FlagsExtension
.
HasValue
?
Mask
.
IsFlagsExtension
:
0
)
|
(
UserAssociated
?
Mask
.
UserAssociated
:
0
)
|
(
byte
)
NameType
),
(
byte
)((
IpSec
?
Mask
.
IpSec
:
0
)
|
(
Email
?
Mask
.
Email
:
0
)
|
(
byte
)
Signatory
));
ushort
protocolAndAlgorithm
=
BitSequence
.
Merge
((
byte
)
Protocol
,
(
byte
)
Algorithm
);
uint
sum
=
(
uint
)(
flags
+
protocolAndAlgorithm
+
(
FlagsExtension
.
HasValue
?
FlagsExtension
.
Value
:
0
)
+
PublicKey
.
Sum16Bits
());
return
(
ushort
)(
sum
+
(
sum
>>
16
));
}
}
/// <summary>
/// Two DnsResourceDataKey are equal iff their authentication prohibited, confidentiality prohibited, experimental, user associated, IPSec, email,
/// name type, signatory, protocol, algorithm, flags extension and public key fields are equal.
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Datagram.cs
View file @
cf09203f
...
...
@@ -347,7 +347,7 @@ namespace PcapDotNet.Packets.IpV4
private
ushort
CalculateHeaderChecksum
()
{
uint
sum
=
Sum16Bits
(
Buffer
,
StartOffset
,
Math
.
Min
(
Offset
.
HeaderChecksum
,
Length
))
+
Sum16Bits
(
Buffer
,
StartOffset
+
Offset
.
HeaderChecksum
+
2
,
RealHeaderLength
-
Offset
.
HeaderChecksum
-
2
);
Sum16Bits
(
Buffer
,
StartOffset
+
Offset
.
HeaderChecksum
+
sizeof
(
ushort
),
RealHeaderLength
-
Offset
.
HeaderChecksum
-
sizeof
(
ushort
)
);
return
Sum16BitsToChecksum
(
sum
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment