libaesdec: more cosmetic tweaks

This commit is contained in:
Jaroslav Kysela 2014-08-06 08:59:25 +02:00
parent 482e46e6a0
commit deaa9ceaa2
2 changed files with 29 additions and 23 deletions

View file

@ -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
@ -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;

View file

@ -8,22 +8,27 @@
#ifndef LIBAESDEC_H_
#define LIBAESDEC_H_
#include "build.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
#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_ */