Hannes Tschofenig
/
aes-gcm-test-program
Example program to test AES-GCM functionality. Used for a workshop
SSL/library/pbkdf2.c@0:796d0f61a05b, 2018-09-27 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
HannesTschofenig | 0:796d0f61a05b | 1 | /** |
HannesTschofenig | 0:796d0f61a05b | 2 | * \file pbkdf2.c |
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.c 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 | /* |
HannesTschofenig | 0:796d0f61a05b | 31 | * PBKDF2 is part of PKCS#5 |
HannesTschofenig | 0:796d0f61a05b | 32 | * |
HannesTschofenig | 0:796d0f61a05b | 33 | * http://tools.ietf.org/html/rfc2898 (Specification) |
HannesTschofenig | 0:796d0f61a05b | 34 | * http://tools.ietf.org/html/rfc6070 (Test vectors) |
HannesTschofenig | 0:796d0f61a05b | 35 | */ |
HannesTschofenig | 0:796d0f61a05b | 36 | |
HannesTschofenig | 0:796d0f61a05b | 37 | #if !defined(POLARSSL_CONFIG_FILE) |
HannesTschofenig | 0:796d0f61a05b | 38 | #include "polarssl/config.h" |
HannesTschofenig | 0:796d0f61a05b | 39 | #else |
HannesTschofenig | 0:796d0f61a05b | 40 | #include POLARSSL_CONFIG_FILE |
HannesTschofenig | 0:796d0f61a05b | 41 | #endif |
HannesTschofenig | 0:796d0f61a05b | 42 | |
HannesTschofenig | 0:796d0f61a05b | 43 | #if defined(POLARSSL_PBKDF2_C) |
HannesTschofenig | 0:796d0f61a05b | 44 | |
HannesTschofenig | 0:796d0f61a05b | 45 | #include "polarssl/pbkdf2.h" |
HannesTschofenig | 0:796d0f61a05b | 46 | #include "polarssl/pkcs5.h" |
HannesTschofenig | 0:796d0f61a05b | 47 | |
HannesTschofenig | 0:796d0f61a05b | 48 | int pbkdf2_hmac( md_context_t *ctx, const unsigned char *password, size_t plen, |
HannesTschofenig | 0:796d0f61a05b | 49 | const unsigned char *salt, size_t slen, |
HannesTschofenig | 0:796d0f61a05b | 50 | unsigned int iteration_count, |
HannesTschofenig | 0:796d0f61a05b | 51 | uint32_t key_length, unsigned char *output ) |
HannesTschofenig | 0:796d0f61a05b | 52 | { |
HannesTschofenig | 0:796d0f61a05b | 53 | return pkcs5_pbkdf2_hmac( ctx, password, plen, salt, slen, iteration_count, |
HannesTschofenig | 0:796d0f61a05b | 54 | key_length, output ); |
HannesTschofenig | 0:796d0f61a05b | 55 | } |
HannesTschofenig | 0:796d0f61a05b | 56 | |
HannesTschofenig | 0:796d0f61a05b | 57 | #if defined(POLARSSL_SELF_TEST) |
HannesTschofenig | 0:796d0f61a05b | 58 | int pbkdf2_self_test( int verbose ) |
HannesTschofenig | 0:796d0f61a05b | 59 | { |
HannesTschofenig | 0:796d0f61a05b | 60 | return pkcs5_self_test( verbose ); |
HannesTschofenig | 0:796d0f61a05b | 61 | } |
HannesTschofenig | 0:796d0f61a05b | 62 | #endif /* POLARSSL_SELF_TEST */ |
HannesTschofenig | 0:796d0f61a05b | 63 | |
HannesTschofenig | 0:796d0f61a05b | 64 | #endif /* POLARSSL_PBKDF2_C */ |
HannesTschofenig | 0:796d0f61a05b | 65 | |
HannesTschofenig | 0:796d0f61a05b | 66 |