Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
libaesdec: more cosmetic tweaks
  • Loading branch information
perexg committed Aug 6, 2014
1 parent 482e46e commit deaa9ce
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
13 changes: 7 additions & 6 deletions src/descrambler/libaesdec/libaesdec.c
Expand Up @@ -64,15 +64,16 @@ void aes_decrypt_packet(void *keys, unsigned char *packet) {
AES_KEY k;

xc0 = pkt[3] & 0xc0;

//skip clear pkt
if (xc0 == 0x00) {
if (xc0 == 0x00)
return;
}

//skip reserved pkt
if (xc0 == 0x40) {
if (xc0 == 0x40)
return;
}
if (xc0 == 0x80 || xc0 == 0xc0) { // encrypted

if (xc0 == 0x80 || xc0 == 0xc0) { // encrypted
ev_od = (xc0 & 0x40) >> 6; // 0 even, 1 odd
pkt[3] &= 0x3f; // consider it decrypted now
if (pkt[3] & 0x20) { // incomplete packet
Expand All @@ -81,7 +82,7 @@ void aes_decrypt_packet(void *keys, unsigned char *packet) {
n = len >> 3;
if (n == 0) { // decrypted==encrypted!
return; // this doesn't need more processing
}
}
} else {
len = 184;
offset = 4;
Expand Down
41 changes: 23 additions & 18 deletions src/descrambler/libaesdec/libaesdec.h
Expand Up @@ -8,22 +8,27 @@
#ifndef LIBAESDEC_H_
#define LIBAESDEC_H_

#include "build.h"

#if ENABLE_SSL
void *aes_get_key_struct(void);
void aes_free_key_struct(void *keys);
void aes_set_control_words(void *keys, const unsigned char *even, const unsigned char *odd);
void aes_set_even_control_word(void *keys, const unsigned char *even);
void aes_set_odd_control_word(void *keys, const unsigned char *odd);
void aes_decrypt_packet(void *keys, unsigned char *packet);
#else
// empty functions
static inline void *aes_get_key_struct(void) { return 0; };
static inline void aes_free_key_struct(void *keys) { return; };
static inline void aes_set_control_words(void *keys, const unsigned char *even, const unsigned char *odd) { return; };
static inline void aes_set_even_control_word(void *keys, const unsigned char *even) { return; };
static inline void aes_set_odd_control_word(void *keys, const unsigned char *odd) { return; };
static inline void aes_decrypt_packet(void *keys, unsigned char *packet) { return; };
#endif
#include "build.h"

#if ENABLE_SSL

void *aes_get_key_struct(void);
void aes_free_key_struct(void *keys);
void aes_set_control_words(void *keys, const unsigned char *even, const unsigned char *odd);
void aes_set_even_control_word(void *keys, const unsigned char *even);
void aes_set_odd_control_word(void *keys, const unsigned char *odd);
void aes_decrypt_packet(void *keys, unsigned char *packet);

#else

// empty functions
static inline void *aes_get_key_struct(void) { return 0; };
static inline void aes_free_key_struct(void *keys) { return; };
static inline void aes_set_control_words(void *keys, const unsigned char *even, const unsigned char *odd) { return; };
static inline void aes_set_even_control_word(void *keys, const unsigned char *even) { return; };
static inline void aes_set_odd_control_word(void *keys, const unsigned char *odd) { return; };
static inline void aes_decrypt_packet(void *keys, unsigned char *packet) { return; };

#endif

#endif /* LIBAESDEC_H_ */

0 comments on commit deaa9ce

Please sign in to comment.