A simple CyaSSL-based HMAC-MD5 implementation. Licensed under GPL v2.

Dependents:   RFrec_full RFtrans_full

The output will be base64-encoded, with trailing "==", like this:

j62o/jZsAZD9i9m+32lIuQ==

Example

#include "mbed.h"
#include "hmac_md5.h"

Serial pc(USBTX, USBRX); // tx, rx

void main(void)
{
    
    const char * key = "MySecretKey";
    
    const char * text = "message to be signed";
    
    char output[26];
    
    HMAC_MD5(key, text, output);

    printf("result = %s\n", output);

    while(true){}
}
Committer:
igrokhotkov
Date:
Wed Feb 06 20:35:03 2013 +0000
Revision:
0:83f3dcfa5c8f
initial revision

Who changed what in which revision?

UserRevisionLine numberNew contents of line
igrokhotkov 0:83f3dcfa5c8f 1 /* misc.h
igrokhotkov 0:83f3dcfa5c8f 2 *
igrokhotkov 0:83f3dcfa5c8f 3 * Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
igrokhotkov 0:83f3dcfa5c8f 4 *
igrokhotkov 0:83f3dcfa5c8f 5 * This file is part of CyaSSL.
igrokhotkov 0:83f3dcfa5c8f 6 *
igrokhotkov 0:83f3dcfa5c8f 7 * CyaSSL is free software; you can redistribute it and/or modify
igrokhotkov 0:83f3dcfa5c8f 8 * it under the terms of the GNU General Public License as published by
igrokhotkov 0:83f3dcfa5c8f 9 * the Free Software Foundation; either version 2 of the License, or
igrokhotkov 0:83f3dcfa5c8f 10 * (at your option) any later version.
igrokhotkov 0:83f3dcfa5c8f 11 *
igrokhotkov 0:83f3dcfa5c8f 12 * CyaSSL is distributed in the hope that it will be useful,
igrokhotkov 0:83f3dcfa5c8f 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
igrokhotkov 0:83f3dcfa5c8f 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
igrokhotkov 0:83f3dcfa5c8f 15 * GNU General Public License for more details.
igrokhotkov 0:83f3dcfa5c8f 16 *
igrokhotkov 0:83f3dcfa5c8f 17 * You should have received a copy of the GNU General Public License
igrokhotkov 0:83f3dcfa5c8f 18 * along with this program; if not, write to the Free Software
igrokhotkov 0:83f3dcfa5c8f 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
igrokhotkov 0:83f3dcfa5c8f 20 */
igrokhotkov 0:83f3dcfa5c8f 21
igrokhotkov 0:83f3dcfa5c8f 22
igrokhotkov 0:83f3dcfa5c8f 23 #ifndef CTAO_CRYPT_MISC_H
igrokhotkov 0:83f3dcfa5c8f 24 #define CTAO_CRYPT_MISC_H
igrokhotkov 0:83f3dcfa5c8f 25
igrokhotkov 0:83f3dcfa5c8f 26
igrokhotkov 0:83f3dcfa5c8f 27 #include "types.h"
igrokhotkov 0:83f3dcfa5c8f 28
igrokhotkov 0:83f3dcfa5c8f 29
igrokhotkov 0:83f3dcfa5c8f 30 #ifdef __cplusplus
igrokhotkov 0:83f3dcfa5c8f 31 extern "C" {
igrokhotkov 0:83f3dcfa5c8f 32 #endif
igrokhotkov 0:83f3dcfa5c8f 33
igrokhotkov 0:83f3dcfa5c8f 34
igrokhotkov 0:83f3dcfa5c8f 35 #ifdef NO_INLINE
igrokhotkov 0:83f3dcfa5c8f 36 CYASSL_LOCAL
igrokhotkov 0:83f3dcfa5c8f 37 word32 rotlFixed(word32, word32);
igrokhotkov 0:83f3dcfa5c8f 38 CYASSL_LOCAL
igrokhotkov 0:83f3dcfa5c8f 39 word32 rotrFixed(word32, word32);
igrokhotkov 0:83f3dcfa5c8f 40
igrokhotkov 0:83f3dcfa5c8f 41 CYASSL_LOCAL
igrokhotkov 0:83f3dcfa5c8f 42 word32 ByteReverseWord32(word32);
igrokhotkov 0:83f3dcfa5c8f 43 CYASSL_LOCAL
igrokhotkov 0:83f3dcfa5c8f 44 void ByteReverseWords(word32*, const word32*, word32);
igrokhotkov 0:83f3dcfa5c8f 45 CYASSL_LOCAL
igrokhotkov 0:83f3dcfa5c8f 46 void ByteReverseBytes(byte*, const byte*, word32);
igrokhotkov 0:83f3dcfa5c8f 47
igrokhotkov 0:83f3dcfa5c8f 48 CYASSL_LOCAL
igrokhotkov 0:83f3dcfa5c8f 49 void XorWords(word*, const word*, word32);
igrokhotkov 0:83f3dcfa5c8f 50 CYASSL_LOCAL
igrokhotkov 0:83f3dcfa5c8f 51 void xorbuf(byte*, const byte*, word32);
igrokhotkov 0:83f3dcfa5c8f 52
igrokhotkov 0:83f3dcfa5c8f 53 #ifdef WORD64_AVAILABLE
igrokhotkov 0:83f3dcfa5c8f 54 CYASSL_LOCAL
igrokhotkov 0:83f3dcfa5c8f 55 word64 rotlFixed64(word64, word64);
igrokhotkov 0:83f3dcfa5c8f 56 CYASSL_LOCAL
igrokhotkov 0:83f3dcfa5c8f 57 word64 rotrFixed64(word64, word64);
igrokhotkov 0:83f3dcfa5c8f 58
igrokhotkov 0:83f3dcfa5c8f 59 CYASSL_LOCAL
igrokhotkov 0:83f3dcfa5c8f 60 word64 ByteReverseWord64(word64);
igrokhotkov 0:83f3dcfa5c8f 61 CYASSL_LOCAL
igrokhotkov 0:83f3dcfa5c8f 62 void ByteReverseWords64(word64*, const word64*, word32);
igrokhotkov 0:83f3dcfa5c8f 63 #endif /* WORD64_AVAILABLE */
igrokhotkov 0:83f3dcfa5c8f 64
igrokhotkov 0:83f3dcfa5c8f 65 #endif /* NO_INLINE */
igrokhotkov 0:83f3dcfa5c8f 66
igrokhotkov 0:83f3dcfa5c8f 67
igrokhotkov 0:83f3dcfa5c8f 68 #ifdef __cplusplus
igrokhotkov 0:83f3dcfa5c8f 69 } /* extern "C" */
igrokhotkov 0:83f3dcfa5c8f 70 #endif
igrokhotkov 0:83f3dcfa5c8f 71
igrokhotkov 0:83f3dcfa5c8f 72
igrokhotkov 0:83f3dcfa5c8f 73 #endif /* CTAO_CRYPT_MISC_H */
igrokhotkov 0:83f3dcfa5c8f 74