Example program to test AES-GCM functionality. Used for a workshop

Dependencies:   mbed

Committer:
HannesTschofenig
Date:
Thu Sep 27 06:34:22 2018 +0000
Revision:
0:796d0f61a05b
Example AES-GCM test program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
HannesTschofenig 0:796d0f61a05b 1 /**
HannesTschofenig 0:796d0f61a05b 2 * \file pbkdf2.h
HannesTschofenig 0:796d0f61a05b 3 *
HannesTschofenig 0:796d0f61a05b 4 * \brief Password-Based Key Derivation Function 2 (from PKCS#5)
HannesTschofenig 0:796d0f61a05b 5 * DEPRECATED: use pkcs5.h instead.
HannesTschofenig 0:796d0f61a05b 6 *
HannesTschofenig 0:796d0f61a05b 7 * \author Mathias Olsson <mathias@kompetensum.com>
HannesTschofenig 0:796d0f61a05b 8 *
HannesTschofenig 0:796d0f61a05b 9 * Copyright (C) 2006-2012, Brainspark B.V.
HannesTschofenig 0:796d0f61a05b 10 *
HannesTschofenig 0:796d0f61a05b 11 * This file is part of PolarSSL (http://www.polarssl.org)
HannesTschofenig 0:796d0f61a05b 12 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
HannesTschofenig 0:796d0f61a05b 13 *
HannesTschofenig 0:796d0f61a05b 14 * All rights reserved.
HannesTschofenig 0:796d0f61a05b 15 *
HannesTschofenig 0:796d0f61a05b 16 * This program is free software; you can redistribute it and/or modify
HannesTschofenig 0:796d0f61a05b 17 * it under the terms of the GNU General Public License as published by
HannesTschofenig 0:796d0f61a05b 18 * the Free Software Foundation; either version 2 of the License, or
HannesTschofenig 0:796d0f61a05b 19 * (at your option) any later version.
HannesTschofenig 0:796d0f61a05b 20 *
HannesTschofenig 0:796d0f61a05b 21 * This program is distributed in the hope that it will be useful,
HannesTschofenig 0:796d0f61a05b 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
HannesTschofenig 0:796d0f61a05b 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
HannesTschofenig 0:796d0f61a05b 24 * GNU General Public License for more details.
HannesTschofenig 0:796d0f61a05b 25 *
HannesTschofenig 0:796d0f61a05b 26 * You should have received a copy of the GNU General Public License along
HannesTschofenig 0:796d0f61a05b 27 * with this program; if not, write to the Free Software Foundation, Inc.,
HannesTschofenig 0:796d0f61a05b 28 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
HannesTschofenig 0:796d0f61a05b 29 */
HannesTschofenig 0:796d0f61a05b 30 #ifndef POLARSSL_PBKDF2_H
HannesTschofenig 0:796d0f61a05b 31 #define POLARSSL_PBKDF2_H
HannesTschofenig 0:796d0f61a05b 32
HannesTschofenig 0:796d0f61a05b 33 #include <string.h>
HannesTschofenig 0:796d0f61a05b 34
HannesTschofenig 0:796d0f61a05b 35 #include "md.h"
HannesTschofenig 0:796d0f61a05b 36
HannesTschofenig 0:796d0f61a05b 37 #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
HannesTschofenig 0:796d0f61a05b 38 #include <basetsd.h>
HannesTschofenig 0:796d0f61a05b 39 typedef UINT32 uint32_t;
HannesTschofenig 0:796d0f61a05b 40 #else
HannesTschofenig 0:796d0f61a05b 41 #include <inttypes.h>
HannesTschofenig 0:796d0f61a05b 42 #endif
HannesTschofenig 0:796d0f61a05b 43
HannesTschofenig 0:796d0f61a05b 44 #define POLARSSL_ERR_PBKDF2_BAD_INPUT_DATA -0x007C /**< Bad input parameters to function. */
HannesTschofenig 0:796d0f61a05b 45
HannesTschofenig 0:796d0f61a05b 46 #ifdef __cplusplus
HannesTschofenig 0:796d0f61a05b 47 extern "C" {
HannesTschofenig 0:796d0f61a05b 48 #endif
HannesTschofenig 0:796d0f61a05b 49
HannesTschofenig 0:796d0f61a05b 50 /**
HannesTschofenig 0:796d0f61a05b 51 * \brief PKCS#5 PBKDF2 using HMAC
HannesTschofenig 0:796d0f61a05b 52 * DEPRECATED: Use pkcs5_pbkdf2_hmac() instead!
HannesTschofenig 0:796d0f61a05b 53 *
HannesTschofenig 0:796d0f61a05b 54 * \param ctx Generic HMAC context
HannesTschofenig 0:796d0f61a05b 55 * \param password Password to use when generating key
HannesTschofenig 0:796d0f61a05b 56 * \param plen Length of password
HannesTschofenig 0:796d0f61a05b 57 * \param salt Salt to use when generating key
HannesTschofenig 0:796d0f61a05b 58 * \param slen Length of salt
HannesTschofenig 0:796d0f61a05b 59 * \param iteration_count Iteration count
HannesTschofenig 0:796d0f61a05b 60 * \param key_length Length of generated key
HannesTschofenig 0:796d0f61a05b 61 * \param output Generated key. Must be at least as big as key_length
HannesTschofenig 0:796d0f61a05b 62 *
HannesTschofenig 0:796d0f61a05b 63 * \returns 0 on success, or a PolarSSL error code if verification fails.
HannesTschofenig 0:796d0f61a05b 64 */
HannesTschofenig 0:796d0f61a05b 65 int pbkdf2_hmac( md_context_t *ctx, const unsigned char *password,
HannesTschofenig 0:796d0f61a05b 66 size_t plen, const unsigned char *salt, size_t slen,
HannesTschofenig 0:796d0f61a05b 67 unsigned int iteration_count,
HannesTschofenig 0:796d0f61a05b 68 uint32_t key_length, unsigned char *output );
HannesTschofenig 0:796d0f61a05b 69
HannesTschofenig 0:796d0f61a05b 70 /**
HannesTschofenig 0:796d0f61a05b 71 * \brief Checkup routine
HannesTschofenig 0:796d0f61a05b 72 * DEPRECATED: Use pkcs5_self_test() instead!
HannesTschofenig 0:796d0f61a05b 73 *
HannesTschofenig 0:796d0f61a05b 74 * \return 0 if successful, or 1 if the test failed
HannesTschofenig 0:796d0f61a05b 75 */
HannesTschofenig 0:796d0f61a05b 76 int pbkdf2_self_test( int verbose );
HannesTschofenig 0:796d0f61a05b 77
HannesTschofenig 0:796d0f61a05b 78 #ifdef __cplusplus
HannesTschofenig 0:796d0f61a05b 79 }
HannesTschofenig 0:796d0f61a05b 80 #endif
HannesTschofenig 0:796d0f61a05b 81
HannesTschofenig 0:796d0f61a05b 82 #endif /* pbkdf2.h */
HannesTschofenig 0:796d0f61a05b 83
HannesTschofenig 0:796d0f61a05b 84