Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MiniTLS-GPL by
crypto/crypto_aes_128.h@4:cbaf466d717d, 2014-06-10 (annotated)
- Committer:
- MiniTLS
- Date:
- Tue Jun 10 14:23:09 2014 +0000
- Revision:
- 4:cbaf466d717d
- Parent:
- 2:527a66d0a1a9
Fixes for mbed
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| MiniTLS | 2:527a66d0a1a9 | 1 | /* |
| MiniTLS | 2:527a66d0a1a9 | 2 | MiniTLS - A super trimmed down TLS/SSL Library for embedded devices |
| MiniTLS | 2:527a66d0a1a9 | 3 | Author: Donatien Garnier |
| MiniTLS | 2:527a66d0a1a9 | 4 | Copyright (C) 2013-2014 AppNearMe Ltd |
| MiniTLS | 2:527a66d0a1a9 | 5 | |
| MiniTLS | 2:527a66d0a1a9 | 6 | This program is free software; you can redistribute it and/or |
| MiniTLS | 2:527a66d0a1a9 | 7 | modify it under the terms of the GNU General Public License |
| MiniTLS | 2:527a66d0a1a9 | 8 | as published by the Free Software Foundation; either version 2 |
| MiniTLS | 2:527a66d0a1a9 | 9 | of the License, or (at your option) any later version. |
| MiniTLS | 2:527a66d0a1a9 | 10 | |
| MiniTLS | 2:527a66d0a1a9 | 11 | This program is distributed in the hope that it will be useful, |
| MiniTLS | 2:527a66d0a1a9 | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MiniTLS | 2:527a66d0a1a9 | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| MiniTLS | 2:527a66d0a1a9 | 14 | GNU General Public License for more details. |
| MiniTLS | 2:527a66d0a1a9 | 15 | |
| MiniTLS | 2:527a66d0a1a9 | 16 | You should have received a copy of the GNU General Public License |
| MiniTLS | 2:527a66d0a1a9 | 17 | along with this program; if not, write to the Free Software |
| MiniTLS | 2:527a66d0a1a9 | 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| MiniTLS | 2:527a66d0a1a9 | 19 | *//** |
| MiniTLS | 2:527a66d0a1a9 | 20 | * \file crypto_aes_128.h |
| MiniTLS | 2:527a66d0a1a9 | 21 | * \copyright Copyright (c) AppNearMe Ltd 2013 |
| MiniTLS | 2:527a66d0a1a9 | 22 | * \author Donatien Garnier |
| MiniTLS | 2:527a66d0a1a9 | 23 | */ |
| MiniTLS | 2:527a66d0a1a9 | 24 | |
| MiniTLS | 2:527a66d0a1a9 | 25 | #ifndef CRYPTO_AES_128_H_ |
| MiniTLS | 2:527a66d0a1a9 | 26 | #define CRYPTO_AES_128_H_ |
| MiniTLS | 2:527a66d0a1a9 | 27 | |
| MiniTLS | 2:527a66d0a1a9 | 28 | #ifdef __cplusplus |
| MiniTLS | 2:527a66d0a1a9 | 29 | extern "C" { |
| MiniTLS | 2:527a66d0a1a9 | 30 | #endif |
| MiniTLS | 2:527a66d0a1a9 | 31 | |
| MiniTLS | 2:527a66d0a1a9 | 32 | #include "inc/minitls_errors.h" |
| MiniTLS | 2:527a66d0a1a9 | 33 | |
| MiniTLS | 2:527a66d0a1a9 | 34 | #define AES_128_KEY_SIZE 16 //128 bits |
| MiniTLS | 2:527a66d0a1a9 | 35 | #define AES_128_BLOCK_SIZE AES_128_KEY_SIZE |
| MiniTLS | 2:527a66d0a1a9 | 36 | |
| MiniTLS | 2:527a66d0a1a9 | 37 | //This cipher is based on the Rijndael cipher and the rijndael.c reference implementation |
| MiniTLS | 2:527a66d0a1a9 | 38 | |
| MiniTLS | 2:527a66d0a1a9 | 39 | #define AES_128_EXPANDED_KEY_SIZE (28 + AES_128_KEY_SIZE) |
| MiniTLS | 2:527a66d0a1a9 | 40 | |
| MiniTLS | 2:527a66d0a1a9 | 41 | typedef enum __crypto_aes_128_key_expansion_type |
| MiniTLS | 2:527a66d0a1a9 | 42 | { |
| MiniTLS | 2:527a66d0a1a9 | 43 | expand_encryption_key, |
| MiniTLS | 2:527a66d0a1a9 | 44 | expand_decryption_key, |
| MiniTLS | 2:527a66d0a1a9 | 45 | } crypto_aes_128_key_expansion_type_t; |
| MiniTLS | 2:527a66d0a1a9 | 46 | |
| MiniTLS | 2:527a66d0a1a9 | 47 | //One-way implementation only |
| MiniTLS | 2:527a66d0a1a9 | 48 | typedef struct __crypto_aes_128 |
| MiniTLS | 2:527a66d0a1a9 | 49 | { |
| MiniTLS | 2:527a66d0a1a9 | 50 | uint32_t expanded_key[AES_128_EXPANDED_KEY_SIZE]; |
| MiniTLS | 2:527a66d0a1a9 | 51 | } crypto_aes_128_t; |
| MiniTLS | 2:527a66d0a1a9 | 52 | |
| MiniTLS | 2:527a66d0a1a9 | 53 | //Asymmetric impl: To diminish key sizes, only the AES encipher OR decipher operation can be executed - on the other side, only the reverse operation is executed |
| MiniTLS | 2:527a66d0a1a9 | 54 | void crypto_aes_128_init(crypto_aes_128_t* aes_128, const uint8_t* key, crypto_aes_128_key_expansion_type_t expansion_type); |
| MiniTLS | 2:527a66d0a1a9 | 55 | |
| MiniTLS | 2:527a66d0a1a9 | 56 | void crypto_aes_128_encrypt(crypto_aes_128_t* aes_128, const uint8_t* plaintext, uint8_t* ciphertext); |
| MiniTLS | 2:527a66d0a1a9 | 57 | void crypto_aes_128_decrypt(crypto_aes_128_t* aes_128, const uint8_t* ciphertext, uint8_t* plaintext); |
| MiniTLS | 2:527a66d0a1a9 | 58 | |
| MiniTLS | 2:527a66d0a1a9 | 59 | #ifdef __cplusplus |
| MiniTLS | 2:527a66d0a1a9 | 60 | } |
| MiniTLS | 2:527a66d0a1a9 | 61 | #endif |
| MiniTLS | 2:527a66d0a1a9 | 62 | |
| MiniTLS | 2:527a66d0a1a9 | 63 | #endif /* CRYPTO_AES_128_H_ */ |
