1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: crypto_Sha1.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_SHA1_H_ 22 #define NN_CRYPTO_CRYPTO_SHA1_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 Sha1Context : public ShaBlock512BitContext 35 { 36 public: 37 static const size_t HASH_SIZE = (160/8); // 160 bit 38 39 private: 40 u32 m_H[5]; 41 42 protected: 43 virtual void ProcessBlock(); 44 45 public: 46 47 /* Please see man pages for details 48 49 50 51 */ Sha1Context()52 Sha1Context() {} 53 54 /* Please see man pages for details 55 56 57 58 */ ~Sha1Context()59 virtual ~Sha1Context() {}; 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(Sha1Context) == 100 102 103 /* Please see man pages for details 104 105 106 107 108 109 110 111 */ 112 void CalculateSha1(void *pOut, const void *pData, size_t length); 113 114 }} // namespace nn::crypto 115 116 #endif // __cplusplus 117 118 119 #endif /* NN_CRYPTO_CRYPTO_SHA1_H_ */ 120