1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: crypto_RsaKey.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 #ifndef NN_CRYPTO_CRYPTO_RSAKEY_H_ 17 #define NN_CRYPTO_CRYPTO_RSAKEY_H_ 18 19 #include <nn/os.h> 20 #include <nn/types.h> 21 #include <nn/config.h> 22 #include <nn/Result.h> 23 24 #ifdef __cplusplus 25 26 namespace nn{ namespace crypto{ 27 28 /* Please see man pages for details 29 30 31 32 33 34 35 */ 36 class RsaKey 37 { 38 public: 39 RsaKey(); ~RsaKey()40 ~RsaKey(){}; 41 42 static const int MAX_KEY_LENGTH = 2048; 43 static const int MAX_KEY_BYTES = MAX_KEY_LENGTH / 8; 44 45 /* Please see man pages for details 46 47 48 49 50 51 52 53 54 55 */ 56 nn::Result InitializeKey( const void* pModulus, const void* pExp, s32 keyLength, bool isPrivate ); 57 58 /* Please see man pages for details 59 60 61 62 63 64 65 66 67 */ 68 nn::Result InitializePrivateKey( const void* pKey, s32 keyLength ); 69 70 /* Please see man pages for details 71 72 73 74 75 76 77 78 79 80 */ 81 nn::Result InitializePublicKey( const void* pKey, s32 keyLength ); 82 83 /* Please see man pages for details 84 85 86 87 88 */ 89 void Finalize(); 90 91 /* Please see man pages for details 92 93 94 95 */ GetKeyLength()96 s32 GetKeyLength() const { return m_KeyLength; } GetKeySize()97 s32 GetKeySize() const NN_ATTRIBUTE_DEPRECATED { return GetKeyLength(); } 98 99 /* Please see man pages for details 100 101 102 103 */ IsPrivate()104 bool IsPrivate() const { return m_IsPrivateKey; } 105 106 /* Please see man pages for details 107 108 109 110 */ GetModulus()111 const void* GetModulus() const { return m_Modulus; } 112 113 /* Please see man pages for details 114 115 116 117 */ GetExp()118 const void* GetExp() const { return m_Exp; } 119 120 private : 121 u8 m_Modulus[ MAX_KEY_BYTES ]; 122 u8 m_Exp[ MAX_KEY_BYTES ]; 123 s32 m_KeyLength; 124 bool m_IsPrivateKey; 125 NN_PADDING3; 126 }; 127 128 }} // namespace nn::crypto 129 130 #endif // __cplusplus 131 132 #endif /* NN_CRYPTO_CRYPTO_RSAKEY_H_ */ 133