CyaSSL is an SSL library for devices like mbed.
Dependents: cyassl-client Sync
ctc_hmac.h
00001 /* ctc_hmac.h 00002 * 00003 * Copyright (C) 2006-2009 Sawtooth Consulting Ltd. 00004 * 00005 * This file is part of CyaSSL. 00006 * 00007 * CyaSSL 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 * CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 00020 */ 00021 00022 #ifndef NO_HMAC 00023 00024 #ifndef CTAO_CRYPT_HMAC_H 00025 #define CTAO_CRYPT_HMAC_H 00026 00027 #include "ctc_md5.h" 00028 #include "ctc_sha.h" 00029 00030 #ifndef NO_SHA256 00031 #include "sha256.h" 00032 #endif 00033 00034 #ifdef __cplusplus 00035 extern "C" { 00036 #endif 00037 00038 00039 00040 enum { 00041 IPAD = 0x36, 00042 OPAD = 0x5C, 00043 #ifndef NO_SHA256 00044 INNER_HASH_SIZE = SHA256_DIGEST_SIZE, 00045 #else 00046 INNER_HASH_SIZE = SHA_DIGEST_SIZE, 00047 SHA256 = 2, /* hash type unique */ 00048 #endif 00049 HMAC_BLOCK_SIZE = MD5_BLOCK_SIZE 00050 }; 00051 00052 00053 /* hash union */ 00054 typedef union { 00055 Md5 md5; 00056 Sha sha; 00057 #ifndef NO_SHA256 00058 Sha256 sha256; 00059 #endif 00060 } Hash; 00061 00062 /* Hmac digest */ 00063 typedef struct Hmac { 00064 Hash hash; 00065 word32 ipad[HMAC_BLOCK_SIZE / sizeof(word32)]; /* same block size all*/ 00066 word32 opad[HMAC_BLOCK_SIZE / sizeof(word32)]; 00067 word32 innerHash[INNER_HASH_SIZE / sizeof(word32)]; /* max size */ 00068 byte macType; /* md5 sha or sha256 */ 00069 byte innerHashKeyed; /* keyed flag */ 00070 } Hmac; 00071 00072 00073 void HmacSetKey(Hmac*, int type, const byte* key, word32 keySz); /* does init */ 00074 void HmacUpdate(Hmac*, const byte*, word32); 00075 void HmacFinal(Hmac*, byte*); 00076 00077 00078 #ifdef __cplusplus 00079 } /* extern "C" */ 00080 #endif 00081 00082 #endif /* CTAO_CRYPT_HMAC_H */ 00083 00084 #endif /* NO_HMAC */ 00085
Generated on Tue Jul 12 2022 18:43:19 by 1.7.2