Android-cuttlefish cvd tool
Classes | Macros | Typedefs | Functions
fec_private.h File Reference
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <memory>
#include <string>
#include <vector>
#include <android-base/threads.h>
#include <crypto_utils/android_pubkey.h>
#include <fec/ecc.h>
#include <fec/io.h>
#include <openssl/obj_mac.h>
#include <openssl/sha.h>
#include <utils/Compat.h>
#include <cutils/klog.h>
Include dependency graph for fec_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  verity_header
 
struct  ecc_info
 
struct  hashtree_info
 
struct  verity_info
 
struct  avb_info
 
struct  fec_handle
 

Macros

#define WORK_MIN_THREADS   1
 
#define WORK_MAX_THREADS   64
 
#define VERITY_CACHE_BLOCKS   4096
 
#define VERITY_NO_CACHE   UINT64_MAX
 
#define VERITY_METADATA_SIZE   (8 * FEC_BLOCKSIZE)
 
#define VERITY_TABLE_ARGS   10 /* mandatory arguments */
 
#define VERITY_MIN_TABLE_SIZE   (VERITY_TABLE_ARGS * 2) /* for quick validation */
 
#define VERITY_MAX_TABLE_SIZE   (VERITY_METADATA_SIZE - sizeof(verity_header))
 
#define VERITY_MAGIC   0xB001B001
 
#define VERITY_MAGIC_DISABLE   0x46464F56
 
#define VERITY_VERSION   0
 
#define VERITY_TABLE_FIELDS   10
 
#define VERITY_TABLE_VERSION   1
 
#define unlikely(x)   __builtin_expect(!!(x), 0)
 
#define likely(x)   __builtin_expect(!!(x), 1)
 
#define __stringify(x)   #x
 
#define stringify(x)   __stringify(x)
 
#define __log(func, type, format, args...)
 
#define debug(format, args...)   __log(DEBUG, "debug", format, ##args)
 
#define warn(format, args...)   __log(WARNING, "warning", format, ##args)
 
#define error(format, args...)   __log(ERROR, "error", format, ##args)
 
#define check(p)
 

Typedefs

typedef ssize_t(* read_func) (fec_handle *f, uint8_t *dest, size_t count, uint64_t offset, size_t *errors)
 

Functions

bool raw_pread (int fd, void *buf, size_t count, uint64_t offset)
 
bool raw_pwrite (int fd, const void *buf, size_t count, uint64_t offset)
 
ssize_t process (fec_handle *f, uint8_t *buf, size_t count, uint64_t offset, read_func func)
 
uint64_t verity_get_size (uint64_t file_size, uint32_t *verity_levels, uint32_t *level_hashes, uint32_t padded_digest_size)
 
int verity_parse_header (fec_handle *f, uint64_t offset)
 

Macro Definition Documentation

◆ __log

#define __log (   func,
  type,
  format,
  args... 
)
Value:
KLOG_##func("fec", "<%d> " type ": %s: " format "\n", \
(int)syscall(SYS_gettid), __FUNCTION__, ##args)
EventFormat format
Definition: kernel_log_server.cc:57
uint8_t type
Definition: pairing_connection.h:0

◆ __stringify

#define __stringify (   x)    #x

◆ check

#define check (   p)
Value:
if (unlikely(!(p))) { \
error("`%s' failed", #p); \
errno = EFAULT; \
return -1; \
}
#define unlikely(x)
Definition: fec_private.h:172

◆ debug

#define debug (   format,
  args... 
)    __log(DEBUG, "debug", format, ##args)

◆ error

#define error (   format,
  args... 
)    __log(ERROR, "error", format, ##args)

◆ likely

#define likely (   x)    __builtin_expect(!!(x), 1)

◆ stringify

#define stringify (   x)    __stringify(x)

◆ unlikely

#define unlikely (   x)    __builtin_expect(!!(x), 0)

◆ VERITY_CACHE_BLOCKS

#define VERITY_CACHE_BLOCKS   4096

◆ VERITY_MAGIC

#define VERITY_MAGIC   0xB001B001

◆ VERITY_MAGIC_DISABLE

#define VERITY_MAGIC_DISABLE   0x46464F56

◆ VERITY_MAX_TABLE_SIZE

#define VERITY_MAX_TABLE_SIZE   (VERITY_METADATA_SIZE - sizeof(verity_header))

◆ VERITY_METADATA_SIZE

#define VERITY_METADATA_SIZE   (8 * FEC_BLOCKSIZE)

◆ VERITY_MIN_TABLE_SIZE

#define VERITY_MIN_TABLE_SIZE   (VERITY_TABLE_ARGS * 2) /* for quick validation */

◆ VERITY_NO_CACHE

#define VERITY_NO_CACHE   UINT64_MAX

◆ VERITY_TABLE_ARGS

#define VERITY_TABLE_ARGS   10 /* mandatory arguments */

◆ VERITY_TABLE_FIELDS

#define VERITY_TABLE_FIELDS   10

◆ VERITY_TABLE_VERSION

#define VERITY_TABLE_VERSION   1

◆ VERITY_VERSION

#define VERITY_VERSION   0

◆ warn

#define warn (   format,
  args... 
)    __log(WARNING, "warning", format, ##args)

◆ WORK_MAX_THREADS

#define WORK_MAX_THREADS   64

◆ WORK_MIN_THREADS

#define WORK_MIN_THREADS   1

Typedef Documentation

◆ read_func

typedef ssize_t(* read_func) (fec_handle *f, uint8_t *dest, size_t count, uint64_t offset, size_t *errors)

Function Documentation

◆ process()

ssize_t process ( fec_handle f,
uint8_t *  buf,
size_t  count,
uint64_t  offset,
read_func  func 
)

◆ raw_pread()

bool raw_pread ( int  fd,
void *  buf,
size_t  count,
uint64_t  offset 
)

◆ raw_pwrite()

bool raw_pwrite ( int  fd,
const void *  buf,
size_t  count,
uint64_t  offset 
)

◆ verity_get_size()

uint64_t verity_get_size ( uint64_t  file_size,
uint32_t *  verity_levels,
uint32_t *  level_hashes,
uint32_t  padded_digest_size 
)

◆ verity_parse_header()

int verity_parse_header ( fec_handle f,
uint64_t  offset 
)