55 static inline const char *
85 DBGC (
info,
"PCCRC %p data underrun at [%zx,%zx) of %zx\n",
104 const void *
hash,
const void *secret ){
151 sizeof (
raw ) ) ) != 0 )
168 unsigned int index ) {
176 assert ( index < info->segments );
184 for ( i = 0 ; i <
index ; i++ ) {
190 DBGC (
info,
"PCCRC %p segment %d could not get number " 220 DBGC (
info,
"PCCRC %p could not get V1 content information: " 227 switch (
raw.hash ) {
238 DBGC (
info,
"PCCRC %p unsupported hash algorithm %#08x\n",
242 info->digestsize =
info->digest->digestsize;
244 DBGC2 (
info,
"PCCRC %p using %s[%zd]\n",
259 info->trim.start = (
first.range.start + first_skip );
263 (
info->segments - 1 ) ) ) != 0 )
273 last_skip = ( last.
index ? 0 : first_skip );
304 sizeof (
raw ) ) ) != 0 ) {
305 DBGC (
info,
"PCCRC %p segment %d could not get segment " 323 if ( raw_offset < 0 ) {
332 DBGC (
info,
"PCCRC %p segment %d could not get number of " 372 if ( raw_offset < 0 ) {
381 DBGC (
info,
"PCCRC %p segment %d block %d could not get " 452 sizeof ( chunk ) ) ) != 0 )
462 sizeof (
raw.segment ) ) ) != 0 )
469 cursor->
offset +=
sizeof ( chunk );
485 unsigned int segments;
490 cursor.
offset <
info->raw.len ; segments++ ) {
495 DBGC (
info,
"PCCRC %p segment %d could not update " 496 "segment cursor: %s\n",
522 DBGC (
info,
"PCCRC %p could not get V2 content information: " 529 switch (
raw.hash ) {
532 info->digestsize = ( 256 / 8 );
535 DBGC (
info,
"PCCRC %p unsupported hash algorithm %#02x\n",
540 DBGC2 (
info,
"PCCRC %p using %s[%zd]\n",
545 if ( segments < 0 ) {
547 DBGC (
info,
"PCCRC %p could not get segment count and length: " 551 info->segments = segments;
594 DBGC (
info,
"PCCRC %p segment %d could not update " 595 "segment cursor: %s\n",
603 sizeof (
raw ) ) ) != 0 ) {
604 DBGC (
info,
"PCCRC %p segment %d could not get segment " 681 sizeof (
version ) ) ) != 0 ) {
682 DBGC (
info,
"PCCRC %p could not get version: %s\n",
686 DBGC2 (
info,
"PCCRC %p version %d.%d\n",
698 DBGC (
info,
"PCCRC %p unsupported version %d.%d\n",
709 DBGC2 (
info,
"PCCRC %p range [%08zx,%08zx) covers [%08zx,%08zx) with " 710 "%d segments\n",
info,
info->range.start,
info->range.end,
725 unsigned int index ) {
733 DBGC (
info,
"PCCRC %p segment %d of [0,%d) out of range\n",
747 DBGC2 (
info,
"PCCRC %p segment %d range [%08zx,%08zx) with %d " 769 unsigned int index ) {
781 DBGC (
info,
"PCCRC %p segment %d block %d of [0,%d) out of " 807 DBGC2 (
info,
"PCCRC %p segment %d block %d hash %s\n",
810 DBGC2 (
info,
"PCCRC %p segment %d block %d range [%08zx,%08zx) covers " void hmac_init(struct digest_algorithm *digest, void *ctx, const void *key, size_t key_len)
Initialise HMAC.
uint16_t segment
Code segment.
struct arbelprm_rc_send_wqe rc
pseudo_bit_t hash[0x00010]
static const char * peerdist_info_hash_ntoa(const struct peerdist_info *info, const void *hash)
Transcribe hash value (for debugging)
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define PEERDIST_INFO_V1_HASH_SHA512
SHA-512 hash algorithm.
A content information segment.
static void peerdist_info_v2_cursor_init(struct peerdist_info_v2_cursor *cursor)
Initialise segment cursor.
#define le32_to_cpu(value)
Content Information version 1 data structure header.
uint32_t first
First block in range.
struct digest_algorithm sha512_algorithm
SHA-512 algorithm.
size_t start
Start offset.
static __always_inline void copy_from_user(void *dest, userptr_t src, off_t src_off, size_t len)
Copy data from user buffer.
uint32_t segments
Number of segments within the content information.
struct digest_algorithm sha384_algorithm
SHA-384 algorithm.
#define offsetof(type, field)
Get offset of a field within a structure.
unsigned int index
Segment index.
struct golan_eq_context ctx
Access to external ("user") memory.
#define ENOTSUP
Operation not supported.
uint32_t start
Starting offset.
static size_t base16_encoded_len(size_t raw_len)
Calculate length of base16-encoded data.
A content information block.
Content Information version 1 block description header.
static struct peerdist_info_operations peerdist_info_v1_operations
Content information version 1 operations.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
unsigned int remaining
Number of segments remaining within this chunk.
u32 version
Driver version.
uint32_t userptr_t
A pointer to a user buffer.
#define PEERDIST_SEGMENT_ID_MAGIC
Magic string constant used to calculate segment identifier.
struct peerdist_range range
Content range.
static int peerdist_info_v1(struct peerdist_info *info)
Populate content information.
#define PEERDIST_INFO_V2
Content Information version 2.
#define be32_to_cpu(value)
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
Keyed-Hashing for Message Authentication.
struct peerdist_range trim
Trimmed content range.
int peerdist_info_segment(const struct peerdist_info *info, struct peerdist_info_segment *segment, unsigned int index)
Populate content information segment.
uint32_t len
Chunk data length.
static int peerdist_info_v2_segments(const struct peerdist_info *info, size_t *len)
Get number of segments and total length.
static int peerdist_info_v2(struct peerdist_info *info)
Populate content information.
static int peerdist_info_v1_segment(struct peerdist_info_segment *segment)
Populate content information segment.
static ssize_t peerdist_info_v1_block_offset(const struct peerdist_info *info, unsigned int index)
Locate block description.
int peerdist_info(userptr_t data, size_t len, struct peerdist_info *info)
Populate content information.
#define cpu_to_le32(value)
size_t offset
Raw data offset.
Peer Content Caching and Retrieval: Content Identification [MS-PCCRC].
static void hmac_update(struct digest_algorithm *digest, void *ctx, const void *data, size_t len)
Update HMAC.
#define ERANGE
Result too large.
static size_t hmac_ctxsize(struct digest_algorithm *digest)
Calculate HMAC context size.
char * strerror(int errno)
Retrieve string representation of error number.
#define be64_to_cpu(value)
#define peerdist_info_v2_segment_t(digestsize)
Content Information version 2 segment description.
static void peerdist_info_segment_hash(struct peerdist_info_segment *segment, const void *hash, const void *secret)
Populate segment hashes.
static int peerdist_info_get(const struct peerdist_info *info, void *data, size_t offset, size_t len)
Get raw data.
#define PEERDIST_INFO_V1_HASH_SHA384
SHA-384 hash algorithm.
int peerdist_info_block(const struct peerdist_info_segment *segment, struct peerdist_info_block *block, unsigned int index)
Populate content information block.
static int peerdist_info_v1_block(struct peerdist_info_block *block)
Populate content information block.
#define PEERDIST_INFO_V1_HASH_SHA256
SHA-256 hash algorithm.
uint16_t magic
Magic signature.
static int peerdist_info_v2_block(struct peerdist_info_block *block)
Populate content information block.
#define PEERDIST_DIGEST_MAX_SIZE
Maximum digest size for any supported algorithm.
static int peerdist_info_v1_blocks(const struct peerdist_info *info, size_t offset)
Get number of blocks within a block description.
size_t len
Accumulated segment length.
#define peerdist_info_v1_segment_t(digestsize)
Content Information version 1 segment description.
struct digest_algorithm sha256_algorithm
SHA-256 algorithm.
uint32_t blocks
Number of blocks within the block description.
uint8_t block[3][8]
DES-encrypted blocks.
static struct peerdist_info_operations peerdist_info_v2_operations
Content information version 2 operations.
static int peerdist_info_v2_cursor_next(const struct peerdist_info *info, struct peerdist_info_v2_cursor *cursor)
Update segment cursor to next segment description.
#define PEERDIST_INFO_V2_HASH_SHA512_TRUNC
SHA-512 hash algorithm with output truncated to first 256 bits.
#define cpu_to_le16(value)
A message digest algorithm.
uint32_t end
Ending offset.
uint8_t data[48]
Additional event data.
void hmac_final(struct digest_algorithm *digest, void *ctx, void *hmac)
Finalise HMAC.
uint16_t offset
Offset to command line.
static int peerdist_info_v2_segment(struct peerdist_info_segment *segment)
Populate content information segment.
int(* info)(struct peerdist_info *info)
Populate content information.
typeof(acpi_finder=acpi_find)
ACPI table finder.
uint32_t digestsize
Digest size (i.e.
Content Information version 2 data structure header.
Content Information version 2 chunk description header.
#define le64_to_cpu(value)
int(* block)(struct peerdist_info_block *block)
Populate content information block.
Content information operations.
#define NULL
NULL pointer (VOID *)
#define PEERDIST_INFO_V1
Content Information version 1.
Content Information version number.
#define peerdist_info_v1_block_t(digestsize, blocks)
Content Information version 1 block description.
void * memset(void *dest, int character, size_t len) __nonnull