1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     crypto_Sha256.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 /* Please see man pages for details
17 
18 
19 */
20 
21 #ifndef NN_CRYPTO_CRYPTO_SHA256_H_
22 #define NN_CRYPTO_CRYPTO_SHA256_H_
23 
24 #include <nn/crypto/crypto_HashContextBase.h>
25 #include <nn/crypto/crypto_ShaBlock512BitContext.h>
26 
27 #ifdef __cplusplus
28 
29 namespace nn{ namespace crypto{
30 
31 /* Please see man pages for details
32 
33 
34 
35 */
36 class Sha256Context : public ShaBlock512BitContext
37 {
38 public:
39     static const size_t HASH_SIZE  = (256/8);  // 256bit
40 
41 private:
42     u32     m_H[8];
43 
44 protected:
45     virtual void ProcessBlock();
46 
47 public:
48 
49     /* Please see man pages for details
50 
51 
52 
53     */
Sha256Context()54     Sha256Context() {}
55 
56     /* Please see man pages for details
57 
58 
59 
60     */
~Sha256Context()61     virtual ~Sha256Context() {}
62 
63     /* Please see man pages for details
64 
65 
66 
67     */
68     virtual void Initialize();
69 
70     /* Please see man pages for details
71 
72 
73 
74     */
Finalize()75     virtual void Finalize() {}
76 
77     /* Please see man pages for details
78 
79 
80 
81 
82 
83 
84     */
85     virtual void Update(const void* pData, size_t size);
86 
87     /* Please see man pages for details
88 
89 
90 
91     */
GetHashSize()92     virtual size_t GetHashSize() { return HASH_SIZE; }
GetHashLength()93     size_t GetHashLength() NN_ATTRIBUTE_DEPRECATED { return GetHashSize(); }
94 
95     /* Please see man pages for details
96 
97 
98 
99 
100 
101     */
102     virtual void GetHash(void* pOut);
103 
104     virtual void InitializeWithContext(const void *pContext, u64 size);
105 
106 };  // sizeof(Sha256Context) == 112
107 
108 /* Please see man pages for details
109 
110 
111 
112 
113 
114 
115 
116 */
117 void CalculateSha256(void *pOut, const void *pData, size_t size);
118 
119 }} // namespace nn::crypto
120 
121 #endif // __cplusplus
122 
123 
124 #endif /* NN_CRYPTO_CRYPTO_SHA256_H_ */
125