ARM Shanghai IoT Team (Internal) / newMiniTLS-GPL

Fork of MiniTLS-GPL by Donatien Garnier

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers crypto_aes_128.h Source File

crypto_aes_128.h

Go to the documentation of this file.
00001 /*
00002 MiniTLS - A super trimmed down TLS/SSL Library for embedded devices
00003 Author: Donatien Garnier
00004 Copyright (C) 2013-2014 AppNearMe Ltd
00005 
00006 This program is free software; you can redistribute it and/or
00007 modify it under the terms of the GNU General Public License
00008 as published by the Free Software Foundation; either version 2
00009 of the License, or (at your option) any later version.
00010 
00011 This program is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU General Public License for more details.
00015 
00016 You should have received a copy of the GNU General Public License
00017 along with this program; if not, write to the Free Software
00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00019 *//**
00020  * \file crypto_aes_128.h
00021  * \copyright Copyright (c) AppNearMe Ltd 2013
00022  * \author Donatien Garnier
00023  */
00024 
00025 #ifndef CRYPTO_AES_128_H_
00026 #define CRYPTO_AES_128_H_
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 #include "inc/minitls_errors.h"
00033 
00034 #define AES_128_KEY_SIZE 16 //128 bits
00035 #define AES_128_BLOCK_SIZE AES_128_KEY_SIZE
00036 
00037 //This cipher is based on the Rijndael cipher and the rijndael.c reference implementation
00038 
00039 #define AES_128_EXPANDED_KEY_SIZE (28 + AES_128_KEY_SIZE)
00040 
00041 typedef enum __crypto_aes_128_key_expansion_type
00042 {
00043   expand_encryption_key,
00044   expand_decryption_key,
00045 } crypto_aes_128_key_expansion_type_t;
00046 
00047 //One-way implementation only
00048 typedef struct __crypto_aes_128
00049 {
00050   uint32_t expanded_key[AES_128_EXPANDED_KEY_SIZE];
00051 } crypto_aes_128_t;
00052 
00053 //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
00054 void crypto_aes_128_init(crypto_aes_128_t* aes_128, const uint8_t* key, crypto_aes_128_key_expansion_type_t expansion_type);
00055 
00056 void crypto_aes_128_encrypt(crypto_aes_128_t* aes_128, const uint8_t* plaintext, uint8_t* ciphertext);
00057 void crypto_aes_128_decrypt(crypto_aes_128_t* aes_128, const uint8_t* ciphertext, uint8_t* plaintext);
00058 
00059 #ifdef __cplusplus
00060 }
00061 #endif
00062 
00063 #endif /* CRYPTO_AES_128_H_ */