1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: crypto_AuthenticatedEncryptor.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_AUTHENTICATEDENCRYPTOR_H_ 17 #define NN_CRYPTO_CRYPTO_AUTHENTICATEDENCRYPTOR_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 AuthenticatedEncryptor : public CipherMode 41 { 42 public: AuthenticatedEncryptor()43 AuthenticatedEncryptor(){} ~AuthenticatedEncryptor()44 virtual ~AuthenticatedEncryptor(){} 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 virtual size_t UpdatePdata(void* pDst, size_t dstSize, const void* pSrc, size_t srcSize) = 0; 131 132 /* Please see man pages for details 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 */ 156 virtual size_t UpdatePdataFinal(void* pDst, size_t size) = 0; 157 158 /* Please see man pages for details 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 */ 175 virtual void GenerateMac(void* pDst, size_t size) = 0; 176 177 protected: 178 void EncryptAndGenerate( 179 void* pMac, void* pDst, size_t dstSize, const void* pAdata, size_t adataSize, 180 const void* pPdata, size_t pdataSize, size_t macSize); 181 }; 182 183 184 185 } // namespace crypto 186 } // namespace nn 187 188 189 190 #endif /* NN_CRYPTO_CRYPTO_AUTHENTICATEDENCRYPTOR_H_ */ 191