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 /* error.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_ERROR_H
igrokhotkov 0:83f3dcfa5c8f 24 #define CTAO_CRYPT_ERROR_H
igrokhotkov 0:83f3dcfa5c8f 25
igrokhotkov 0:83f3dcfa5c8f 26 #include "types.h"
igrokhotkov 0:83f3dcfa5c8f 27
igrokhotkov 0:83f3dcfa5c8f 28
igrokhotkov 0:83f3dcfa5c8f 29 #ifdef __cplusplus
igrokhotkov 0:83f3dcfa5c8f 30 extern "C" {
igrokhotkov 0:83f3dcfa5c8f 31 #endif
igrokhotkov 0:83f3dcfa5c8f 32
igrokhotkov 0:83f3dcfa5c8f 33
igrokhotkov 0:83f3dcfa5c8f 34 /* error codes */
igrokhotkov 0:83f3dcfa5c8f 35 enum {
igrokhotkov 0:83f3dcfa5c8f 36 MAX_ERROR_SZ = 80, /* max size of error string */
igrokhotkov 0:83f3dcfa5c8f 37 MAX_CODE_E = -100, /* errors -101 - -199 */
igrokhotkov 0:83f3dcfa5c8f 38 OPEN_RAN_E = -101, /* opening random device error */
igrokhotkov 0:83f3dcfa5c8f 39 READ_RAN_E = -102, /* reading random device error */
igrokhotkov 0:83f3dcfa5c8f 40 WINCRYPT_E = -103, /* windows crypt init error */
igrokhotkov 0:83f3dcfa5c8f 41 CRYPTGEN_E = -104, /* windows crypt generation error */
igrokhotkov 0:83f3dcfa5c8f 42 RAN_BLOCK_E = -105, /* reading random device would block */
igrokhotkov 0:83f3dcfa5c8f 43
igrokhotkov 0:83f3dcfa5c8f 44 MP_INIT_E = -110, /* mp_init error state */
igrokhotkov 0:83f3dcfa5c8f 45 MP_READ_E = -111, /* mp_read error state */
igrokhotkov 0:83f3dcfa5c8f 46 MP_EXPTMOD_E = -112, /* mp_exptmod error state */
igrokhotkov 0:83f3dcfa5c8f 47 MP_TO_E = -113, /* mp_to_xxx error state, can't convert */
igrokhotkov 0:83f3dcfa5c8f 48 MP_SUB_E = -114, /* mp_sub error state, can't subtract */
igrokhotkov 0:83f3dcfa5c8f 49 MP_ADD_E = -115, /* mp_add error state, can't add */
igrokhotkov 0:83f3dcfa5c8f 50 MP_MUL_E = -116, /* mp_mul error state, can't multiply */
igrokhotkov 0:83f3dcfa5c8f 51 MP_MULMOD_E = -117, /* mp_mulmod error state, can't multiply mod */
igrokhotkov 0:83f3dcfa5c8f 52 MP_MOD_E = -118, /* mp_mod error state, can't mod */
igrokhotkov 0:83f3dcfa5c8f 53 MP_INVMOD_E = -119, /* mp_invmod error state, can't inv mod */
igrokhotkov 0:83f3dcfa5c8f 54 MP_CMP_E = -120, /* mp_cmp error state */
igrokhotkov 0:83f3dcfa5c8f 55 MP_ZERO_E = -121, /* got a mp zero result, not expected */
igrokhotkov 0:83f3dcfa5c8f 56
igrokhotkov 0:83f3dcfa5c8f 57 MEMORY_E = -125, /* out of memory error */
igrokhotkov 0:83f3dcfa5c8f 58
igrokhotkov 0:83f3dcfa5c8f 59 RSA_WRONG_TYPE_E = -130, /* RSA wrong block type for RSA function */
igrokhotkov 0:83f3dcfa5c8f 60 RSA_BUFFER_E = -131, /* RSA buffer error, output too small or
igrokhotkov 0:83f3dcfa5c8f 61 input too large */
igrokhotkov 0:83f3dcfa5c8f 62 BUFFER_E = -132, /* output buffer too small or input too large */
igrokhotkov 0:83f3dcfa5c8f 63 ALGO_ID_E = -133, /* setting algo id error */
igrokhotkov 0:83f3dcfa5c8f 64 PUBLIC_KEY_E = -134, /* setting public key error */
igrokhotkov 0:83f3dcfa5c8f 65 DATE_E = -135, /* setting date validity error */
igrokhotkov 0:83f3dcfa5c8f 66 SUBJECT_E = -136, /* setting subject name error */
igrokhotkov 0:83f3dcfa5c8f 67 ISSUER_E = -137, /* setting issuer name error */
igrokhotkov 0:83f3dcfa5c8f 68 CA_TRUE_E = -138, /* setting CA basic constraint true error */
igrokhotkov 0:83f3dcfa5c8f 69 EXTENSIONS_E = -139, /* setting extensions error */
igrokhotkov 0:83f3dcfa5c8f 70
igrokhotkov 0:83f3dcfa5c8f 71 ASN_PARSE_E = -140, /* ASN parsing error, invalid input */
igrokhotkov 0:83f3dcfa5c8f 72 ASN_VERSION_E = -141, /* ASN version error, invalid number */
igrokhotkov 0:83f3dcfa5c8f 73 ASN_GETINT_E = -142, /* ASN get big int error, invalid data */
igrokhotkov 0:83f3dcfa5c8f 74 ASN_RSA_KEY_E = -143, /* ASN key init error, invalid input */
igrokhotkov 0:83f3dcfa5c8f 75 ASN_OBJECT_ID_E = -144, /* ASN object id error, invalid id */
igrokhotkov 0:83f3dcfa5c8f 76 ASN_TAG_NULL_E = -145, /* ASN tag error, not null */
igrokhotkov 0:83f3dcfa5c8f 77 ASN_EXPECT_0_E = -146, /* ASN expect error, not zero */
igrokhotkov 0:83f3dcfa5c8f 78 ASN_BITSTR_E = -147, /* ASN bit string error, wrong id */
igrokhotkov 0:83f3dcfa5c8f 79 ASN_UNKNOWN_OID_E = -148, /* ASN oid error, unknown sum id */
igrokhotkov 0:83f3dcfa5c8f 80 ASN_DATE_SZ_E = -149, /* ASN date error, bad size */
igrokhotkov 0:83f3dcfa5c8f 81 ASN_BEFORE_DATE_E = -150, /* ASN date error, current date before */
igrokhotkov 0:83f3dcfa5c8f 82 ASN_AFTER_DATE_E = -151, /* ASN date error, current date after */
igrokhotkov 0:83f3dcfa5c8f 83 ASN_SIG_OID_E = -152, /* ASN signature error, mismatched oid */
igrokhotkov 0:83f3dcfa5c8f 84 ASN_TIME_E = -153, /* ASN time error, unknown time type */
igrokhotkov 0:83f3dcfa5c8f 85 ASN_INPUT_E = -154, /* ASN input error, not enough data */
igrokhotkov 0:83f3dcfa5c8f 86 ASN_SIG_CONFIRM_E = -155, /* ASN sig error, confirm failure */
igrokhotkov 0:83f3dcfa5c8f 87 ASN_SIG_HASH_E = -156, /* ASN sig error, unsupported hash type */
igrokhotkov 0:83f3dcfa5c8f 88 ASN_SIG_KEY_E = -157, /* ASN sig error, unsupported key type */
igrokhotkov 0:83f3dcfa5c8f 89 ASN_DH_KEY_E = -158, /* ASN key init error, invalid input */
igrokhotkov 0:83f3dcfa5c8f 90 ASN_NTRU_KEY_E = -159, /* ASN ntru key decode error, invalid input */
igrokhotkov 0:83f3dcfa5c8f 91
igrokhotkov 0:83f3dcfa5c8f 92 ECC_BAD_ARG_E = -170, /* ECC input argument of wrong type */
igrokhotkov 0:83f3dcfa5c8f 93 ASN_ECC_KEY_E = -171, /* ASN ECC bad input */
igrokhotkov 0:83f3dcfa5c8f 94 ECC_CURVE_OID_E = -172, /* Unsupported ECC OID curve type */
igrokhotkov 0:83f3dcfa5c8f 95 BAD_FUNC_ARG = -173, /* Bad function argument provided */
igrokhotkov 0:83f3dcfa5c8f 96 NOT_COMPILED_IN = -174, /* Feature not compiled in */
igrokhotkov 0:83f3dcfa5c8f 97 UNICODE_SIZE_E = -175, /* Unicode password too big */
igrokhotkov 0:83f3dcfa5c8f 98 NO_PASSWORD = -176, /* no password provided by user */
igrokhotkov 0:83f3dcfa5c8f 99 ALT_NAME_E = -177, /* alt name size problem, too big */
igrokhotkov 0:83f3dcfa5c8f 100
igrokhotkov 0:83f3dcfa5c8f 101 AES_GCM_AUTH_E = -180, /* AES-GCM Authentication check failure */
igrokhotkov 0:83f3dcfa5c8f 102 AES_CCM_AUTH_E = -181, /* AES-CCM Authentication check failure */
igrokhotkov 0:83f3dcfa5c8f 103
igrokhotkov 0:83f3dcfa5c8f 104 CAVIUM_INIT_E = -182, /* Cavium Init type error */
igrokhotkov 0:83f3dcfa5c8f 105
igrokhotkov 0:83f3dcfa5c8f 106 MIN_CODE_E = -200 /* errors -101 - -199 */
igrokhotkov 0:83f3dcfa5c8f 107 };
igrokhotkov 0:83f3dcfa5c8f 108
igrokhotkov 0:83f3dcfa5c8f 109
igrokhotkov 0:83f3dcfa5c8f 110 CYASSL_API void CTaoCryptErrorString(int error, char* buffer);
igrokhotkov 0:83f3dcfa5c8f 111
igrokhotkov 0:83f3dcfa5c8f 112
igrokhotkov 0:83f3dcfa5c8f 113 #ifdef __cplusplus
igrokhotkov 0:83f3dcfa5c8f 114 } /* extern "C" */
igrokhotkov 0:83f3dcfa5c8f 115 #endif
igrokhotkov 0:83f3dcfa5c8f 116
igrokhotkov 0:83f3dcfa5c8f 117 #endif /* CTAO_CRYPT_ERROR_H */
igrokhotkov 0:83f3dcfa5c8f 118