Commit 89f4efd5 authored by cRTrn13's avatar cRTrn13
Browse files

Build fixes

parent 2ab93629
#include <stdio.h>
#include <malloc.h>
#include "aacs.h"
#include "crypto.h"
......@@ -16,13 +17,15 @@ int _verify_ts(uint8_t *buf);
AACS *aacs_open(const char *path)
{
uint8_t key[16];
AACS aacs = malloc(sizeof(AACS));
AACS *aacs = malloc(sizeof(AACS));
// perform aacs waterfall
_calc_pk(key);
_calc_mk(key);
_calc_vuk(key, path);
_calc_uks(aacs, key);
return aacs;
}
void aacs_close(AACS *aacs)
......@@ -43,4 +46,6 @@ int aacs_decrypt_unit(AACS *aacs, uint8_t *buf)
//AES_set_decrypt_key( seed, 128, &bluray->aes );
//AES_cbc_encrypt( buf + 16, buf + 16, len - 16, &bluray->aes, bluray->iv, 0 );
return 1;
}
......@@ -6,13 +6,13 @@ void _aesg3(const uint8_t *src_key, uint8_t *dst_key, uint8_t inc);
void _aesg3(const uint8_t *src_key, uint8_t *dst_key, uint8_t inc)
{
int a;
AES_KEY aes;
//AES_KEY aes;
uint8_t seed[16] = { 0x7B, 0x10, 0x3C, 0x5D, 0xCB, 0x08, 0xC4, 0xE5, 0x1A, 0x27, 0xB0, 0x17, 0x99, 0x05, 0x3B, 0xD9 };
seed[15] += inc;
AES_set_decrypt_key(src_key, 128, &aes);
AES_decrypt(seed, dst_key, &aes);
//AES_set_decrypt_key(src_key, 128, &aes);
//AES_decrypt(seed, dst_key, &aes);
for (a = 0; a < 16; a++)
dst_key[a] ^= seed[a];
......@@ -21,11 +21,11 @@ void _aesg3(const uint8_t *src_key, uint8_t *dst_key, uint8_t inc)
void crypto_aesg3(const uint8_t *D, uint8_t *lsubk, uint8_t* rsubk, uint8_t *pk)
{
if (lsubk)
_bd_aesg3(D, lsubk, 0);
_aesg3(D, lsubk, 0);
if (pk)
_bd_aesg3(D, pk, 1);
_aesg3(D, pk, 1);
if (rsubk)
_bd_aesg3(D, rsubk, 2);
}
\ No newline at end of file
_aesg3(D, rsubk, 2);
}
......@@ -7,4 +7,4 @@
void crypto_aesg3(const uint8_t *D, uint8_t *lsubk, uint8_t* rsubk, uint8_t *pk); // returns left, centre, right keys
#endif CRYPTO_H_
#endif /* CRYPTO_H_ */
#include "mkb.h"
#include <malloc.h>
#include "mkb.h"
#include "../util/macro.h"
uint8_t *_record(MKB *mkb, uint8_t type, size_t *rec_len); // returns ptr to requests MKB record
......@@ -10,14 +11,14 @@ uint8_t *_record(MKB *mkb, uint8_t type, size_t *rec_len)
size_t pos = 0, len = 0;
while (pos + 4 <= len) {
len = MKINT_BE24(buf + pos + 1);
len = MKINT_BE24(mkb->buf + pos + 1);
if (rec_len) {
*rec_len = len;
}
if (buf[pos] == type)
return (uint8_t *)buf + pos;
if (mkb->buf[pos] == type)
return mkb->buf + pos;
pos += len;
}
......@@ -39,7 +40,7 @@ struct mkb *mkb_open(const char *path)
mkb->size = ftell(fp);
rewind(fp);
buf = malloc(mkb->size);
mkb->buf = malloc(mkb->size);
fread(mkb->buf, 1, mkb->size, fp);
......@@ -63,14 +64,14 @@ uint8_t mkb_type(MKB *mkb)
return MKINT_BE32(rec + 4);
}
uint8_t mkb_version(MKB *mkb)
uint32_t mkb_version(MKB *mkb)
{
uint8_t *rec = _record(mkb, 0x10, NULL);
return MKINT_BE32(rec + 8);
}
uint8_t *mkb_subdiff_records(MKB *mkb, uint32_t *len)
uint8_t *mkb_subdiff_records(MKB *mkb, size_t *len)
{
uint8_t *rec = _record(mkb, 0x04, len) + 4;
*len -= 4;
......@@ -78,7 +79,7 @@ uint8_t *mkb_subdiff_records(MKB *mkb, uint32_t *len)
return rec;
}
uint8_t *mkb_cvalues(MKB *mkb, uint32_t *len)
uint8_t *mkb_cvalues(MKB *mkb, size_t *len)
{
uint8_t *rec = _record(mkb, 0x05, len) + 4;
*len -= 4;
......@@ -91,7 +92,7 @@ uint8_t *mkb_mk_dv(MKB *mkb)
return _record(mkb, 0x81, NULL) + 4;
}
uint8_t *mkb_signature(MKB *mkb, uint32_t *len)
uint8_t *mkb_signature(MKB *mkb, size_t *len)
{
uint8_t *rec = _record(mkb, 0x02, len);
*len -= 4;
......
......@@ -17,13 +17,13 @@ void mkb_close(MKB *mkb); // free MKB
uint8_t mkb_type(MKB *mkb); // returns type
uint32_t mkb_version(MKB *mkb); // returns version
uint8_t *mkb_host_revokation_entries(MKB *mkb, uint32_t *len); // returns list of revoked host entries
uint8_t *mkb_drive_revokation_entries(MKB *mkb, uint32_t *len); // returns list of revoked drive entries
uint8_t *mkb_subdiff_records(MKB *mkb, uint32_t *len); // returns subset-diff records
uint8_t *mkb_subdiff_offsets(MKB *mkb, uint32_t *len); // returns list of subset-diff offsets
uint8_t *mkb_cvalues(MKB *mkb, uint32_t *len); // returns list of cvalues
uint8_t *mkb_host_revokation_entries(MKB *mkb, size_t *len); // returns list of revoked host entries
uint8_t *mkb_drive_revokation_entries(MKB *mkb, size_t *len); // returns list of revoked drive entries
uint8_t *mkb_subdiff_records(MKB *mkb, size_t *len); // returns subset-diff records
uint8_t *mkb_subdiff_offsets(MKB *mkb, size_t *len); // returns list of subset-diff offsets
uint8_t *mkb_cvalues(MKB *mkb, size_t *len); // returns list of cvalues
uint8_t *mkb_mk_dv(MKB *mkb); // media key verification data return in param (always 16 bytes)
uint8_t *mkb_signature(MKB *mkb, uint32_t *len); // returns MKB signature
uint8_t *mkb_signature(MKB *mkb, size_t *len); // returns MKB signature
/* 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