1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: crypto_AesImpl.h 4 5 Copyright (C)2009-2012 Nintendo Co., Ltd. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Rev: 46347 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NN_CRYPTO_DETAIL_CRYPTO_AESIMPL_H_ 17 #define NN_CRYPTO_DETAIL_CRYPTO_AESIMPL_H_ 18 19 #include <nn/config.h> 20 #include <nn/types.h> 21 22 namespace nn { 23 namespace crypto { 24 namespace detail { 25 26 27 28 template <size_t KeySize> 29 class AesImpl 30 { 31 public: 32 static const size_t BLOCK_SIZE = 16; 33 static const size_t KEY_SIZE = KeySize; 34 35 private: 36 static const int NUM_ROUND = (KEY_SIZE / 4) + 6; 37 38 public: 39 void SetKey(const void* pKey, size_t keySize); 40 void Encrypt(void* pDst, const void* pSrc); 41 void Decrypt(void* pDst, const void* pSrc); 42 43 private: 44 bit32 m_Key[ BLOCK_SIZE * (NUM_ROUND + 1) / sizeof(bit32) ]; 45 bool m_IsEncryptKey; 46 NN_PADDING3; 47 }; 48 49 50 51 } // namespace detail 52 } // namespace crypto 53 } // namespace nn 54 55 56 57 #endif /* NN_CRYPTO_DETAIL_CRYPTO_AESIMPL_H_ */ 58