Browse Source

Fix adaptation field check and add more debugging output of MPEG

header.
tags/v1.1
Bernhard Fröhlich 4 years ago
parent
commit
d5d443553f
1 changed files with 14 additions and 25 deletions
  1. 14
    25
      drmdecrypt.c

+ 14
- 25
drmdecrypt.c View File

@@ -227,7 +227,6 @@ int decrypt_aes128cbc(unsigned char *pin, int len, unsigned char *pout)
227 227
 int decode_packet(unsigned char *data, unsigned char *outdata)
228 228
 {
229 229
    int offset;
230
-   int scrambling, adaptation;
231 230
 
232 231
    if(data[0] != 0x47)
233 232
    {
@@ -236,33 +235,23 @@ int decode_packet(unsigned char *data, unsigned char *outdata)
236 235
    }
237 236
 
238 237
    memcpy(outdata, data, 188);
239
-
240
-   scrambling = data[3] & 0xC0;
241
-   adaptation = data[3] & 0x20;
242
-
243
-   if(scrambling == 0x80)
244
-   {
245
-      trace(TRC_DEBUG, "packet scrambled with even key");
246
-   }
247
-   else if(scrambling == 0xC0)
248
-   {
249
-      trace(TRC_DEBUG, "packet scrambled with odd key");
250
-   }
251
-   else if(scrambling == 0x00)
252
-   {
253
-      trace(TRC_DEBUG, "packet not scrambled");
254
-      return 0;
255
-   }
256
-   else
257
-   {
258
-      trace(TRC_ERROR, "scrambling info seems to be invalid!");
259
-      return 0;
260
-   }
238
+   
239
+   trace(TRC_DEBUG, "-------------------");
240
+   trace(TRC_DEBUG, "Trans. Error Indicator: 0x%x", data[2] & 0x80);
241
+   trace(TRC_DEBUG, "Payload Unit start Ind: 0x%x", data[2] & 0x40);
242
+   trace(TRC_DEBUG, "Transport Priority    : 0x%x", data[2] & 0x20);
243
+   trace(TRC_DEBUG, "Scrambling control    : 0x%x", data[3] & 0xC0);
244
+   trace(TRC_DEBUG, "Adaptation field exist: 0x%x", data[3] & 0x20);
245
+   trace(TRC_DEBUG, "Contains payload      : 0x%x", data[3] & 0x10);
246
+   trace(TRC_DEBUG, "Continuity counter    : 0x%x", data[3] & 0x0f);
247
+
248
+   if((data[3] & 0x20) == 0x01)
249
+	   trace(TRC_DEBUG, "Adaptation Field length: 0x%x", data[4]+1);
261 250
 
262 251
    offset=4;
263 252
 
264 253
    /* skip adaption field */
265
-   if(adaptation)
254
+   if((data[3] & 0x20) == 0x01)
266 255
       offset += (data[4]+1);
267 256
 
268 257
    /* remove scrambling bits */
@@ -271,7 +260,7 @@ int decode_packet(unsigned char *data, unsigned char *outdata)
271 260
    /* decrypt only full blocks (they seem to avoid padding) */
272 261
    decrypt_aes128cbc(data + offset, ((188 - offset)/BLOCK_SIZE)*BLOCK_SIZE, outdata + offset);
273 262
 
274
-   return 1;		
263
+   return 1;
275 264
 }
276 265
 
277 266
 int decryptsrf(char *srffile, char *outdir)

Loading…
Cancel
Save