1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     crypto_Aes.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_CRYPTO_AES_H_
17 #define NN_CRYPTO_CRYPTO_AES_H_
18 
19 #include <nn/crypto/crypto_BlockCipher.h>
20 #include <nn/crypto/detail/crypto_AesImpl.h>
21 
22 
23 namespace nn {
24 namespace crypto {
25 
26 
27 
28 /* Please see man pages for details
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 */
44 template <size_t KeySize>
45 class Aes : public BlockCipher
46 {
47 private:
48     // ARMCC 2819: class "~" has an implicitly instantiated key function "~"
49     // AesImp is inserted in order to define all virtual functions inline for the purpose of avoiding
50     typedef detail::AesImpl<KeySize> ImplT;
51 
52 public:
53     //
54     static const size_t BLOCK_SIZE = ImplT::BLOCK_SIZE;
55 
56     //
57     static const size_t KEY_SIZE   = ImplT::KEY_SIZE;
58 
59 public:
Aes()60     Aes(){}
~Aes()61     virtual ~Aes(){}
62 
63     /* Please see man pages for details
64 
65 
66 
67 
68 
69 
70 
71 
72     */
GetBlockSize()73     virtual size_t GetBlockSize() const { return BLOCK_SIZE; }
74 
75     /* Please see man pages for details
76 
77 
78 
79 
80 
81 
82 
83     */
GetKeySize()84     virtual size_t GetKeySize()   const { return KEY_SIZE;   }
85 
86     /* Please see man pages for details
87 
88 
89 
90 
91 
92 
93 
94 
95 
96 
97     */
SetKey(const void * pKey,size_t keySize)98     virtual void SetKey(const void* pKey, size_t keySize)
99     { return m_Impl.SetKey(pKey, keySize); }
100 
101 
102 
103     /* Please see man pages for details
104 
105 
106 
107 
108 
109 
110 
111 
112 
113 
114     */
Encrypt(void * pDst,const void * pSrc)115     virtual void Encrypt(void* pDst, const void* pSrc) const
116     { return m_Impl.Encrypt(pDst, pSrc); }
117 
118     /* Please see man pages for details
119 
120 
121 
122 
123 
124 
125 
126 
127 
128 
129     */
Decrypt(void * pDst,const void * pSrc)130     virtual void Decrypt(void* pDst, const void* pSrc) const
131     { return m_Impl.Decrypt(pDst, pSrc); }
132 
133 private:
134     mutable ImplT   m_Impl;
135 };
136 
137 
138 //
139 typedef Aes<16>    Aes128;
140 
141 //
142 typedef Aes<24>    Aes192;
143 
144 //
145 typedef Aes<32>    Aes256;
146 
147 
148 
149 }   // namespace crypto
150 }   // namespace nn
151 
152 
153 
154 #endif /* NN_CRYPTO_CRYPTO_AES_H_ */
155