3 * Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
5 * This file is part of CyaSSL.
7 * CyaSSL is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * CyaSSL is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
25 #ifndef CTAO_CRYPT_HMAC_H
26 #define CTAO_CRYPT_HMAC_H
28 #include <cyassl/ctaocrypt/md5.h>
29 #include <cyassl/ctaocrypt/sha.h>
32 #include <cyassl/ctaocrypt/sha256.h>
36 #include <cyassl/ctaocrypt/sha512.h>
47 #if defined(CYASSL_SHA384)
48 INNER_HASH_SIZE = SHA384_DIGEST_SIZE,
49 HMAC_BLOCK_SIZE = SHA384_BLOCK_SIZE
50 #elif !defined(NO_SHA256)
51 INNER_HASH_SIZE = SHA256_DIGEST_SIZE,
52 HMAC_BLOCK_SIZE = SHA256_BLOCK_SIZE,
55 INNER_HASH_SIZE = SHA_DIGEST_SIZE,
56 HMAC_BLOCK_SIZE = SHA_BLOCK_SIZE,
57 SHA256 = 2, /* hash type unique */
78 word32 ipad[HMAC_BLOCK_SIZE / sizeof(word32)]; /* same block size all*/
79 word32 opad[HMAC_BLOCK_SIZE / sizeof(word32)];
80 word32 innerHash[INNER_HASH_SIZE / sizeof(word32)]; /* max size */
81 byte macType; /* md5 sha or sha256 */
82 byte innerHashKeyed; /* keyed flag */
87 CYASSL_API void HmacSetKey(Hmac*, int type, const byte* key, word32 keySz);
88 CYASSL_API void HmacUpdate(Hmac*, const byte*, word32);
89 CYASSL_API void HmacFinal(Hmac*, byte*);
96 #endif /* CTAO_CRYPT_HMAC_H */