wolf SSL / wolfSSL-TLS13-Beta

Fork of wolfSSL by wolf SSL

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cmac.h Source File

cmac.h

00001 /* cmac.h
00002  *
00003  * Copyright (C) 2006-2016 wolfSSL Inc.
00004  *
00005  * This file is part of wolfSSL.
00006  *
00007  * wolfSSL is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * wolfSSL is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
00020  */
00021 
00022 
00023 #ifndef WOLF_CRYPT_CMAC_H
00024 #define WOLF_CRYPT_CMAC_H
00025 
00026 #include <wolfssl/wolfcrypt/types.h>
00027 #include <wolfssl/wolfcrypt/aes.h>
00028 
00029 #if !defined(NO_AES) && defined(WOLFSSL_CMAC)
00030 
00031 #ifdef __cplusplus
00032     extern "C" {
00033 #endif
00034 
00035 typedef struct Cmac {
00036     Aes aes;
00037     byte buffer[AES_BLOCK_SIZE]; /* partially stored block */
00038     byte digest[AES_BLOCK_SIZE]; /* running digest */
00039     byte k1[AES_BLOCK_SIZE];
00040     byte k2[AES_BLOCK_SIZE];
00041     word32 bufferSz;
00042     word32 totalSz;
00043 } Cmac;
00044 
00045 
00046 typedef enum CmacType {
00047     WC_CMAC_AES = 1
00048 } CmacType;
00049 
00050 
00051 WOLFSSL_API
00052 int wc_InitCmac(Cmac* cmac,
00053                 const byte* key, word32 keySz,
00054                 int type, void* unused);
00055 WOLFSSL_API
00056 int wc_CmacUpdate(Cmac* cmac,
00057                   const byte* in, word32 inSz);
00058 WOLFSSL_API
00059 int wc_CmacFinal(Cmac* cmac,
00060                  byte* out, word32* outSz);
00061 
00062 WOLFSSL_API
00063 int wc_AesCmacGenerate(byte* out, word32* outSz,
00064                        const byte* in, word32 inSz,
00065                        const byte* key, word32 keySz);
00066 
00067 WOLFSSL_API
00068 int wc_AesCmacVerify(const byte* check, word32 checkSz,
00069                      const byte* in, word32 inSz,
00070                      const byte* key, word32 keySz);
00071 
00072 #ifdef __cplusplus
00073     } /* extern "C" */
00074 #endif
00075 
00076 
00077 #endif /* NO_AES && WOLFSSL_CMAC */
00078 #endif /* WOLF_CRYPT_CMAC_H */
00079 
00080