1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     crypto_Sha256.h
4   Copyright (C)2009 Nintendo Co., Ltd.  All rights reserved.
5   These coded instructions, statements, and computer programs contain
6   proprietary information of Nintendo of America Inc. and/or Nintendo
7   Company Ltd., and are protected by Federal copyright law. They may
8   not be disclosed to third parties or copied or duplicated in any form,
9   in whole or in part, without the prior written consent of Nintendo.
10   $Rev: 35449 $
11  *---------------------------------------------------------------------------
12 
13 
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 class Sha256Context : public ShaBlock512BitContext
35 {
36 public:
37     static const size_t HASH_SIZE  = (256/8);  // 256 bit
38 
39 private:
40     u32     m_H[8];
41 
42 protected:
43     virtual void ProcessBlock();
44 
45 public:
46 
47     /* Please see man pages for details
48 
49 
50 
51     */
Sha256Context()52     Sha256Context() {}
53 
54     /* Please see man pages for details
55 
56 
57 
58     */
~Sha256Context()59     virtual ~Sha256Context() {}
60 
61     /* Please see man pages for details
62 
63 
64 
65     */
66     virtual void Initialize();
67 
68     /* Please see man pages for details
69 
70 
71 
72     */
Finalize()73     virtual void Finalize() {}
74 
75     /* Please see man pages for details
76 
77 
78 
79 
80 
81 
82     */
83     virtual void Update(const void* pData, size_t length);
84 
85     /* Please see man pages for details
86 
87 
88 
89     */
GetHashLength()90     virtual size_t GetHashLength() { return HASH_SIZE; }
91 
92     /* Please see man pages for details
93 
94 
95 
96 
97 
98     */
99     virtual void GetHash(void* pOut);
100 
101 };  // sizeof(Sha256Context) == 112
102 
103 /* Please see man pages for details
104 
105 
106 
107 
108 
109 
110 
111 */
112 void CalculateSha256(void *pOut, const void *pData, size_t length);
113 
114 }} // namespace nn::crypto
115 
116 #endif // __cplusplus
117 
118 
119 #endif /* NN_CRYPTO_CRYPTO_SHA256_H_ */
120