Compile ccm128.c, move some structures to modes_lcl.h add prototypes.
authorDr. Stephen Henson <steve@openssl.org>
Mon, 18 Apr 2011 13:15:37 +0000 (13:15 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Mon, 18 Apr 2011 13:15:37 +0000 (13:15 +0000)
crypto/modes/Makefile
crypto/modes/ccm128.c
crypto/modes/modes.h
crypto/modes/modes_lcl.h

index 57433fdbd013385d66c31204400f05e589da6873..755c4413286629462c569ee9433b6477a50eb738 100644 (file)
@@ -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)
 
index 7cae1af95b07b98330c7e11ee32cebdd2be4fdb5..943b8bab91e4ac4066d40a255eba9d43fb8cff4e 100644 (file)
 #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))
index 1ef78cef222a94b4abf1bf33bf0f540bb0945413..c65e7815dd0f013e2f01b6308b9c9d5886f3d0be 100644 (file)
@@ -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,
index 1ac0e01a88277b1dff430c98909b834742d7428a..4dab6a67fe57929d7e9f6b4cb8cb899ddf1093e0 100644 (file)
@@ -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;
+};
+