wolfSSL SSL/TLS library, support up to TLS1.3

Dependents:   CyaSSL-Twitter-OAuth4Tw Example-client-tls-cert TwitterReader TweetTest ... more

Committer:
wolfSSL
Date:
Tue May 02 08:44:26 2017 +0000
Revision:
6:fa3bd0ca5896
wolfSSL3.10.2;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 6:fa3bd0ca5896 1 /* cmac.h
wolfSSL 6:fa3bd0ca5896 2 *
wolfSSL 6:fa3bd0ca5896 3 * Copyright (C) 2006-2016 wolfSSL Inc.
wolfSSL 6:fa3bd0ca5896 4 *
wolfSSL 6:fa3bd0ca5896 5 * This file is part of wolfSSL.
wolfSSL 6:fa3bd0ca5896 6 *
wolfSSL 6:fa3bd0ca5896 7 * wolfSSL is free software; you can redistribute it and/or modify
wolfSSL 6:fa3bd0ca5896 8 * it under the terms of the GNU General Public License as published by
wolfSSL 6:fa3bd0ca5896 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 6:fa3bd0ca5896 10 * (at your option) any later version.
wolfSSL 6:fa3bd0ca5896 11 *
wolfSSL 6:fa3bd0ca5896 12 * wolfSSL is distributed in the hope that it will be useful,
wolfSSL 6:fa3bd0ca5896 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 6:fa3bd0ca5896 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 6:fa3bd0ca5896 15 * GNU General Public License for more details.
wolfSSL 6:fa3bd0ca5896 16 *
wolfSSL 6:fa3bd0ca5896 17 * You should have received a copy of the GNU General Public License
wolfSSL 6:fa3bd0ca5896 18 * along with this program; if not, write to the Free Software
wolfSSL 6:fa3bd0ca5896 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
wolfSSL 6:fa3bd0ca5896 20 */
wolfSSL 6:fa3bd0ca5896 21
wolfSSL 6:fa3bd0ca5896 22
wolfSSL 6:fa3bd0ca5896 23 #ifndef WOLF_CRYPT_CMAC_H
wolfSSL 6:fa3bd0ca5896 24 #define WOLF_CRYPT_CMAC_H
wolfSSL 6:fa3bd0ca5896 25
wolfSSL 6:fa3bd0ca5896 26 #include <wolfssl/wolfcrypt/types.h>
wolfSSL 6:fa3bd0ca5896 27 #include <wolfssl/wolfcrypt/aes.h>
wolfSSL 6:fa3bd0ca5896 28
wolfSSL 6:fa3bd0ca5896 29 #if !defined(NO_AES) && defined(WOLFSSL_CMAC)
wolfSSL 6:fa3bd0ca5896 30
wolfSSL 6:fa3bd0ca5896 31 #ifdef __cplusplus
wolfSSL 6:fa3bd0ca5896 32 extern "C" {
wolfSSL 6:fa3bd0ca5896 33 #endif
wolfSSL 6:fa3bd0ca5896 34
wolfSSL 6:fa3bd0ca5896 35 typedef struct Cmac {
wolfSSL 6:fa3bd0ca5896 36 Aes aes;
wolfSSL 6:fa3bd0ca5896 37 byte buffer[AES_BLOCK_SIZE]; /* partially stored block */
wolfSSL 6:fa3bd0ca5896 38 byte digest[AES_BLOCK_SIZE]; /* running digest */
wolfSSL 6:fa3bd0ca5896 39 byte k1[AES_BLOCK_SIZE];
wolfSSL 6:fa3bd0ca5896 40 byte k2[AES_BLOCK_SIZE];
wolfSSL 6:fa3bd0ca5896 41 word32 bufferSz;
wolfSSL 6:fa3bd0ca5896 42 word32 totalSz;
wolfSSL 6:fa3bd0ca5896 43 } Cmac;
wolfSSL 6:fa3bd0ca5896 44
wolfSSL 6:fa3bd0ca5896 45
wolfSSL 6:fa3bd0ca5896 46 typedef enum CmacType {
wolfSSL 6:fa3bd0ca5896 47 WC_CMAC_AES = 1
wolfSSL 6:fa3bd0ca5896 48 } CmacType;
wolfSSL 6:fa3bd0ca5896 49
wolfSSL 6:fa3bd0ca5896 50
wolfSSL 6:fa3bd0ca5896 51 WOLFSSL_API
wolfSSL 6:fa3bd0ca5896 52 int wc_InitCmac(Cmac* cmac,
wolfSSL 6:fa3bd0ca5896 53 const byte* key, word32 keySz,
wolfSSL 6:fa3bd0ca5896 54 int type, void* unused);
wolfSSL 6:fa3bd0ca5896 55 WOLFSSL_API
wolfSSL 6:fa3bd0ca5896 56 int wc_CmacUpdate(Cmac* cmac,
wolfSSL 6:fa3bd0ca5896 57 const byte* in, word32 inSz);
wolfSSL 6:fa3bd0ca5896 58 WOLFSSL_API
wolfSSL 6:fa3bd0ca5896 59 int wc_CmacFinal(Cmac* cmac,
wolfSSL 6:fa3bd0ca5896 60 byte* out, word32* outSz);
wolfSSL 6:fa3bd0ca5896 61
wolfSSL 6:fa3bd0ca5896 62 WOLFSSL_API
wolfSSL 6:fa3bd0ca5896 63 int wc_AesCmacGenerate(byte* out, word32* outSz,
wolfSSL 6:fa3bd0ca5896 64 const byte* in, word32 inSz,
wolfSSL 6:fa3bd0ca5896 65 const byte* key, word32 keySz);
wolfSSL 6:fa3bd0ca5896 66
wolfSSL 6:fa3bd0ca5896 67 WOLFSSL_API
wolfSSL 6:fa3bd0ca5896 68 int wc_AesCmacVerify(const byte* check, word32 checkSz,
wolfSSL 6:fa3bd0ca5896 69 const byte* in, word32 inSz,
wolfSSL 6:fa3bd0ca5896 70 const byte* key, word32 keySz);
wolfSSL 6:fa3bd0ca5896 71
wolfSSL 6:fa3bd0ca5896 72 #ifdef __cplusplus
wolfSSL 6:fa3bd0ca5896 73 } /* extern "C" */
wolfSSL 6:fa3bd0ca5896 74 #endif
wolfSSL 6:fa3bd0ca5896 75
wolfSSL 6:fa3bd0ca5896 76
wolfSSL 6:fa3bd0ca5896 77 #endif /* NO_AES && WOLFSSL_CMAC */
wolfSSL 6:fa3bd0ca5896 78 #endif /* WOLF_CRYPT_CMAC_H */
wolfSSL 6:fa3bd0ca5896 79
wolfSSL 6:fa3bd0ca5896 80