1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - AES - include
3   File:     aes_internal.h
4 
5   Copyright 2007-2008 Nintendo. 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   $Date:: 2008-09-17#$
14   $Rev: 8556 $
15   $Author: okubata_ryoma $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef	TWL_AES_COMMON_AES_INTERNAL_H_
19 #define	TWL_AES_COMMON_AES_INTERNAL_H_
20 
21 #include	<twl/aes/common/types.h>
22 
23 #ifdef	__cplusplus
24 extern "C" {
25 #endif
26 
27 /*===========================================================================*/
28 
29 #define AES_SIGN_FOR_JPEG_SIZE  28
30 
31 /*---------------------------------------------------------------------------*
32 	Function Definitions
33  *---------------------------------------------------------------------------*/
34 
35 u32 AESi_GetExpRegionBegin(void);
36 u32 AESi_GetExpRegionEnd(void);
37 
38 void AESi_Init(void);
39 
40 AESResult AESi_SetKey(const AESKey* pKey);
41 void AESi_AddToCounter(AESCounter* pCounter, u32 value);
42 void AESi_ReverseBytes(const void* src, void* dst, u32 size);
43 void AESi_SwapEndianEach128(const void* src, void* dst, u32 size);
44 
45 AESResult AESi_SeedRand(const void* pSeed);
46 AESResult AESi_RandUnit(void* dst);
47 AESResult AESi_Ctr(
48     const AESCounter*   pCounter,
49     const void*         src,
50     u32                 srcSize,
51     void*               dst,
52     AESCallback         callback,
53     void*               arg );
54 
55 AESResult AESi_CcmEncryptAndSign(
56     const AESNonce* pNonce,
57     const void*     src,
58     u32             srcASize,
59     u32             srcPSize,
60     AESMacLength    macLength,
61     void*           dst,                // Require size = srcBSize + macSize
62     AESCallback     callback,
63     void*           arg );
64 
65 AESResult AESi_CcmDecryptAndVerify(
66     const AESNonce* pNonce,
67     const void*     src,
68     u32             srcASize,
69     u32             srcCSize,
70     AESMacLength    macLength,
71     void*           dst,                // Require size = srcCSize - macSize
72     AESCallback     callback,
73     void*           arg );
74 
75 AESResult AESi_CalcMac(
76     const AESNonce* pNonce,
77     const void*     src,
78     u32             srcSize,
79     void*           mac,
80     AESCallback     callback,
81     void*           arg );
82 
83 AESResult AESi_SignForJpeg(void* sign, const void* src, u32 srcSize);
84 AESResult AESi_VerifySignForJpeg(const void* sign, const void* src, u32 srcSize);
85 BOOL      AESi_UseCustomKeyForJpeg(BOOL bEnable);
86 
87 
88 
89 /*===========================================================================*/
90 
91 #ifdef	__cplusplus
92 }          /* extern "C" */
93 #endif
94 
95 #endif /* TWL_AES_COMMON_AES_INTERNAL_H_ */
96 
97 /*---------------------------------------------------------------------------*
98   End of file
99  *---------------------------------------------------------------------------*/
100