aacs.c 1.13 KB
Newer Older
cRTrn13's avatar
cRTrn13 committed
1 2

#include <stdio.h>
cRTrn13's avatar
cRTrn13 committed
3
#include <malloc.h>
cRTrn13's avatar
cRTrn13 committed
4 5

#include "aacs.h"
6
#include "crypto.h"
cRTrn13's avatar
cRTrn13 committed
7 8
#include "../util/macro.h"

9 10 11 12 13 14 15 16
int _calc_pk(uint8_t *key);
int _calc_mk(uint8_t *key);
int _calc_vuk(uint8_t *key, const char *path);
int _calc_uks(AACS *aacs, uint8_t *vuk);
int _validate_pk(uint8_t *pk, uint8_t *cvalue, uint8_t *uv, uint8_t *vd);
int _verify_ts(uint8_t *buf);


cRTrn13's avatar
cRTrn13 committed
17 18
AACS *aacs_open(const char *path)
{
19
    uint8_t key[16];
cRTrn13's avatar
cRTrn13 committed
20
    AACS *aacs = malloc(sizeof(AACS));
21 22 23 24 25 26

    // perform aacs waterfall
    _calc_pk(key);
    _calc_mk(key);
    _calc_vuk(key, path);
    _calc_uks(aacs, key);
cRTrn13's avatar
cRTrn13 committed
27 28

    return aacs;
cRTrn13's avatar
cRTrn13 committed
29 30 31 32 33 34 35
}

void aacs_close(AACS *aacs)
{
    X_FREE(aacs);
}

36 37 38 39 40 41 42 43 44 45 46 47 48
int aacs_decrypt_unit(AACS *aacs, uint8_t *buf)
{
    uint8_t seed[16], iv[] = { 0x0b, 0xa0, 0xf8, 0xdd, 0xfe, 0xa6, 0x1f, 0xb3, 0xd8, 0xdf, 0x9f, 0x56, 0x6a, 0x05, 0x0f, 0x78 };

    //AES_set_encrypt_key(bluray->uk, 128, &bluray->aes);
    //AES_encrypt(buf, seed, &bluray->aes);

    int a;
    for (a = 0; a < 16; a++)
        seed[a] ^= buf[a];

    //AES_set_decrypt_key( seed, 128, &bluray->aes );
    //AES_cbc_encrypt( buf + 16, buf + 16, len - 16, &bluray->aes, bluray->iv, 0 );
cRTrn13's avatar
cRTrn13 committed
49 50

    return 1;
51
}