Commit ffc10f40 authored by npzacs's avatar npzacs
Browse files

MKB: added const (MKB data is read-only)

parent 23066570
......@@ -56,7 +56,8 @@ struct aacs {
static const uint8_t empty_key[] = "\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00";
static int _validate_pk(uint8_t *pk, uint8_t *cvalue, uint8_t *uv, uint8_t *vd,
static int _validate_pk(const uint8_t *pk,
const uint8_t *cvalue, const uint8_t *uv, const uint8_t *vd,
uint8_t *mk)
{
gcry_cipher_hd_t gcry_h;
......@@ -94,8 +95,9 @@ static int _calc_mk(AACS *aacs, const char *path)
{
int a, num_uvs = 0;
size_t len;
uint8_t *buf = NULL, *rec, *uvs;
uint8_t *buf = NULL;
MKB *mkb = NULL;
const uint8_t *rec, *uvs;
/* Skip if retrieved from config file */
if (memcmp(aacs->mk, empty_key, 16))
......
......@@ -30,7 +30,7 @@ struct mkb {
uint8_t *buf; // file contents
};
static uint8_t *_record(MKB *mkb, uint8_t type, size_t *rec_len)
static const uint8_t *_record(MKB *mkb, uint8_t type, size_t *rec_len)
{
size_t pos = 0, len = 0;
......@@ -96,58 +96,58 @@ void mkb_close(MKB *mkb)
uint8_t mkb_type(MKB *mkb)
{
uint8_t *rec = _record(mkb, 0x10, NULL);
const uint8_t *rec = _record(mkb, 0x10, NULL);
return MKINT_BE32(rec + 4);
}
uint32_t mkb_version(MKB *mkb)
{
uint8_t *rec = _record(mkb, 0x10, NULL);
const uint8_t *rec = _record(mkb, 0x10, NULL);
return MKINT_BE32(rec + 8);
}
uint8_t *mkb_host_revokation_entries(MKB *mkb, size_t *len)
const uint8_t *mkb_host_revokation_entries(MKB *mkb, size_t *len)
{
uint8_t *rec = _record(mkb, 0x21, len);
const uint8_t *rec = _record(mkb, 0x21, len);
*len -= 4;
return rec + 4;
}
uint8_t *mkb_drive_revokation_entries(MKB *mkb, size_t *len)
const uint8_t *mkb_drive_revokation_entries(MKB *mkb, size_t *len)
{
uint8_t *rec = _record(mkb, 0x20, len);
const uint8_t *rec = _record(mkb, 0x20, len);
*len -= 4;
return rec + 4;
}
uint8_t *mkb_subdiff_records(MKB *mkb, size_t *len)
const uint8_t *mkb_subdiff_records(MKB *mkb, size_t *len)
{
uint8_t *rec = _record(mkb, 0x04, len) + 4;
const uint8_t *rec = _record(mkb, 0x04, len) + 4;
*len -= 4;
return rec;
}
uint8_t *mkb_cvalues(MKB *mkb, size_t *len)
const uint8_t *mkb_cvalues(MKB *mkb, size_t *len)
{
uint8_t *rec = _record(mkb, 0x05, len) + 4;
const uint8_t *rec = _record(mkb, 0x05, len) + 4;
*len -= 4;
return rec;
}
uint8_t *mkb_mk_dv(MKB *mkb)
const uint8_t *mkb_mk_dv(MKB *mkb)
{
return _record(mkb, 0x81, NULL) + 4;
}
uint8_t *mkb_signature(MKB *mkb, size_t *len)
const uint8_t *mkb_signature(MKB *mkb, size_t *len)
{
uint8_t *rec = _record(mkb, 0x02, len);
const uint8_t *rec = _record(mkb, 0x02, len);
*len -= 4;
return rec + 4;
......
......@@ -35,19 +35,19 @@ AACS_PRIVATE uint8_t mkb_type(MKB *mkb);
// returns version
AACS_PRIVATE uint32_t mkb_version(MKB *mkb);
// returns list of revoked host entries
AACS_PRIVATE uint8_t *mkb_host_revokation_entries(MKB *mkb, size_t *len);
AACS_PRIVATE const uint8_t *mkb_host_revokation_entries(MKB *mkb, size_t *len);
// returns list of revoked drive entries
AACS_PRIVATE uint8_t *mkb_drive_revokation_entries(MKB *mkb, size_t *len);
AACS_PRIVATE const uint8_t *mkb_drive_revokation_entries(MKB *mkb, size_t *len);
// returns subset-diff records
AACS_PRIVATE uint8_t *mkb_subdiff_records(MKB *mkb, size_t *len);
AACS_PRIVATE const uint8_t *mkb_subdiff_records(MKB *mkb, size_t *len);
// returns list of subset-diff offsets
AACS_PRIVATE uint8_t *mkb_subdiff_offsets(MKB *mkb, size_t *len);
AACS_PRIVATE const uint8_t *mkb_subdiff_offsets(MKB *mkb, size_t *len);
// returns list of cvalues
AACS_PRIVATE uint8_t *mkb_cvalues(MKB *mkb, size_t *len);
AACS_PRIVATE const uint8_t *mkb_cvalues(MKB *mkb, size_t *len);
// media key verification data return in param (always 16 bytes)
AACS_PRIVATE uint8_t *mkb_mk_dv(MKB *mkb);
AACS_PRIVATE const uint8_t *mkb_mk_dv(MKB *mkb);
// returns MKB signature
AACS_PRIVATE uint8_t *mkb_signature(MKB *mkb, size_t *len);
AACS_PRIVATE const uint8_t *mkb_signature(MKB *mkb, size_t *len);
/* The Media Key block is of variable size but must be a multiple of 4
* MKB Structure:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment