private void VerifySegmentDescription(PccrtpResponse pccrtpResponse)
{
#region MS-PCCRC_R67
// Add the debug information
Site.Log.Add(
LogEntryKind.Debug,
@"Verify MS-PCCRC_R67, the actual number of SegmentDescription fields in segments field is {0}",
pccrtpResponse.ContentInfo.segments.Length);
// Verify MS-PCCRC requirement: MS-PCCRC_R67
Site.CaptureRequirementIfAreEqual<uint>(
pccrtpResponse.ContentInfo.cSegments,
(uint)pccrtpResponse.ContentInfo.segments.Length,
67,
@"[In SegmentDescription] The segments field is composed of a number cSegments of
SegmentDescription fields.");
#endregion
#region MS-PCCRC_R69
bool isVerifyR69 = true;
for (int i = 0; i < pccrtpResponse.ContentInfo.cSegments - 1; i++)
{
if (pccrtpResponse.ContentInfo.segments[i].cbSegment != STANDARDSEGMENTSIZE)
{
isVerifyR69 = false;
break;
}
}
// Add the debug information
Site.Log.Add(
LogEntryKind.Debug,
@"Verify MS-PCCRC_R69, the actual size of every segment except for the last segment is {0}32 megabytes",
isVerifyR69 ? string.Empty : "not ");
// Verify MS-PCCRC requirement: MS-PCCRC_R69
Site.CaptureRequirementIfIsTrue(
isVerifyR69,
69,
@"[In SegmentDescription] Every segment except for the last segment must be exactly
32 megabytes in size.");
#endregion
int hashLength = 0;
switch (pccrtpResponse.ContentInfo.dwHashAlgo)
{
case dwHashAlgo_Values.V1:
hashLength = 32;
break;
case dwHashAlgo_Values.V2:
hashLength = 48;
break;
case dwHashAlgo_Values.V3:
hashLength = 64;
break;
default:
break;
}
#region MS-PCCRC_R74
bool isVerifyR74 = true;
bool isVerifyR77 = true;
bool isVerifyR79 = true;
bool isVerifyR83 = true;
bool isVerifyR76 = true;
for (int i = 1; i < pccrtpResponse.ContentInfo.cSegments; i++)
{
ulong offset = pccrtpResponse.ContentInfo.segments[i - 1].ullOffsetInContent
+ pccrtpResponse.ContentInfo.segments[i - 1].cbSegment;
if (pccrtpResponse.ContentInfo.segments[i].ullOffsetInContent != offset)
{
isVerifyR74 = false;
}
if (pccrtpResponse.ContentInfo.segments[i].cbBlockSize != STANDARDBBLOCKSIZE)
{
isVerifyR77 = false;
}
if (Marshal.SizeOf(pccrtpResponse.ContentInfo.segments[i].cbBlockSize) != 4)
{
isVerifyR76 = false;
}
if (pccrtpResponse.ContentInfo.segments[i].SegmentHashOfData.Length != hashLength)
{
isVerifyR79 = false;
}
if (pccrtpResponse.ContentInfo.segments[i].SegmentSecret.Length != hashLength)
{
isVerifyR83 = false;
}
}
if (pccrtpResponse.ContentInfo.segments[0].ullOffsetInContent != 0)
{
isVerifyR74 = false;
}
// Add the debug information
Site.Log.Add(
LogEntryKind.Debug,
@"Verify MS-PCCRC_R74, the ullOffsetInContent in every SegmentDescription field is {0}content offset
at which the start of the segment begins.",
isVerifyR74 ? string.Empty : "not ");
// Verify MS-PCCRC requirement: MS-PCCRC_R74
Site.CaptureRequirementIfIsTrue(
isVerifyR74,
74,
@"[In SegmentDescription] ullOffsetInContent (8 bytes): Content offset at which the start
of the segment begins.");
#endregion
#region MS-PCCRC_R75
// Add the debug information
Site.Log.Add(
LogEntryKind.Debug,
@"Verify MS-PCCRC_R75. The actual size of the cbSegment is {0}.",
Marshal.SizeOf(pccrtpResponse.ContentInfo.segments[0].cbSegment));
// Verify MS-PCCRC requirement: MS-PCCRC_R75
Site.CaptureRequirementIfAreEqual<int>(
4,
Marshal.SizeOf(pccrtpResponse.ContentInfo.segments[0].cbSegment),
75,
@"[In SegmentDescription] cbSegment (4 bytes): Total number of bytes in the segment,
regardless of how many of those bytes intersect the content range.");
#endregion
#region MS-PCCRC_R76
// Add the debug information
Site.Log.Add(
LogEntryKind.Debug,
@"Verify MS-PCCRC_R76. The actual size of the cbBlockSize is {0}4 bytes.",
isVerifyR76 ? string.Empty : "not ");
// Verify MS-PCCRC requirement: MS-PCCRC_R76
Site.CaptureRequirementIfIsTrue(
isVerifyR76,
76,
@"[In SegmentDescription] cbBlockSize (4 bytes):
Length of a content block within this segment, in bytes.");
#endregion
#region MS-PCCRC_R77
// Add the debug information
Site.Log.Add(
LogEntryKind.Debug,
@"Verify MS-PCCRC_R77, the block size of every segment is {0}65536 bytes",
isVerifyR77 ? string.Empty : "not ");
// Verify MS-PCCRC requirement: MS-PCCRC_R77
Site.CaptureRequirementIfIsTrue(
isVerifyR77,
77,
@"[In SegmentDescription] cbBlockSize (4 bytes): Every segment MUST use the block size of 65536 bytes.");
#endregion
#region MS-PCCRC_R79
// Add the debug information
Site.Log.Add(
LogEntryKind.Debug,
@"Verify MS-PCCRC_R79, the actual SegmentHashOfData is {0} of length 32",
isVerifyR79 ? string.Empty : "not ");
// Verify MS-PCCRC requirement: MS-PCCRC_R79
Site.CaptureRequirementIfIsTrue(
isVerifyR79,
79,
@"[In SegmentDescription] SegmentHashOfData (variable): The hash is of length 32 if dwHashAlgo
at the start of the Content Information was 0x800C = SHA-256.");
#endregion
#region MS-PCCRC_R83
// Add the debug information
Site.Log.Add(
LogEntryKind.Debug,
@"Verify MS-PCCRC_R83, the actual length of the SegmentSecret is {0}",
hashLength);
// Verify MS-PCCRC requirement: MS-PCCRC_R83
Site.CaptureRequirementIfIsTrue(
isVerifyR83,
83,
@"[In SegmentDescription] SegmentSecret (variable):The hash is of length 32 if dwHashAlgo
at the start of the Content Information was 0x800C = SHA-256.");
#endregion
}