1 /*---------------------------------------------------------------------------* 2 3 Copyright (C) Nintendo. All rights reserved. 4 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 11 *---------------------------------------------------------------------------*/ 12 13 #ifndef NN_ACT_TYPES_H_ 14 #define NN_ACT_TYPES_H_ 15 16 17 #include <nn/ffl/fflStandard.h> 18 #include <nn/act/act_Result.h> 19 20 21 #define ACT_INVALID_SLOT_NO (0) 22 #define ACT_SLOT_NO_CURRENT (254U) 23 #define ACT_SLOT_NO_COMMON (255U) 24 25 #define ACT_INVALID_PERSISTENT_ID (0U) 26 #define ACT_INVALID_TRANSFERBALE_ID (0ULL) 27 #define ACT_INVALID_SIMPLE_ADDRESS_ID (0U) 28 #define ACT_INVALID_PRINCIPAL_ID (0U) 29 30 #define ACT_MII_NAME_LENGTH_MAX (10) 31 #define ACT_ACCOUNT_ID_LENGTH_MIN (6) 32 #define ACT_ACCOUNT_ID_LENGTH_MAX (16) 33 #define ACT_COUNTRY_LENGTH (2) 34 #define ACT_LANGUAGE_LENGTH (2) 35 36 #define ACT_MII_NAME_SIZE (ACT_MII_NAME_LENGTH_MAX + 1) 37 #define ACT_ACCOUNT_ID_SIZE (ACT_ACCOUNT_ID_LENGTH_MAX + 1) 38 #define ACT_COUNTRY_SIZE (ACT_COUNTRY_LENGTH + 1) 39 #define ACT_LANGUAGE_SIZE (ACT_LANGUAGE_LENGTH + 1) 40 41 #define ACT_CLIENT_ID_LENGTH (32) 42 #define ACT_CLIENT_ID_SIZE (ACT_CLIENT_ID_LENGTH + 1) 43 44 #define ACT_INDEPENDENT_SERVICE_TOKEN_LENGTH (512) 45 #define ACT_INDEPENDENT_SERVICE_TOKEN_SIZE (ACT_INDEPENDENT_SERVICE_TOKEN_LENGTH + 1) 46 47 #define ACT_SLOT_NUM (12) 48 49 #define ACT_ERROR_CODE_BASE (1020000U) 50 #define ACT_ERROR_CODE_UNKNOWN (ACT_ERROR_CODE_BASE + 9999U) 51 52 #define ACT_SIMPLE_ADDRESS_COUNTRY_SHIFT (24) 53 #define ACT_SIMPLE_ADDRESS_AREA_SHIFT (16) 54 55 #define ACT_SIMPLE_ADDRESS_COUNTRY_MASK (0xFF000000U) 56 #define ACT_SIMPLE_ADDRESS_AREA_MASK (0x00FF0000U) 57 58 #define ACT_SIMPLE_ADDRESS_COUNTRY( id ) ((u8)(((u32)id & ACT_SIMPLE_ADDRESS_COUNTRY_MASK) >> ACT_SIMPLE_ADDRESS_COUNTRY_SHIFT)) 59 #define ACT_SIMPLE_ADDRESS_AREA( id ) ((u8)(((u32)id & ACT_SIMPLE_ADDRESS_AREA_MASK) >> ACT_SIMPLE_ADDRESS_AREA_SHIFT)) 60 #define ACT_SIMPLE_ADDRESS_ID( country, area ) ((((u32)country << ACT_SIMPLE_ADDRESS_COUNTRY_SHIFT) & ACT_SIMPLE_ADDRESS_COUNTRY_MASK) | (((u32)area << ACT_SIMPLE_ADDRESS_AREA_SHIFT) & ACT_SIMPLE_ADDRESS_AREA_MASK)) 61 62 #define ACT_NNAS_SERVER_TYPE_LENGTH (2) 63 #define ACT_NNAS_SERVER_TYPE_SIZE (ACT_NNAS_SERVER_TYPE_LENGTH + 1) 64 65 #define ACT_INDEPENDENT_SERVICE_TOKEN_IV_LENGTH ( (16 + 2) / 3 * 4 ) // 128-bit 66 #define ACT_INDEPENDENT_SERVICE_TOKEN_IV_SIZE (ACT_INDEPENDENT_SERVICE_TOKEN_IV_LENGTH + 1) 67 68 #define ACT_INDEPENDENT_SERVICE_TOKEN_SIGNATURE_LENGTH ( (256 + 2 ) / 3 * 4 ) // 2048-bit 69 #define ACT_INDEPENDENT_SERVICE_TOKEN_SIGNATURE_SIZE (ACT_INDEPENDENT_SERVICE_TOKEN_SIGNATURE_LENGTH + 1) 70 71 72 /*! 73 @brief Stores a Universally Unique Identifier (UUID). 74 75 A UUID is an identifier that can be used with an expectation of global uniqueness. 76 77 Currently, the UUID retrieved from the account library complies with the Version 1 specifications defined in RFC 4122, but the ID format could change to the extent that it does not impair the uniqueness of the ID. 78 Be sure to handle the ID in its entirety as a single value. Do not use any individual parts of the ID as a timestamp or device identifier. 79 80 */ 81 typedef struct ACTUuid 82 { 83 u8 data[16]; 84 85 #ifdef __cplusplus 86 /*! 87 @brief Equivalence operator for an <tt>@ref ACTUuid</tt> object. 88 89 If the UUID values are identical, the objects are determined to be equivalent. 90 91 @param[in] uuid Specifies the UUID to compare. 92 93 @return Returns <tt>true</tt> if the objects are equivalent, or <tt>false</tt> if they are non-equivalent. 94 */ 95 inline bool operator==( const ACTUuid& uuid ) const 96 { 97 return data[0] == uuid.data[0] && data[1] == uuid.data[1] && data[2] == uuid.data[2] && data[3] == uuid.data[3] && 98 data[4] == uuid.data[4] && data[5] == uuid.data[5] && data[6] == uuid.data[6] && data[7] == uuid.data[7] && 99 data[8] == uuid.data[8] && data[9] == uuid.data[9] && data[10] == uuid.data[10] && data[11] == uuid.data[11] && 100 data[12] == uuid.data[12] && data[13] == uuid.data[13] && data[14] == uuid.data[14] && data[15] == uuid.data[15]; 101 } 102 103 /*! 104 @brief Non-equivalence operator for an <tt>@ref ACTUuid</tt> object. 105 106 If the UUID values are different, the objects are determined to be non-equivalent. 107 108 @param[in] uuid Specifies the UUID to compare. 109 110 @return Returns <tt>true</tt> if the objects are non-equivalent, or <tt>false</tt> if they are equivalent. 111 */ 112 inline bool operator!=( const ACTUuid& uuid ) const 113 { 114 return !(*this == uuid); 115 } 116 #endif 117 } ACTUuid; 118 119 typedef struct ACTServiceTokenV2 120 { 121 char token[ACT_INDEPENDENT_SERVICE_TOKEN_SIZE]; 122 int : 24; 123 char iv[ACT_INDEPENDENT_SERVICE_TOKEN_IV_SIZE]; 124 int : 24; 125 char signature[ACT_INDEPENDENT_SERVICE_TOKEN_SIGNATURE_SIZE]; 126 int : 24; 127 char environment[ACT_NNAS_SERVER_TYPE_SIZE]; 128 int : 8; 129 } ACTServiceTokenV2; 130 131 #endif // NN_ACT_TYPES_H_ 132