1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-23 02:36:41 +00:00
nxdumptool/include/core/smc.h
Pablo Curiel 8f75b6b923 *FormattedStringToBuffer: relax input validation
Affects both utilsAppendFormattedStringToBuffer() and logWriteFormattedStringToBuffer(). Fixes logging issues within both the exception handler and memory debugging code.

Other changes include:

* bfttf: rename BfttfFontType_Total -> BfttfFontType_Count.
* config: rename "append_authoringtool_data" -> "generate_authoringtool_data".
* fs_ext: update FsGameCardCertificate struct
* gamecard: fix gamecardReadLotusAsicFirmwareBlob() not returning false if FS .data segment memory couldn't be retrieved; update GameCardInfo struct to reflect a recently discovered area that's not zeroed out.
* mem: expand MemoryProgramSegmentType enum; define extra macros for PID buffer size and memory page type checks; force empty memory page attribute and R/X permission checks while looking for the last FS .text segment; make memory page filtering code more readable.
* npdm: rename KernelCapability enums; rename entry_value -> bitmask in all KernelCapability descriptor structs.
* tik: force byte-for-byte memory lookup while dumping volatile tickets.
* libs: update libusbhsfs to latest commit.
* codebase: add missing comments to some enums; add missing "None" and "Count" elements to some enums. "Count" entries from enums with bitmasks will only reflect the number of available bitmask values. Enums with hex values remain unchanged.
* PoC builds: use EXIT_SUCCESS and EXIT_FAILURE as return values.
* nxdt_rw_poc: move "end" jump label within main() to avoid a crash if utilsInitializeResources() fails; reflect changes in config.c.
2023-07-17 01:03:05 +02:00

79 lines
2.5 KiB
C

/*
* smc.h
*
* Copyright (c) Atmosphère-NX.
* Copyright (c) 2020-2023, DarkMatterCore <pabloacurielz@gmail.com>.
*
* This file is part of nxdumptool (https://github.com/DarkMatterCore/nxdumptool).
*
* nxdumptool is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* nxdumptool is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#ifndef __SMC_H__
#define __SMC_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
SmcKeyType_Default = 0, ///< Also known as "aes_kek_generation_source".
SmcKeyType_NormalOnly = 1,
SmcKeyType_RecoveryOnly = 2,
SmcKeyType_NormalAndRecovery = 3,
SmcKeyType_Count = 4 ///< Total values supported by this enum.
} SmcKeyType;
typedef enum {
SmcSealKey_LoadAesKey = 0,
SmcSealKey_DecryptDeviceUniqueData = 1,
SmcSealKey_ImportLotusKey = 2,
SmcSealKey_ImportEsDeviceKey = 3,
SmcSealKey_ReencryptDeviceUniqueData = 4,
SmcSealKey_ImportSslKey = 5,
SmcSealKey_ImportEsClientCertKey = 6,
SmcSealKey_Count = 7 ///< Total values supported by this enum.
} SmcSealKey;
typedef struct {
union {
u32 value; ///< Can be used with spl calls.
struct {
u32 is_device_unique : 1;
u32 key_type_idx : 4; ///< SmcKeyType.
u32 seal_key_idx : 3; ///< SmcSealKey.
u32 reserved : 24;
} fields;
};
} SmcGenerateAesKekOption;
/// Helper inline functions.
NX_INLINE void smcPrepareGenerateAesKekOption(bool is_device_unique, u32 key_type_idx, u32 seal_key_idx, SmcGenerateAesKekOption *out)
{
if (key_type_idx >= SmcKeyType_Count || seal_key_idx >= SmcSealKey_Count) return;
out->fields.is_device_unique = (u32)(is_device_unique & 1);
out->fields.key_type_idx = key_type_idx;
out->fields.seal_key_idx = seal_key_idx;
out->fields.reserved = 0;
}
#ifdef __cplusplus
}
#endif
#endif /* __SMC_H__ */