#ifndef _CRYPTO_XFORM_ENC_H_
#define _CRYPTO_XFORM_ENC_H_
#include <sys/types.h>
#include <crypto/rijndael/rijndael.h>
#include <crypto/camellia/camellia.h>
#include <opencrypto/cryptodev.h>
#ifdef _STANDALONE
#include <stand.h>
#endif
#define AESICM_BLOCKSIZE AES_BLOCK_LEN
#define AES_XTS_BLOCKSIZE 16
#define AES_XTS_IVSIZE 8
#define AES_XTS_ALPHA 0x87
struct enc_xform {
int type;
const char *name;
size_t ctxsize;
uint16_t blocksize;
uint16_t native_blocksize;
uint16_t ivsize;
uint16_t minkey, maxkey;
uint16_t macsize;
int (*setkey) (void *, const uint8_t *, int len);
void (*reinit) (void *, const uint8_t *, size_t);
void (*encrypt) (void *, const uint8_t *, uint8_t *);
void (*decrypt) (void *, const uint8_t *, uint8_t *);
void (*encrypt_multi) (void *, const uint8_t *, uint8_t *, size_t);
void (*decrypt_multi) (void *, const uint8_t *, uint8_t *, size_t);
void (*encrypt_last) (void *, const uint8_t *, uint8_t *, size_t len);
void (*decrypt_last) (void *, const uint8_t *, uint8_t *, size_t len);
int (*update) (void *, const void *, u_int);
void (*final) (uint8_t *, void *);
};
extern const struct enc_xform enc_xform_null;
extern const struct enc_xform enc_xform_aes_cbc;
extern const struct enc_xform enc_xform_aes_icm;
extern const struct enc_xform enc_xform_aes_nist_gcm;
extern const struct enc_xform enc_xform_aes_nist_gmac;
extern const struct enc_xform enc_xform_aes_xts;
extern const struct enc_xform enc_xform_camellia;
extern const struct enc_xform enc_xform_chacha20;
extern const struct enc_xform enc_xform_chacha20_poly1305;
extern const struct enc_xform enc_xform_xchacha20_poly1305;
extern const struct enc_xform enc_xform_ccm;
struct aes_icm_ctx {
uint32_t ac_ek[4*(RIJNDAEL_MAXNR + 1)];
uint8_t ac_block[AESICM_BLOCKSIZE];
int ac_nr;
};
struct aes_xts_ctx {
rijndael_ctx key1;
rijndael_ctx key2;
uint8_t tweak[AES_XTS_BLOCKSIZE];
};
#endif