2008-12-23 11:18:45 +00:00
|
|
|
/* ====================================================================
|
|
|
|
* Copyright (c) 2008 The OpenSSL Project. All rights reserved.
|
|
|
|
*
|
|
|
|
* Rights for redistribution and usage in source and binary
|
|
|
|
* forms are granted according to the OpenSSL license.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
typedef void (*block128_f)(const unsigned char in[16],
|
2008-12-16 08:39:21 +00:00
|
|
|
unsigned char out[16],
|
|
|
|
const void *key);
|
|
|
|
|
2008-12-27 13:40:45 +00:00
|
|
|
typedef void (*cbc128_f)(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len, const void *key,
|
|
|
|
unsigned char ivec[16], int enc);
|
|
|
|
|
2010-05-04 19:23:02 +00:00
|
|
|
typedef void (*ctr128_f)(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t blocks, const void *key,
|
|
|
|
const unsigned char ivec[16]);
|
|
|
|
|
2011-04-24 11:10:14 +00:00
|
|
|
typedef void (*ccm128_f)(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t blocks, const void *key,
|
|
|
|
const unsigned char ivec[16],unsigned char cmac[16]);
|
|
|
|
|
2008-12-16 08:39:21 +00:00
|
|
|
void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len, const void *key,
|
2008-12-23 11:18:45 +00:00
|
|
|
unsigned char ivec[16], block128_f block);
|
2008-12-16 08:39:21 +00:00
|
|
|
void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len, const void *key,
|
2008-12-23 11:18:45 +00:00
|
|
|
unsigned char ivec[16], block128_f block);
|
2008-12-16 08:39:21 +00:00
|
|
|
|
|
|
|
void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len, const void *key,
|
|
|
|
unsigned char ivec[16], unsigned char ecount_buf[16],
|
2008-12-23 11:18:45 +00:00
|
|
|
unsigned int *num, block128_f block);
|
2008-12-16 08:39:21 +00:00
|
|
|
|
2010-05-04 19:23:02 +00:00
|
|
|
void CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len, const void *key,
|
|
|
|
unsigned char ivec[16], unsigned char ecount_buf[16],
|
|
|
|
unsigned int *num, ctr128_f ctr);
|
|
|
|
|
2008-12-16 08:39:21 +00:00
|
|
|
void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len, const void *key,
|
|
|
|
unsigned char ivec[16], int *num,
|
2008-12-23 11:18:45 +00:00
|
|
|
block128_f block);
|
2008-12-16 08:39:21 +00:00
|
|
|
|
|
|
|
void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len, const void *key,
|
|
|
|
unsigned char ivec[16], int *num,
|
2008-12-23 11:18:45 +00:00
|
|
|
int enc, block128_f block);
|
2008-12-16 08:39:21 +00:00
|
|
|
void CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t length, const void *key,
|
|
|
|
unsigned char ivec[16], int *num,
|
2008-12-23 11:18:45 +00:00
|
|
|
int enc, block128_f block);
|
2008-12-16 08:39:21 +00:00
|
|
|
void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t bits, const void *key,
|
|
|
|
unsigned char ivec[16], int *num,
|
2008-12-23 11:18:45 +00:00
|
|
|
int enc, block128_f block);
|
2008-12-27 13:40:45 +00:00
|
|
|
|
|
|
|
size_t CRYPTO_cts128_encrypt_block(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len, const void *key,
|
|
|
|
unsigned char ivec[16], block128_f block);
|
|
|
|
size_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len, const void *key,
|
|
|
|
unsigned char ivec[16], cbc128_f cbc);
|
|
|
|
size_t CRYPTO_cts128_decrypt_block(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len, const void *key,
|
|
|
|
unsigned char ivec[16], block128_f block);
|
|
|
|
size_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len, const void *key,
|
|
|
|
unsigned char ivec[16], cbc128_f cbc);
|
2010-04-10 14:01:02 +00:00
|
|
|
|
|
|
|
size_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len, const void *key,
|
|
|
|
unsigned char ivec[16], block128_f block);
|
|
|
|
size_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len, const void *key,
|
|
|
|
unsigned char ivec[16], cbc128_f cbc);
|
|
|
|
size_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len, const void *key,
|
|
|
|
unsigned char ivec[16], block128_f block);
|
|
|
|
size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len, const void *key,
|
|
|
|
unsigned char ivec[16], cbc128_f cbc);
|
2010-05-01 14:41:25 +00:00
|
|
|
|
|
|
|
typedef struct gcm128_context GCM128_CONTEXT;
|
|
|
|
|
2010-07-09 14:10:51 +00:00
|
|
|
GCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block);
|
2010-07-27 16:34:29 +00:00
|
|
|
void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx,void *key,block128_f block);
|
2010-05-01 14:41:25 +00:00
|
|
|
void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv,
|
2010-07-09 14:10:51 +00:00
|
|
|
size_t len);
|
2011-02-07 19:11:13 +00:00
|
|
|
int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad,
|
2010-07-09 14:10:51 +00:00
|
|
|
size_t len);
|
2011-02-07 19:11:13 +00:00
|
|
|
int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
|
2010-07-09 14:10:51 +00:00
|
|
|
const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len);
|
2011-02-07 19:11:13 +00:00
|
|
|
int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,
|
2010-07-09 14:10:51 +00:00
|
|
|
const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len);
|
2011-02-07 19:11:13 +00:00
|
|
|
int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx,
|
2010-08-02 21:39:51 +00:00
|
|
|
const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len, ctr128_f stream);
|
2011-02-07 19:11:13 +00:00
|
|
|
int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx,
|
2010-08-02 21:39:51 +00:00
|
|
|
const unsigned char *in, unsigned char *out,
|
|
|
|
size_t len, ctr128_f stream);
|
2011-04-24 11:10:14 +00:00
|
|
|
int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx,const unsigned char *tag,
|
2010-07-09 14:10:51 +00:00
|
|
|
size_t len);
|
2011-04-24 11:10:14 +00:00
|
|
|
void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len);
|
2010-07-09 14:10:51 +00:00
|
|
|
void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx);
|
2011-04-12 23:21:33 +00:00
|
|
|
|
2011-04-18 13:15:37 +00:00
|
|
|
typedef struct ccm128_context CCM128_CONTEXT;
|
|
|
|
|
|
|
|
void CRYPTO_ccm128_init(CCM128_CONTEXT *ctx,
|
2011-04-18 14:25:11 +00:00
|
|
|
unsigned int M, unsigned int L, void *key,block128_f block);
|
2011-04-18 13:15:37 +00:00
|
|
|
int CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx,
|
2011-04-18 14:25:11 +00:00
|
|
|
const unsigned char *nonce, size_t nlen, size_t mlen);
|
2011-04-18 13:15:37 +00:00
|
|
|
void CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx,
|
2011-04-18 14:25:11 +00:00
|
|
|
const unsigned char *aad, size_t alen);
|
2011-04-18 13:15:37 +00:00
|
|
|
int CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx,
|
2011-04-18 14:25:11 +00:00
|
|
|
const unsigned char *inp, unsigned char *out, size_t len);
|
2011-04-18 13:15:37 +00:00
|
|
|
int CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx,
|
2011-04-18 14:25:11 +00:00
|
|
|
const unsigned char *inp, unsigned char *out, size_t len);
|
2011-04-24 11:10:14 +00:00
|
|
|
int CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx,
|
|
|
|
const unsigned char *inp, unsigned char *out, size_t len,
|
|
|
|
ccm128_f stream);
|
|
|
|
int CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx,
|
|
|
|
const unsigned char *inp, unsigned char *out, size_t len,
|
|
|
|
ccm128_f stream);
|
2011-04-18 14:25:11 +00:00
|
|
|
size_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx, unsigned char *tag, size_t len);
|
2011-04-18 13:15:37 +00:00
|
|
|
|
2011-04-12 23:21:33 +00:00
|
|
|
typedef struct xts128_context XTS128_CONTEXT;
|
|
|
|
|
2011-04-20 08:13:58 +00:00
|
|
|
int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char iv[16],
|
2011-04-18 14:25:11 +00:00
|
|
|
const unsigned char *inp, unsigned char *out, size_t len, int enc);
|