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
e3dbedb2
Commit
e3dbedb2
authored
Nov 15, 2011
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DNS
parent
181b8dde
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
142 additions
and
1 deletion
+142
-1
RandomDnsExtensions.cs
...t/src/PcapDotNet.Packets.TestUtils/RandomDnsExtensions.cs
+3
-0
DnsResourceData.cs
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsResourceData.cs
+137
-1
DnsType.cs
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsType.cs
+2
-0
No files found.
PcapDotNet/src/PcapDotNet.Packets.TestUtils/RandomDnsExtensions.cs
View file @
e3dbedb2
...
...
@@ -270,6 +270,9 @@ namespace PcapDotNet.Packets.TestUtils
return
new
DnsResourceDataNextDomainSecure
(
random
.
NextDnsDomainName
(),
((
Func
<
DnsType
>)(()
=>
random
.
NextEnum
<
DnsType
>())).
GenerateArray
(
random
.
Next
(
100
)));
case
DnsType
.
DnsKey
:
return
new
DnsResourceDataDnsKey
(
random
.
NextBool
(),
random
.
NextBool
(),
random
.
NextByte
(),
random
.
NextEnum
<
DnsAlgorithm
>(),
random
.
NextDataSegment
(
random
.
Next
(
100
)));
default
:
return
new
DnsResourceDataAnything
(
random
.
NextDataSegment
(
random
.
Next
(
100
)));
}
...
...
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsResourceData.cs
View file @
e3dbedb2
...
...
@@ -1244,7 +1244,7 @@ namespace PcapDotNet.Packets.Dns
}
/// <summary>
/// RFC
2535
.
/// RFC
s 2535, 2536, 2537, 2539, 3110, 3755, 4034, 5155, 5702, 5933
.
/// The key algorithm.
/// </summary>
public
enum
DnsAlgorithm
...
...
@@ -5232,4 +5232,140 @@ namespace PcapDotNet.Packets.Dns
private
readonly
List
<
DnsType
>
_typesExist
;
}
/// <summary>
/// RFC 4034.
/// <pre>
/// +-----+----------+----------+----------+--------------------+
/// | bit | 0-6 | 7 | 8-14 | 15 |
/// +-----+----------+----------+----------+--------------------+
/// | 0 | Reserved | Zone Key | Reserved | Secure Entry Point |
/// +-----+----------+----------+----------+--------------------+
/// | 16 | Protocol | Algorithm |
/// +-----+---------------------+-------------------------------+
/// | 32 | Public Key |
/// | ... | |
/// +-----+---------------------+-------------------------------+
/// </pre>
/// </summary>
[
DnsTypeRegistration
(
Type
=
DnsType
.
DnsKey
)]
public
sealed
class
DnsResourceDataDnsKey
:
DnsResourceDataSimple
,
IEquatable
<
DnsResourceDataDnsKey
>
{
public
const
byte
ProtocolValue
=
3
;
private
static
class
Offset
{
public
const
int
ZoneKey
=
0
;
public
const
int
SecureEntryPoint
=
1
;
public
const
int
Protocol
=
sizeof
(
ushort
);
public
const
int
Algorithm
=
Protocol
+
sizeof
(
byte
);
public
const
int
PublicKey
=
Algorithm
+
sizeof
(
byte
);
}
private
static
class
Mask
{
public
const
byte
ZoneKey
=
0x01
;
public
const
byte
SecureEntryPoint
=
0x01
;
}
private
const
int
ConstantPartLength
=
Offset
.
PublicKey
;
public
DnsResourceDataDnsKey
(
bool
zoneKey
,
bool
secureEntryPoint
,
byte
protocol
,
DnsAlgorithm
algorithm
,
DataSegment
publicKey
)
{
ZoneKey
=
zoneKey
;
SecureEntryPoint
=
secureEntryPoint
;
Protocol
=
protocol
;
Algorithm
=
algorithm
;
PublicKey
=
publicKey
;
}
/// <summary>
/// If true, the DNSKEY record holds a DNS zone key, and the DNSKEY RR's owner name must be the name of a zone.
/// If false, then the DNSKEY record holds some other type of DNS public key and must not be used to verify RRSIGs that cover RRsets.
/// </summary>
public
bool
ZoneKey
{
get
;
private
set
;
}
/// <summary>
/// RFC 3757.
/// If true, then the DNSKEY record holds a key intended for use as a secure entry point.
/// This flag is only intended to be a hint to zone signing or debugging software as to the intended use of this DNSKEY record;
/// validators must not alter their behavior during the signature validation process in any way based on the setting of this bit.
/// This also means that a DNSKEY RR with the SEP bit set would also need the Zone Key flag set in order to be able to generate signatures legally.
/// A DNSKEY RR with the SEP set and the Zone Key flag not set MUST NOT be used to verify RRSIGs that cover RRsets.
/// </summary>
public
bool
SecureEntryPoint
{
get
;
private
set
;
}
/// <summary>
/// Musthave value 3, and the DNSKEY RR MUST be treated as invalid during signature verification if it is found to be some value other than 3.
/// </summary>
public
byte
Protocol
{
get
;
private
set
;
}
/// <summary>
/// Identifies the public key's cryptographic algorithm and determines the format of the Public Key field.
/// </summary>
public
DnsAlgorithm
Algorithm
{
get
;
private
set
;
}
/// <summary>
/// The public key material.
/// The format depends on the algorithm of the key being stored.
/// </summary>
public
DataSegment
PublicKey
{
get
;
private
set
;
}
public
bool
Equals
(
DnsResourceDataDnsKey
other
)
{
return
other
!=
null
&&
ZoneKey
.
Equals
(
other
.
ZoneKey
)
&&
SecureEntryPoint
.
Equals
(
other
.
SecureEntryPoint
)
&&
Protocol
.
Equals
(
other
.
Protocol
)
&&
Algorithm
.
Equals
(
other
.
Algorithm
)
&&
PublicKey
.
Equals
(
other
.
PublicKey
);
}
public
override
bool
Equals
(
DnsResourceData
other
)
{
return
Equals
(
other
as
DnsResourceDataDnsKey
);
}
internal
DnsResourceDataDnsKey
()
:
this
(
false
,
false
,
ProtocolValue
,
DnsAlgorithm
.
None
,
DataSegment
.
Empty
)
{
}
internal
override
int
GetLength
()
{
return
ConstantPartLength
+
PublicKey
.
Length
;
}
internal
override
void
WriteDataSimple
(
byte
[]
buffer
,
int
offset
)
{
byte
flagsByte0
=
0
;
if
(
ZoneKey
)
flagsByte0
|=
Mask
.
ZoneKey
;
buffer
.
Write
(
offset
+
Offset
.
ZoneKey
,
flagsByte0
);
byte
flagsByte1
=
0
;
if
(
SecureEntryPoint
)
flagsByte1
|=
Mask
.
SecureEntryPoint
;
buffer
.
Write
(
offset
+
Offset
.
SecureEntryPoint
,
flagsByte1
);
buffer
.
Write
(
offset
+
Offset
.
Protocol
,
Protocol
);
buffer
.
Write
(
offset
+
Offset
.
Algorithm
,
(
byte
)
Algorithm
);
PublicKey
.
Write
(
buffer
,
offset
+
Offset
.
PublicKey
);
}
internal
override
DnsResourceData
CreateInstance
(
DataSegment
data
)
{
if
(
data
.
Length
<
ConstantPartLength
)
return
null
;
bool
zoneKey
=
data
.
ReadBool
(
Offset
.
ZoneKey
,
Mask
.
ZoneKey
);
bool
secureEntryPoint
=
data
.
ReadBool
(
Offset
.
SecureEntryPoint
,
Mask
.
SecureEntryPoint
);
byte
protocol
=
data
[
Offset
.
Protocol
];
DnsAlgorithm
algorithm
=
(
DnsAlgorithm
)
data
[
Offset
.
Algorithm
];
DataSegment
publicKey
=
data
.
SubSegment
(
Offset
.
PublicKey
,
data
.
Length
-
ConstantPartLength
);
return
new
DnsResourceDataDnsKey
(
zoneKey
,
secureEntryPoint
,
protocol
,
algorithm
,
publicKey
);
}
}
}
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsType.cs
View file @
e3dbedb2
...
...
@@ -342,6 +342,8 @@
/// <summary>
/// RFCs 3755, 4034.
/// DNSKEY.
/// Represents the public key.
/// Payload type: DnsResourceDataDnsKey.
/// </summary>
DnsKey
=
48
,
...
...
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