private void VerifySegmentContentBlocks(PccrtpResponse pccrtpResponse)
{
#region MS-PCCRC_R86
// Add the debug information
Site.Log.Add(
LogEntryKind.Debug,
@"Verify MS-PCCRC_R86, the actual number of SegmentContentBlocks fields in blocks field is {0}",
pccrtpResponse.ContentInfo.blocks.Length);
// Verify MS-PCCRC requirement: MS-PCCRC_R86
Site.CaptureRequirementIfAreEqual<uint>(
pccrtpResponse.ContentInfo.cSegments,
(uint)pccrtpResponse.ContentInfo.blocks.Length,
86,
@"[In SegmentContentBlocks] The blocks field contains a number cSegments of
SegmentContentBlocks fields.");
#endregion
#region MS-PCCRC_R89
bool isVerifyR89 = true;
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;
}
foreach (SegmentContentBlocks segContentBlocks in pccrtpResponse.ContentInfo.blocks)
{
if (segContentBlocks.BlockHashes.Length != segContentBlocks.cBlocks * hashLength)
{
isVerifyR89 = false;
break;
}
}
// Add the debug information
Site.Log.Add(
LogEntryKind.Debug,
@"Verify MS-PCCRC_R89, the actual size of BlockHashes field is {0} cBlocks * {1}",
isVerifyR89 ? string.Empty : "not ",
hashLength);
// Verify MS-PCCRC requirement: MS-PCCRC_R89
Site.CaptureRequirementIfIsTrue(
isVerifyR89,
89,
@"[In SegmentContentBlocks] BlockHashes (variable):The size of this field is
cBlocks * (32, 48 or 64, depending on which hash was used).");
#endregion
#region MS-PCCRC_R12
// The BlockHashes field is parsed according the cBlocks and the hash algorithm by the stack.
// If MS-PCCRC_R89 is verified successfully, it indicates that the BlockHashes is the hash list
// of each block in the order the block in the segment.So MS-PCCRC_R12 is captured directly.
Site.CaptureRequirement(
12,
@"[In Content, Segments, and Blocks] Blocks within a segment are identified by their progressive
index within the segment (Block 0 is the first block in the segment, Block 1 the second, and so on).");
#endregion
}