UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
crypt_aes.h
Go to the documentation of this file.
1
38#ifndef __RIJNDAEL_API_FST_H
39#define __RIJNDAEL_API_FST_H
40
41#include <stdio.h>
42#include "crypt_aes_impl.h"
43
44/* Generic Defines */
45#define DIR_ENCRYPT 0 /* Are we encrpyting? */
46#define DIR_DECRYPT 1 /* Are we decrpyting? */
47#define MODE_ECB 1 /* Are we ciphering in ECB mode? */
48#define MODE_CBC 2 /* Are we ciphering in CBC mode? */
49#define MODE_CFB1 3 /* Are we ciphering in 1-bit CFB mode? */
50#define TRUE 1
51#define FALSE 0
52#define BITSPERBLOCK 128 /* Default number of bits in a cipher block */
53
54/* Error Codes */
55#define BAD_KEY_DIR -1 /* Key direction is invalid, e.g., unknown value */
56#define BAD_KEY_MAT -2 /* Key material not of correct length */
57#define BAD_KEY_INSTANCE -3 /* Key passed is not valid */
58#define BAD_CIPHER_MODE -4 /* Params struct passed to cipherInit invalid */
59#define BAD_CIPHER_STATE -5 /* Cipher in wrong state (e.g., not initialized) */
60#define BAD_BLOCK_LENGTH -6
61#define BAD_CIPHER_INSTANCE -7
62#define BAD_DATA -8 /* Data contents are invalid, e.g., invalid padding */
63#define BAD_OTHER -9 /* Unknown error */
64
65/* Algorithm-specific Defines */
66#define MAX_KEY_SIZE 64 /* # of ASCII char's needed to represent a key */
67#define MAX_IV_SIZE 16 /* # bytes needed to represent an IV */
68
69/* Typedefs */
70
71typedef unsigned char BYTE;
72
73/* The structure for key information */
74typedef struct {
75 BYTE direction; /* Key used for encrypting or decrypting? */
76 int keyLen; /* Length of the key */
77 char keyMaterial[MAX_KEY_SIZE+1]; /* Raw key data in ASCII, e.g., user input or KAT values */
78 int Nr; /* key-length-dependent number of rounds */
79 u32 rk[4*(MAXNR + 1)]; /* key schedule */
80 u32 ek[4*(MAXNR + 1)]; /* CFB1 key schedule (encryption only) */
82
83/* The structure for cipher information */
84typedef struct { /* changed order of the components */
85 BYTE mode; /* MODE_ECB, MODE_CBC, or MODE_CFB1 */
86 BYTE IV[MAX_IV_SIZE]; /* A possible Initialization Vector for ciphering */
88
89/* Function prototypes */
90
91int makeKey(keyInstance *key, BYTE direction, int keyLen, const char *keyMaterial);
92
93int cipherInit(cipherInstance *cipher, BYTE mode, char *IV);
94
96 BYTE *input, int inputLen, BYTE *outBuffer);
97
99 BYTE *input, int inputOctets, BYTE *outBuffer);
100
102 BYTE *input, int inputLen, BYTE *outBuffer);
103
105 BYTE *input, int inputOctets, BYTE *outBuffer);
106
108 BYTE *input, int inputLen, BYTE *outBuffer, int Rounds);
109
110#endif /* __RIJNDAEL_API_FST_H */
int blockEncrypt(cipherInstance *cipher, keyInstance *key, BYTE *input, int inputLen, BYTE *outBuffer)
Definition crypt_aes.c:145
unsigned char BYTE
Definition crypt_aes.h:71
#define MAX_KEY_SIZE
Definition crypt_aes.h:66
int padEncrypt(cipherInstance *cipher, keyInstance *key, BYTE *input, int inputOctets, BYTE *outBuffer)
Definition crypt_aes.c:224
int cipherUpdateRounds(cipherInstance *cipher, keyInstance *key, BYTE *input, int inputLen, BYTE *outBuffer, int Rounds)
Definition crypt_aes.c:444
int blockDecrypt(cipherInstance *cipher, keyInstance *key, BYTE *input, int inputLen, BYTE *outBuffer)
Definition crypt_aes.c:287
int makeKey(keyInstance *key, BYTE direction, int keyLen, const char *keyMaterial)
Definition crypt_aes.c:45
int cipherInit(cipherInstance *cipher, BYTE mode, char *IV)
Definition crypt_aes.c:105
#define MAX_IV_SIZE
Definition crypt_aes.h:67
int padDecrypt(cipherInstance *cipher, keyInstance *key, BYTE *input, int inputOctets, BYTE *outBuffer)
Definition crypt_aes.c:356
#define MAXNR
unsigned int u32
Definition cuda_dxt.cu:12
enum openssl_mode mode
BYTE direction
Definition crypt_aes.h:75
const char * key
Definition cineform.cpp:125