1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: crypto_Sha1.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_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 35 */ 36 class Sha1Context : public ShaBlock512BitContext 37 { 38 public: 39 static const size_t HASH_SIZE = (160/8); // 160bit 40 41 private: 42 u32 m_H[5]; 43 44 protected: 45 virtual void ProcessBlock(); 46 47 public: 48 49 /* Please see man pages for details 50 51 52 53 */ Sha1Context()54 Sha1Context() {} 55 56 /* Please see man pages for details 57 58 59 60 */ ~Sha1Context()61 virtual ~Sha1Context() {}; 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 */ 75 virtual void InitializeWithContext(const void *pContext, u64 size); 76 77 /* Please see man pages for details 78 79 80 81 */ Finalize()82 virtual void Finalize() {} 83 84 /* Please see man pages for details 85 86 87 88 89 90 91 */ 92 virtual void Update(const void* pData, size_t size); 93 94 /* Please see man pages for details 95 96 97 98 */ GetHashSize()99 virtual size_t GetHashSize() { return HASH_SIZE; } GetHashLength()100 size_t GetHashLength() NN_ATTRIBUTE_DEPRECATED { return GetHashSize(); } 101 102 /* Please see man pages for details 103 104 105 106 107 108 */ 109 virtual void GetHash(void* pOut); 110 111 }; // sizeof(Sha1Context) == 100 112 113 /* Please see man pages for details 114 115 116 117 118 119 120 121 */ 122 void CalculateSha1(void *pOut, const void *pData, size_t size); 123 124 }} // namespace nn::crypto 125 126 #endif // __cplusplus 127 128 129 #endif /* NN_CRYPTO_CRYPTO_SHA1_H_ */ 130