Create tag for version 1.20
[oscam.git] / cscrypt / aes.h
blobe6de6b7afff3559b7917ed62fcbdec6567028678
1 #if defined(WITH_SSL) || defined(WITH_LIBCRYPTO)
2 # include <openssl/aes.h>
3 #else
4 #ifndef HEADER_AES_H
5 #define HEADER_AES_H
7 #define AES_ENCRYPT 1
8 #define AES_DECRYPT 0
10 /* Because array size can't be a const in C, the following two are macros.
11 Both sizes are in bytes. */
12 #define AES_MAXNR 14
13 #define AES_BLOCK_SIZE 16
15 # define GETU32(pt) (((uint32_t)(pt)[0] << 24) ^ ((uint32_t)(pt)[1] << 16) ^ ((uint32_t)(pt)[2] << 8) ^ ((uint32_t)(pt)[3]))
16 # define PUTU32(ct, st) { (ct)[0] = (uint8_t)((st) >> 24); (ct)[1] = (uint8_t)((st) >> 16); (ct)[2] = (uint8_t)((st) >> 8); (ct)[3] = (uint8_t)(st); }
18 #include <stdint.h>
20 #define MAXKC (256/32)
21 #define MAXKB (256/8)
22 #define MAXNR 14
24 /* This controls loop-unrolling in aes_core.c */
25 #undef FULL_UNROLL
27 /* This should be a hidden type, but EVP requires that the size be known */
28 struct aes_key_st
30 uint32_t rd_key[4 * (AES_MAXNR + 1)];
31 int rounds;
33 typedef struct aes_key_st AES_KEY;
35 int AES_set_encrypt_key(const uint8_t *userKey, const int bits, AES_KEY *key);
36 int AES_set_decrypt_key(const uint8_t *userKey, const int bits, AES_KEY *key);
38 void AES_encrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key);
39 void AES_decrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key);
41 void AES_cbc_encrypt(const uint8_t *in, uint8_t *out, const unsigned long length,
42 const AES_KEY *key, uint8_t *ivec, const int enc);
43 #endif /* !HEADER_AES_H */
45 #endif