CTR Pia  4.11.3
Game Communication Engine
common_SignatureSetting.h
1 /*---------------------------------------------------------------------------*
2  Project: Pia
3  File: common_SignatureSetting.h
4 
5  Copyright Nintendo. 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 
14 
15 #pragma once
16 
17 #include <pia/common/common_definitions.h>
18 
19 
20 namespace nn
21 {
22 namespace pia
23 {
24 namespace common
25 {
26 
27 
28 /*!
29 @brief This class maintains signature setting information.
30 
31 @date 2012-11-30 Initial version.
32 */
34 {
35 public:
36  static const u32 SIGNATURE_KEY_DATA_SIZE_MAX = 32; //!< Maximum number of bytes for the key data used for the signature.
37 
38 /*!
39 @brief Indicates the type of signature algorithm.
40 */
41  enum Mode
42  {
43  MODE_NOTHING = 0, //!< No signature.
44  MODE_HMAC_MD5 //!< HMAC-MD5 signature.
45  };
46 
47 
48 /*!
49 @brief Instantiates an object. Initializes the object instance using the signature algorithm and key data specified.
50 
51 @param[in] mode Specifies the type of signature algorithm.
52 @param[in] cpKeyData Specifies the address of the signature data. Data being referenced must be maintained until this instance is destroyed or reinitialized.
53 @param[in] keySize Specifies the size of the key data, in bytes.
54 */
55  SignatureSetting(Mode mode, const void* cpKeyData, size_t keySize);
56 
57 
58 /*!
59 @brief Instantiates an object. Initializes the object using the predefined algorithm (HMAC-MD5) and the specified key data.
60 
61 @param[in] cpKeyData Specifies the address of the signature data. Data being referenced must be maintained until this instance is destroyed or reinitialized.
62 @param[in] keySize Specifies the size of the key data, in bytes.
63 */
64  SignatureSetting(const void* cpKeyData, size_t keySize);
65 
66 
67 /*!
68 @brief Instantiates an object. Initializes the instance without a signature.
69 */
71  : m_Mode(MODE_NOTHING), m_cpKeyData(NULL), m_KeySize(0)
72  {
73  }
74 
75 
76 /*!
77 @brief Sets signature settings.
78 
79 @param[in] mode Specifies the type of signature algorithm.
80 @param[in] cpKeyData Specifies the address of the signature data. Data being referenced must be maintained until this instance is destroyed or reinitialized.
81 @param[in] keySize Specifies the size of the key data, in bytes.
82 
83 @return Returns a <tt>Result</tt> that indicates success if configured correctly.
84 @retval ResultInvalidArgument Indicates an invalid argument. Programming error. Fix your program so that this error is not returned.
85 */
86  nn::Result Set(Mode mode, const void* cpKeyData, size_t keySize);
87 
88 
89 /*!
90 @brief Gets the signature algorithm that is currently specified.
91 @return Returns the signature algorithm that is currently specified.
92 */
93  Mode GetMode() const
94  {
95  return m_Mode;
96  }
97 
98 
99 /*!
100 @brief Gets the address of the key data that is currently specified.
101 @return Returns the address of the key data that is currently specified.
102 */
103  const void* GetKeyData() const
104  {
105  return m_cpKeyData;
106  }
107 
108 
109 /*!
110 @brief Gets the size of the key data that is currently specified.
111 @return Returns the address of the key data that is currently specified.
112 */
113  size_t GetKeySize() const
114  {
115  return m_KeySize;
116  }
117 
118  virtual void Trace(u64 flag) const;
119 
120 /*!
121 @brief Specifies an instance of the signature setting class that has no signature.
122 */
124 
125 private:
126  Mode m_Mode;
127  const void* m_cpKeyData;
128  size_t m_KeySize;
129 };
130 }
131 }
132 } // end of namespace nn::pia::common
Mode GetMode() const
Gets the signature algorithm that is currently specified.
Definition: common_SignatureSetting.h:93
This class maintains signature setting information.
Definition: common_SignatureSetting.h:33
Definition: assert.h:115
This class is the trace class.
Definition: common_Trace.h:212
size_t GetKeySize() const
Gets the size of the key data that is currently specified.
Definition: common_SignatureSetting.h:113
const void * GetKeyData() const
Gets the address of the key data that is currently specified.
Definition: common_SignatureSetting.h:103
static const u32 SIGNATURE_KEY_DATA_SIZE_MAX
Maximum number of bytes for the key data used for the signature.
Definition: common_SignatureSetting.h:36
No signature.
Definition: common_SignatureSetting.h:43
Mode
Indicates the type of signature algorithm.
Definition: common_SignatureSetting.h:41
nn::Result Set(Mode mode, const void *cpKeyData, size_t keySize)
Sets signature settings.
HMAC-MD5 signature.
Definition: common_SignatureSetting.h:44
static const SignatureSetting NO_SIGNATURE
Specifies an instance of the signature setting class that has no signature.
Definition: common_SignatureSetting.h:123
SignatureSetting()
Instantiates an object. Initializes the instance without a signature.
Definition: common_SignatureSetting.h:70