Commit 57ac89fd authored by Brickner_cp's avatar Brickner_cp

Warnings, Code Analysis and Documentation. 79 warnings left.

parent 888c8784
...@@ -29,8 +29,27 @@ namespace PcapDotNet.Packets.Dns ...@@ -29,8 +29,27 @@ namespace PcapDotNet.Packets.Dns
public const int Certificate = Algorithm + sizeof(byte); public const int Certificate = Algorithm + sizeof(byte);
} }
public const int ConstantPartLength = Offset.Certificate; private const int ConstantPartLength = Offset.Certificate;
/// <summary>
/// Constructs an instance from the certificate type, key tag, algorithm and certificate fields.
/// </summary>
/// <param name="certificateType">The certificate type.</param>
/// <param name="keyTag">
/// Value computed for the key embedded in the certificate, using the RRSIG Key Tag algorithm.
/// This field is used as an efficiency measure to pick which CERT RRs may be applicable to a particular key.
/// The key tag can be calculated for the key in question, and then only CERT RRs with the same key tag need to be examined.
/// Note that two different keys can have the same key tag.
/// However, the key must be transformed to the format it would have as the public key portion of a DNSKEY RR before the key tag is computed.
/// This is only possible if the key is applicable to an algorithm and complies to limits (such as key size) defined for DNS security.
/// If it is not, the algorithm field must be zero and the tag field is meaningless and should be zero.
/// </param>
/// <param name="algorithm">
/// Has the same meaning as the algorithm field in DNSKEY and RRSIG RRs,
/// except that a zero algorithm field indicates that the algorithm is unknown to a secure DNS,
/// which may simply be the result of the algorithm not having been standardized for DNSSEC.
/// </param>
/// <param name="certificate">The certificate data according to the type.</param>
public DnsResourceDataCertificate(DnsCertificateType certificateType, ushort keyTag, DnsAlgorithm algorithm, DataSegment certificate) public DnsResourceDataCertificate(DnsCertificateType certificateType, ushort keyTag, DnsAlgorithm algorithm, DataSegment certificate)
{ {
CertificateType = certificateType; CertificateType = certificateType;
...@@ -67,6 +86,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -67,6 +86,9 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
public DataSegment Certificate { get; private set; } public DataSegment Certificate { get; private set; }
/// <summary>
/// Two DnsResourceDataCertificate are equal iff their certificate type, key tag, algorithm and certificate fields are equal.
/// </summary>
public bool Equals(DnsResourceDataCertificate other) public bool Equals(DnsResourceDataCertificate other)
{ {
return other != null && return other != null &&
...@@ -76,11 +98,17 @@ namespace PcapDotNet.Packets.Dns ...@@ -76,11 +98,17 @@ namespace PcapDotNet.Packets.Dns
Certificate.Equals(other.Certificate); Certificate.Equals(other.Certificate);
} }
/// <summary>
/// Two DnsResourceDataCertificate are equal iff their certificate type, key tag, algorithm and certificate fields are equal.
/// </summary>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return Equals(obj as DnsResourceDataCertificate); return Equals(obj as DnsResourceDataCertificate);
} }
/// <summary>
/// A hash code of the combination of the certificate type, key tag, algorithm and certificate fields.
/// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return Sequence.GetHashCode(BitSequence.Merge((ushort)CertificateType, KeyTag), Algorithm, Certificate); return Sequence.GetHashCode(BitSequence.Merge((ushort)CertificateType, KeyTag), Algorithm, Certificate);
......
...@@ -30,10 +30,29 @@ namespace PcapDotNet.Packets.Dns ...@@ -30,10 +30,29 @@ namespace PcapDotNet.Packets.Dns
[DnsTypeRegistration(Type = DnsType.NSec3)] [DnsTypeRegistration(Type = DnsType.NSec3)]
public sealed class DnsResourceDataNextDomainSecure3 : DnsResourceDataNextDomainSecure3Base, IEquatable<DnsResourceDataNextDomainSecure3> public sealed class DnsResourceDataNextDomainSecure3 : DnsResourceDataNextDomainSecure3Base, IEquatable<DnsResourceDataNextDomainSecure3>
{ {
/// <summary>
/// Constructs an instance out of the hash algorithm, flags, iterations, salt, next hashed owner name and types exist fields.
/// </summary>
/// <param name="hashAlgorithm">Identifies the cryptographic hash algorithm used to construct the hash-value.</param>
/// <param name="flags">Can be used to indicate different processing. All undefined flags must be zero.</param>
/// <param name="iterations">
/// Defines the number of additional times the hash function has been performed.
/// More iterations result in greater resiliency of the hash value against dictionary attacks,
/// but at a higher computational cost for both the server and resolver.
/// </param>
/// <param name="salt">Appended to the original owner name before hashing in order to defend against pre-calculated dictionary attacks.</param>
/// <param name="nextHashedOwnerName">
/// Contains the next hashed owner name in hash order.
/// This value is in binary format.
/// Given the ordered set of all hashed owner names, the Next Hashed Owner Name field contains the hash of an owner name that immediately follows the owner name of the given NSEC3 RR.
/// The value of the Next Hashed Owner Name field in the last NSEC3 RR in the zone is the same as the hashed owner name of the first NSEC3 RR in the zone in hash order.
/// Note that, unlike the owner name of the NSEC3 RR, the value of this field does not contain the appended zone name.
/// </param>
/// <param name="typesExist">Identifies the RRSet types that exist at the original owner name of the NSEC3 RR.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "flags")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "flags")]
public DnsResourceDataNextDomainSecure3(DnsSecNSec3HashAlgorithm hashAlgorithm, DnsSecNSec3Flags flags, ushort iterations, DataSegment salt, public DnsResourceDataNextDomainSecure3(DnsSecNSec3HashAlgorithm hashAlgorithm, DnsSecNSec3Flags flags, ushort iterations, DataSegment salt,
DataSegment nextHashedOwnerName, IEnumerable<DnsType> existTypes) DataSegment nextHashedOwnerName, IEnumerable<DnsType> typesExist)
: this(hashAlgorithm, flags, iterations, salt, nextHashedOwnerName, new DnsTypeBitmaps(existTypes)) : this(hashAlgorithm, flags, iterations, salt, nextHashedOwnerName, new DnsTypeBitmaps(typesExist))
{ {
} }
...@@ -51,6 +70,10 @@ namespace PcapDotNet.Packets.Dns ...@@ -51,6 +70,10 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
public ReadOnlyCollection<DnsType> TypesExist { get { return _typeBitmaps.TypesExist.AsReadOnly(); } } public ReadOnlyCollection<DnsType> TypesExist { get { return _typeBitmaps.TypesExist.AsReadOnly(); } }
/// <summary>
/// Two DnsResourceDataNextDomainSecure3 are equal iff their hash algorithm, flags, iterations, salt, next hashed owner name and types exist fields
/// are equal.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")]
public bool Equals(DnsResourceDataNextDomainSecure3 other) public bool Equals(DnsResourceDataNextDomainSecure3 other)
{ {
...@@ -59,14 +82,21 @@ namespace PcapDotNet.Packets.Dns ...@@ -59,14 +82,21 @@ namespace PcapDotNet.Packets.Dns
_typeBitmaps.Equals(other._typeBitmaps); _typeBitmaps.Equals(other._typeBitmaps);
} }
/// <summary>
/// Two DnsResourceDataNextDomainSecure3 are equal iff their hash algorithm, flags, iterations, salt, next hashed owner name and types exist fields
/// are equal.
/// </summary>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return Equals(obj as DnsResourceDataNextDomainSecure3); return Equals(obj as DnsResourceDataNextDomainSecure3);
} }
/// <summary>
/// A hash code of the combination of the hash algorithm, flags, iterations, salt, next hashed owner name and types exist fields.
/// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return Sequence.GetHashCode(NextHashedOwnerName, _typeBitmaps); return GetHashCodeParameters() ^ Sequence.GetHashCode(NextHashedOwnerName, _typeBitmaps);
} }
internal DnsResourceDataNextDomainSecure3() internal DnsResourceDataNextDomainSecure3()
......
...@@ -30,6 +30,12 @@ namespace PcapDotNet.Packets.Dns ...@@ -30,6 +30,12 @@ namespace PcapDotNet.Packets.Dns
private const int ConstantPartLength = Offset.Map822; private const int ConstantPartLength = Offset.Map822;
/// <summary>
/// Constructs an instance out of the preference, map822 and mapX400 fields.
/// </summary>
/// <param name="preference">The preference given to this RR among others at the same owner. Lower values are preferred.</param>
/// <param name="map822">RFC 822 domain. The RFC 822 part of the MCGAM.</param>
/// <param name="mapX400">The value of x400-in-domain-syntax derived from the X.400 part of the MCGAM.</param>
public DnsResourceDataX400Pointer(ushort preference, DnsDomainName map822, DnsDomainName mapX400) public DnsResourceDataX400Pointer(ushort preference, DnsDomainName map822, DnsDomainName mapX400)
{ {
Preference = preference; Preference = preference;
...@@ -54,6 +60,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -54,6 +60,9 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
public DnsDomainName MapX400 { get; private set; } public DnsDomainName MapX400 { get; private set; }
/// <summary>
/// Two DnsResourceDataX400Pointer are equal iff their preference, map822 and mapX400 fields are equal.
/// </summary>
public bool Equals(DnsResourceDataX400Pointer other) public bool Equals(DnsResourceDataX400Pointer other)
{ {
return other != null && return other != null &&
...@@ -62,11 +71,17 @@ namespace PcapDotNet.Packets.Dns ...@@ -62,11 +71,17 @@ namespace PcapDotNet.Packets.Dns
MapX400.Equals(other.MapX400); MapX400.Equals(other.MapX400);
} }
/// <summary>
/// Two DnsResourceDataX400Pointer are equal iff their preference, map822 and mapX400 fields are equal.
/// </summary>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return Equals(obj as DnsResourceDataX400Pointer); return Equals(obj as DnsResourceDataX400Pointer);
} }
/// <summary>
/// A hash code of the combination of the preference, map822 and mapX400 fields.
/// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return Sequence.GetHashCode(Preference, Map822, MapX400); return Sequence.GetHashCode(Preference, Map822, MapX400);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment