iPXE
Data Structures | Macros | Functions | Variables
pccrc_test.c File Reference

Peer Content Caching and Retrieval: Content Identification [MS-PCCRC] tests. More...

#include <stdint.h>
#include <string.h>
#include <assert.h>
#include <ipxe/uaccess.h>
#include <ipxe/pccrc.h>
#include <ipxe/sha256.h>
#include <ipxe/sha512.h>
#include <ipxe/hmac.h>
#include <ipxe/test.h>

Go to the source code of this file.

Data Structures

struct  peerdist_info_test
 A content information test. More...
 
struct  peerdist_info_segment_test
 A content information segment test. More...
 
struct  peerdist_info_block_test
 A content information block test. More...
 

Macros

#define DATA(...)   { __VA_ARGS__ }
 Define inline raw data. More...
 
#define RANGE(START, END)   { .start = START, .end = END }
 Define an inline content range. More...
 
#define TRIM(START, END)   { .start = START, .end = END }
 Define an inline trimmed content range. More...
 
#define PEERDIST_INFO_TEST(name, DATA, DIGEST, DIGESTSIZE, RANGE, TRIM, SEGMENTS)
 Define a content information test. More...
 
#define PEERDIST_INFO_SEGMENT_TEST(name, INDEX, RANGE, BLOCKS, BLKSIZE, HASH, SECRET, ID)
 Define a content information segment test. More...
 
#define PEERDIST_INFO_BLOCK_TEST(name, INDEX, RANGE, TRIM, HASH)
 Define a content information block test. More...
 
#define SERVER_PASSPHRASE(name, DATA)   static uint8_t name[] = DATA
 Define a server passphrase. More...
 
#define peerdist_info_ok(test, info)   peerdist_info_okx ( test, info, __FILE__, __LINE__ )
 
#define peerdist_info_segment_ok(test, info, segment)   peerdist_info_segment_okx ( test, info, segment, __FILE__, __LINE__ )
 
#define peerdist_info_block_ok(test, segment, block)   peerdist_info_block_okx ( test, segment, block, __FILE__, __LINE__ )
 
#define peerdist_info_passphrase_ok(test, info, pass, pass_len)
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
 SERVER_PASSPHRASE (passphrase, DATA(0x2a, 0x3d, 0x73, 0xeb, 0x43, 0x5e, 0x9f, 0x2b, 0x8a, 0x34, 0x42, 0x67, 0xe7, 0x46, 0x7a, 0x3c, 0x73, 0x85, 0xc6, 0xe0, 0x55, 0xe2, 0xb4, 0xd3, 0x0d, 0xfe, 0xc7, 0xc3, 0x8b, 0x0e, 0xd7, 0x2c))
 Server passphrase used for these test vectors. More...
 
 PEERDIST_INFO_TEST (iis_85_png_v1, DATA(0x00, 0x01, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x85, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0xd8, 0xd9, 0x76, 0x35, 0x4a, 0x48, 0x72, 0xe9, 0x25, 0x76, 0x18, 0x03, 0xf4, 0x58, 0xd9, 0xda, 0xaa, 0x67, 0xf8, 0xe3, 0x1c, 0x63, 0x0f, 0xb7, 0x4e, 0x6a, 0x31, 0x2e, 0xf8, 0xa2, 0x5a, 0xba, 0x11, 0xaf, 0xc0, 0xd7, 0x94, 0x92, 0x43, 0xf9, 0x4f, 0x9c, 0x1f, 0xab, 0x35, 0xd9, 0xfd, 0x1e, 0x33, 0x1f, 0xcf, 0x78, 0x11, 0xa2, 0xe0, 0x1d, 0x35, 0x87, 0xb3, 0x8d, 0x77, 0x0a, 0x29, 0xe2, 0x02, 0x00, 0x00, 0x00, 0x73, 0xc1, 0x8a, 0xb8, 0x54, 0x91, 0x10, 0xf8, 0xe9, 0x0e, 0x71, 0xbb, 0xc3, 0xab, 0x2a, 0xa8, 0xc4, 0x4d, 0x13, 0xf4, 0x92, 0x94, 0x99, 0x25, 0x5b, 0x66, 0x0f, 0x24, 0xec, 0x77, 0x80, 0x0b, 0x97, 0x4b, 0xdd, 0x65, 0x56, 0x7f, 0xde, 0xec, 0xcd, 0xaf, 0xe4, 0x57, 0xa9, 0x50, 0x3b, 0x45, 0x48, 0xf6, 0x6e, 0xd3, 0xb1, 0x88, 0xdc, 0xfd, 0xa0, 0xac, 0x38, 0x2b, 0x09, 0x71, 0x1a, 0xcc), &sha256_algorithm, 32, RANGE(0, 99710), TRIM(0, 99710), 1)
 IIS logo (iis-85.png) content information version 1. More...
 
 PEERDIST_INFO_SEGMENT_TEST (iis_85_png_v1_s0, 0, RANGE(0, 99710), 2, 65536, DATA(0xd8, 0xd9, 0x76, 0x35, 0x4a, 0x48, 0x72, 0xe9, 0x25, 0x76, 0x18, 0x03, 0xf4, 0x58, 0xd9, 0xda, 0xaa, 0x67, 0xf8, 0xe3, 0x1c, 0x63, 0x0f, 0xb7, 0x4e, 0x6a, 0x31, 0x2e, 0xf8, 0xa2, 0x5a, 0xba), DATA(0x11, 0xaf, 0xc0, 0xd7, 0x94, 0x92, 0x43, 0xf9, 0x4f, 0x9c, 0x1f, 0xab, 0x35, 0xd9, 0xfd, 0x1e, 0x33, 0x1f, 0xcf, 0x78, 0x11, 0xa2, 0xe0, 0x1d, 0x35, 0x87, 0xb3, 0x8d, 0x77, 0x0a, 0x29, 0xe2), DATA(0x49, 0x1b, 0x21, 0x7d, 0xbe, 0xe2, 0xb5, 0xf1, 0x2c, 0xa7, 0x9b, 0x01, 0x5e, 0x06, 0xf4, 0xbb, 0xe6, 0x4f, 0x97, 0x45, 0xba, 0xd7, 0x86, 0x7a, 0xef, 0x17, 0xde, 0x59, 0x92, 0x7e, 0xdc, 0xe9))
 IIS logo (iis-85.png) content information version 1 segment 0. More...
 
 PEERDIST_INFO_BLOCK_TEST (iis_85_png_v1_s0_b0, 0, RANGE(0, 65536), TRIM(0, 65536), DATA(0x73, 0xc1, 0x8a, 0xb8, 0x54, 0x91, 0x10, 0xf8, 0xe9, 0x0e, 0x71, 0xbb, 0xc3, 0xab, 0x2a, 0xa8, 0xc4, 0x4d, 0x13, 0xf4, 0x92, 0x94, 0x99, 0x25, 0x5b, 0x66, 0x0f, 0x24, 0xec, 0x77, 0x80, 0x0b))
 IIS logo (iis-85.png) content information version 1 segment 0 block 0. More...
 
 PEERDIST_INFO_BLOCK_TEST (iis_85_png_v1_s0_b1, 1, RANGE(65536, 99710), TRIM(65536, 99710), DATA(0x97, 0x4b, 0xdd, 0x65, 0x56, 0x7f, 0xde, 0xec, 0xcd, 0xaf, 0xe4, 0x57, 0xa9, 0x50, 0x3b, 0x45, 0x48, 0xf6, 0x6e, 0xd3, 0xb1, 0x88, 0xdc, 0xfd, 0xa0, 0xac, 0x38, 0x2b, 0x09, 0x71, 0x1a, 0xcc))
 IIS logo (iis-85.png) content information version 1 segment 0 block 1. More...
 
 PEERDIST_INFO_TEST (iis_85_png_v2, DATA(0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x99, 0xde, 0xe0, 0xd0, 0xc3, 0x58, 0xe2, 0x68, 0x4b, 0x62, 0x33, 0x0d, 0x32, 0xb5, 0xf1, 0x97, 0x87, 0x24, 0xa0, 0xd0, 0xa5, 0x2b, 0xdc, 0x5e, 0x78, 0x1f, 0xae, 0x71, 0xff, 0x57, 0xa8, 0xbe, 0x3d, 0xd4, 0x58, 0x03, 0x7e, 0xd4, 0x04, 0x11, 0x6b, 0xb6, 0x16, 0xd9, 0xb1, 0x41, 0x16, 0x08, 0x85, 0x20, 0xc4, 0x7c, 0xdc, 0x50, 0xab, 0xce, 0xa3, 0xfa, 0xe1, 0x88, 0xa9, 0x8e, 0xa2, 0x2d, 0xf3, 0xc0, 0x00, 0x00, 0xeb, 0xa0, 0x33, 0x81, 0xd0, 0xd0, 0xcb, 0x74, 0xf4, 0xb6, 0x13, 0xd8, 0x21, 0x0f, 0x37, 0xf0, 0x02, 0xa0, 0x6f, 0x39, 0x10, 0x58, 0x60, 0x96, 0xa1, 0x30, 0xd3, 0x43, 0x98, 0xc0, 0x8e, 0x66, 0xd7, 0xbc, 0xb8, 0xb6, 0xeb, 0x77, 0x83, 0xe4, 0xf8, 0x07, 0x64, 0x7b, 0x63, 0xf1, 0x46, 0xb5, 0x2f, 0x4a, 0xc8, 0x9c, 0xcc, 0x7a, 0xbf, 0x5f, 0xa1, 0x1a, 0xca, 0xfc, 0x2a, 0xcf, 0x50, 0x28, 0x58, 0x6c), &sha512_algorithm, 32, RANGE(0, 99710), TRIM(0, 99710), 2)
 IIS logo (iis-85.png) content information version 2. More...
 
 PEERDIST_INFO_SEGMENT_TEST (iis_85_png_v2_s0, 0, RANGE(0, 39390), 1, 39390, DATA(0xe0, 0xd0, 0xc3, 0x58, 0xe2, 0x68, 0x4b, 0x62, 0x33, 0x0d, 0x32, 0xb5, 0xf1, 0x97, 0x87, 0x24, 0xa0, 0xd0, 0xa5, 0x2b, 0xdc, 0x5e, 0x78, 0x1f, 0xae, 0x71, 0xff, 0x57, 0xa8, 0xbe, 0x3d, 0xd4), DATA(0x58, 0x03, 0x7e, 0xd4, 0x04, 0x11, 0x6b, 0xb6, 0x16, 0xd9, 0xb1, 0x41, 0x16, 0x08, 0x85, 0x20, 0xc4, 0x7c, 0xdc, 0x50, 0xab, 0xce, 0xa3, 0xfa, 0xe1, 0x88, 0xa9, 0x8e, 0xa2, 0x2d, 0xf3, 0xc0), DATA(0x33, 0x71, 0xbb, 0xea, 0xdd, 0xb6, 0x23, 0x53, 0xad, 0xce, 0xf9, 0x70, 0xa0, 0x6f, 0xdf, 0x65, 0x00, 0x1e, 0x04, 0x21, 0xf4, 0xc7, 0x10, 0x82, 0x76, 0xb0, 0xc3, 0x7a, 0x9f, 0x9e, 0xc1, 0x0f))
 IIS logo (iis-85.png) content information version 2 segment 0. More...
 
 PEERDIST_INFO_BLOCK_TEST (iis_85_png_v2_s0_b0, 0, RANGE(0, 39390), TRIM(0, 39390), DATA(0xe0, 0xd0, 0xc3, 0x58, 0xe2, 0x68, 0x4b, 0x62, 0x33, 0x0d, 0x32, 0xb5, 0xf1, 0x97, 0x87, 0x24, 0xa0, 0xd0, 0xa5, 0x2b, 0xdc, 0x5e, 0x78, 0x1f, 0xae, 0x71, 0xff, 0x57, 0xa8, 0xbe, 0x3d, 0xd4))
 IIS logo (iis-85.png) content information version 2 segment 0 block 0. More...
 
 PEERDIST_INFO_SEGMENT_TEST (iis_85_png_v2_s1, 1, RANGE(39390, 99710), 1, 60320, DATA(0x33, 0x81, 0xd0, 0xd0, 0xcb, 0x74, 0xf4, 0xb6, 0x13, 0xd8, 0x21, 0x0f, 0x37, 0xf0, 0x02, 0xa0, 0x6f, 0x39, 0x10, 0x58, 0x60, 0x96, 0xa1, 0x30, 0xd3, 0x43, 0x98, 0xc0, 0x8e, 0x66, 0xd7, 0xbc), DATA(0xb8, 0xb6, 0xeb, 0x77, 0x83, 0xe4, 0xf8, 0x07, 0x64, 0x7b, 0x63, 0xf1, 0x46, 0xb5, 0x2f, 0x4a, 0xc8, 0x9c, 0xcc, 0x7a, 0xbf, 0x5f, 0xa1, 0x1a, 0xca, 0xfc, 0x2a, 0xcf, 0x50, 0x28, 0x58, 0x6c), DATA(0xd7, 0xe9, 0x24, 0x42, 0x5e, 0x8f, 0x4f, 0x88, 0xf0, 0x1d, 0xc6, 0xa9, 0xbb, 0x1b, 0xc3, 0x7b, 0xe1, 0x13, 0xec, 0x79, 0x17, 0xc7, 0x45, 0xd4, 0x96, 0x5c, 0x2b, 0x55, 0xfa, 0x16, 0x3a, 0x6e))
 IIS logo (iis-85.png) content information version 2 segment 1. More...
 
 PEERDIST_INFO_BLOCK_TEST (iis_85_png_v2_s1_b0, 0, RANGE(39390, 99710), TRIM(39390, 99710), DATA(0x33, 0x81, 0xd0, 0xd0, 0xcb, 0x74, 0xf4, 0xb6, 0x13, 0xd8, 0x21, 0x0f, 0x37, 0xf0, 0x02, 0xa0, 0x6f, 0x39, 0x10, 0x58, 0x60, 0x96, 0xa1, 0x30, 0xd3, 0x43, 0x98, 0xc0, 0x8e, 0x66, 0xd7, 0xbc))
 IIS logo (iis-85.png) content information version 2 segment 1 block 0. More...
 
static void peerdist_info_okx (struct peerdist_info_test *test, struct peerdist_info *info, const char *file, unsigned int line)
 Report content information test result. More...
 
static void peerdist_info_segment_okx (struct peerdist_info_segment_test *test, const struct peerdist_info *info, struct peerdist_info_segment *segment, const char *file, unsigned int line)
 Report content information segment test result. More...
 
static void peerdist_info_block_okx (struct peerdist_info_block_test *test, const struct peerdist_info_segment *segment, struct peerdist_info_block *block, const char *file, unsigned int line)
 Report content information block test result. More...
 
static void peerdist_info_passphrase_okx (struct peerdist_info_segment_test *test, const struct peerdist_info *info, uint8_t *pass, size_t pass_len, const char *file, unsigned int line)
 Report server passphrase test result. More...
 
static void peerdist_info_test_exec (void)
 Perform content information self-tests. More...
 

Variables

struct self_test peerdist_info_test __self_test
 Content information self-test. More...
 

Detailed Description

Peer Content Caching and Retrieval: Content Identification [MS-PCCRC] tests.

Definition in file pccrc_test.c.

Macro Definition Documentation

◆ DATA

#define DATA (   ...)    { __VA_ARGS__ }

Define inline raw data.

Definition at line 46 of file pccrc_test.c.

◆ RANGE

#define RANGE (   START,
  END 
)    { .start = START, .end = END }

Define an inline content range.

Parameters
STARTStart offset
ENDEnd offset
Return values
rangeContent range

Definition at line 55 of file pccrc_test.c.

◆ TRIM

#define TRIM (   START,
  END 
)    { .start = START, .end = END }

Define an inline trimmed content range.

Parameters
STARTStart offset
ENDEnd offset
Return values
trimTrimmed content range

Definition at line 64 of file pccrc_test.c.

◆ PEERDIST_INFO_TEST

#define PEERDIST_INFO_TEST (   name,
  DATA,
  DIGEST,
  DIGESTSIZE,
  RANGE,
  TRIM,
  SEGMENTS 
)
Value:
static const uint8_t name ## _data[] = DATA; \
static struct peerdist_info_test name = { \
.data = name ## _data, \
.len = sizeof ( name ## _data ), \
.expected_digestsize = DIGESTSIZE, \
.expected_segments = SEGMENTS, \
}
#define TRIM(START, END)
Define an inline trimmed content range.
Definition: pccrc_test.c:64
const char * name
Definition: ath9k_hw.c:1984
size_t expected_digestsize
Expected digest size.
Definition: pccrc_test.c:75
unsigned int expected_segments
Expected number of segments.
Definition: pccrc_test.c:81
unsigned char uint8_t
Definition: stdint.h:10
struct peerdist_range expected_range
Expected content range.
Definition: pccrc_test.c:77
#define RANGE(START, END)
Define an inline content range.
Definition: pccrc_test.c:55
A content information test.
Definition: pccrc_test.c:67
struct digest_algorithm * expected_digest
Expected digest algorithm.
Definition: pccrc_test.c:73
struct peerdist_range expected_trim
Expected trimmed content range.
Definition: pccrc_test.c:79
#define DATA(...)
Define inline raw data.
Definition: pccrc_test.c:46
#define DIGEST(...)
Define inline expected digest.
Definition: der_test.c:45

Define a content information test.

Parameters
nameTest name
DATARaw content information
DIGESTExpected digest algorithm
DIGESTSIZEExpected digest size
RANGEExpected content range
TRIMExpected trimmer content range
SEGMENTSExpected number of segments
Return values
testContent information test

Raw content information can be obtained from PeerDist-capable web servers using wget's "--header" option to inject the relevant PeerDist headers. For example:

wget –header "Accept-Encoding: peerdist" \ –header "X-P2P-PeerDist: Version=1.0" \ http://peerdist.server.address/test.url -O - | xxd -i -c 11

Version 1 content information can be retrieved using the headers:

Accept-Encoding: peerdist X-P2P-PeerDist: Version=1.0

Version 2 content information can be retrieved (from compatible servers) using the headers:

Accept-Encoding: peerdist X-P2P-PeerDist: Version=1.1 X-P2P-PeerDistEx: MinContentInformation=2.0, MaxContentInformation=2.0

Definition at line 116 of file pccrc_test.c.

◆ PEERDIST_INFO_SEGMENT_TEST

#define PEERDIST_INFO_SEGMENT_TEST (   name,
  INDEX,
  RANGE,
  BLOCKS,
  BLKSIZE,
  HASH,
  SECRET,
  ID 
)
Value:
static struct peerdist_info_segment_test name = { \
.index = INDEX, \
.expected_range = RANGE, \
.expected_blocks = BLOCKS, \
.expected_blksize = BLKSIZE, \
.expected_hash = HASH, \
.expected_secret = SECRET, \
.expected_id = ID, \
}
const char * name
Definition: ath9k_hw.c:1984
A content information segment test.
Definition: pccrc_test.c:130
#define RANGE(START, END)
Define an inline content range.
Definition: pccrc_test.c:55

Define a content information segment test.

Parameters
nameTest name
INDEXSegment index
RANGEExpected content range
BLOCKSExpected number of blocks
BLKSIZEExpected block size
HASHExpected segment hash of data
SECRETExpected segment secret
IDExpected segment identifier
Return values
testContent information segment test

Definition at line 160 of file pccrc_test.c.

◆ PEERDIST_INFO_BLOCK_TEST

#define PEERDIST_INFO_BLOCK_TEST (   name,
  INDEX,
  RANGE,
  TRIM,
  HASH 
)
Value:
static struct peerdist_info_block_test name = { \
.index = INDEX, \
.expected_range = RANGE, \
.expected_trim = TRIM, \
.expected_hash = HASH, \
}
#define TRIM(START, END)
Define an inline trimmed content range.
Definition: pccrc_test.c:64
const char * name
Definition: ath9k_hw.c:1984
A content information block test.
Definition: pccrc_test.c:173
#define RANGE(START, END)
Define an inline content range.
Definition: pccrc_test.c:55

Define a content information block test.

Parameters
nameTest name
INDEXBlock index
RANGEExpected content range
TRIMExpected trimmed content range
HASHExpected hash of data
Return values
testContent information block test

Definition at line 194 of file pccrc_test.c.

◆ SERVER_PASSPHRASE

#define SERVER_PASSPHRASE (   name,
  DATA 
)    static uint8_t name[] = DATA

Define a server passphrase.

Parameters
nameServer passphrase name
DATARaw server passphrase

The server passphrase can be exported from a Windows BranchCache server using the command:

netsh branchcache exportkey exported.key somepassword

and this encrypted exported key can be decrypted using the oSSL_key_dx or mcrypt_key_dx utilities found in the (prototype) Prequel project at https://fedorahosted.org/prequel/ :

oSSL_key_dx exported.key somepassword or mcrypt_key_dx exported.key somepassword

Either command will display both the server passphrase and the "Server Secret". Note that this latter is the version 1 server secret (i.e. the SHA-256 of the server passphrase); the corresponding version 2 server secret can be obtained by calculating the truncated SHA-512 of the server passphrase.

We do not know the server passphrase during normal operation. We use it in the self-tests only to check for typos and other errors in the test vectors, by checking that the segment secret defined in a content information segment test is as expected.

Definition at line 232 of file pccrc_test.c.

◆ peerdist_info_ok

#define peerdist_info_ok (   test,
  info 
)    peerdist_info_okx ( test, info, __FILE__, __LINE__ )

Definition at line 381 of file pccrc_test.c.

◆ peerdist_info_segment_ok

#define peerdist_info_segment_ok (   test,
  info,
  segment 
)    peerdist_info_segment_okx ( test, info, segment, __FILE__, __LINE__ )

Definition at line 417 of file pccrc_test.c.

◆ peerdist_info_block_ok

#define peerdist_info_block_ok (   test,
  segment,
  block 
)    peerdist_info_block_okx ( test, segment, block, __FILE__, __LINE__ )

Definition at line 451 of file pccrc_test.c.

◆ peerdist_info_passphrase_ok

#define peerdist_info_passphrase_ok (   test,
  info,
  pass,
  pass_len 
)
Value:
peerdist_info_passphrase_okx ( test, info, pass, pass_len, \
__FILE__, __LINE__ )
u32 info
Definition: ar9003_mac.h:67
static void peerdist_info_passphrase_okx(struct peerdist_info_segment_test *test, const struct peerdist_info *info, uint8_t *pass, size_t pass_len, const char *file, unsigned int line)
Report server passphrase test result.
Definition: pccrc_test.c:465
static int test
Definition: epic100.c:73

Definition at line 489 of file pccrc_test.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ SERVER_PASSPHRASE()

SERVER_PASSPHRASE ( passphrase  ,
DATA(0x2a, 0x3d, 0x73, 0xeb, 0x43, 0x5e, 0x9f, 0x2b, 0x8a, 0x34, 0x42, 0x67, 0xe7, 0x46, 0x7a, 0x3c, 0x73, 0x85, 0xc6, 0xe0, 0x55, 0xe2, 0xb4, 0xd3, 0x0d, 0xfe, 0xc7, 0xc3, 0x8b, 0x0e, 0xd7, 0x2c)   
)

Server passphrase used for these test vectors.

◆ PEERDIST_INFO_TEST() [1/2]

PEERDIST_INFO_TEST ( iis_85_png_v1  ,
DATA(0x00, 0x01, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x85, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0xd8, 0xd9, 0x76, 0x35, 0x4a, 0x48, 0x72, 0xe9, 0x25, 0x76, 0x18, 0x03, 0xf4, 0x58, 0xd9, 0xda, 0xaa, 0x67, 0xf8, 0xe3, 0x1c, 0x63, 0x0f, 0xb7, 0x4e, 0x6a, 0x31, 0x2e, 0xf8, 0xa2, 0x5a, 0xba, 0x11, 0xaf, 0xc0, 0xd7, 0x94, 0x92, 0x43, 0xf9, 0x4f, 0x9c, 0x1f, 0xab, 0x35, 0xd9, 0xfd, 0x1e, 0x33, 0x1f, 0xcf, 0x78, 0x11, 0xa2, 0xe0, 0x1d, 0x35, 0x87, 0xb3, 0x8d, 0x77, 0x0a, 0x29, 0xe2, 0x02, 0x00, 0x00, 0x00, 0x73, 0xc1, 0x8a, 0xb8, 0x54, 0x91, 0x10, 0xf8, 0xe9, 0x0e, 0x71, 0xbb, 0xc3, 0xab, 0x2a, 0xa8, 0xc4, 0x4d, 0x13, 0xf4, 0x92, 0x94, 0x99, 0x25, 0x5b, 0x66, 0x0f, 0x24, 0xec, 0x77, 0x80, 0x0b, 0x97, 0x4b, 0xdd, 0x65, 0x56, 0x7f, 0xde, 0xec, 0xcd, 0xaf, 0xe4, 0x57, 0xa9, 0x50, 0x3b, 0x45, 0x48, 0xf6, 0x6e, 0xd3, 0xb1, 0x88, 0xdc, 0xfd, 0xa0, 0xac, 0x38, 0x2b, 0x09, 0x71, 0x1a, 0xcc)  ,
sha256_algorithm,
32  ,
RANGE(0, 99710)  ,
TRIM(0, 99710)  ,
 
)

IIS logo (iis-85.png) content information version 1.

◆ PEERDIST_INFO_SEGMENT_TEST() [1/3]

PEERDIST_INFO_SEGMENT_TEST ( iis_85_png_v1_s0  ,
,
RANGE(0, 99710)  ,
,
65536  ,
DATA(0xd8, 0xd9, 0x76, 0x35, 0x4a, 0x48, 0x72, 0xe9, 0x25, 0x76, 0x18, 0x03, 0xf4, 0x58, 0xd9, 0xda, 0xaa, 0x67, 0xf8, 0xe3, 0x1c, 0x63, 0x0f, 0xb7, 0x4e, 0x6a, 0x31, 0x2e, 0xf8, 0xa2, 0x5a, 0xba)  ,
DATA(0x11, 0xaf, 0xc0, 0xd7, 0x94, 0x92, 0x43, 0xf9, 0x4f, 0x9c, 0x1f, 0xab, 0x35, 0xd9, 0xfd, 0x1e, 0x33, 0x1f, 0xcf, 0x78, 0x11, 0xa2, 0xe0, 0x1d, 0x35, 0x87, 0xb3, 0x8d, 0x77, 0x0a, 0x29, 0xe2)  ,
DATA(0x49, 0x1b, 0x21, 0x7d, 0xbe, 0xe2, 0xb5, 0xf1, 0x2c, 0xa7, 0x9b, 0x01, 0x5e, 0x06, 0xf4, 0xbb, 0xe6, 0x4f, 0x97, 0x45, 0xba, 0xd7, 0x86, 0x7a, 0xef, 0x17, 0xde, 0x59, 0x92, 0x7e, 0xdc, 0xe9)   
)

IIS logo (iis-85.png) content information version 1 segment 0.

◆ PEERDIST_INFO_BLOCK_TEST() [1/4]

PEERDIST_INFO_BLOCK_TEST ( iis_85_png_v1_s0_b0  ,
,
RANGE(0, 65536)  ,
TRIM(0, 65536)  ,
DATA(0x73, 0xc1, 0x8a, 0xb8, 0x54, 0x91, 0x10, 0xf8, 0xe9, 0x0e, 0x71, 0xbb, 0xc3, 0xab, 0x2a, 0xa8, 0xc4, 0x4d, 0x13, 0xf4, 0x92, 0x94, 0x99, 0x25, 0x5b, 0x66, 0x0f, 0x24, 0xec, 0x77, 0x80, 0x0b)   
)

IIS logo (iis-85.png) content information version 1 segment 0 block 0.

◆ PEERDIST_INFO_BLOCK_TEST() [2/4]

PEERDIST_INFO_BLOCK_TEST ( iis_85_png_v1_s0_b1  ,
,
RANGE(65536, 99710)  ,
TRIM(65536, 99710)  ,
DATA(0x97, 0x4b, 0xdd, 0x65, 0x56, 0x7f, 0xde, 0xec, 0xcd, 0xaf, 0xe4, 0x57, 0xa9, 0x50, 0x3b, 0x45, 0x48, 0xf6, 0x6e, 0xd3, 0xb1, 0x88, 0xdc, 0xfd, 0xa0, 0xac, 0x38, 0x2b, 0x09, 0x71, 0x1a, 0xcc)   
)

IIS logo (iis-85.png) content information version 1 segment 0 block 1.

◆ PEERDIST_INFO_TEST() [2/2]

PEERDIST_INFO_TEST ( iis_85_png_v2  ,
DATA(0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x99, 0xde, 0xe0, 0xd0, 0xc3, 0x58, 0xe2, 0x68, 0x4b, 0x62, 0x33, 0x0d, 0x32, 0xb5, 0xf1, 0x97, 0x87, 0x24, 0xa0, 0xd0, 0xa5, 0x2b, 0xdc, 0x5e, 0x78, 0x1f, 0xae, 0x71, 0xff, 0x57, 0xa8, 0xbe, 0x3d, 0xd4, 0x58, 0x03, 0x7e, 0xd4, 0x04, 0x11, 0x6b, 0xb6, 0x16, 0xd9, 0xb1, 0x41, 0x16, 0x08, 0x85, 0x20, 0xc4, 0x7c, 0xdc, 0x50, 0xab, 0xce, 0xa3, 0xfa, 0xe1, 0x88, 0xa9, 0x8e, 0xa2, 0x2d, 0xf3, 0xc0, 0x00, 0x00, 0xeb, 0xa0, 0x33, 0x81, 0xd0, 0xd0, 0xcb, 0x74, 0xf4, 0xb6, 0x13, 0xd8, 0x21, 0x0f, 0x37, 0xf0, 0x02, 0xa0, 0x6f, 0x39, 0x10, 0x58, 0x60, 0x96, 0xa1, 0x30, 0xd3, 0x43, 0x98, 0xc0, 0x8e, 0x66, 0xd7, 0xbc, 0xb8, 0xb6, 0xeb, 0x77, 0x83, 0xe4, 0xf8, 0x07, 0x64, 0x7b, 0x63, 0xf1, 0x46, 0xb5, 0x2f, 0x4a, 0xc8, 0x9c, 0xcc, 0x7a, 0xbf, 0x5f, 0xa1, 0x1a, 0xca, 0xfc, 0x2a, 0xcf, 0x50, 0x28, 0x58, 0x6c)  ,
sha512_algorithm,
32  ,
RANGE(0, 99710)  ,
TRIM(0, 99710)  ,
 
)

IIS logo (iis-85.png) content information version 2.

◆ PEERDIST_INFO_SEGMENT_TEST() [2/3]

PEERDIST_INFO_SEGMENT_TEST ( iis_85_png_v2_s0  ,
,
RANGE(0, 39390)  ,
,
39390  ,
DATA(0xe0, 0xd0, 0xc3, 0x58, 0xe2, 0x68, 0x4b, 0x62, 0x33, 0x0d, 0x32, 0xb5, 0xf1, 0x97, 0x87, 0x24, 0xa0, 0xd0, 0xa5, 0x2b, 0xdc, 0x5e, 0x78, 0x1f, 0xae, 0x71, 0xff, 0x57, 0xa8, 0xbe, 0x3d, 0xd4)  ,
DATA(0x58, 0x03, 0x7e, 0xd4, 0x04, 0x11, 0x6b, 0xb6, 0x16, 0xd9, 0xb1, 0x41, 0x16, 0x08, 0x85, 0x20, 0xc4, 0x7c, 0xdc, 0x50, 0xab, 0xce, 0xa3, 0xfa, 0xe1, 0x88, 0xa9, 0x8e, 0xa2, 0x2d, 0xf3, 0xc0)  ,
DATA(0x33, 0x71, 0xbb, 0xea, 0xdd, 0xb6, 0x23, 0x53, 0xad, 0xce, 0xf9, 0x70, 0xa0, 0x6f, 0xdf, 0x65, 0x00, 0x1e, 0x04, 0x21, 0xf4, 0xc7, 0x10, 0x82, 0x76, 0xb0, 0xc3, 0x7a, 0x9f, 0x9e, 0xc1, 0x0f)   
)

IIS logo (iis-85.png) content information version 2 segment 0.

◆ PEERDIST_INFO_BLOCK_TEST() [3/4]

PEERDIST_INFO_BLOCK_TEST ( iis_85_png_v2_s0_b0  ,
,
RANGE(0, 39390)  ,
TRIM(0, 39390)  ,
DATA(0xe0, 0xd0, 0xc3, 0x58, 0xe2, 0x68, 0x4b, 0x62, 0x33, 0x0d, 0x32, 0xb5, 0xf1, 0x97, 0x87, 0x24, 0xa0, 0xd0, 0xa5, 0x2b, 0xdc, 0x5e, 0x78, 0x1f, 0xae, 0x71, 0xff, 0x57, 0xa8, 0xbe, 0x3d, 0xd4)   
)

IIS logo (iis-85.png) content information version 2 segment 0 block 0.

◆ PEERDIST_INFO_SEGMENT_TEST() [3/3]

PEERDIST_INFO_SEGMENT_TEST ( iis_85_png_v2_s1  ,
,
RANGE(39390, 99710)  ,
,
60320  ,
DATA(0x33, 0x81, 0xd0, 0xd0, 0xcb, 0x74, 0xf4, 0xb6, 0x13, 0xd8, 0x21, 0x0f, 0x37, 0xf0, 0x02, 0xa0, 0x6f, 0x39, 0x10, 0x58, 0x60, 0x96, 0xa1, 0x30, 0xd3, 0x43, 0x98, 0xc0, 0x8e, 0x66, 0xd7, 0xbc)  ,
DATA(0xb8, 0xb6, 0xeb, 0x77, 0x83, 0xe4, 0xf8, 0x07, 0x64, 0x7b, 0x63, 0xf1, 0x46, 0xb5, 0x2f, 0x4a, 0xc8, 0x9c, 0xcc, 0x7a, 0xbf, 0x5f, 0xa1, 0x1a, 0xca, 0xfc, 0x2a, 0xcf, 0x50, 0x28, 0x58, 0x6c)  ,
DATA(0xd7, 0xe9, 0x24, 0x42, 0x5e, 0x8f, 0x4f, 0x88, 0xf0, 0x1d, 0xc6, 0xa9, 0xbb, 0x1b, 0xc3, 0x7b, 0xe1, 0x13, 0xec, 0x79, 0x17, 0xc7, 0x45, 0xd4, 0x96, 0x5c, 0x2b, 0x55, 0xfa, 0x16, 0x3a, 0x6e)   
)

IIS logo (iis-85.png) content information version 2 segment 1.

◆ PEERDIST_INFO_BLOCK_TEST() [4/4]

PEERDIST_INFO_BLOCK_TEST ( iis_85_png_v2_s1_b0  ,
,
RANGE(39390, 99710)  ,
TRIM(39390, 99710)  ,
DATA(0x33, 0x81, 0xd0, 0xd0, 0xcb, 0x74, 0xf4, 0xb6, 0x13, 0xd8, 0x21, 0x0f, 0x37, 0xf0, 0x02, 0xa0, 0x6f, 0x39, 0x10, 0x58, 0x60, 0x96, 0xa1, 0x30, 0xd3, 0x43, 0x98, 0xc0, 0x8e, 0x66, 0xd7, 0xbc)   
)

IIS logo (iis-85.png) content information version 2 segment 1 block 0.

◆ peerdist_info_okx()

static void peerdist_info_okx ( struct peerdist_info_test test,
struct peerdist_info info,
const char *  file,
unsigned int  line 
)
static

Report content information test result.

Parameters
testContent information test
infoContent information to fill in
fileTest code file
lineTest code line

Definition at line 360 of file pccrc_test.c.

362  {
363 
364  /* Parse content information */
365  okx ( peerdist_info ( virt_to_user ( test->data ), test->len,
366  info ) == 0, file, line );
367 
368  /* Verify content information */
369  okx ( info->raw.data == virt_to_user ( test->data ), file, line );
370  okx ( info->raw.len == test->len, file, line );
371  okx ( info->digest == test->expected_digest, file, line );
372  okx ( info->digestsize == test->expected_digestsize, file, line );
373  okx ( info->range.start == test->expected_range.start, file, line );
374  okx ( info->range.end == test->expected_range.end, file, line );
375  okx ( info->trim.start == test->expected_trim.start, file, line );
376  okx ( info->trim.end == test->expected_trim.end, file, line );
377  okx ( info->trim.start >= info->range.start, file, line );
378  okx ( info->trim.end <= info->range.end, file, line );
379  okx ( info->segments == test->expected_segments, file, line );
380 }
u32 info
Definition: ar9003_mac.h:67
#define okx(success, file, line)
Report test result.
Definition: test.h:44
Content information.
Definition: pccrc.h:317
userptr_t virt_to_user(volatile const void *addr)
Convert virtual address to user pointer.
static int test
Definition: epic100.c:73

References info, okx, test, and virt_to_user().

◆ peerdist_info_segment_okx()

static void peerdist_info_segment_okx ( struct peerdist_info_segment_test test,
const struct peerdist_info info,
struct peerdist_info_segment segment,
const char *  file,
unsigned int  line 
)
static

Report content information segment test result.

Parameters
testContent information segment test
infoContent information
segmentSegment information to fill in
fileTest code file
lineTest code line

Definition at line 393 of file pccrc_test.c.

396  {
397  size_t digestsize = info->digestsize;
398 
399  /* Parse content information segment */
400  okx ( peerdist_info_segment ( info, segment, test->index ) == 0,
401  file, line );
402 
403  /* Verify content information segment */
404  okx ( segment->info == info, file, line );
405  okx ( segment->index == test->index, file, line );
406  okx ( segment->range.start == test->expected_range.start, file, line );
407  okx ( segment->range.end == test->expected_range.end, file, line );
408  okx ( segment->blocks == test->expected_blocks, file, line );
409  okx ( segment->blksize == test->expected_blksize, file, line );
410  okx ( memcmp ( segment->hash, test->expected_hash,
411  digestsize ) == 0, file, line );
412  okx ( memcmp ( segment->secret, test->expected_secret,
413  digestsize ) == 0, file, line );
414  okx ( memcmp ( segment->id, test->expected_id,
415  digestsize ) == 0, file, line );
416 }
uint16_t segment
Code segment.
Definition: librm.h:252
u32 info
Definition: ar9003_mac.h:67
A content information segment.
Definition: pccrc.h:347
#define okx(success, file, line)
Report test result.
Definition: test.h:44
uint32_t digestsize
Digest size (i.e.
Definition: pccrr.h:14
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
static int test
Definition: epic100.c:73

References digestsize, info, memcmp(), okx, segment, and test.

◆ peerdist_info_block_okx()

static void peerdist_info_block_okx ( struct peerdist_info_block_test test,
const struct peerdist_info_segment segment,
struct peerdist_info_block block,
const char *  file,
unsigned int  line 
)
static

Report content information block test result.

Parameters
testContent information block test
segmentSegment information
blockBlock information to fill in
fileTest code file
lineTest code line

Definition at line 430 of file pccrc_test.c.

433  {
434  const struct peerdist_info *info = segment->info;
435  size_t digestsize = info->digestsize;
436 
437  /* Parse content information block */
438  okx ( peerdist_info_block ( segment, block, test->index ) == 0,
439  file, line );
440 
441  /* Verify content information block */
442  okx ( block->segment == segment, file, line );
443  okx ( block->index == test->index, file, line );
444  okx ( block->range.start == test->expected_range.start, file, line );
445  okx ( block->range.end == test->expected_range.end, file, line );
446  okx ( block->trim.start == test->expected_trim.start, file, line );
447  okx ( block->trim.end == test->expected_trim.end, file, line );
448  okx ( memcmp ( block->hash, test->expected_hash,
449  digestsize ) == 0, file, line );
450 }
uint16_t segment
Code segment.
Definition: librm.h:252
u32 info
Definition: ar9003_mac.h:67
A content information block.
Definition: pccrc.h:394
#define okx(success, file, line)
Report test result.
Definition: test.h:44
Content information.
Definition: pccrc.h:317
uint8_t block[3][8]
DES-encrypted blocks.
Definition: mschapv2.h:12
uint32_t digestsize
Digest size (i.e.
Definition: pccrr.h:14
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
static int test
Definition: epic100.c:73

References block, digestsize, info, memcmp(), okx, segment, and test.

◆ peerdist_info_passphrase_okx()

static void peerdist_info_passphrase_okx ( struct peerdist_info_segment_test test,
const struct peerdist_info info,
uint8_t pass,
size_t  pass_len,
const char *  file,
unsigned int  line 
)
static

Report server passphrase test result.

Parameters
testContent information segment test
infoContent information
passServer passphrase
pass_lenLength of server passphrase
fileTest code file
lineTest code line

Definition at line 465 of file pccrc_test.c.

468  {
469  struct digest_algorithm *digest = info->digest;
470  uint8_t ctx[ hmac_ctxsize ( digest ) ];
471  uint8_t secret[digest->digestsize];
472  uint8_t expected[digest->digestsize];
473  size_t digestsize = info->digestsize;
474 
475  /* Calculate server secret */
476  digest_init ( digest, ctx );
477  digest_update ( digest, ctx, pass, pass_len );
478  digest_final ( digest, ctx, secret );
479 
480  /* Calculate expected segment secret */
481  hmac_init ( digest, ctx, secret, digestsize );
482  hmac_update ( digest, ctx, test->expected_hash, digestsize );
483  hmac_final ( digest, ctx, expected );
484 
485  /* Verify segment secret */
486  okx ( memcmp ( test->expected_secret, expected, digestsize ) == 0,
487  file, line );
488 }
void hmac_init(struct digest_algorithm *digest, void *ctx, const void *key, size_t key_len)
Initialise HMAC.
Definition: hmac.c:57
u32 info
Definition: ar9003_mac.h:67
#define okx(success, file, line)
Report test result.
Definition: test.h:44
static void struct digest_algorithm * digest
HMAC-MD5 digest.
Definition: crypto.h:308
static void hmac_update(struct digest_algorithm *digest, void *ctx, const void *data, size_t len)
Update HMAC.
Definition: hmac.h:42
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
unsigned char uint8_t
Definition: stdint.h:10
size_t digestsize
Digest size.
Definition: crypto.h:25
A message digest algorithm.
Definition: crypto.h:17
void hmac_final(struct digest_algorithm *digest, void *ctx, void *hmac)
Finalise HMAC.
Definition: hmac.c:87
uint32_t digestsize
Digest size (i.e.
Definition: pccrr.h:14
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
static int test
Definition: epic100.c:73

References ctx, digest, digestsize, digest_algorithm::digestsize, hmac_final(), hmac_init(), hmac_update(), info, memcmp(), okx, and test.

◆ peerdist_info_test_exec()

static void peerdist_info_test_exec ( void  )
static

Perform content information self-tests.

Definition at line 497 of file pccrc_test.c.

497  {
498  struct peerdist_info info;
500  struct peerdist_info_block block;
501 
502  /* IIS logo (iis-85.png) content information version 1 */
503  peerdist_info_ok ( &iis_85_png_v1, &info );
504  peerdist_info_passphrase_ok ( &iis_85_png_v1_s0, &info,
505  passphrase, sizeof ( passphrase ) );
506  peerdist_info_segment_ok ( &iis_85_png_v1_s0, &info, &segment );
507  peerdist_info_block_ok ( &iis_85_png_v1_s0_b0, &segment, &block );
508  peerdist_info_block_ok ( &iis_85_png_v1_s0_b1, &segment, &block );
509 
510  /* IIS logo (iis-85.png) content information version 2 */
511  peerdist_info_ok ( &iis_85_png_v2, &info );
512  peerdist_info_passphrase_ok ( &iis_85_png_v2_s0, &info,
513  passphrase, sizeof ( passphrase ) );
514  peerdist_info_segment_ok ( &iis_85_png_v2_s0, &info, &segment );
515  peerdist_info_block_ok ( &iis_85_png_v2_s0_b0, &segment, &block );
516  peerdist_info_passphrase_ok ( &iis_85_png_v2_s1, &info,
517  passphrase, sizeof ( passphrase ) );
518  peerdist_info_segment_ok ( &iis_85_png_v2_s1, &info, &segment );
519  peerdist_info_block_ok ( &iis_85_png_v2_s1_b0, &segment, &block );
520 }
uint16_t segment
Code segment.
Definition: librm.h:252
#define peerdist_info_ok(test, info)
Definition: pccrc_test.c:381
u32 info
Definition: ar9003_mac.h:67
A content information segment.
Definition: pccrc.h:347
A content information block.
Definition: pccrc.h:394
#define peerdist_info_passphrase_ok(test, info, pass, pass_len)
Definition: pccrc_test.c:489
Content information.
Definition: pccrc.h:317
#define peerdist_info_segment_ok(test, info, segment)
Definition: pccrc_test.c:417
uint8_t block[3][8]
DES-encrypted blocks.
Definition: mschapv2.h:12
#define peerdist_info_block_ok(test, segment, block)
Definition: pccrc_test.c:451

References block, info, peerdist_info_block_ok, peerdist_info_ok, peerdist_info_passphrase_ok, peerdist_info_segment_ok, and segment.

Variable Documentation

◆ __self_test

struct self_test peerdist_info_test __self_test
Initial value:
= {
.name = "pccrc",
}
static void peerdist_info_test_exec(void)
Perform content information self-tests.
Definition: pccrc_test.c:497

Content information self-test.

Definition at line 523 of file pccrc_test.c.