History

Add support for playing Audible AAXC (.aaxc) files [PATCH v4]

The AAXC container format is the same as the (already supported) Audible AAX format but it uses a different encryption scheme. Note: audible_key and audible_iv values are variable (per file) and are externally fed. It is possible to extend https://github.com/mkb79/Audible to derive the audible_key and audible_key values. Relevant code: def decrypt_voucher(deviceSerialNumber, customerId, deviceType, asin, voucher): buf = (deviceType + deviceSerialNumber + customerId + asin).encode("ascii") digest = hashlib.sha256(buf).digest() key = digest[0:16] iv = digest[16:] # decrypt "voucher" using AES in CBC mode with no padding cipher = AES.new(key, AES.MODE_CBC, iv) plaintext = cipher.decrypt(voucher).rstrip(b"\x00") # improve this! return json.loads(plaintext) The decrypted "voucher" has the required audible_key and audible_iv values. Update (Nov-2020): This patch has now been tested by multiple folks - details at the following URL: https://github.com/mkb79/Audible/issues/3

Vesselin Bontchev committed 26 years ago

Commit 03fb3141 parent 70d80772 files · +37 −0Browse files

Showing the changes to libavformat (2 of 2 files). Show all

Unified · Split

2 files
  1. libavformat/isom.h +4 −0
  2. libavformat/mov.c +33 −0
libavformat/isom.h+4−0
@@ -286,6 +286,10 @@ typedef struct MOVContext { · 285 unmodified lines
286286 int activation_bytes_size;
287287 void *audible_fixed_key;
288288 int audible_fixed_key_size;
289+ void *audible_key;
290+ int audible_key_size;
291+ void *audible_iv;
292+ int audible_iv_size;
289293 struct AVAES *aes_decrypt;
290294 uint8_t *decryption_key;
291295 int decryption_key_len;
libavformat/mov.c+33−0
@@ -1075,6 +1075,30 @@ fail: · 1074 unmodified lines
10751075 return ret;
10761076 }
10771077
1078+static int mov_aaxc_crypto(MOVContext *c)
1079+{
1080+ if (c->audible_key_size != 16) {
1081+ av_log(c->fc, AV_LOG_FATAL, "[aaxc] audible_key value needs to be 16 bytes!\n");
1082+ return AVERROR(EINVAL);
1083+ }
1084+
1085+ if (c->audible_iv_size != 16) {
1086+ av_log(c->fc, AV_LOG_FATAL, "[aaxc] audible_iv value needs to be 16 bytes!\n");
1087+ return AVERROR(EINVAL);
1088+ }
1089+
1090+ c->aes_decrypt = av_aes_alloc();
1091+ if (!c->aes_decrypt) {
1092+ return AVERROR(ENOMEM);
1093+ }
1094+
1095+ memcpy(c->file_key, c->audible_key, 16);
1096+ memcpy(c->file_iv, c->audible_iv, 16);
1097+ c->aax_mode = 1;
1098+
1099+ return 0;
1100+}
1101+
10781102 // Audible AAX (and AAX+) bytestream decryption
10791103 static int aax_filter(uint8_t *input, int size, MOVContext *c)
10801104 {
@@ -1123,6 +1147,11 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 42 unmodified lines
11231147 av_dict_set(&c->fc->metadata, "compatible_brands",
11241148 comp_brands_str, AV_DICT_DONT_STRDUP_VAL);
11251149
1150+ // Logic for handling Audible's .aaxc files
1151+ if (!strcmp(type, "aaxc")) {
1152+ mov_aaxc_crypto(c);
1153+ }
1154+
11261155 return 0;
11271156 }
11281157
@@ -8170,6 +8199,10 @@ static const AVOption mov_options[] = { · 7041 unmodified lines
81708199 AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = FLAGS },
81718200 { "activation_bytes", "Secret bytes for Audible AAX files", OFFSET(activation_bytes),
81728201 AV_OPT_TYPE_BINARY, .flags = AV_OPT_FLAG_DECODING_PARAM },
8202+ { "audible_key", "AES-128 Key for Audible AAXC files", OFFSET(audible_key),
8203+ AV_OPT_TYPE_BINARY, .flags = AV_OPT_FLAG_DECODING_PARAM },
8204+ { "audible_iv", "AES-128 IV for Audible AAXC files", OFFSET(audible_iv),
8205+ AV_OPT_TYPE_BINARY, .flags = AV_OPT_FLAG_DECODING_PARAM },
81738206 { "audible_fixed_key", // extracted from libAAX_SDK.so and AAXSDKWin.dll files!
81748207 "Fixed key used for handling Audible AAX files", OFFSET(audible_fixed_key),
81758208 AV_OPT_TYPE_BINARY, {.str="77214d4b196a87cd520045fd20a51d67"},

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t