1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     crypto_AuthenticatedDecryptor.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_AUTHENTICATEDDECRYPTOR_H_
17 #define NN_CRYPTO_CRYPTO_AUTHENTICATEDDECRYPTOR_H_
18 
19 #include <nn/crypto/crypto_BlockCipher.h>
20 #include <nn/crypto/crypto_CipherMode.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 class AuthenticatedDecryptor : public CipherMode
41 {
42 public:
AuthenticatedDecryptor()43     AuthenticatedDecryptor(){}
~AuthenticatedDecryptor()44     virtual ~AuthenticatedDecryptor(){}
45 
46 
47 
48     /* Please see man pages for details
49 
50 
51 
52 
53 
54     */
55     virtual size_t  GetMacSize() const = 0;
56 
57 
58 
59     /* Please see man pages for details
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72     */
73     virtual void    UpdateAdata(const void* pSrc, size_t size) = 0;
74 
75     /* Please see man pages for details
76 
77 
78 
79 
80 
81 
82 
83     */
84     virtual void    UpdateAdataFinal() = 0;
85 
86     /* Please see man pages for details
87 
88 
89 
90 
91 
92 
93 
94 
95 
96 
97 
98 
99 
100 
101 
102 
103 
104 
105 
106 
107 
108 
109 
110 
111 
112 
113 
114 
115 
116 
117 
118 
119 
120 
121 
122 
123 
124 
125 
126 
127 
128 
129 
130     */
131     virtual size_t  UpdateCdata(void* pDst, size_t dstSize, const void* pSrc, size_t srcSize) = 0;
132 
133     /* Please see man pages for details
134 
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
145 
146 
147 
148 
149 
150 
151 
152 
153 
154 
155 
156 
157     */
158     virtual size_t  UpdateCdataFinal(void* pDst, size_t size) = 0;
159 
160     /* Please see man pages for details
161 
162 
163 
164 
165 
166 
167 
168 
169 
170 
171 
172 
173 
174 
175 
176     */
177     virtual void    GenerateMac(void* pDst, size_t size) = 0;
178 
179 protected:
180     bool DecryptAndVerify(
181             void* pDst, size_t dstSize, const void* pAdata, size_t adataSize,
182             const void* pCdata, size_t cdataSize, const void* pMac, size_t macSize);
183 };
184 
185 
186 
187 }   // namespace crypto
188 }   // namespace nn
189 
190 
191 
192 #endif /* NN_CRYPTO_CRYPTO_AUTHENTICATEDDECRYPTOR_H_ */
193