diff options
Diffstat (limited to 'crypto/modes')
-rw-r--r-- | crypto/modes/Makefile | 5 | ||||
-rw-r--r-- | crypto/modes/ccm128.c | 9 | ||||
-rw-r--r-- | crypto/modes/modes.h | 16 | ||||
-rw-r--r-- | crypto/modes/modes_lcl.h | 7 |
4 files changed, 27 insertions, 10 deletions
diff --git a/crypto/modes/Makefile b/crypto/modes/Makefile index 57433fdbd0..755c441328 100644 --- a/crypto/modes/Makefile +++ b/crypto/modes/Makefile @@ -21,9 +21,10 @@ TEST= APPS= LIB=$(TOP)/libcrypto.a -LIBSRC= cbc128.c ctr128.c cts128.c cfb128.c ofb128.c gcm128.c xts128.c +LIBSRC= cbc128.c ctr128.c cts128.c cfb128.c ofb128.c gcm128.c \ + ccm128.c xts128.c LIBOBJ= cbc128.o ctr128.o cts128.o cfb128.o ofb128.o gcm128.o \ - xts128.o $(MODES_ASM_OBJ) + ccm128.o xts128.o $(MODES_ASM_OBJ) SRC= $(LIBSRC) diff --git a/crypto/modes/ccm128.c b/crypto/modes/ccm128.c index 7cae1af95b..943b8bab91 100644 --- a/crypto/modes/ccm128.c +++ b/crypto/modes/ccm128.c @@ -58,13 +58,6 @@ #endif #include <assert.h> -typedef struct { - union { u64 u[2]; u8 c[16]; } nonce, cmac; - u64 blocks; - block128_f block; - void *key; -} CCM128_CONTEXT; - /* First you setup M and L parameters and pass the key schedule */ void CRYPTO_ccm128_init(CCM128_CONTEXT *ctx, unsigned int M,unsigned int L,void *key,block128_f block) @@ -251,7 +244,7 @@ int CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx, size_t n; unsigned int i,L; unsigned char flags0 = ctx->nonce.c[0]; - block128_f block; + block128_f block = ctx->block; union { u64 u[2]; u8 c[16]; } scratch; if (!(flags0&0x40)) diff --git a/crypto/modes/modes.h b/crypto/modes/modes.h index 1ef78cef22..c65e7815dd 100644 --- a/crypto/modes/modes.h +++ b/crypto/modes/modes.h @@ -105,6 +105,22 @@ int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx,const unsigned char *tag, void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len); void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx); +typedef struct ccm128_context CCM128_CONTEXT; + +void CRYPTO_ccm128_init(CCM128_CONTEXT *ctx, + unsigned int M,unsigned int L,void *key,block128_f block); +int CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx, + const unsigned char *nonce,size_t nlen,size_t mlen); +void CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx, + const unsigned char *aad,size_t alen); +int CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx, + const unsigned char *inp, unsigned char *out, + size_t len); +int CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx, + const unsigned char *inp, unsigned char *out, + size_t len); +size_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx,unsigned char *tag,size_t len); + typedef struct xts128_context XTS128_CONTEXT; int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char *iv, diff --git a/crypto/modes/modes_lcl.h b/crypto/modes/modes_lcl.h index 1ac0e01a88..4dab6a67fe 100644 --- a/crypto/modes/modes_lcl.h +++ b/crypto/modes/modes_lcl.h @@ -122,3 +122,10 @@ struct xts128_context { block128_f block1,block2; }; +struct ccm128_context { + union { u64 u[2]; u8 c[16]; } nonce, cmac; + u64 blocks; + block128_f block; + void *key; +}; + |