id
int64
0
755k
file_name
stringlengths
3
109
file_path
stringlengths
13
185
content
stringlengths
31
9.38M
size
int64
31
9.38M
language
stringclasses
1 value
extension
stringclasses
11 values
total_lines
int64
1
340k
avg_line_length
float64
2.18
149k
max_line_length
int64
7
2.22M
alphanum_fraction
float64
0
1
repo_name
stringlengths
6
65
repo_stars
int64
100
47.3k
repo_forks
int64
0
12k
repo_open_issues
int64
0
3.4k
repo_license
stringclasses
9 values
repo_extraction_date
stringclasses
92 values
exact_duplicates_redpajama
bool
2 classes
near_duplicates_redpajama
bool
2 classes
exact_duplicates_githubcode
bool
2 classes
exact_duplicates_stackv2
bool
1 class
exact_duplicates_stackv1
bool
2 classes
near_duplicates_githubcode
bool
2 classes
near_duplicates_stackv1
bool
2 classes
near_duplicates_stackv2
bool
1 class
8,971
htcfs_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/htcfs_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::htcfs, 31); namespace ams::htcfs { R_DEFINE_ERROR_RESULT(InvalidArgument, 3); R_DEFINE_ERROR_RANGE(ConnectionFailure, 100, 199); R_DEFINE_ERROR_RESULT(HtclowChannelClosed, 101); R_DEFINE_ERROR_RANGE(UnexpectedResponse, 110, 119); R_DEFINE_ERROR_RESULT(UnexpectedResponseProtocolId, 111); R_DEFINE_ERROR_RESULT(UnexpectedResponseProtocolVersion, 112); R_DEFINE_ERROR_RESULT(UnexpectedResponsePacketCategory, 113); R_DEFINE_ERROR_RESULT(UnexpectedResponsePacketType, 114); R_DEFINE_ERROR_RESULT(UnexpectedResponseBodySize, 115); R_DEFINE_ERROR_RESULT(UnexpectedResponseBody, 116); R_DEFINE_ERROR_RANGE(InternalError, 200, 299); R_DEFINE_ERROR_RESULT(InvalidSize, 201); R_DEFINE_ERROR_RESULT(UnknownError, 211); R_DEFINE_ERROR_RESULT(UnsupportedProtocolVersion, 212); R_DEFINE_ERROR_RESULT(InvalidRequest, 213); R_DEFINE_ERROR_RESULT(InvalidHandle, 214); R_DEFINE_ERROR_RESULT(OutOfHandle, 215); }
1,883
C++
.h
37
45.297297
76
0.690968
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,972
dmnt_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/dmnt_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::dmnt, 13); namespace ams::dmnt { R_DEFINE_ERROR_RESULT(Unknown, 1); R_DEFINE_ERROR_RESULT(DebuggingDisabled, 2); /* Atmosphere extension. */ // namespace cheat { R_DEFINE_ABSTRACT_ERROR_RANGE_NS(cheat, CheatError, 6500, 6599); R_DEFINE_ERROR_RESULT_NS(cheat, CheatNotAttached, 6500); R_DEFINE_ERROR_RESULT_NS(cheat, CheatNullBuffer, 6501); R_DEFINE_ERROR_RESULT_NS(cheat, CheatInvalidBuffer, 6502); R_DEFINE_ERROR_RESULT_NS(cheat, CheatUnknownId, 6503); R_DEFINE_ERROR_RESULT_NS(cheat, CheatOutOfResource, 6504); R_DEFINE_ERROR_RESULT_NS(cheat, CheatInvalid, 6505); R_DEFINE_ERROR_RESULT_NS(cheat, CheatCannotDisable, 6506); R_DEFINE_ABSTRACT_ERROR_RANGE_NS(cheat, FrozenAddressError, 6600, 6699); R_DEFINE_ERROR_RESULT_NS(cheat, FrozenAddressInvalidWidth, 6600); R_DEFINE_ERROR_RESULT_NS(cheat, FrozenAddressAlreadyExists, 6601); R_DEFINE_ERROR_RESULT_NS(cheat, FrozenAddressNotFound, 6602); R_DEFINE_ERROR_RESULT_NS(cheat, FrozenAddressOutOfResource, 6603); R_DEFINE_ABSTRACT_ERROR_RANGE_NS(cheat, VirtualMachineError, 6700, 6799); R_DEFINE_ERROR_RESULT_NS(cheat, VirtualMachineInvalidConditionDepth, 6700); // } }
2,092
C++
.h
40
46
87
0.696866
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,973
htc_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/htc_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::htc, 18); namespace ams::htc { R_DEFINE_ERROR_RESULT(ConnectionFailure, 1); R_DEFINE_ERROR_RESULT(NotFound, 2); R_DEFINE_ERROR_RESULT(NotEnoughBuffer, 3); R_DEFINE_ERROR_RESULT(Cancelled, 101); R_DEFINE_ERROR_RESULT(Unknown, 1023); R_DEFINE_ERROR_RESULT(Unknown2001, 2001); R_DEFINE_ERROR_RESULT(InvalidTaskId, 2003); R_DEFINE_ERROR_RESULT(InvalidSize, 2011); R_DEFINE_ERROR_RESULT(TaskCancelled, 2021); R_DEFINE_ERROR_RESULT(TaskNotCompleted, 2022); R_DEFINE_ERROR_RESULT(TaskQueueNotAvailable, 2033); R_DEFINE_ERROR_RESULT(Unknown2101, 2101); R_DEFINE_ERROR_RESULT(OutOfRpcTask, 2102); R_DEFINE_ERROR_RESULT(InvalidCategory, 2123); }
1,509
C++
.h
34
41.088235
76
0.711656
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,974
pm_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/pm_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::pm, 15); namespace ams::pm { R_DEFINE_ERROR_RESULT(ProcessNotFound, 1); R_DEFINE_ERROR_RESULT(AlreadyStarted, 2); R_DEFINE_ERROR_RESULT(NotTerminated, 3); R_DEFINE_ERROR_RESULT(DebugHookInUse, 4); R_DEFINE_ERROR_RESULT(ApplicationRunning, 5); R_DEFINE_ERROR_RESULT(InvalidSize, 6); R_DEFINE_ERROR_RESULT(Unknown7, 7); }
1,118
C++
.h
27
38.666667
76
0.728361
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,975
err_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/err_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::err, 162); namespace ams::err { R_DEFINE_ERROR_RESULT(ApplicationAbort, 1); R_DEFINE_ERROR_RESULT(SystemProgramAbort, 2); R_DEFINE_ERROR_RESULT(ForcedShutdownDetected, 4); }
934
C++
.h
23
38.217391
76
0.752486
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,976
fatal_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/fatal_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::fatal, 163); namespace ams::fatal { R_DEFINE_ERROR_RESULT(AllocationFailed, 1); R_DEFINE_ERROR_RESULT(NullGraphicsBuffer, 2); R_DEFINE_ERROR_RESULT(AlreadyThrown, 3); R_DEFINE_ERROR_RESULT(TooManyEvents, 4); R_DEFINE_ERROR_RESULT(InRepairWithoutVolHeld, 5); R_DEFINE_ERROR_RESULT(InRepairWithoutTimeReviserCartridge, 6); }
1,177
C++
.h
26
42.615385
76
0.700698
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,977
ns_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/ns_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::ns, 16); namespace ams::ns { R_DEFINE_ERROR_RESULT(Canceled, 90); R_DEFINE_ERROR_RESULT(OutOfMaxRunningTask, 110); R_DEFINE_ERROR_RESULT(CardUpdateNotSetup, 270); R_DEFINE_ERROR_RESULT(CardUpdateNotPrepared, 280); R_DEFINE_ERROR_RESULT(CardUpdateAlreadySetup, 290); R_DEFINE_ERROR_RESULT(PrepareCardUpdateAlreadyRequested, 460); }
1,170
C++
.h
26
42.346154
76
0.712028
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,978
powctl_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/powctl_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::powctl, 198); namespace ams::powctl { R_DEFINE_ERROR_RESULT(NotSupported, 1); R_DEFINE_ERROR_RESULT(InvalidArgument, 2); R_DEFINE_ERROR_RESULT(NotAvailable, 3); R_DEFINE_ERROR_RESULT(CalibrationDataCrcError, 101); }
976
C++
.h
24
38.166667
76
0.754757
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,979
debug_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/debug_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::dbg, 183); namespace ams::dbg { R_DEFINE_ERROR_RESULT(CannotDebug, 1); R_DEFINE_ERROR_RESULT(AlreadyAttached, 2); R_DEFINE_ERROR_RESULT(Cancelled, 3); }
912
C++
.h
23
37.304348
76
0.746606
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,980
hipc_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/hipc_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::sf::hipc, 11); namespace ams::sf::hipc { R_DEFINE_ABSTRACT_ERROR_RANGE(OutOfResource, 100, 299); R_DEFINE_ERROR_RESULT(OutOfSessionMemory, 102); R_DEFINE_ERROR_RANGE (OutOfSessions, 131, 139); R_DEFINE_ERROR_RESULT(PointerBufferTooSmall, 141); R_DEFINE_ERROR_RESULT(OutOfDomains, 200); R_DEFINE_ABSTRACT_ERROR_RANGE(CommunicationError, 300, 349); R_DEFINE_ERROR_RESULT(SessionClosed, 301); R_DEFINE_ERROR_RESULT(InvalidRequestSize, 402); R_DEFINE_ERROR_RESULT(UnknownCommandType, 403); R_DEFINE_ERROR_RESULT(InvalidCmifRequest, 420); R_DEFINE_ERROR_RESULT(TargetNotDomain, 491); R_DEFINE_ERROR_RESULT(DomainObjectNotFound, 492); }
1,480
C++
.h
32
42.375
76
0.726008
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,981
creport_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/creport_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::creport, 168); namespace ams::creport { R_DEFINE_ERROR_RESULT(UndefinedInstruction, 0); R_DEFINE_ERROR_RESULT(InstructionAbort, 1); R_DEFINE_ERROR_RESULT(DataAbort, 2); R_DEFINE_ERROR_RESULT(AlignmentFault, 3); R_DEFINE_ERROR_RESULT(DebuggerAttached, 4); R_DEFINE_ERROR_RESULT(BreakPoint, 5); R_DEFINE_ERROR_RESULT(UserBreak, 6); R_DEFINE_ERROR_RESULT(DebuggerBreak, 7); R_DEFINE_ERROR_RESULT(UndefinedSystemCall, 8); R_DEFINE_ERROR_RESULT(MemorySystemError, 9); R_DEFINE_ERROR_RESULT(IncompleteReport, 99); }
1,353
C++
.h
31
40.580645
76
0.718085
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,982
pgl_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/pgl_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::pgl, 228); namespace ams::pgl { R_DEFINE_ERROR_RESULT(NotImplemented, 1); R_DEFINE_ERROR_RESULT(NotAvailable, 2); R_DEFINE_ERROR_RESULT(ApplicationNotRunning, 3); R_DEFINE_ERROR_RESULT(BufferNotEnough, 4); R_DEFINE_ERROR_RESULT(ApplicationContentNotFound, 5); R_DEFINE_ERROR_RESULT(ContentMetaNotFound, 6); R_DEFINE_ERROR_RESULT(OutOfMemory, 7); }
1,177
C++
.h
27
40.851852
76
0.715284
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,983
settings_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/settings_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::settings, 105); namespace ams::settings { R_DEFINE_ERROR_RESULT(SettingsItemNotFound, 11); R_DEFINE_ERROR_RESULT(StopIteration, 21); R_DEFINE_ERROR_RANGE(InternalError, 100, 149); R_DEFINE_ERROR_RESULT(SettingsItemKeyAllocationFailed, 101); R_DEFINE_ERROR_RESULT(SettingsItemValueAllocationFailed, 102); R_DEFINE_ERROR_RESULT(SettingsItemKeyIteratorAllocationFailed, 111); R_DEFINE_ERROR_RESULT(TooLargeSystemSaveData, 141); R_DEFINE_ERROR_RANGE(InvalidArgument, 200, 399); R_DEFINE_ERROR_RESULT(NullSettingsName, 201); R_DEFINE_ERROR_RESULT(NullSettingsItemKey, 202); R_DEFINE_ERROR_RESULT(NullSettingsItemValue, 203); R_DEFINE_ERROR_RESULT(NullSettingsItemKeyBuffer, 204); R_DEFINE_ERROR_RESULT(NullSettingsItemValueBuffer, 205); R_DEFINE_ERROR_RESULT(EmptySettingsName, 221); R_DEFINE_ERROR_RESULT(EmptySettingsItemKey, 222); R_DEFINE_ERROR_RESULT(TooLongSettingsName, 241); R_DEFINE_ERROR_RESULT(TooLongSettingsItemKey, 242); R_DEFINE_ERROR_RESULT(InvalidFormatSettingsName, 261); R_DEFINE_ERROR_RESULT(InvalidFormatSettingsItemKey, 262); R_DEFINE_ERROR_RESULT(InvalidFormatSettingsItemValue, 263); R_DEFINE_ERROR_RESULT(NotFoundSettingsItemKeyIterator, 281); R_DEFINE_ERROR_RANGE(CalibrationDataError, 580, 599); R_DEFINE_ERROR_RESULT(CalibrationDataFileSystemCorrupted, 581); R_DEFINE_ERROR_RESULT(CalibrationDataCrcError, 582); R_DEFINE_ERROR_RESULT(CalibrationDataShaError, 583); }
2,678
C++
.h
45
53.933333
81
0.645937
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,984
sdmmc_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/sdmmc_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::sdmmc, 24); namespace ams::sdmmc { R_DEFINE_ERROR_RESULT(NoDevice, 1); R_DEFINE_ERROR_RESULT(NotActivated, 2); R_DEFINE_ERROR_RESULT(DeviceRemoved, 3); R_DEFINE_ERROR_RESULT(NotAwakened, 4); R_DEFINE_ERROR_RANGE(CommunicationError, 32, 126); R_DEFINE_ERROR_RANGE(CommunicationNotAttained, 33, 46); R_DEFINE_ERROR_RESULT(ResponseIndexError, 34); R_DEFINE_ERROR_RESULT(ResponseEndBitError, 35); R_DEFINE_ERROR_RESULT(ResponseCrcError, 36); R_DEFINE_ERROR_RESULT(ResponseTimeoutError, 37); R_DEFINE_ERROR_RESULT(DataEndBitError, 38); R_DEFINE_ERROR_RESULT(DataCrcError, 39); R_DEFINE_ERROR_RESULT(DataTimeoutError, 40); R_DEFINE_ERROR_RESULT(AutoCommandResponseIndexError, 41); R_DEFINE_ERROR_RESULT(AutoCommandResponseEndBitError, 42); R_DEFINE_ERROR_RESULT(AutoCommandResponseCrcError, 43); R_DEFINE_ERROR_RESULT(AutoCommandResponseTimeoutError, 44); R_DEFINE_ERROR_RESULT(CommandCompleteSoftwareTimeout, 45); R_DEFINE_ERROR_RESULT(TransferCompleteSoftwareTimeout, 46); R_DEFINE_ERROR_RANGE(DeviceStatusHasError, 48, 70); R_DEFINE_ERROR_RESULT(DeviceStatusAddressOutOfRange, 49); R_DEFINE_ERROR_RESULT(DeviceStatusAddressMisaligned, 50); R_DEFINE_ERROR_RESULT(DeviceStatusBlockLenError, 51); R_DEFINE_ERROR_RESULT(DeviceStatusEraseSeqError, 52); R_DEFINE_ERROR_RESULT(DeviceStatusEraseParam, 53); R_DEFINE_ERROR_RESULT(DeviceStatusWpViolation, 54); R_DEFINE_ERROR_RESULT(DeviceStatusLockUnlockFailed, 55); R_DEFINE_ERROR_RESULT(DeviceStatusComCrcError, 56); R_DEFINE_ERROR_RESULT(DeviceStatusIllegalCommand, 57); R_DEFINE_ERROR_RESULT(DeviceStatusDeviceEccFailed, 58); R_DEFINE_ERROR_RESULT(DeviceStatusCcError, 59); R_DEFINE_ERROR_RESULT(DeviceStatusError, 60); R_DEFINE_ERROR_RESULT(DeviceStatusCidCsdOverwrite, 61); R_DEFINE_ERROR_RESULT(DeviceStatusWpEraseSkip, 62); R_DEFINE_ERROR_RESULT(DeviceStatusEraseReset, 63); R_DEFINE_ERROR_RESULT(DeviceStatusSwitchError, 64); R_DEFINE_ERROR_RESULT(UnexpectedDeviceState, 72); R_DEFINE_ERROR_RESULT(UnexpectedDeviceCsdValue, 73); R_DEFINE_ERROR_RESULT(AbortTransactionSoftwareTimeout, 74); R_DEFINE_ERROR_RESULT(CommandInhibitCmdSoftwareTimeout, 75); R_DEFINE_ERROR_RESULT(CommandInhibitDatSoftwareTimeout, 76); R_DEFINE_ERROR_RESULT(BusySoftwareTimeout, 77); R_DEFINE_ERROR_RESULT(IssueTuningCommandSoftwareTimeout, 78); R_DEFINE_ERROR_RESULT(TuningFailed, 79); R_DEFINE_ERROR_RESULT(MmcInitializationSoftwareTimeout, 80); R_DEFINE_ERROR_RESULT(MmcNotSupportExtendedCsd, 81); R_DEFINE_ERROR_RESULT(UnexpectedMmcExtendedCsdValue, 82); R_DEFINE_ERROR_RESULT(MmcEraseSoftwareTimeout, 83); R_DEFINE_ERROR_RESULT(SdCardValidationError, 84); R_DEFINE_ERROR_RESULT(SdCardInitializationSoftwareTimeout, 85); R_DEFINE_ERROR_RESULT(SdCardGetValidRcaSoftwareTimeout, 86); R_DEFINE_ERROR_RESULT(UnexpectedSdCardAcmdDisabled, 87); R_DEFINE_ERROR_RESULT(SdCardNotSupportSwitchFunctionStatus, 88); R_DEFINE_ERROR_RESULT(UnexpectedSdCardSwitchFunctionStatus, 89); R_DEFINE_ERROR_RESULT(SdCardNotSupportAccessMode, 90); R_DEFINE_ERROR_RESULT(SdCardNot4BitBusWidthAtUhsIMode, 91); R_DEFINE_ERROR_RESULT(SdCardNotSupportSdr104AndSdr50, 92); R_DEFINE_ERROR_RESULT(SdCardCannotSwitchAccessMode, 93); R_DEFINE_ERROR_RESULT(SdCardFailedSwitchAccessMode, 94); R_DEFINE_ERROR_RESULT(SdCardUnacceptableCurrentConsumption, 95); R_DEFINE_ERROR_RESULT(SdCardNotReadyToVoltageSwitch, 96); R_DEFINE_ERROR_RESULT(SdCardNotCompleteVoltageSwitch, 97); R_DEFINE_ERROR_RANGE(HostControllerUnexpected, 128, 158); R_DEFINE_ERROR_RESULT(InternalClockStableSoftwareTimeout, 129); R_DEFINE_ERROR_RESULT(SdHostStandardUnknownAutoCmdError, 130); R_DEFINE_ERROR_RESULT(SdHostStandardUnknownError, 131); R_DEFINE_ERROR_RESULT(SdmmcDllCalibrationSoftwareTimeout, 132); R_DEFINE_ERROR_RESULT(SdmmcDllApplicationSoftwareTimeout, 133); R_DEFINE_ERROR_RESULT(SdHostStandardFailSwitchTo1_8V, 134); R_DEFINE_ERROR_RESULT(DriveStrengthCalibrationNotCompleted, 135); R_DEFINE_ERROR_RESULT(DriveStrengthCalibrationSoftwareTimeout, 136); R_DEFINE_ERROR_RESULT(SdmmcCompShortToGnd, 137); R_DEFINE_ERROR_RESULT(SdmmcCompOpen, 138); R_DEFINE_ERROR_RANGE(InternalError, 160, 190); R_DEFINE_ERROR_RESULT(NoWaitedInterrupt, 161); R_DEFINE_ERROR_RESULT(WaitInterruptSoftwareTimeout, 162); R_DEFINE_ERROR_RESULT(NotImplemented, 201); }
6,176
C++
.h
97
55.226804
77
0.666941
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,985
sf_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/sf_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::sf, 10); namespace ams::sf { R_DEFINE_ERROR_RESULT(NotSupported, 1); R_DEFINE_ERROR_RESULT(PreconditionViolation, 3); //namespace cmif { R_DEFINE_ERROR_RESULT_NS(cmif, InvalidHeaderSize, 202); R_DEFINE_ERROR_RESULT_NS(cmif, InvalidInHeader, 211); R_DEFINE_ERROR_RESULT_NS(cmif, UnknownCommandId, 221); R_DEFINE_ERROR_RESULT_NS(cmif, InvalidOutRawSize, 232); R_DEFINE_ERROR_RESULT_NS(cmif, InvalidNumInObjects, 235); R_DEFINE_ERROR_RESULT_NS(cmif, InvalidNumOutObjects, 236); R_DEFINE_ERROR_RESULT_NS(cmif, InvalidInObject, 239); R_DEFINE_ERROR_RESULT_NS(cmif, TargetNotFound, 261); R_DEFINE_ERROR_RESULT_NS(cmif, OutOfDomainEntries, 301); //} //namespace impl { R_DEFINE_ABSTRACT_ERROR_RANGE_NS(impl, RequestContextChanged, 800, 899); R_DEFINE_ABSTRACT_ERROR_RANGE_NS(impl, RequestInvalidated, 801, 809); R_DEFINE_ERROR_RESULT_NS(impl, RequestInvalidatedByUser, 802); //} R_DEFINE_ABSTRACT_ERROR_RANGE(RequestDeferred, 811, 819); R_DEFINE_ERROR_RESULT(RequestDeferredByUser, 812); }
1,917
C++
.h
40
42.625
81
0.702093
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,986
dd_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/dd_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::dd, 6); namespace ams::dd { R_DEFINE_ERROR_RESULT(EndOfQuery, 1); R_DEFINE_ERROR_RESULT(InvalidCurrentMemory, 2); R_DEFINE_ERROR_RESULT(NotSingleRegion, 3); R_DEFINE_ERROR_RESULT(InvalidMemoryState, 4); R_DEFINE_ERROR_RESULT(OutOfMemory, 5); R_DEFINE_ERROR_RESULT(OutOfResource, 6); R_DEFINE_ERROR_RESULT(NotSupported, 7); R_DEFINE_ERROR_RESULT(InvalidHandle, 8); R_DEFINE_ERROR_RESULT(InternalError, 1023); }
1,263
C++
.h
29
40.62069
76
0.702769
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,987
psc_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/psc_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::psc, 138); namespace ams::psc { R_DEFINE_ERROR_RESULT(AlreadyInitialized, 2); R_DEFINE_ERROR_RESULT(NotInitialized, 3); }
871
C++
.h
22
37.363636
76
0.755924
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,988
kvdb_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/kvdb_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::kvdb, 20); namespace ams::kvdb { R_DEFINE_ERROR_RESULT(OutOfKeyResource, 1); R_DEFINE_ERROR_RESULT(KeyNotFound, 2); R_DEFINE_ERROR_RESULT(AllocationFailed, 4); R_DEFINE_ERROR_RESULT(InvalidKeyValue, 5); R_DEFINE_ERROR_RESULT(BufferInsufficient, 6); R_DEFINE_ERROR_RESULT(InvalidFilesystemState, 8); R_DEFINE_ERROR_RESULT(NotCreated, 9); }
1,158
C++
.h
27
40.111111
76
0.72
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,989
time_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/time_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::time, 116); namespace ams::time { R_DEFINE_ERROR_RESULT(NotInitialized, 0); R_DEFINE_ERROR_RESULT(NotComparable, 200); R_DEFINE_ERROR_RESULT(Overflowed, 201); R_DEFINE_ABSTRACT_ERROR_RANGE(InvalidArgument, 900, 919); R_DEFINE_ERROR_RESULT(InvalidPointer, 901); }
1,031
C++
.h
25
38.44
76
0.74975
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,990
lr_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/lr_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::lr, 8); namespace ams::lr { R_DEFINE_ERROR_RESULT(ProgramNotFound, 2); R_DEFINE_ERROR_RESULT(DataNotFound, 3); R_DEFINE_ERROR_RESULT(UnknownStorageId, 4); R_DEFINE_ERROR_RESULT(HtmlDocumentNotFound, 6); R_DEFINE_ERROR_RESULT(AddOnContentNotFound, 7); R_DEFINE_ERROR_RESULT(ControlNotFound, 8); R_DEFINE_ERROR_RESULT(LegalInformationNotFound, 9); R_DEFINE_ERROR_RESULT(DebugProgramNotFound, 10); R_DEFINE_ERROR_RESULT(TooManyRegisteredPaths, 90); R_DEFINE_ERROR_RESULT(InvalidPath, 140); }
1,331
C++
.h
30
41.333333
76
0.72102
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,991
ro_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/ro_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::ro, 22); namespace ams::ro { R_DEFINE_ERROR_RANGE(RoError, 1, 1023); R_DEFINE_ERROR_RESULT(OutOfAddressSpace, 2); R_DEFINE_ERROR_RESULT(AlreadyLoaded, 3); R_DEFINE_ERROR_RESULT(InvalidNro, 4); R_DEFINE_ERROR_RESULT(InvalidNrr, 6); R_DEFINE_ERROR_RESULT(TooManyNro, 7); R_DEFINE_ERROR_RESULT(TooManyNrr, 8); R_DEFINE_ERROR_RESULT(NotAuthorized, 9); R_DEFINE_ERROR_RESULT(InvalidNrrKind, 10); R_DEFINE_ERROR_RESULT(InternalError, 1023); R_DEFINE_ERROR_RESULT(InvalidAddress, 1025); R_DEFINE_ERROR_RESULT(InvalidSize, 1026); R_DEFINE_ERROR_RESULT(NotLoaded, 1028); R_DEFINE_ERROR_RESULT(NotRegistered, 1029); R_DEFINE_ERROR_RESULT(InvalidSession, 1030); R_DEFINE_ERROR_RESULT(InvalidProcess, 1031); }
1,714
C++
.h
36
43.194444
76
0.650689
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,992
socket_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/socket_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::socket, 27); namespace ams::socket { R_DEFINE_ERROR_RESULT(InsufficientProvidedMemory, 1); }
834
C++
.h
21
37.619048
76
0.764851
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,993
nim_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/nim_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::nim, 137); namespace ams::nim { R_DEFINE_ERROR_RESULT(HttpConnectionCanceled, 70); }
826
C++
.h
21
37.238095
76
0.7625
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,994
svc_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/svc_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::svc, 1); namespace ams::svc { R_DEFINE_ERROR_RESULT(OutOfSessions, 7); R_DEFINE_ERROR_RESULT(InvalidArgument, 14); R_DEFINE_ERROR_RESULT(NotImplemented, 33); R_DEFINE_ERROR_RESULT(StopProcessingException, 54); R_DEFINE_ERROR_RESULT(NoSynchronizationObject, 57); R_DEFINE_ERROR_RESULT(TerminationRequested, 59); R_DEFINE_ERROR_RESULT(NoEvent, 70); R_DEFINE_ERROR_RESULT(InvalidSize, 101); R_DEFINE_ERROR_RESULT(InvalidAddress, 102); R_DEFINE_ERROR_RESULT(OutOfResource, 103); R_DEFINE_ERROR_RESULT(OutOfMemory, 104); R_DEFINE_ERROR_RESULT(OutOfHandles, 105); R_DEFINE_ERROR_RESULT(InvalidCurrentMemory, 106); R_DEFINE_ERROR_RESULT(InvalidNewMemoryPermission, 108); R_DEFINE_ERROR_RESULT(InvalidMemoryRegion, 110); R_DEFINE_ERROR_RESULT(InvalidPriority, 112); R_DEFINE_ERROR_RESULT(InvalidCoreId, 113); R_DEFINE_ERROR_RESULT(InvalidHandle, 114); R_DEFINE_ERROR_RESULT(InvalidPointer, 115); R_DEFINE_ERROR_RESULT(InvalidCombination, 116); R_DEFINE_ERROR_RESULT(TimedOut, 117); R_DEFINE_ERROR_RESULT(Cancelled, 118); R_DEFINE_ERROR_RESULT(OutOfRange, 119); R_DEFINE_ERROR_RESULT(InvalidEnumValue, 120); R_DEFINE_ERROR_RESULT(NotFound, 121); R_DEFINE_ERROR_RESULT(Busy, 122); R_DEFINE_ERROR_RESULT(SessionClosed, 123); R_DEFINE_ERROR_RESULT(NotHandled, 124); R_DEFINE_ERROR_RESULT(InvalidState, 125); R_DEFINE_ERROR_RESULT(ReservedUsed, 126); R_DEFINE_ERROR_RESULT(NotSupported, 127); R_DEFINE_ERROR_RESULT(Debug, 128); R_DEFINE_ERROR_RESULT(NoThread, 129); R_DEFINE_ERROR_RESULT(UnknownThread, 130); R_DEFINE_ERROR_RESULT(PortClosed, 131); R_DEFINE_ERROR_RESULT(LimitReached, 132); R_DEFINE_ERROR_RESULT(InvalidMemoryPool, 133); R_DEFINE_ERROR_RESULT(ReceiveListBroken, 258); R_DEFINE_ERROR_RESULT(OutOfAddressSpace, 259); R_DEFINE_ERROR_RESULT(MessageTooLarge, 260); R_DEFINE_ERROR_RESULT(InvalidProcessId, 517); R_DEFINE_ERROR_RESULT(InvalidThreadId, 518); R_DEFINE_ERROR_RESULT(InvalidId, 519); R_DEFINE_ERROR_RESULT(ProcessTerminated, 520); }
3,501
C++
.h
64
50.46875
76
0.60848
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,995
htcs_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/htcs_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::htcs, 4); namespace ams::htcs { R_DEFINE_ERROR_RESULT(InvalidHandle, 9); R_DEFINE_ERROR_RESULT(InvalidArgument, 2001); R_DEFINE_ERROR_RESULT(InvalidServerHandle, 2003); R_DEFINE_ERROR_RESULT(InvalidSize, 2014); R_DEFINE_ERROR_RESULT(Cancelled, 2021); R_DEFINE_ERROR_RESULT(Completed, 2023); R_DEFINE_ERROR_RESULT(InvalidTask, 2103); }
1,140
C++
.h
27
39.481481
76
0.727437
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,996
scs_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/scs_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> #include <vapours/results/cs_results.hpp> namespace ams::scs { using ams::cs::ResultUnknownCommand; using ams::cs::ResultOutOfResource; using ams::cs::ResultNoSocket; }
879
C++
.h
23
35.913043
76
0.75939
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,997
fs_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/fs_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::fs, 2); namespace ams::fs { R_DEFINE_ERROR_RANGE(HandledByAllProcess, 0, 999); R_DEFINE_ERROR_RESULT(PathNotFound, 1); R_DEFINE_ERROR_RESULT(PathAlreadyExists, 2); R_DEFINE_ERROR_RESULT(TargetLocked, 7); R_DEFINE_ERROR_RESULT(DirectoryNotEmpty, 8); R_DEFINE_ERROR_RANGE (NotEnoughFreeSpace, 30, 45); R_DEFINE_ERROR_RANGE(NotEnoughFreeSpaceBis, 34, 38); R_DEFINE_ERROR_RESULT(NotEnoughFreeSpaceBisCalibration, 35); R_DEFINE_ERROR_RESULT(NotEnoughFreeSpaceBisSafe, 36); R_DEFINE_ERROR_RESULT(NotEnoughFreeSpaceBisUser, 37); R_DEFINE_ERROR_RESULT(NotEnoughFreeSpaceBisSystem, 38); R_DEFINE_ERROR_RESULT(NotEnoughFreeSpaceSdCard, 39); R_DEFINE_ERROR_RESULT(UnsupportedSdkVersion, 50); R_DEFINE_ERROR_RESULT(MountNameAlreadyExists, 60); R_DEFINE_ERROR_RANGE(HandledBySystemProcess, 1000, 2999); R_DEFINE_ERROR_RESULT(PartitionNotFound, 1001); R_DEFINE_ERROR_RESULT(TargetNotFound, 1002); R_DEFINE_ERROR_RESULT(NcaExternalKeyNotFound, 1004); R_DEFINE_ERROR_RANGE(SdCardAccessFailed, 2000, 2499); R_DEFINE_ERROR_RESULT(SdCardNotPresent, 2001); R_DEFINE_ERROR_RANGE(GameCardAccessFailed, 2500, 2999); R_DEFINE_ERROR_RESULT(GameCardPreconditionViolation, 2503); R_DEFINE_ERROR_RANGE(GameCardCardAccessFailure, 2530, 2559); R_DEFINE_ERROR_RANGE(CameCardWrongCard, 2543, 2546); R_DEFINE_ERROR_RESULT(GameCardInitialDataMismatch, 2544); R_DEFINE_ERROR_RESULT(GameCardInitialNotFilledWithZero, 2545); R_DEFINE_ERROR_RESULT(GameCardKekIndexMismatch, 2546); R_DEFINE_ERROR_RESULT(GameCardInvalidCardHeader, 2554); R_DEFINE_ERROR_RESULT(GameCardInvalidT1CardCertificate, 2555); R_DEFINE_ERROR_RESULT(GameCardInvalidCa10Certificate, 2557); R_DEFINE_ERROR_RANGE(GameCardSplFailure, 2665, 2669); R_DEFINE_ERROR_RESULT(GameCardSplDecryptAesKeyFailure, 2666); R_DEFINE_ERROR_RESULT(NotImplemented, 3001); R_DEFINE_ERROR_RESULT(UnsupportedVersion, 3002); R_DEFINE_ERROR_RESULT(OutOfRange, 3005); R_DEFINE_ERROR_RESULT(SystemPartitionNotReady, 3100); R_DEFINE_ERROR_RANGE(AllocationMemoryFailed, 3200, 3499); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInFatFileSystemA, 3201); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInFatFileSystemC, 3203); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInFatFileSystemD, 3204); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInFatFileSystemE, 3205); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInFatFileSystemF, 3206); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInFatFileSystemH, 3208); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInFileSystemAccessorA, 3211); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInFileSystemAccessorB, 3212); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInApplicationA, 3213); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInBcatSaveDataA, 3214); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInBisA, 3215); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInBisB, 3216); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInBisC, 3217); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInCodeA, 3218); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInContentA, 3219); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInContentStorageA, 3220); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInContentStorageB, 3221); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInDataA, 3222); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInDataB, 3223); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInDeviceSaveDataA, 3224); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardA, 3225); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardB, 3226); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardC, 3227); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardD, 3228); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInHostA, 3229); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInHostB, 3230); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInHostC, 3231); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInImageDirectoryA, 3232); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInLogoA, 3233); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInRomA, 3234); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInRomB, 3235); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInRomC, 3236); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInRomD, 3237); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInRomE, 3238); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInRomF, 3239); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSaveDataManagementA, 3242); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSaveDataThumbnailA, 3243); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSdCardA, 3244); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSdCardB, 3245); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSystemSaveDataA, 3246); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInRomFsFileSystemA, 3247); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInRomFsFileSystemB, 3248); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInRomFsFileSystemC, 3249); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGuidPartitionTableA, 3251); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInDeviceDetectionEventManagerA, 3252); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSaveDataFileSystemServiceImplA, 3253); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInFileSystemProxyCoreImplB, 3254); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSdCardProxyFileSystemCreatorA, 3255); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInNcaFileSystemServiceImplA, 3256); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInNcaFileSystemServiceImplB, 3257); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInProgramRegistryManagerA, 3258); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSdmmcStorageServiceA, 3259); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInBuiltInStorageCreatorA, 3260); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInBuiltInStorageCreatorB, 3261); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInBuiltInStorageCreatorC, 3262); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedFatFileSystemWithBufferA, 3264); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInFatFileSystemCreatorA, 3265); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInFatFileSystemCreatorB, 3266); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardFileSystemCreatorA, 3267); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardFileSystemCreatorB, 3268); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardFileSystemCreatorC, 3269); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardFileSystemCreatorD, 3270); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardFileSystemCreatorE, 3271); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardFileSystemCreatorF, 3272); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardManagerA, 3273); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardManagerB, 3274); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardManagerC, 3275); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardManagerD, 3276); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardManagerE, 3277); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardManagerF, 3278); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInLocalFileSystemCreatorA, 3279); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInPartitionFileSystemCreatorA, 3280); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInRomFileSystemCreatorA, 3281); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSaveDataFileSystemCreatorA, 3282); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSaveDataFileSystemCreatorB, 3283); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSaveDataFileSystemCreatorC, 3284); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSaveDataFileSystemCreatorD, 3285); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSaveDataFileSystemCreatorE, 3286); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInStorageOnNcaCreatorA, 3288); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInStorageOnNcaCreatorB, 3289); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSubDirectoryFileSystemCreatorA, 3290); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInTargetManagerFileSystemCreatorA, 3291); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSaveDataIndexerA, 3292); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSaveDataIndexerB, 3293); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInFileSystemBuddyHeapA, 3294); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInFileSystemBufferManagerA, 3295); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInBlockCacheBufferedStorageA, 3296); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInBlockCacheBufferedStorageB, 3297); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInDuplexStorageA, 3298); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInIntegrityVerificationStorageA, 3304); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInIntegrityVerificationStorageB, 3305); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInJournalStorageA, 3306); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInJournalStorageB, 3307); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSaveDataFileSystemCoreA, 3310); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSaveDataFileSystemCoreB, 3311); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInAesXtsFileA, 3312); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInAesXtsFileB, 3313); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInAesXtsFileC, 3314); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInAesXtsFileD, 3315); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInAesXtsFileSystemA, 3316); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInConcatenationFileSystemA, 3319); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInConcatenationFileSystemB, 3320); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInDirectorySaveDataFileSystemA, 3321); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInLocalFileSystemA, 3322); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInLocalFileSystemB, 3323); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInNcaFileSystemDriverI, 3341); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInPartitionFileSystemA, 3347); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInPartitionFileSystemB, 3348); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInPartitionFileSystemC, 3349); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInPartitionFileSystemMetaA, 3350); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInPartitionFileSystemMetaB, 3351); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInRomFsFileSystemD, 3352); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSubdirectoryFileSystemA, 3355); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInTmFileSystemA, 3356); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInTmFileSystemB, 3357); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInProxyFileSystemA, 3359); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInProxyFileSystemB, 3360); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSaveDataExtraDataAccessorCacheManagerA, 3362); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInNcaReaderA, 3363); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInRegisterA, 3365); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInRegisterB, 3366); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInPathNormalizer, 3367); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInDbmRomKeyValueStorage, 3375); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInDbmHierarchicalRomFileTable, 3376); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInRomFsFileSystemE, 3377); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInISaveFileSystemA, 3378); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInISaveFileSystemB, 3379); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInRomOnFileA, 3380); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInRomOnFileB, 3381); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInRomOnFileC, 3382); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInAesXtsFileE, 3383); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInAesXtsFileF, 3384); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInAesXtsFileG, 3385); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInReadOnlyFileSystemA, 3386); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInEncryptedFileSystemCreatorA, 3394); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInAesCtrCounterExtendedStorageA, 3399); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInAesCtrCounterExtendedStorageB, 3400); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSdmmcStorageServiceB, 3406); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInFileSystemInterfaceAdapterA, 3407); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardFileSystemCreatorG, 3408); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardFileSystemCreatorH, 3409); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInAesXtsFileSystemB, 3410); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInBufferedStorageA, 3411); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInIntegrityRomFsStorageA, 3412); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSaveDataFileSystemServiceImplB, 3416); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedNew, 3420); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInFileSystemProxyImplA, 3421); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedMakeUnique, 3422); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedAllocateShared, 3423); R_DEFINE_ERROR_RESULT(AllocationPooledBufferNotEnoughSize, 3424); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInWriteThroughCacheStorageA, 3428); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSaveDataTransferManagerA, 3429); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInSaveDataTransferManagerB, 3430); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInHtcFileSystemA, 3431); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInHtcFileSystemB, 3432); R_DEFINE_ERROR_RESULT(AllocationMemoryFailedInGameCardManagerG, 3433); R_DEFINE_ERROR_RANGE(Internal, 3000, 7999); R_DEFINE_ERROR_RANGE(MmcAccessFailed, 3500, 3999); R_DEFINE_ERROR_RANGE(DataCorrupted, 4000, 4999); R_DEFINE_ERROR_RANGE(RomCorrupted, 4001, 4299); R_DEFINE_ERROR_RESULT(UnsupportedRomVersion, 4002); R_DEFINE_ERROR_RANGE(AesCtrCounterExtendedStorageCorrupted, 4011, 4019); R_DEFINE_ERROR_RESULT(InvalidAesCtrCounterExtendedEntryOffset, 4012); R_DEFINE_ERROR_RESULT(InvalidAesCtrCounterExtendedTableSize, 4013); R_DEFINE_ERROR_RESULT(InvalidAesCtrCounterExtendedGeneration, 4014); R_DEFINE_ERROR_RESULT(InvalidAesCtrCounterExtendedOffset, 4015); R_DEFINE_ERROR_RANGE(IndirectStorageCorrupted, 4021, 4029); R_DEFINE_ERROR_RESULT(InvalidIndirectEntryOffset, 4022); R_DEFINE_ERROR_RESULT(InvalidIndirectEntryStorageIndex, 4023); R_DEFINE_ERROR_RESULT(InvalidIndirectStorageSize, 4024); R_DEFINE_ERROR_RESULT(InvalidIndirectVirtualOffset, 4025); R_DEFINE_ERROR_RESULT(InvalidIndirectPhysicalOffset, 4026); R_DEFINE_ERROR_RESULT(InvalidIndirectStorageIndex, 4027); R_DEFINE_ERROR_RANGE(BucketTreeCorrupted, 4031, 4039); R_DEFINE_ERROR_RESULT(InvalidBucketTreeSignature, 4032); R_DEFINE_ERROR_RESULT(InvalidBucketTreeEntryCount, 4033); R_DEFINE_ERROR_RESULT(InvalidBucketTreeNodeEntryCount, 4034); R_DEFINE_ERROR_RESULT(InvalidBucketTreeNodeOffset, 4035); R_DEFINE_ERROR_RESULT(InvalidBucketTreeEntryOffset, 4036); R_DEFINE_ERROR_RESULT(InvalidBucketTreeEntrySetOffset, 4037); R_DEFINE_ERROR_RESULT(InvalidBucketTreeNodeIndex, 4038); R_DEFINE_ERROR_RESULT(InvalidBucketTreeVirtualOffset, 4039); R_DEFINE_ERROR_RANGE(RomNcaCorrupted, 4041, 4139); R_DEFINE_ERROR_RANGE(RomNcaFileSystemCorrupted, 4051, 4069); R_DEFINE_ERROR_RESULT(InvalidRomNcaFileSystemType, 4052); R_DEFINE_ERROR_RESULT(InvalidRomAcidFileSize, 4053); R_DEFINE_ERROR_RESULT(InvalidRomAcidSize, 4054); R_DEFINE_ERROR_RESULT(InvalidRomAcid, 4055); R_DEFINE_ERROR_RESULT(RomAcidVerificationFailed, 4056); R_DEFINE_ERROR_RESULT(InvalidRomNcaSignature, 4057); R_DEFINE_ERROR_RESULT(RomNcaHeaderSignature1VerificationFailed, 4058); R_DEFINE_ERROR_RESULT(RomNcaHeaderSignature2VerificationFailed, 4059); R_DEFINE_ERROR_RESULT(RomNcaFsHeaderHashVerificationFailed, 4060); R_DEFINE_ERROR_RESULT(InvalidRomNcaKeyIndex, 4061); R_DEFINE_ERROR_RESULT(InvalidRomNcaFsHeaderHashType, 4062); R_DEFINE_ERROR_RESULT(InvalidRomNcaFsHeaderEncryptionType, 4063); R_DEFINE_ERROR_RANGE(RomNcaHierarchicalSha256StorageCorrupted, 4071, 4079); R_DEFINE_ERROR_RESULT(InvalidRomHierarchicalSha256BlockSize, 4072); R_DEFINE_ERROR_RESULT(InvalidRomHierarchicalSha256LayerCount, 4073); R_DEFINE_ERROR_RESULT(RomHierarchicalSha256BaseStorageTooLarge, 4074); R_DEFINE_ERROR_RESULT(RomHierarchicalSha256HashVerificationFailed, 4075); R_DEFINE_ERROR_RESULT(RomNcaInvalidHierarchicalIntegrityVerificationLayerCount, 4081); R_DEFINE_ERROR_RESULT(RomNcaInvalidNcaIndirectStorageOutOfRange, 4082); R_DEFINE_ERROR_RESULT(RomNcaInvalidCompressionInfo, 4083); R_DEFINE_ERROR_RESULT(RomNcaInvalidPatchMetaDataHashType, 4084); R_DEFINE_ERROR_RESULT(RomNcaInvalidIntegrityLayerInfoOffset, 4085); R_DEFINE_ERROR_RESULT(RomNcaInvalidPatchMetaDataHashDataSize, 4086); R_DEFINE_ERROR_RESULT(RomNcaInvalidPatchMetaDataHashDataOffset, 4087); R_DEFINE_ERROR_RESULT(RomNcaInvalidPatchMetaDataHashDataHash, 4088); R_DEFINE_ERROR_RESULT(RomNcaInvalidSparseMetaDataHashType, 4089); R_DEFINE_ERROR_RESULT(RomNcaInvalidSparseMetaDataHashDataSize, 4090); R_DEFINE_ERROR_RESULT(RomNcaInvalidSparseMetaDataHashDataOffset, 4091); R_DEFINE_ERROR_RESULT(RomNcaInvalidSparseMetaDataHashDataHash, 4092); R_DEFINE_ERROR_RANGE(RomIntegrityVerificationStorageCorrupted, 4141, 4179); R_DEFINE_ERROR_RESULT(IncorrectRomIntegrityVerificationMagic, 4142); R_DEFINE_ERROR_RESULT(InvalidRomZeroHash, 4143); R_DEFINE_ERROR_RESULT(RomNonRealDataVerificationFailed, 4144); R_DEFINE_ERROR_RESULT(InvalidRomHierarchicalIntegrityVerificationLayerCount, 4145); R_DEFINE_ERROR_RANGE(RomRealDataVerificationFailed, 4151, 4159); R_DEFINE_ERROR_RESULT(ClearedRomRealDataVerificationFailed, 4152); R_DEFINE_ERROR_RESULT(UnclearedRomRealDataVerificationFailed, 4153); R_DEFINE_ERROR_RANGE(RomPartitionFileSystemCorrupted, 4181, 4199); R_DEFINE_ERROR_RESULT(InvalidRomSha256PartitionHashTarget, 4182); R_DEFINE_ERROR_RESULT(RomSha256PartitionHashVerificationFailed, 4183); R_DEFINE_ERROR_RESULT(RomPartitionSignatureVerificationFailed, 4184); R_DEFINE_ERROR_RESULT(RomSha256PartitionSignatureVerificationFailed, 4185); R_DEFINE_ERROR_RESULT(InvalidRomPartitionEntryOffset, 4186); R_DEFINE_ERROR_RESULT(InvalidRomSha256PartitionMetaDataSize, 4187); R_DEFINE_ERROR_RANGE(RomBuiltInStorageCorrupted, 4201, 4219); R_DEFINE_ERROR_RESULT(RomGptHeaderVerificationFailed, 4202); R_DEFINE_ERROR_RANGE(RomHostFileSystemCorrupted, 4241, 4259); R_DEFINE_ERROR_RESULT(RomHostEntryCorrupted, 4242); R_DEFINE_ERROR_RESULT(RomHostFileDataCorrupted, 4243); R_DEFINE_ERROR_RESULT(RomHostFileCorrupted, 4244); R_DEFINE_ERROR_RESULT(InvalidRomHostHandle, 4245); R_DEFINE_ERROR_RANGE(RomDatabaseCorrupted, 4261, 4279); R_DEFINE_ERROR_RESULT(InvalidRomAllocationTableBlock, 4262); R_DEFINE_ERROR_RESULT(InvalidRomKeyValueListElementIndex, 4263); R_DEFINE_ERROR_RANGE(SaveDataCorrupted, 4301, 4499); R_DEFINE_ERROR_RANGE(NcaCorrupted, 4501, 4599); R_DEFINE_ERROR_RESULT(NcaBaseStorageOutOfRangeA, 4508); R_DEFINE_ERROR_RESULT(NcaBaseStorageOutOfRangeB, 4509); R_DEFINE_ERROR_RESULT(NcaBaseStorageOutOfRangeC, 4510); R_DEFINE_ERROR_RESULT(NcaBaseStorageOutOfRangeD, 4511); R_DEFINE_ERROR_RESULT_CLASS_IMPL(NcaFileSystemCorrupted, 4512, 4529); R_DEFINE_ERROR_RESULT(InvalidNcaFileSystemType, 4512); R_DEFINE_ERROR_RESULT(InvalidAcidFileSize, 4513); R_DEFINE_ERROR_RESULT(InvalidAcidSize, 4514); R_DEFINE_ERROR_RESULT(InvalidAcid, 4515); R_DEFINE_ERROR_RESULT(AcidVerificationFailed, 4516); R_DEFINE_ERROR_RESULT(InvalidNcaSignature, 4517); R_DEFINE_ERROR_RESULT(NcaHeaderSignature1VerificationFailed, 4518); R_DEFINE_ERROR_RESULT(NcaHeaderSignature2VerificationFailed, 4519); R_DEFINE_ERROR_RESULT(NcaFsHeaderHashVerificationFailed, 4520); R_DEFINE_ERROR_RESULT(InvalidNcaKeyIndex, 4521); R_DEFINE_ERROR_RESULT(InvalidNcaFsHeaderHashType, 4522); R_DEFINE_ERROR_RESULT(InvalidNcaFsHeaderEncryptionType, 4523); R_DEFINE_ERROR_RESULT(InvalidNcaPatchInfoIndirectSize, 4524); R_DEFINE_ERROR_RESULT(InvalidNcaPatchInfoAesCtrExSize, 4525); R_DEFINE_ERROR_RESULT(InvalidNcaPatchInfoAesCtrExOffset, 4526); R_DEFINE_ERROR_RESULT(InvalidNcaId, 4527); R_DEFINE_ERROR_RESULT(InvalidNcaHeader, 4528); R_DEFINE_ERROR_RESULT(InvalidNcaFsHeader, 4529); R_DEFINE_ERROR_RESULT(NcaBaseStorageOutOfRangeE, 4530); R_DEFINE_ERROR_RANGE(NcaHierarchicalSha256StorageCorrupted, 4531, 4539); R_DEFINE_ERROR_RESULT(InvalidHierarchicalSha256BlockSize, 4532); R_DEFINE_ERROR_RESULT(InvalidHierarchicalSha256LayerCount, 4533); R_DEFINE_ERROR_RESULT(HierarchicalSha256BaseStorageTooLarge, 4534); R_DEFINE_ERROR_RESULT(HierarchicalSha256HashVerificationFailed, 4535); /* TODO: Range? */ R_DEFINE_ERROR_RESULT(InvalidNcaHierarchicalIntegrityVerificationLayerCount, 4541); R_DEFINE_ERROR_RESULT(InvalidNcaIndirectStorageOutOfRange, 4542); R_DEFINE_ERROR_RESULT(InvalidNcaHeader1SignatureKeyGeneration, 4543); /* TODO: Range? */ R_DEFINE_ERROR_RESULT(InvalidCompressedStorageSize, 4547); R_DEFINE_ERROR_RESULT(InvalidNcaMetaDataHashDataSize, 4548); R_DEFINE_ERROR_RESULT(InvalidNcaMetaDataHashDataHash, 4549); R_DEFINE_ERROR_RANGE(IntegrityVerificationStorageCorrupted, 4601, 4639); R_DEFINE_ERROR_RESULT(IncorrectIntegrityVerificationMagic, 4602); R_DEFINE_ERROR_RESULT(InvalidZeroHash, 4603); R_DEFINE_ERROR_RESULT(NonRealDataVerificationFailed, 4604); R_DEFINE_ERROR_RESULT(InvalidHierarchicalIntegrityVerificationLayerCount, 4605); R_DEFINE_ERROR_RANGE(RealDataVerificationFailed, 4611, 4619); R_DEFINE_ERROR_RESULT(ClearedRealDataVerificationFailed, 4612); R_DEFINE_ERROR_RESULT(UnclearedRealDataVerificationFailed, 4613); R_DEFINE_ERROR_RANGE(PartitionFileSystemCorrupted, 4641, 4659); R_DEFINE_ERROR_RESULT(InvalidSha256PartitionHashTarget, 4642); R_DEFINE_ERROR_RESULT(Sha256PartitionHashVerificationFailed, 4643); R_DEFINE_ERROR_RESULT(PartitionSignatureVerificationFailed, 4644); R_DEFINE_ERROR_RESULT(Sha256PartitionSignatureVerificationFailed, 4645); R_DEFINE_ERROR_RESULT(InvalidPartitionEntryOffset, 4646); R_DEFINE_ERROR_RESULT(InvalidSha256PartitionMetaDataSize, 4647); R_DEFINE_ERROR_RANGE(BuiltInStorageCorrupted, 4661, 4679); R_DEFINE_ERROR_RESULT(GptHeaderVerificationFailed, 4662); R_DEFINE_ERROR_RANGE(FatFileSystemCorrupted, 4681, 4699); R_DEFINE_ERROR_RESULT(ExFatUnavailable, 4685); R_DEFINE_ERROR_RANGE(HostFileSystemCorrupted, 4701, 4719); R_DEFINE_ERROR_RESULT(HostEntryCorrupted, 4702); R_DEFINE_ERROR_RESULT(HostFileDataCorrupted, 4703); R_DEFINE_ERROR_RESULT(HostFileCorrupted, 4704); R_DEFINE_ERROR_RESULT(InvalidHostHandle, 4705); R_DEFINE_ERROR_RANGE(DatabaseCorrupted, 4721, 4739); R_DEFINE_ERROR_RESULT(InvalidAllocationTableBlock, 4722); R_DEFINE_ERROR_RESULT(InvalidKeyValueListElementIndex, 4723); R_DEFINE_ERROR_RANGE(AesXtsFileSystemCorrupted, 4741, 4759); R_DEFINE_ERROR_RANGE(SaveDataTransferDataCorrupted, 4761, 4769); R_DEFINE_ERROR_RANGE(SignedSystemPartitionDataCorrupted, 4771, 4779); R_DEFINE_ERROR_RESULT(GameCardLogoDataCorrupted, 4781); R_DEFINE_ERROR_RANGE(Unexpected, 5000, 5999); R_DEFINE_ERROR_RESULT(UnexpectedInLocalFileSystemA, 5305); R_DEFINE_ERROR_RESULT(UnexpectedInLocalFileSystemB, 5306); R_DEFINE_ERROR_RESULT(UnexpectedInLocalFileSystemC, 5307); R_DEFINE_ERROR_RESULT(UnexpectedInLocalFileSystemD, 5308); R_DEFINE_ERROR_RESULT(UnexpectedInLocalFileSystemE, 5309); R_DEFINE_ERROR_RESULT(UnexpectedInLocalFileSystemF, 5310); R_DEFINE_ERROR_RESULT(UnexpectedInPathOnExecutionDirectoryA, 5312); R_DEFINE_ERROR_RESULT(UnexpectedInPathOnExecutionDirectoryB, 5313); R_DEFINE_ERROR_RESULT(UnexpectedInPathOnExecutionDirectoryC, 5314); R_DEFINE_ERROR_RESULT(UnexpectedInAesCtrStorageA, 5315); R_DEFINE_ERROR_RESULT(UnexpectedInAesXtsStorageA, 5316); R_DEFINE_ERROR_RESULT(UnexpectedInFindFileSystemA, 5319); R_DEFINE_ERROR_RESULT(UnexpectedInCompressedStorageA, 5324); R_DEFINE_ERROR_RESULT(UnexpectedInCompressedStorageB, 5325); R_DEFINE_ERROR_RESULT(UnexpectedInCompressedStorageC, 5326); R_DEFINE_ERROR_RESULT(UnexpectedInCompressedStorageD, 5327); R_DEFINE_ERROR_RESULT(UnexpectedInPathA, 5328); R_DEFINE_ERROR_RANGE(PreconditionViolation, 6000, 6499); R_DEFINE_ERROR_RANGE(InvalidArgument, 6001, 6199); R_DEFINE_ERROR_RANGE(InvalidPath, 6002, 6029); R_DEFINE_ERROR_RESULT(TooLongPath, 6003); R_DEFINE_ERROR_RESULT(InvalidCharacter, 6004); R_DEFINE_ERROR_RESULT(InvalidPathFormat, 6005); R_DEFINE_ERROR_RESULT(DirectoryUnobtainable, 6006); R_DEFINE_ERROR_RESULT(NotNormalized, 6007); R_DEFINE_ERROR_RANGE(InvalidPathForOperation, 6030, 6059); R_DEFINE_ERROR_RESULT(DirectoryNotDeletable, 6031); R_DEFINE_ERROR_RESULT(DirectoryNotRenamable, 6032); R_DEFINE_ERROR_RESULT(IncompatiblePath, 6033); R_DEFINE_ERROR_RESULT(RenameToOtherFileSystem, 6034); R_DEFINE_ERROR_RESULT(InvalidOffset, 6061); R_DEFINE_ERROR_RESULT(InvalidSize, 6062); R_DEFINE_ERROR_RESULT(NullptrArgument, 6063); R_DEFINE_ERROR_RESULT(InvalidAlignment, 6064); R_DEFINE_ERROR_RESULT(InvalidMountName, 6065); R_DEFINE_ERROR_RESULT(ExtensionSizeTooLarge, 6066); R_DEFINE_ERROR_RESULT(ExtensionSizeInvalid, 6067); R_DEFINE_ERROR_RESULT(InvalidOpenMode, 6072); R_DEFINE_ERROR_RESULT(TooLargeSize, 6073); R_DEFINE_ERROR_RANGE(InvalidEnumValue, 6080, 6099); R_DEFINE_ERROR_RESULT(InvalidSaveDataState, 6081); R_DEFINE_ERROR_RESULT(InvalidSaveDataSpaceId, 6082); R_DEFINE_ERROR_RANGE(InvalidOperationForOpenMode, 6200, 6299); R_DEFINE_ERROR_RESULT(FileExtensionWithoutOpenModeAllowAppend, 6201); R_DEFINE_ERROR_RESULT(ReadNotPermitted, 6202); R_DEFINE_ERROR_RESULT(WriteNotPermitted, 6203); R_DEFINE_ERROR_RANGE(UnsupportedOperation, 6300, 6399); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForNotResizableSubStorage, 6302); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForResizableSubStorage, 6303); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForMemoryStorage, 6304); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForMemoryStorage, 6305); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForFileStorage, 6306); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForFileHandleStorage, 6307); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForSwitchStorage, 6308); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForStorageServiceObjectAdapter, 6309); R_DEFINE_ERROR_RESULT(UnsupportedWriteForAesCtrCounterExtendedStorage, 6310); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForAesCtrCounterExtendedStorage, 6311); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForAesCtrCounterExtendedStorage, 6312); R_DEFINE_ERROR_RESULT(UnsupportedWriteForAesCtrStorageExternal, 6313); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForAesCtrStorageExternal, 6314); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForAesCtrStorage, 6315); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForHierarchicalIntegrityVerificationStorage, 6316); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForHierarchicalIntegrityVerificationStorage, 6317); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForIntegrityVerificationStorage, 6318); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForWritableIntegrityVerificationStorage, 6319); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForIntegrityVerificationStorage, 6320); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForBlockCacheBufferedStorage, 6321); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForWritableBlockCacheBufferedStorage, 6322); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForBlockCacheBufferedStorage, 6323); R_DEFINE_ERROR_RESULT(UnsupportedWriteForIndirectStorage, 6324); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForIndirectStorage, 6325); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForIndirectStorage, 6326); R_DEFINE_ERROR_RESULT(UnsupportedWriteForZeroStorage, 6327); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForZeroStorage, 6328); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForHierarchicalSha256Storage, 6329); R_DEFINE_ERROR_RESULT(UnsupportedWriteForReadOnlyBlockCacheStorage, 6330); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForReadOnlyBlockCacheStorage, 6331); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForIntegrityRomFsStorage, 6332); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForDuplexStorage, 6333); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForDuplexStorage, 6334); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForHierarchicalDuplexStorage, 6335); R_DEFINE_ERROR_RESULT(UnsupportedGetSizeForRemapStorage, 6336); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForRemapStorage, 6337); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForRemapStorage, 6338); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForIntegritySaveDataStorage, 6339); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForIntegritySaveDataStorage, 6340); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForJournalIntegritySaveDataStorage, 6341); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForJournalIntegritySaveDataStorage, 6342); R_DEFINE_ERROR_RESULT(UnsupportedGetSizeForJournalStorage, 6343); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForJournalStorage, 6344); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForJournalStorage, 6345); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForUnionStorage, 6346); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForAllocationTableStorage, 6347); R_DEFINE_ERROR_RESULT(UnsupportedReadForWriteOnlyGameCardStorage, 6348); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForWriteOnlyGameCardStorage, 6349); R_DEFINE_ERROR_RESULT(UnsupportedWriteForReadOnlyGameCardStorage, 6350); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForReadOnlyGameCardStorage, 6351); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForReadOnlyGameCardStorage, 6352); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForSdmmcStorage, 6353); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForSdmmcStorage, 6354); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForFatFile, 6355); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForStorageFile, 6356); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForInternalStorageConcatenationFile, 6357); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForInternalStorageConcatenationFile, 6358); R_DEFINE_ERROR_RESULT(UnsupportedQueryEntryForConcatenationFileSystem, 6359); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForConcatenationFile, 6360); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForZeroBitmapFile, 6361); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForFileServiceObjectAdapter, 6362); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForAesXtsFile, 6363); R_DEFINE_ERROR_RESULT(UnsupportedWriteForRomFsFileSystem, 6364); R_DEFINE_ERROR_RESULT(UnsupportedCommitProvisionallyForRomFsFileSystem, 6365); R_DEFINE_ERROR_RESULT(UnsupportedGetTotalSpaceSizeForRomFsFileSystem, 6366); R_DEFINE_ERROR_RESULT(UnsupportedWriteForRomFsFile, 6367); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForRomFsFile, 6368); R_DEFINE_ERROR_RESULT(UnsupportedWriteForReadOnlyFileSystem, 6369); R_DEFINE_ERROR_RESULT(UnsupportedCommitProvisionallyForReadOnlyFileSystem, 6370); R_DEFINE_ERROR_RESULT(UnsupportedGetTotalSpaceSizeForReadOnlyFileSystem, 6371); R_DEFINE_ERROR_RESULT(UnsupportedWriteForReadOnlyFile, 6372); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForReadOnlyFile, 6373); R_DEFINE_ERROR_RESULT(UnsupportedWriteForPartitionFileSystem, 6374); R_DEFINE_ERROR_RESULT(UnsupportedCommitProvisionallyForPartitionFileSystem, 6375); R_DEFINE_ERROR_RESULT(UnsupportedWriteForPartitionFile, 6376); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForPartitionFile, 6377); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForTmFileSystemFile, 6378); R_DEFINE_ERROR_RESULT(UnsupportedWriteForSaveDataInternalStorageFileSystem, 6379); R_DEFINE_ERROR_RESULT(UnsupportedCommitProvisionallyForApplicationTemporaryFileSystem, 6382); R_DEFINE_ERROR_RESULT(UnsupportedCommitProvisionallyForSaveDataFileSystem, 6383); R_DEFINE_ERROR_RESULT(UnsupportedCommitProvisionallyForDirectorySaveDataFileSystem, 6384); R_DEFINE_ERROR_RESULT(UnsupportedWriteForZeroBitmapHashStorageFile, 6385); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForZeroBitmapHashStorageFile, 6386); R_DEFINE_ERROR_RESULT(UnsupportedWriteForCompressedStorage, 6387); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForCompressedStorage, 6388); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForRegionSwitchStorage, 6397); R_DEFINE_ERROR_RANGE(PermissionDenied, 6400, 6449); R_DEFINE_ERROR_RESULT(PermissionDeniedForCreateHostFileSystem, 6403); R_DEFINE_ERROR_RESULT(PortAcceptableCountLimited, 6450); R_DEFINE_ERROR_RESULT(NcaExternalKeyUnregistered, 6451); R_DEFINE_ERROR_RESULT(NcaExternalKeyInconsistent, 6452); R_DEFINE_ERROR_RESULT(NeedFlush, 6454); R_DEFINE_ERROR_RESULT(FileNotClosed, 6455); R_DEFINE_ERROR_RESULT(DirectoryNotClosed, 6456); R_DEFINE_ERROR_RESULT(WriteModeFileNotClosed, 6457); R_DEFINE_ERROR_RESULT(AllocatorAlreadyRegistered, 6458); R_DEFINE_ERROR_RESULT(DefaultAllocatorUsed, 6459); R_DEFINE_ERROR_RESULT(AllocatorAlignmentViolation, 6461); R_DEFINE_ERROR_RESULT(UserNotExist, 6465); R_DEFINE_ERROR_RANGE(NotFound, 6600, 6699); R_DEFINE_ERROR_RESULT(ProgramInfoNotFound, 6605); R_DEFINE_ERROR_RANGE(OutOfResource, 6700, 6799); R_DEFINE_ERROR_RESULT(BufferAllocationFailed, 6705); R_DEFINE_ERROR_RESULT(MappingTableFull, 6706); R_DEFINE_ERROR_RESULT(OpenCountLimit, 6709); R_DEFINE_ERROR_RANGE(MappingFailed, 6800, 6899); R_DEFINE_ERROR_RESULT(MapFull, 6811); R_DEFINE_ERROR_RANGE(BadState, 6900, 6999); R_DEFINE_ERROR_RESULT(NotInitialized, 6902); R_DEFINE_ERROR_RESULT(NotMounted, 6905); R_DEFINE_ERROR_RANGE(DbmNotFound, 7901, 7904); R_DEFINE_ERROR_RESULT(DbmKeyNotFound, 7902); R_DEFINE_ERROR_RESULT(DbmFileNotFound, 7903); R_DEFINE_ERROR_RESULT(DbmDirectoryNotFound, 7904); R_DEFINE_ERROR_RESULT(DbmAlreadyExists, 7906); R_DEFINE_ERROR_RESULT(DbmKeyFull, 7907); R_DEFINE_ERROR_RESULT(DbmDirectoryEntryFull, 7908); R_DEFINE_ERROR_RESULT(DbmFileEntryFull, 7909); R_DEFINE_ERROR_RANGE(DbmFindFinished, 7910, 7912); R_DEFINE_ERROR_RESULT(DbmFindKeyFinished, 7911); R_DEFINE_ERROR_RESULT(DbmIterationFinished, 7912); R_DEFINE_ERROR_RESULT(DbmInvalidOperation, 7914); R_DEFINE_ERROR_RESULT(DbmInvalidPathFormat, 7915); R_DEFINE_ERROR_RESULT(DbmDirectoryNameTooLong, 7916); R_DEFINE_ERROR_RESULT(DbmFileNameTooLong, 7917); }
48,820
C++
.h
538
74.680297
116
0.605115
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,998
sprofile_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/sprofile_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::sprofile, 246); namespace ams::sprofile { R_DEFINE_ERROR_RESULT(InvalidArgument, 100); R_DEFINE_ERROR_RESULT(InvalidState, 101); R_DEFINE_ERROR_RESULT(NotPermitted, 303); R_DEFINE_ERROR_RESULT(AllocationFailed, 401); R_DEFINE_ERROR_RESULT(KeyNotFound, 600); R_DEFINE_ERROR_RESULT(InvalidDataType, 601); R_DEFINE_ERROR_RESULT(MaxListeners, 620); R_DEFINE_ERROR_RESULT(AlreadyListening, 621); R_DEFINE_ERROR_RESULT(NotListening, 622); R_DEFINE_ERROR_RESULT(MaxObservers, 623); R_DEFINE_ERROR_RESULT(InvalidMetadataVersion, 3210); R_DEFINE_ERROR_RESULT(InvalidMetadataHash, 3211); R_DEFINE_ERROR_RESULT(InvalidDataVersion, 3230); R_DEFINE_ERROR_RESULT(InvalidDataHash, 3231); }
1,514
C++
.h
34
41.176471
76
0.736735
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,999
spl_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/spl_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::spl, 26); namespace ams::spl { R_DEFINE_ERROR_RANGE(SecureMonitorError, 0, 99); R_DEFINE_ERROR_RESULT(SecureMonitorNotSupported, 1); R_DEFINE_ERROR_RESULT(SecureMonitorInvalidArgument, 2); R_DEFINE_ERROR_RESULT(SecureMonitorBusy, 3); R_DEFINE_ERROR_RESULT(SecureMonitorNoAsyncOperation, 4); R_DEFINE_ERROR_RESULT(SecureMonitorInvalidAsyncOperation, 5); R_DEFINE_ERROR_RESULT(SecureMonitorNotPermitted, 6); R_DEFINE_ERROR_RESULT(SecureMonitorNotInitialized, 7); R_DEFINE_ERROR_RESULT(InvalidBufferSize, 100); R_DEFINE_ERROR_RESULT(UnexpectedSecureMonitorResult, 101); R_DEFINE_ERROR_RESULT(DecryptionFailed, 102); R_DEFINE_ERROR_RESULT(InvalidDeviceUniqueDataType, 103); R_DEFINE_ERROR_RESULT(NoAvailableKeySlot, 104); R_DEFINE_ERROR_RESULT(InvalidKeySlot, 105); R_DEFINE_ERROR_RESULT(BootReasonAlreadyInitialized, 106); R_DEFINE_ERROR_RESULT(BootReasonNotInitialized, 107); R_DEFINE_ERROR_RESULT(InvalidArgument, 108); }
1,881
C++
.h
37
46.702703
76
0.707291
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,000
erpt_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/erpt_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::erpt, 147); namespace ams::erpt { R_DEFINE_ERROR_RESULT(NotInitialized, 1); R_DEFINE_ERROR_RESULT(AlreadyInitialized, 2); R_DEFINE_ERROR_RESULT(OutOfArraySpace, 3); R_DEFINE_ERROR_RESULT(OutOfFieldSpace, 4); R_DEFINE_ERROR_RESULT(OutOfMemory, 5); R_DEFINE_ERROR_RESULT(NotSupported, 6); R_DEFINE_ERROR_RESULT(InvalidArgument, 7); R_DEFINE_ERROR_RESULT(NotFound, 8); R_DEFINE_ERROR_RESULT(FieldCategoryMismatch, 9); R_DEFINE_ERROR_RESULT(FieldTypeMismatch, 10); R_DEFINE_ERROR_RESULT(AlreadyExists, 11); R_DEFINE_ERROR_RESULT(CorruptJournal, 12); R_DEFINE_ERROR_RESULT(CategoryNotFound, 13); R_DEFINE_ERROR_RESULT(RequiredContextMissing, 14); R_DEFINE_ERROR_RESULT(RequiredFieldMissing, 15); R_DEFINE_ERROR_RESULT(FormatterError, 16); R_DEFINE_ERROR_RESULT(InvalidPowerState, 17); R_DEFINE_ERROR_RESULT(ArrayFieldTooLarge, 18); R_DEFINE_ERROR_RESULT(AlreadyOwned, 19); }
1,856
C++
.h
39
44.153846
76
0.680464
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,001
usb_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/usb_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::usb, 140); namespace ams::usb { R_DEFINE_ERROR_RESULT(NotInitialized, 0); R_DEFINE_ERROR_RESULT(AlreadyInitialized, 1); R_DEFINE_ERROR_RANGE(InvalidParameter, 100, 199); R_DEFINE_ERROR_RESULT(AlignmentError, 103); R_DEFINE_ERROR_RESULT(OperationDenied, 201); R_DEFINE_ERROR_RESULT(MemAllocFailure, 202); R_DEFINE_ERROR_RESULT(ResourceBusy, 206); R_DEFINE_ERROR_RESULT(InternalStateError, 207); R_DEFINE_ERROR_RESULT(TransactionError, 401); R_DEFINE_ERROR_RESULT(Interrupted, 409); }
1,295
C++
.h
30
40
76
0.735294
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,002
htclow_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/htclow_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::htclow, 29); namespace ams::htclow { R_DEFINE_ERROR_RESULT(ConnectionFailure, 1); R_DEFINE_ERROR_RESULT(UnknownDriverType, 3); R_DEFINE_ERROR_RESULT(NonBlockingReceiveFailed, 5); R_DEFINE_ERROR_RESULT(ChannelWaitCancelled, 8); R_DEFINE_ERROR_RESULT(ChannelAlreadyExist, 9); R_DEFINE_ERROR_RESULT(ChannelNotExist, 10); R_DEFINE_ERROR_RESULT(OutOfChannel, 151); R_DEFINE_ERROR_RESULT(OutOfTask, 152); R_DEFINE_ERROR_RESULT(InvalidChannelState, 200); R_DEFINE_ERROR_RESULT(InvalidChannelStateDisconnected, 201); R_DEFINE_ERROR_RANGE(InternalError, 1000, 2999); R_DEFINE_ERROR_RESULT(Overflow, 1001); R_DEFINE_ERROR_RESULT(OutOfMemory, 1002); R_DEFINE_ERROR_RESULT(InvalidArgument, 1003); R_DEFINE_ERROR_RESULT(ProtocolError, 1004); R_DEFINE_ERROR_RESULT(Cancelled, 1005); R_DEFINE_ERROR_RANGE(MuxError, 1100, 1199); R_DEFINE_ERROR_RESULT(ChannelBufferOverflow, 1101); R_DEFINE_ERROR_RESULT(ChannelBufferHasNotEnoughData, 1102); R_DEFINE_ERROR_RESULT(ChannelVersionNotMatched, 1103); R_DEFINE_ERROR_RESULT(ChannelStateTransitionError, 1104); R_DEFINE_ERROR_RESULT(ChannelReceiveBufferEmpty, 1106); R_DEFINE_ERROR_RESULT(ChannelSequenceIdNotMatched, 1107); R_DEFINE_ERROR_RESULT(ChannelCannotDiscard, 1108); R_DEFINE_ERROR_RANGE(DriverError, 1200, 1999); R_DEFINE_ERROR_RESULT(DriverOpened, 1201); R_DEFINE_ERROR_RANGE(SocketDriverError, 1300, 1399); R_DEFINE_ERROR_RESULT(SocketSocketExemptError, 1301); R_DEFINE_ERROR_RESULT(SocketBindError, 1302); R_DEFINE_ERROR_RESULT(SocketListenError, 1304); R_DEFINE_ERROR_RESULT(SocketAcceptError, 1305); R_DEFINE_ERROR_RESULT(SocketReceiveError, 1306); R_DEFINE_ERROR_RESULT(SocketSendError, 1307); R_DEFINE_ERROR_RESULT(SocketReceiveFromError, 1308); R_DEFINE_ERROR_RESULT(SocketSendToError, 1309); R_DEFINE_ERROR_RESULT(SocketSetSockOptError, 1310); R_DEFINE_ERROR_RESULT(SocketGetSockNameError, 1311); R_DEFINE_ERROR_RANGE(UsbDriverError, 1400, 1499); R_DEFINE_ERROR_RESULT(UsbDriverUnknownError, 1401); R_DEFINE_ERROR_RESULT(UsbDriverBusyError, 1402); R_DEFINE_ERROR_RESULT(UsbDriverReceiveError, 1403); R_DEFINE_ERROR_RESULT(UsbDriverSendError, 1404); R_DEFINE_ERROR_RESULT(HtcctrlError, 2000); /* TODO: Range? */ R_DEFINE_ERROR_RESULT(HtcctrlStateTransitionNotAllowed, 2001); R_DEFINE_ERROR_RESULT(HtcctrlReceiveUnexpectedPacket, 2002); }
3,661
C++
.h
65
47.6
76
0.667411
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,003
loader_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/loader_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::ldr, 9); namespace ams::ldr { R_DEFINE_ERROR_RESULT(ArgumentOverflow, 1); R_DEFINE_ERROR_RESULT(ArgumentCountOverflow, 2); R_DEFINE_ERROR_RESULT(MetaOverflow, 3); R_DEFINE_ERROR_RESULT(InvalidMeta, 4); R_DEFINE_ERROR_RESULT(InvalidNso, 5); R_DEFINE_ERROR_RESULT(InvalidPath, 6); R_DEFINE_ERROR_RESULT(MaxProcess, 7); R_DEFINE_ERROR_RESULT(NotPinned, 8); R_DEFINE_ERROR_RESULT(InvalidProgramId, 9); R_DEFINE_ERROR_RESULT(InvalidVersion, 10); R_DEFINE_ERROR_RESULT(InvalidAcidSignature, 11); R_DEFINE_ERROR_RESULT(InvalidNcaSignature, 12); R_DEFINE_ERROR_RESULT(InvalidPlatformId, 14); R_DEFINE_ERROR_RESULT(OutOfAddressSpace, 51); R_DEFINE_ERROR_RESULT(InvalidNroImage, 52); R_DEFINE_ERROR_RESULT(InvalidNrrImage, 53); R_DEFINE_ERROR_RESULT(NotAuthorized, 54); R_DEFINE_ERROR_RESULT(MaxModule, 55); R_DEFINE_ERROR_RESULT(MaxRegistration, 56); R_DEFINE_ERROR_RESULT(NroAlreadyLoaded, 57); R_DEFINE_ERROR_RESULT(InvalidAddress, 81); R_DEFINE_ERROR_RESULT(InvalidSize, 82); R_DEFINE_ERROR_RESULT(InvalidCurrentMemory, 83); R_DEFINE_ERROR_RESULT(NotLoaded, 84); R_DEFINE_ERROR_RESULT(NotRegistered, 85); R_DEFINE_ERROR_RESULT(InvalidSession, 86); R_DEFINE_ERROR_RESULT(InvalidProcess, 87); R_DEFINE_ERROR_RESULT(UnknownCapability, 100); R_DEFINE_ERROR_RESULT(InvalidCapabilityKernelFlags, 103); R_DEFINE_ERROR_RESULT(InvalidCapabilitySyscallMask, 104); R_DEFINE_ERROR_RESULT(InvalidCapabilityMapRange, 106); R_DEFINE_ERROR_RESULT(InvalidCapabilityMapPage, 107); R_DEFINE_ERROR_RESULT(InvalidCapabilityMapRegion, 110); R_DEFINE_ERROR_RESULT(InvalidCapabilityInterruptPair, 111); R_DEFINE_ERROR_RESULT(InvalidCapabilityApplicationType, 113); R_DEFINE_ERROR_RESULT(InvalidCapabilityKernelVersion, 114); R_DEFINE_ERROR_RESULT(InvalidCapabilityHandleTable, 115); R_DEFINE_ERROR_RESULT(InvalidCapabilityDebugFlags, 116); R_DEFINE_ERROR_RESULT(InternalError, 200); }
3,054
C++
.h
59
47.711864
76
0.682747
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,004
vi_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/vi_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::vi, 114); namespace ams::vi { R_DEFINE_ERROR_RESULT(OperationFailed, 1); R_DEFINE_ERROR_RESULT(NotSupported, 6); R_DEFINE_ERROR_RESULT(NotFound, 7); }
922
C++
.h
23
37.73913
76
0.736018
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,005
sm_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/sm_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> R_DEFINE_NAMESPACE_RESULT_MODULE(ams::sm, 21); namespace ams::sm { R_DEFINE_ERROR_RESULT(OutOfProcesses, 1); R_DEFINE_ERROR_RESULT(InvalidClient, 2); R_DEFINE_ERROR_RESULT(OutOfSessions, 3); R_DEFINE_ERROR_RESULT(AlreadyRegistered, 4); R_DEFINE_ERROR_RESULT(OutOfServices, 5); R_DEFINE_ERROR_RESULT(InvalidServiceName, 6); R_DEFINE_ERROR_RESULT(NotRegistered, 7); R_DEFINE_ERROR_RESULT(NotAllowed, 8); R_DEFINE_ERROR_RESULT(TooLargeAccessControl, 9); /* Results 1000-2000 used as extension for Atmosphere Mitm. */ //namespace mitm { R_DEFINE_ERROR_RESULT_NS(mitm, ShouldForwardToSession, 1000); R_DEFINE_ERROR_RESULT_NS(mitm, ProcessNotAssociated, 1100); //} }
1,486
C++
.h
34
40.176471
76
0.710526
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,006
cal_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/cal_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> #include <vapours/results/powctl_results.hpp> namespace ams::cal { using powctl::ResultCalibrationDataCrcError; }
816
C++
.h
21
36.809524
76
0.768647
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,007
exosphere_results.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/results/exosphere_results.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/results/results_common.hpp> /* Please note: These results are all custom, and not official. */ R_DEFINE_NAMESPACE_RESULT_MODULE(ams::exosphere, 444); namespace ams::exosphere { /* Result 1-1000 reserved for Atmosphere. */ R_DEFINE_ERROR_RESULT(NotPresent, 1); R_DEFINE_ERROR_RESULT(VersionMismatch, 2); }
995
C++
.h
24
39.166667
76
0.748447
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,008
sdmmc_common.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/sdmmc/sdmmc_common.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/sdmmc/sdmmc_build_config.hpp> namespace ams::sdmmc { enum BusPower { BusPower_Off = 0, BusPower_1_8V = 1, BusPower_3_3V = 2, }; enum BusWidth { BusWidth_1Bit = 0, BusWidth_4Bit = 1, BusWidth_8Bit = 2, }; enum SpeedMode { SpeedMode_MmcIdentification = 0, SpeedMode_MmcLegacySpeed = 1, SpeedMode_MmcHighSpeed = 2, SpeedMode_MmcHs200 = 3, SpeedMode_MmcHs400 = 4, SpeedMode_SdCardIdentification = 5, SpeedMode_SdCardDefaultSpeed = 6, SpeedMode_SdCardHighSpeed = 7, SpeedMode_SdCardSdr12 = 8, SpeedMode_SdCardSdr25 = 9, SpeedMode_SdCardSdr50 = 10, SpeedMode_SdCardSdr104 = 11, SpeedMode_SdCardDdr50 = 12, SpeedMode_GcAsicFpgaSpeed = 13, SpeedMode_GcAsicSpeed = 14, }; enum Port { Port_Mmc0 = 0, Port_SdCard0 = 1, Port_GcAsic0 = 2, }; struct ErrorInfo { u32 num_activation_failures; u32 num_activation_error_corrections; u32 num_read_write_failures; u32 num_read_write_error_corrections; }; struct DataTransfer { void *buffer; size_t buffer_size; size_t block_size; u32 num_blocks; bool is_read; }; using DeviceDetectionEventCallback = void (*)(void *); constexpr inline size_t SectorSize = 0x200; constexpr inline size_t DeviceCidSize = 0x10; constexpr inline size_t DeviceCsdSize = 0x10; constexpr inline size_t BufferDeviceVirtualAddressAlignment = alignof(ams::dd::DeviceVirtualAddress); static_assert(BufferDeviceVirtualAddressAlignment >= 8); void Initialize(Port port); void Finalize(Port port); #if defined(AMS_SDMMC_USE_PCV_CLOCK_RESET_CONTROL) void SwitchToPcvClockResetControl(); #endif #if defined(AMS_SDMMC_USE_DEVICE_VIRTUAL_ADDRESS) void RegisterDeviceVirtualAddress(Port port, uintptr_t buffer, size_t buffer_size, ams::dd::DeviceVirtualAddress buffer_device_virtual_address); void UnregisterDeviceVirtualAddress(Port port, uintptr_t buffer, size_t buffer_size, ams::dd::DeviceVirtualAddress buffer_device_virtual_address); #endif void ChangeCheckTransferInterval(Port port, u32 ms); void SetDefaultCheckTransferInterval(Port port); Result Activate(Port port); void Deactivate(Port port); Result Read(void *dst, size_t dst_size, Port port, u32 sector_index, u32 num_sectors); Result Write(Port port, u32 sector_index, u32 num_sectors, const void *src, size_t src_size); Result CheckConnection(SpeedMode *out_speed_mode, BusWidth *out_bus_width, Port port); Result GetDeviceSpeedMode(SpeedMode *out, Port port); Result GetDeviceMemoryCapacity(u32 *out_num_sectors, Port port); Result GetDeviceStatus(u32 *out_device_status, Port port); Result GetDeviceCid(void *out, size_t out_size, Port port); Result GetDeviceCsd(void *out, size_t out_size, Port port); void GetAndClearErrorInfo(ErrorInfo *out_error_info, size_t *out_log_size, char *out_log_buffer, size_t log_buffer_size, Port port); }
3,930
C++
.h
92
36.902174
150
0.681425
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,009
sdmmc_sd_card.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/sdmmc/sdmmc_sd_card.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/sdmmc/sdmmc_build_config.hpp> namespace ams::sdmmc { enum SdCardSwitchFunction { SdCardSwitchFunction_CheckSupportedFunction = 0, SdCardSwitchFunction_CheckDefault = 1, SdCardSwitchFunction_CheckHighSpeed = 2, SdCardSwitchFunction_CheckSdr50 = 3, SdCardSwitchFunction_CheckSdr104 = 4, SdCardSwitchFunction_CheckDdr50 = 5, }; constexpr inline size_t SdCardScrSize = 0x08; constexpr inline size_t SdCardSwitchFunctionStatusSize = 0x40; constexpr inline size_t SdCardSdStatusSize = 0x40; constexpr inline size_t SdCardWorkBufferSize = SdCardSdStatusSize; void SetSdCardWorkBuffer(Port port, void *buffer, size_t buffer_size); void PutSdCardToSleep(Port port); void AwakenSdCard(Port port); Result GetSdCardProtectedAreaCapacity(u32 *out_num_sectors, Port port); Result GetSdCardScr(void *dst, size_t dst_size, Port port); Result GetSdCardSwitchFunctionStatus(void *dst, size_t dst_size, Port port, SdCardSwitchFunction switch_function); Result GetSdCardCurrentConsumption(u16 *out_current_consumption, Port port, SpeedMode speed_mode); Result GetSdCardSdStatus(void *dst, size_t dst_size, Port port); Result CheckSdCardConnection(SpeedMode *out_speed_mode, BusWidth *out_bus_width, Port port); bool IsSdCardInserted(Port port); bool IsSdCardRemoved(Port port); void RegisterSdCardDetectionEventCallback(Port port, DeviceDetectionEventCallback callback, void *arg); void UnregisterSdCardDetectionEventCallback(Port port); }
2,311
C++
.h
44
48.181818
118
0.738264
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,010
sdmmc_build_config.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/sdmmc/sdmmc_build_config.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/results.hpp> #include <vapours/util.hpp> #include <vapours/svc.hpp> #include <vapours/dd.hpp> #if defined(ATMOSPHERE_IS_EXOSPHERE) //#define AMS_SDMMC_THREAD_SAFE //#define AMS_SDMMC_USE_DEVICE_VIRTUAL_ADDRESS //#define AMS_SDMMC_USE_PCV_CLOCK_RESET_CONTROL //#define AMS_SDMMC_USE_DEVICE_DETECTOR //#define AMS_SDMMC_USE_LOGGER //#define AMS_SDMMC_USE_OS_EVENTS //#define AMS_SDMMC_USE_OS_TIMER #define AMS_SDMMC_USE_UTIL_TIMER #define AMS_SDMMC_ENABLE_MMC_HS400 #define AMS_SDMMC_ENABLE_SD_UHS_I #define AMS_SDMMC_SET_PLLC4_BASE //#define AMS_SDMMC_USE_SD_CARD_DETECTOR #elif defined(ATMOSPHERE_IS_MESOSPHERE) //#define AMS_SDMMC_THREAD_SAFE //#define AMS_SDMMC_USE_DEVICE_VIRTUAL_ADDRESS //#define AMS_SDMMC_USE_PCV_CLOCK_RESET_CONTROL //#define AMS_SDMMC_USE_DEVICE_DETECTOR //#define AMS_SDMMC_USE_LOGGER //#define AMS_SDMMC_USE_OS_EVENTS //#define AMS_SDMMC_USE_OS_TIMER #define AMS_SDMMC_USE_UTIL_TIMER //#define AMS_SDMMC_ENABLE_MMC_HS400 //#define AMS_SDMMC_ENABLE_SD_UHS_I //#define AMS_SDMMC_SET_PLLC4_BASE //#define AMS_SDMMC_USE_SD_CARD_DETECTOR #elif defined(ATMOSPHERE_IS_STRATOSPHERE) #define AMS_SDMMC_THREAD_SAFE #define AMS_SDMMC_USE_DEVICE_VIRTUAL_ADDRESS #define AMS_SDMMC_USE_PCV_CLOCK_RESET_CONTROL #define AMS_SDMMC_USE_DEVICE_DETECTOR #define AMS_SDMMC_USE_LOGGER #define AMS_SDMMC_USE_OS_EVENTS #define AMS_SDMMC_USE_OS_TIMER //#define AMS_SDMMC_USE_UTIL_TIMER #define AMS_SDMMC_ENABLE_MMC_HS400 #define AMS_SDMMC_ENABLE_SD_UHS_I #define AMS_SDMMC_SET_PLLC4_BASE #define AMS_SDMMC_USE_SD_CARD_DETECTOR #else #error "Unknown execution context for ams::sdmmc!" #endif
2,474
C++
.h
64
35
76
0.73647
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,011
sdmmc_gc_asic.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/sdmmc/sdmmc_gc_asic.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/sdmmc/sdmmc_build_config.hpp> namespace ams::sdmmc { constexpr inline size_t GcAsicOperationSize = 0x40; void PutGcAsicToSleep(Port port); Result AwakenGcAsic(Port port); Result WriteGcAsicOperation(Port port, const void *op_buf, size_t op_buf_size); Result FinishGcAsicOperation(Port port); Result AbortGcAsicOperation(Port port); Result SleepGcAsic(Port port); Result UpdateGcAsicKey(Port port); void SignalGcRemovedEvent(Port port); void ClearGcRemovedEvent(Port port); }
1,186
C++
.h
29
37.862069
83
0.763021
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,012
sdmmc_mmc.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/sdmmc/sdmmc_mmc.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/sdmmc/sdmmc_build_config.hpp> namespace ams::sdmmc { enum MmcPartition { MmcPartition_UserData = 0, MmcPartition_BootPartition1 = 1, MmcPartition_BootPartition2 = 2, MmcPartition_Unknown = 3, }; constexpr inline size_t MmcExtendedCsdSize = 0x200; constexpr inline size_t MmcWorkBufferSize = MmcExtendedCsdSize; void SetMmcWorkBuffer(Port port, void *buffer, size_t buffer_size); void PutMmcToSleep(Port port); void AwakenMmc(Port port); Result SelectMmcPartition(Port port, MmcPartition mmc_partition); Result EraseMmc(Port port); Result GetMmcBootPartitionCapacity(u32 *out_num_sectors, Port port); Result GetMmcExtendedCsd(void *out_buffer, size_t buffer_size, Port port); Result CheckMmcConnection(SpeedMode *out_speed_mode, BusWidth *out_bus_width, Port port); }
1,534
C++
.h
35
39.942857
93
0.742627
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,013
crypto_aes_ccm_encryptor_decryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_aes_ccm_encryptor_decryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_aes_encryptor.hpp> #include <vapours/crypto/crypto_ccm_encryptor.hpp> #include <vapours/crypto/crypto_ccm_decryptor.hpp> namespace ams::crypto { namespace impl { template<template<typename> typename _CcmImpl, typename _AesImpl> class AesCcmCryptor { NON_COPYABLE(AesCcmCryptor); NON_MOVEABLE(AesCcmCryptor); private: using AesImpl = _AesImpl; using CcmImpl = _CcmImpl<AesImpl>; public: static constexpr size_t KeySize = CcmImpl::KeySize; static constexpr size_t BlockSize = CcmImpl::BlockSize; static constexpr size_t MaxMacSize = CcmImpl::MaxMacSize; static constexpr size_t MaxNonceSize = CcmImpl::MaxNonceSize; private: AesImpl m_aes_impl; CcmImpl m_ccm_impl; public: AesCcmCryptor() { /* ... */ } void Initialize(const void *key, size_t key_size, const void *nonce, size_t nonce_size, s64 aad_size, s64 data_size, size_t mac_size) { AMS_ASSERT(key_size == KeySize); AMS_ASSERT(nonce_size <= MaxNonceSize); AMS_ASSERT(mac_size <= MaxMacSize); m_aes_impl.Initialize(key, key_size); m_ccm_impl.Initialize(std::addressof(m_aes_impl), nonce, nonce_size, aad_size, data_size, mac_size); } size_t Update(void *dst, size_t dst_size, const void *src, size_t src_size) { return m_ccm_impl.Update(dst, dst_size, src, src_size); } void UpdateAad(const void *aad, size_t aad_size) { return m_ccm_impl.UpdateAad(aad, aad_size); } void GetMac(void *dst, size_t dst_size) { return m_ccm_impl.GetMac(dst, dst_size); } }; } using Aes128CcmEncryptor = impl::AesCcmCryptor<CcmEncryptor, AesEncryptor128>; using Aes128CcmDecryptor = impl::AesCcmCryptor<CcmDecryptor, AesEncryptor128>; inline size_t EncryptAes128Ccm(void *dst, size_t dst_size, void *mac, size_t mac_buf_size, const void *key, size_t key_size, const void *nonce, size_t nonce_size, const void *src, size_t src_size, const void *aad, size_t aad_size, size_t mac_size) { /* Create encryptor. */ Aes128CcmEncryptor ccm; ccm.Initialize(key, key_size, nonce, nonce_size, aad_size, src_size, mac_size); /* Process aad. */ if (aad_size > 0) { ccm.UpdateAad(aad, aad_size); } /* Process data. */ size_t processed = 0; if (src_size > 0) { processed = ccm.Update(dst, dst_size, src, src_size); } /* Get mac. */ ccm.GetMac(mac, mac_buf_size); return processed; } inline size_t DecryptAes128Ccm(void *dst, size_t dst_size, void *mac, size_t mac_buf_size, const void *key, size_t key_size, const void *nonce, size_t nonce_size, const void *src, size_t src_size, const void *aad, size_t aad_size, size_t mac_size) { /* Create decryptor. */ Aes128CcmDecryptor ccm; ccm.Initialize(key, key_size, nonce, nonce_size, aad_size, src_size, mac_size); /* Process aad. */ if (aad_size > 0) { ccm.UpdateAad(aad, aad_size); } /* Process data. */ size_t processed = 0; if (src_size > 0) { processed = ccm.Update(dst, dst_size, src, src_size); } /* Get mac. */ ccm.GetMac(mac, mac_buf_size); return processed; } }
4,449
C++
.h
96
36.5
253
0.604753
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,014
crypto_cmac_generator.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_cmac_generator.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_cmac_impl.hpp> namespace ams::crypto { template<typename BlockCipher> class CmacGenerator { NON_COPYABLE(CmacGenerator); NON_MOVEABLE(CmacGenerator); private: using Impl = impl::CmacImpl<BlockCipher>; public: static constexpr size_t MacSize = BlockCipher::BlockSize; private: Impl m_impl; public: CmacGenerator() { /* ... */ } void Initialize(const BlockCipher *cipher) { return m_impl.Initialize(cipher); } void Update(const void *data, size_t size) { return m_impl.Update(data, size); } void GetMac(void *dst, size_t dst_size) { return m_impl.GetMac(dst, dst_size); } }; }
1,583
C++
.h
44
29.318182
76
0.653394
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,015
crypto_hmac_sha1_generator.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_hmac_sha1_generator.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/crypto/crypto_sha1_generator.hpp> #include <vapours/crypto/crypto_hmac_generator.hpp> namespace ams::crypto { using HmacSha1Generator = HmacGenerator<Sha1Generator>; void GenerateHmacSha1(void *dst, size_t dst_size, const void *data, size_t data_size, const void *key, size_t key_size); ALWAYS_INLINE void GenerateHmacSha1Mac(void *dst, size_t dst_size, const void *data, size_t data_size, const void *key, size_t key_size) { return GenerateHmacSha1(dst, dst_size, data, data_size, key, key_size); } }
1,198
C++
.h
25
45.16
142
0.750643
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,016
crypto_rsa_oaep_decryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_rsa_oaep_decryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_rsa_calculator.hpp> #include <vapours/crypto/impl/crypto_rsa_oaep_impl.hpp> namespace ams::crypto { template<size_t ModulusSize, typename Hash> requires impl::HashFunction<Hash> class RsaOaepDecryptor { NON_COPYABLE(RsaOaepDecryptor); NON_MOVEABLE(RsaOaepDecryptor); public: static constexpr size_t HashSize = Hash::HashSize; static constexpr size_t BlockSize = ModulusSize; static constexpr size_t MaximumExponentSize = ModulusSize; static constexpr size_t RequiredWorkBufferSize = RsaCalculator<ModulusSize, MaximumExponentSize>::RequiredWorkBufferSize; private: enum class State { None, Initialized, Done, }; private: RsaCalculator<ModulusSize, MaximumExponentSize> m_calculator; Hash m_hash; bool m_set_label_digest; u8 m_label_digest[HashSize]; State m_state; public: RsaOaepDecryptor() : m_set_label_digest(false), m_state(State::None) { std::memset(m_label_digest, 0, sizeof(m_label_digest)); } ~RsaOaepDecryptor() { ClearMemory(m_label_digest, sizeof(m_label_digest)); } bool Initialize(const void *mod, size_t mod_size, const void *exp, size_t exp_size) { m_hash.Initialize(); m_set_label_digest = false; if (m_calculator.Initialize(mod, mod_size, exp, exp_size)) { m_state = State::Initialized; return true; } else { return false; } } void UpdateLabel(const void *data, size_t size) { AMS_ASSERT(m_state == State::Initialized); m_hash.Update(data, size); } void SetLabelDigest(const void *digest, size_t digest_size) { AMS_ASSERT(m_state == State::Initialized); AMS_ABORT_UNLESS(digest_size == sizeof(m_label_digest)); std::memcpy(m_label_digest, digest, digest_size); m_set_label_digest = true; } size_t Decrypt(void *dst, size_t dst_size, const void *src, size_t src_size) { AMS_ASSERT(m_state == State::Initialized); impl::RsaOaepImpl<Hash> impl; u8 message[BlockSize]; ON_SCOPE_EXIT { ClearMemory(message, sizeof(message)); }; if (!m_calculator.ExpMod(message, src, src_size)) { std::memset(dst, 0, dst_size); return false; } if (!m_set_label_digest) { m_hash.GetHash(m_label_digest, sizeof(m_label_digest)); } ON_SCOPE_EXIT { m_state = State::Done; }; return impl.Decode(dst, dst_size, m_label_digest, sizeof(m_label_digest), message, sizeof(message)); } size_t Decrypt(void *dst, size_t dst_size, const void *src, size_t src_size, void *work_buf, size_t work_buf_size) { AMS_ASSERT(m_state == State::Initialized); ON_SCOPE_EXIT { m_state = State::Done; }; impl::RsaOaepImpl<Hash> impl; u8 message[BlockSize]; ON_SCOPE_EXIT { ClearMemory(message, sizeof(message)); }; if (!m_calculator.ExpMod(message, src, src_size, work_buf, work_buf_size)) { return false; } if (!m_set_label_digest) { m_hash.GetHash(m_label_digest, sizeof(m_label_digest)); m_set_label_digest = true; } return impl.Decode(dst, dst_size, m_label_digest, sizeof(m_label_digest), message, sizeof(message)); } static size_t Decrypt(void *dst, size_t dst_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size, const void *lab, size_t lab_size) { RsaOaepDecryptor<ModulusSize, Hash> crypt; if (!crypt.Initialize(mod, mod_size, exp, exp_size)) { return 0; } crypt.UpdateLabel(lab, lab_size); return crypt.Decrypt(dst, dst_size, msg, msg_size); } static size_t Decrypt(void *dst, size_t dst_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size, const void *lab, size_t lab_size, void *work_buf, size_t work_buf_size) { RsaOaepDecryptor<ModulusSize, Hash> crypt; if (!crypt.Initialize(mod, mod_size, exp, exp_size)) { return 0; } crypt.UpdateLabel(lab, lab_size); return crypt.Decrypt(dst, dst_size, msg, msg_size, work_buf, work_buf_size); } }; }
5,791
C++
.h
116
37.077586
237
0.572642
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,017
crypto_rsa_pkcs1_verifier.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_rsa_pkcs1_verifier.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_rsa_calculator.hpp> #include <vapours/crypto/impl/crypto_rsa_pkcs1_impl.hpp> namespace ams::crypto { template<size_t _ModulusSize, impl::HashFunction Hash> class RsaPkcs1Verifier { NON_COPYABLE(RsaPkcs1Verifier); NON_MOVEABLE(RsaPkcs1Verifier); public: static constexpr size_t HashSize = Hash::HashSize; static constexpr size_t ModulusSize = _ModulusSize; static constexpr size_t SignatureSize = ModulusSize; static constexpr size_t MaximumExponentSize = 3; static constexpr size_t RequiredWorkBufferSize = RsaCalculator<ModulusSize, MaximumExponentSize>::RequiredWorkBufferSize; private: enum class State { None, Initialized, Done, }; private: RsaCalculator<ModulusSize, MaximumExponentSize> m_calculator; Hash m_hash; State m_state; public: RsaPkcs1Verifier() : m_state(State::None) { /* ... */ } bool Initialize(const void *mod, size_t mod_size, const void *exp, size_t exp_size) { m_hash.Initialize(); if (m_calculator.Initialize(mod, mod_size, exp, exp_size)) { m_state = State::Initialized; return true; } else { return false; } } void Update(const void *data, size_t size) { AMS_ASSERT(m_state == State::Initialized); return m_hash.Update(data, size); } bool Verify(const void *signature, size_t size) { AMS_ASSERT(m_state == State::Initialized); AMS_ASSERT(size == SignatureSize); AMS_UNUSED(size); ON_SCOPE_EXIT { m_state = State::Done; }; impl::RsaPkcs1Impl<Hash> impl; u8 message[SignatureSize]; return m_calculator.ExpMod(message, signature, SignatureSize) && impl.CheckPad(message, sizeof(message), std::addressof(m_hash)); } bool Verify(const void *signature, size_t size, void *work_buf, size_t work_buf_size) { AMS_ASSERT(m_state == State::Initialized); AMS_ASSERT(size == SignatureSize); AMS_UNUSED(size); ON_SCOPE_EXIT { m_state = State::Done; }; impl::RsaPkcs1Impl<Hash> impl; u8 message[SignatureSize]; return m_calculator.ExpMod(message, signature, SignatureSize, work_buf, work_buf_size) && impl.CheckPad(message, sizeof(message), std::addressof(m_hash)); } void GetHash(void *dst, size_t dst_size) { AMS_ASSERT(m_state == State::Done); if (m_state == State::Done) { m_hash.GetHash(dst, dst_size); } } static bool Verify(const void *sig, size_t sig_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size) { RsaPkcs1Verifier<ModulusSize, Hash> verifier; if (!verifier.Initialize(mod, mod_size, exp, exp_size)) { return false; } verifier.Update(msg, msg_size); return verifier.Verify(sig, sig_size); } static bool Verify(const void *sig, size_t sig_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size, void *work_buf, size_t work_buf_size) { RsaPkcs1Verifier<ModulusSize, Hash> verifier; if (!verifier.Initialize(mod, mod_size, exp, exp_size)) { return false; } verifier.Update(msg, msg_size); return verifier.Verify(sig, sig_size, work_buf, work_buf_size); } }; }
4,769
C++
.h
99
36.20202
206
0.583799
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,018
crypto_aes_128_cmac_generator.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_aes_128_cmac_generator.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_aes_encryptor.hpp> #include <vapours/crypto/crypto_cmac_generator.hpp> namespace ams::crypto { class Aes128CmacGenerator { NON_COPYABLE(Aes128CmacGenerator); NON_MOVEABLE(Aes128CmacGenerator); public: static constexpr size_t MacSize = AesEncryptor128::BlockSize; private: AesEncryptor128 m_aes; CmacGenerator<AesEncryptor128> m_cmac_generator; public: Aes128CmacGenerator() { /* ... */ } void Initialize(const void *key, size_t key_size) { AMS_ASSERT(key_size == AesEncryptor128::KeySize); m_aes.Initialize(key, key_size); m_cmac_generator.Initialize(std::addressof(m_aes)); } void Update(const void *data, size_t size) { m_cmac_generator.Update(data, size); } void GetMac(void *dst, size_t size) { m_cmac_generator.GetMac(dst, size); } }; ALWAYS_INLINE void GenerateAes128Cmac(void *dst, size_t dst_size, const void *data, size_t data_size, const void *key, size_t key_size) { Aes128CmacGenerator cmac_generator; cmac_generator.Initialize(key, key_size); cmac_generator.Update(data, data_size); cmac_generator.GetMac(dst, dst_size); } }
2,104
C++
.h
51
34.137255
141
0.666667
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,019
crypto_ctr_encryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_ctr_encryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_ctr_mode_impl.hpp> namespace ams::crypto { /* TODO: C++20 BlockCipher concept */ template<typename BlockCipher> class CtrEncryptor { NON_COPYABLE(CtrEncryptor); NON_MOVEABLE(CtrEncryptor); private: using Impl = impl::CtrModeImpl<BlockCipher>; public: static constexpr size_t KeySize = Impl::KeySize; static constexpr size_t BlockSize = Impl::BlockSize; static constexpr size_t IvSize = Impl::IvSize; private: Impl m_impl; public: CtrEncryptor() { /* ... */ } void Initialize(const BlockCipher *cipher, const void *iv, size_t iv_size) { m_impl.Initialize(cipher, iv, iv_size); } void Initialize(const BlockCipher *cipher, const void *iv, size_t iv_size, s64 offset) { m_impl.Initialize(cipher, iv, iv_size, offset); } void SwitchMessage(const void *iv, size_t iv_size) { m_impl.SwitchMessage(iv, iv_size); } size_t Update(void *dst, size_t dst_size, const void *src, size_t src_size) { return m_impl.Update(dst, dst_size, src, src_size); } }; }
2,027
C++
.h
50
33.16
100
0.643293
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,020
crypto_csrng.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_csrng.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> namespace ams::crypto { void GenerateCryptographicallyRandomBytes(void *dst, size_t dst_size); }
841
C++
.h
22
36.227273
76
0.764417
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,021
crypto_ccm_encryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_ccm_encryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_ccm_mode_impl.hpp> namespace ams::crypto { template<typename BlockCipher> class CcmEncryptor { NON_COPYABLE(CcmEncryptor); NON_MOVEABLE(CcmEncryptor); private: using Impl = impl::CcmModeImpl<BlockCipher>; public: static constexpr size_t KeySize = Impl::KeySize; static constexpr size_t BlockSize = Impl::BlockSize; static constexpr size_t MaxMacSize = BlockSize; static constexpr size_t MaxNonceSize = 13; private: Impl m_impl; public: CcmEncryptor() { /* ... */ } void Initialize(const BlockCipher *cipher, const void *nonce, size_t nonce_size, s64 aad_size, s64 data_size, size_t mac_size) { m_impl.Initialize(cipher, nonce, nonce_size, aad_size, data_size, mac_size); } size_t Update(void *dst, size_t dst_size, const void *src, size_t src_size) { return m_impl.UpdateEncryption(dst, dst_size, src, src_size); } void UpdateAad(const void *aad, size_t aad_size) { return m_impl.UpdateAad(aad, aad_size); } void GetMac(void *dst, size_t dst_size) { return m_impl.GetMac(dst, dst_size); } }; }
2,089
C++
.h
50
34.26
140
0.645495
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,022
crypto_aes_ctr_encryptor_decryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_aes_ctr_encryptor_decryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_aes_encryptor.hpp> #include <vapours/crypto/crypto_ctr_encryptor.hpp> #include <vapours/crypto/crypto_ctr_decryptor.hpp> namespace ams::crypto { namespace impl { template<template<typename> typename _CtrImpl, typename _AesImpl> class AesCtrCryptor { NON_COPYABLE(AesCtrCryptor); NON_MOVEABLE(AesCtrCryptor); private: using AesImpl = _AesImpl; using CtrImpl = _CtrImpl<AesImpl>; public: static constexpr size_t KeySize = AesImpl::KeySize; static constexpr size_t BlockSize = CtrImpl::BlockSize; static constexpr size_t IvSize = CtrImpl::BlockSize; private: AesImpl m_aes_impl; CtrImpl m_ctr_impl; public: AesCtrCryptor() { /* ... */ } void Initialize(const void *key, size_t key_size, const void *iv, size_t iv_size) { this->Initialize(key, key_size, iv, iv_size, 0); } void Initialize(const void *key, size_t key_size, const void *iv, size_t iv_size, s64 offset) { AMS_ASSERT(key_size == KeySize); AMS_ASSERT(iv_size == IvSize); AMS_ASSERT(offset >= 0); m_aes_impl.Initialize(key, key_size); m_ctr_impl.Initialize(std::addressof(m_aes_impl), iv, iv_size, offset); } void SwitchMessage(const void *iv, size_t iv_size) { return m_ctr_impl.SwitchMessage(iv, iv_size); } size_t Update(void *dst, size_t dst_size, const void *src, size_t src_size) { return m_ctr_impl.Update(dst, dst_size, src, src_size); } }; } using Aes128CtrEncryptor = impl::AesCtrCryptor<CtrEncryptor, AesEncryptor128>; using Aes192CtrEncryptor = impl::AesCtrCryptor<CtrEncryptor, AesEncryptor192>; using Aes256CtrEncryptor = impl::AesCtrCryptor<CtrEncryptor, AesEncryptor256>; using Aes128CtrDecryptor = impl::AesCtrCryptor<CtrDecryptor, AesEncryptor128>; using Aes192CtrDecryptor = impl::AesCtrCryptor<CtrDecryptor, AesEncryptor192>; using Aes256CtrDecryptor = impl::AesCtrCryptor<CtrDecryptor, AesEncryptor256>; size_t EncryptAes128Ctr(void *dst, size_t dst_size, const void *key, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size); size_t EncryptAes192Ctr(void *dst, size_t dst_size, const void *key, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size); size_t EncryptAes256Ctr(void *dst, size_t dst_size, const void *key, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size); size_t DecryptAes128Ctr(void *dst, size_t dst_size, const void *key, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size); size_t DecryptAes192Ctr(void *dst, size_t dst_size, const void *key, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size); size_t DecryptAes256Ctr(void *dst, size_t dst_size, const void *key, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size); size_t EncryptAes128CtrPartial(void *dst, size_t dst_size, const void *key, size_t key_size, const void *iv, size_t iv_size, s64 offset, const void *src, size_t src_size); size_t EncryptAes192CtrPartial(void *dst, size_t dst_size, const void *key, size_t key_size, const void *iv, size_t iv_size, s64 offset, const void *src, size_t src_size); size_t EncryptAes256CtrPartial(void *dst, size_t dst_size, const void *key, size_t key_size, const void *iv, size_t iv_size, s64 offset, const void *src, size_t src_size); size_t DecryptAes128CtrPartial(void *dst, size_t dst_size, const void *key, size_t key_size, const void *iv, size_t iv_size, s64 offset, const void *src, size_t src_size); size_t DecryptAes192CtrPartial(void *dst, size_t dst_size, const void *key, size_t key_size, const void *iv, size_t iv_size, s64 offset, const void *src, size_t src_size); size_t DecryptAes256CtrPartial(void *dst, size_t dst_size, const void *key, size_t key_size, const void *iv, size_t iv_size, s64 offset, const void *src, size_t src_size); }
5,119
C++
.h
77
57.38961
175
0.666667
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,023
crypto_cbc_encryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_cbc_encryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_cbc_mode_impl.hpp> namespace ams::crypto { /* TODO: C++20 BlockCipher concept */ template<typename BlockCipher> class CbcEncryptor { NON_COPYABLE(CbcEncryptor); NON_MOVEABLE(CbcEncryptor); private: using Impl = impl::CbcModeImpl<BlockCipher>; public: static constexpr size_t KeySize = Impl::KeySize; static constexpr size_t BlockSize = Impl::BlockSize; static constexpr size_t IvSize = Impl::IvSize; private: Impl m_impl; public: CbcEncryptor() { /* ... */ } void Initialize(const BlockCipher *cipher, const void *iv, size_t iv_size) { m_impl.Initialize(cipher, iv, iv_size); } size_t Update(void *dst, size_t dst_size, const void *src, size_t src_size) { return m_impl.UpdateEncryption(dst, dst_size, src, src_size); } size_t GetBufferedDataSize() const { return m_impl.GetBufferedDataSize(); } }; }
1,843
C++
.h
47
32.297872
89
0.653244
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,024
crypto_aes_decryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_aes_decryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_aes_impl.hpp> namespace ams::crypto { template<size_t _KeySize> class AesDecryptor { NON_COPYABLE(AesDecryptor); NON_MOVEABLE(AesDecryptor); private: using Impl = impl::AesImpl<_KeySize>; public: static constexpr size_t KeySize = Impl::KeySize; static constexpr size_t BlockSize = Impl::BlockSize; static constexpr size_t RoundKeySize = Impl::RoundKeySize; private: Impl m_impl; public: AesDecryptor() { /* ... */ } void Initialize(const void *key, size_t key_size) { m_impl.Initialize(key, key_size, false); } void DecryptBlock(void *dst, size_t dst_size, const void *src, size_t src_size) const { return m_impl.DecryptBlock(dst, dst_size, src, src_size); } const u8 *GetRoundKey() const { return m_impl.GetRoundKey(); } }; using AesDecryptor128 = AesDecryptor<16>; using AesDecryptor192 = AesDecryptor<24>; using AesDecryptor256 = AesDecryptor<32>; }
1,906
C++
.h
49
32.061224
99
0.654949
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,025
crypto_aes_cbc_encryptor_decryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_aes_cbc_encryptor_decryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_aes_encryptor.hpp> #include <vapours/crypto/crypto_cbc_encryptor.hpp> #include <vapours/crypto/crypto_cbc_decryptor.hpp> namespace ams::crypto { namespace impl { template<template<typename> typename _CbcImpl, typename _AesImpl> class AesCbcCryptor { NON_COPYABLE(AesCbcCryptor); NON_MOVEABLE(AesCbcCryptor); private: using AesImpl = _AesImpl; using CbcImpl = _CbcImpl<AesImpl>; public: static constexpr size_t KeySize = AesImpl::KeySize; static constexpr size_t BlockSize = CbcImpl::BlockSize; static constexpr size_t IvSize = CbcImpl::BlockSize; private: AesImpl m_aes_impl; CbcImpl m_cbc_impl; public: AesCbcCryptor() { /* ... */ } void Initialize(const void *key, size_t key_size, const void *iv, size_t iv_size) { AMS_ASSERT(key_size == KeySize); AMS_ASSERT(iv_size == IvSize); m_aes_impl.Initialize(key, key_size); m_cbc_impl.Initialize(std::addressof(m_aes_impl), iv, iv_size); } size_t Update(void *dst, size_t dst_size, const void *src, size_t src_size) { return m_cbc_impl.Update(dst, dst_size, src, src_size); } size_t GetBufferedDataSize() const { return m_cbc_impl.GetBufferedDataSize(); } }; } using Aes128CbcEncryptor = impl::AesCbcCryptor<CbcEncryptor, AesEncryptor128>; using Aes192CbcEncryptor = impl::AesCbcCryptor<CbcEncryptor, AesEncryptor192>; using Aes256CbcEncryptor = impl::AesCbcCryptor<CbcEncryptor, AesEncryptor256>; using Aes128CbcDecryptor = impl::AesCbcCryptor<CbcDecryptor, AesDecryptor128>; using Aes192CbcDecryptor = impl::AesCbcCryptor<CbcDecryptor, AesDecryptor192>; using Aes256CbcDecryptor = impl::AesCbcCryptor<CbcDecryptor, AesDecryptor256>; size_t EncryptAes128Cbc(void *dst, size_t dst_size, const void *key, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size); size_t EncryptAes192Cbc(void *dst, size_t dst_size, const void *key, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size); size_t EncryptAes256Cbc(void *dst, size_t dst_size, const void *key, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size); size_t DecryptAes128Cbc(void *dst, size_t dst_size, const void *key, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size); size_t DecryptAes192Cbc(void *dst, size_t dst_size, const void *key, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size); size_t DecryptAes256Cbc(void *dst, size_t dst_size, const void *key, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size); }
3,785
C++
.h
67
47.671642
156
0.663607
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,026
crypto_aes_xts_encryptor_decryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_aes_xts_encryptor_decryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_aes_encryptor.hpp> #include <vapours/crypto/crypto_xts_encryptor.hpp> #include <vapours/crypto/crypto_xts_decryptor.hpp> namespace ams::crypto { namespace impl { template<template<typename> typename _XtsImpl, typename _AesImpl1, typename _AesImpl2> class AesXtsCryptor { NON_COPYABLE(AesXtsCryptor); NON_MOVEABLE(AesXtsCryptor); private: using AesImpl1 = _AesImpl1; using AesImpl2 = _AesImpl2; using XtsImpl = _XtsImpl<AesImpl1>; public: static constexpr size_t KeySize = AesImpl1::KeySize; static constexpr size_t BlockSize = AesImpl1::BlockSize; static constexpr size_t IvSize = AesImpl1::BlockSize; static_assert(AesImpl1::KeySize == AesImpl2::KeySize); static_assert(AesImpl1::BlockSize == AesImpl2::BlockSize); private: AesImpl1 m_aes_impl_1; AesImpl2 m_aes_impl_2; XtsImpl m_xts_impl; public: AesXtsCryptor() { /* ... */ } void Initialize(const void *key1, const void *key2, size_t key_size, const void *iv, size_t iv_size) { AMS_ASSERT(key_size == KeySize); AMS_ASSERT(iv_size == IvSize); m_aes_impl_1.Initialize(key1, key_size); m_aes_impl_2.Initialize(key2, key_size); m_xts_impl.Initialize(std::addressof(m_aes_impl_1), std::addressof(m_aes_impl_2), iv, iv_size); } size_t Update(void *dst, size_t dst_size, const void *src, size_t src_size) { return m_xts_impl.Update(dst, dst_size, src, src_size); } size_t Finalize(void *dst, size_t dst_size) { return m_xts_impl.Finalize(dst, dst_size); } }; } using Aes128XtsEncryptor = impl::AesXtsCryptor<XtsEncryptor, AesEncryptor128, AesEncryptor128>; using Aes192XtsEncryptor = impl::AesXtsCryptor<XtsEncryptor, AesEncryptor192, AesEncryptor192>; using Aes256XtsEncryptor = impl::AesXtsCryptor<XtsEncryptor, AesEncryptor256, AesEncryptor256>; using Aes128XtsDecryptor = impl::AesXtsCryptor<XtsDecryptor, AesDecryptor128, AesEncryptor128>; using Aes192XtsDecryptor = impl::AesXtsCryptor<XtsDecryptor, AesDecryptor192, AesEncryptor192>; using Aes256XtsDecryptor = impl::AesXtsCryptor<XtsDecryptor, AesDecryptor256, AesEncryptor256>; inline size_t EncryptAes128Xts(void *dst, size_t dst_size, const void *key1, const void *key2, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size) { u8 *dst_u8 = static_cast<u8 *>(dst); const u8 *src_u8 = static_cast<const u8 *>(src); Aes128XtsEncryptor xts; xts.Initialize(key1, key2, key_size, iv, iv_size); size_t processed = xts.Update(dst_u8, dst_size, src_u8, src_size); dst_u8 += processed; dst_size -= processed; processed += xts.Finalize(dst_u8, dst_size); return processed; } inline size_t EncryptAes192Xts(void *dst, size_t dst_size, const void *key1, const void *key2, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size) { u8 *dst_u8 = static_cast<u8 *>(dst); const u8 *src_u8 = static_cast<const u8 *>(src); Aes192XtsEncryptor xts; xts.Initialize(key1, key2, key_size, iv, iv_size); size_t processed = xts.Update(dst_u8, dst_size, src_u8, src_size); dst_u8 += processed; dst_size -= processed; processed += xts.Finalize(dst_u8, dst_size); return processed; } inline size_t EncryptAes256Xts(void *dst, size_t dst_size, const void *key1, const void *key2, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size) { u8 *dst_u8 = static_cast<u8 *>(dst); const u8 *src_u8 = static_cast<const u8 *>(src); Aes256XtsEncryptor xts; xts.Initialize(key1, key2, key_size, iv, iv_size); size_t processed = xts.Update(dst_u8, dst_size, src_u8, src_size); dst_u8 += processed; dst_size -= processed; processed += xts.Finalize(dst_u8, dst_size); return processed; } inline size_t DecryptAes128Xts(void *dst, size_t dst_size, const void *key1, const void *key2, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size) { u8 *dst_u8 = static_cast<u8 *>(dst); const u8 *src_u8 = static_cast<const u8 *>(src); Aes128XtsDecryptor xts; xts.Initialize(key1, key2, key_size, iv, iv_size); size_t processed = xts.Update(dst_u8, dst_size, src_u8, src_size); dst_u8 += processed; dst_size -= processed; processed += xts.Finalize(dst_u8, dst_size); return processed; } inline size_t DecryptAes192Xts(void *dst, size_t dst_size, const void *key1, const void *key2, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size) { u8 *dst_u8 = static_cast<u8 *>(dst); const u8 *src_u8 = static_cast<const u8 *>(src); Aes192XtsDecryptor xts; xts.Initialize(key1, key2, key_size, iv, iv_size); size_t processed = xts.Update(dst_u8, dst_size, src_u8, src_size); dst_u8 += processed; dst_size -= processed; processed += xts.Finalize(dst_u8, dst_size); return processed; } inline size_t DecryptAes256Xts(void *dst, size_t dst_size, const void *key1, const void *key2, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size) { u8 *dst_u8 = static_cast<u8 *>(dst); const u8 *src_u8 = static_cast<const u8 *>(src); Aes256XtsDecryptor xts; xts.Initialize(key1, key2, key_size, iv, iv_size); size_t processed = xts.Update(dst_u8, dst_size, src_u8, src_size); dst_u8 += processed; dst_size -= processed; processed += xts.Finalize(dst_u8, dst_size); return processed; } }
6,985
C++
.h
132
43.409091
183
0.630722
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,027
crypto_md5_generator.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_md5_generator.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_md5_impl.hpp> namespace ams::crypto { class Md5Generator { NON_COPYABLE(Md5Generator); NON_MOVEABLE(Md5Generator); private: using Impl = impl::Md5Impl; public: static constexpr size_t HashSize = Impl::HashSize; static constexpr size_t BlockSize = Impl::BlockSize; static constexpr inline const u8 Asn1Identifier[] = { 0x30, 0x20, /* Sequence, size 0x20 */ 0x30, 0x0C, /* Sequence, size 0x0C */ 0x06, 0x08, /* Object Identifier */ 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, /* MD5 */ 0x05, 0x00, /* Null */ 0x04, 0x10, /* Octet string, size 0x10 */ }; static constexpr size_t Asn1IdentifierSize = util::size(Asn1Identifier); private: Impl m_impl; public: Md5Generator() { /* ... */ } void Initialize() { m_impl.Initialize(); } void Update(const void *data, size_t size) { m_impl.Update(data, size); } void GetHash(void *dst, size_t size) { m_impl.GetHash(dst, size); } }; void GenerateMd5(void *dst, size_t dst_size, const void *src, size_t src_size); ALWAYS_INLINE void GenerateMd5Hash(void *dst, size_t dst_size, const void *src, size_t src_size) { return GenerateMd5(dst, dst_size, src, src_size); } }
2,317
C++
.h
57
31.789474
102
0.604
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,028
crypto_aes_gcm_encryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_aes_gcm_encryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_aes_encryptor.hpp> #include <vapours/crypto/crypto_gcm_encryptor.hpp> namespace ams::crypto { namespace impl { template<typename _AesImpl> class AesGcmEncryptor { NON_COPYABLE(AesGcmEncryptor); NON_MOVEABLE(AesGcmEncryptor); private: using AesImpl = _AesImpl; using GcmImpl = GcmEncryptor<AesImpl>; public: static constexpr size_t KeySize = AesImpl::KeySize; static constexpr size_t BlockSize = AesImpl::BlockSize; static constexpr size_t MacSize = AesImpl::BlockSize; private: AesImpl m_aes_impl; GcmImpl m_gcm_impl; public: AesGcmEncryptor() { /* ... */ } void Initialize(const void *key, size_t key_size, const void *iv, size_t iv_size) { m_aes_impl.Initialize(key, key_size); m_gcm_impl.Initialize(std::addressof(m_aes_impl), iv, iv_size); } void Reset(const void *iv, size_t iv_size) { m_gcm_impl.Reset(iv, iv_size); } size_t Update(void *dst, size_t dst_size, const void *src, size_t src_size) { return m_gcm_impl.Update(dst, dst_size, src, src_size); } void UpdateAad(const void *aad, size_t aad_size) { return m_gcm_impl.UpdateAad(aad, aad_size); } void GetMac(void *dst, size_t dst_size) { return m_gcm_impl.GetMac(dst, dst_size); } }; } using Aes128GcmEncryptor = impl::AesGcmEncryptor<AesEncryptor128>; /* TODO: Validate AAD/GMAC is same for non-128 bit key using Aes192GcmEncryptor = impl::AesGcmEncryptor<AesEncryptor192>; */ /* TODO: Validate AAD/GMAC is same for non-128 bit key using Aes256GcmEncryptor = impl::AesGcmEncryptor<AesEncryptor256>; */ }
2,774
C++
.h
61
35.459016
128
0.616068
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,029
crypto_rsa_calculator.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_rsa_calculator.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_bignum.hpp> namespace ams::crypto { template<size_t ModulusSize, size_t ExponentSize> class RsaCalculator { NON_COPYABLE(RsaCalculator); NON_MOVEABLE(RsaCalculator); public: static constexpr inline size_t RequiredWorkBufferSize = 0x10 * ModulusSize; private: impl::StaticBigNum<ModulusSize * BITSIZEOF(u8)> m_modulus; impl::StaticBigNum<ExponentSize * BITSIZEOF(u8)> m_exponent; public: RsaCalculator() { /* ... */ } ~RsaCalculator() { m_exponent.ClearToZero(); } bool Initialize(const void *mod, size_t mod_size, const void *exp, size_t exp_size) { if (!m_modulus.Import(mod, mod_size) || m_modulus.IsZero()) { return false; } if (!m_exponent.Import(exp, exp_size) || m_exponent.IsZero()) { return false; } return true; } bool ExpMod(void *dst, const void *src, size_t size, void *work_buf, size_t work_buf_size) { AMS_ASSERT(work_buf_size >= RequiredWorkBufferSize); return m_modulus.ExpMod(dst, src, size, m_exponent, static_cast<u32 *>(work_buf), work_buf_size); } bool ExpMod(void *dst, const void *src, size_t size) { u32 work_buf[RequiredWorkBufferSize / sizeof(u32)]; return this->ExpMod(dst, src, size, work_buf, sizeof(work_buf)); } }; }
2,297
C++
.h
52
35.673077
113
0.630308
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,030
crypto_ccm_decryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_ccm_decryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_ccm_mode_impl.hpp> namespace ams::crypto { template<typename BlockCipher> class CcmDecryptor { NON_COPYABLE(CcmDecryptor); NON_MOVEABLE(CcmDecryptor); private: using Impl = impl::CcmModeImpl<BlockCipher>; public: static constexpr size_t KeySize = Impl::KeySize; static constexpr size_t BlockSize = Impl::BlockSize; static constexpr size_t MaxMacSize = BlockSize; static constexpr size_t MaxNonceSize = 13; private: Impl m_impl; public: CcmDecryptor() { /* ... */ } void Initialize(const BlockCipher *cipher, const void *nonce, size_t nonce_size, s64 aad_size, s64 data_size, size_t mac_size) { m_impl.Initialize(cipher, nonce, nonce_size, aad_size, data_size, mac_size); } size_t Update(void *dst, size_t dst_size, const void *src, size_t src_size) { return m_impl.UpdateDecryption(dst, dst_size, src, src_size); } void UpdateAad(const void *aad, size_t aad_size) { return m_impl.UpdateAad(aad, aad_size); } void GetMac(void *dst, size_t dst_size) { return m_impl.GetMac(dst, dst_size); } }; }
2,089
C++
.h
50
34.26
140
0.645495
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,031
crypto_rsa_oaep_sha256_encryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_rsa_oaep_sha256_encryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_rsa_calculator.hpp> #include <vapours/crypto/crypto_rsa_oaep_encryptor.hpp> #include <vapours/crypto/crypto_sha256_generator.hpp> namespace ams::crypto { namespace impl { template<size_t Bits> using RsaNOaepSha256Encryptor = ::ams::crypto::RsaOaepEncryptor<Bits / BITSIZEOF(u8), ::ams::crypto::Sha256Generator>; } using Rsa2048OaepSha256Encryptor = ::ams::crypto::impl::RsaNOaepSha256Encryptor<2048>; using Rsa4096OaepSha256Encryptor = ::ams::crypto::impl::RsaNOaepSha256Encryptor<4096>; inline size_t EncryptRsa2048OaepSha256(void *dst, size_t dst_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size, const void *salt, size_t salt_size, const void *lab, size_t lab_size) { return Rsa2048OaepSha256Encryptor::Encrypt(dst, dst_size, mod, mod_size, exp, exp_size, msg, msg_size, salt, salt_size, lab, lab_size); } inline size_t EncryptRsa2048OaepSha256(void *dst, size_t dst_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size, const void *salt, size_t salt_size, const void *lab, size_t lab_size, void *work_buf, size_t work_buf_size) { return Rsa2048OaepSha256Encryptor::Encrypt(dst, dst_size, mod, mod_size, exp, exp_size, msg, msg_size, salt, salt_size, lab, lab_size, work_buf, work_buf_size); } inline size_t EncryptRsa4096OaepSha256(void *dst, size_t dst_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size, const void *salt, size_t salt_size, const void *lab, size_t lab_size) { return Rsa4096OaepSha256Encryptor::Encrypt(dst, dst_size, mod, mod_size, exp, exp_size, msg, msg_size, salt, salt_size, lab, lab_size); } inline size_t EncryptRsa4096OaepSha256(void *dst, size_t dst_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size, const void *salt, size_t salt_size, const void *lab, size_t lab_size, void *work_buf, size_t work_buf_size) { return Rsa4096OaepSha256Encryptor::Encrypt(dst, dst_size, mod, mod_size, exp, exp_size, msg, msg_size, salt, salt_size, lab, lab_size, work_buf, work_buf_size); } }
3,007
C++
.h
42
67.714286
282
0.730196
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,032
crypto_aes_encryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_aes_encryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_aes_impl.hpp> namespace ams::crypto { template<size_t _KeySize> class AesEncryptor { NON_COPYABLE(AesEncryptor); NON_MOVEABLE(AesEncryptor); private: using Impl = impl::AesImpl<_KeySize>; public: static constexpr size_t KeySize = Impl::KeySize; static constexpr size_t BlockSize = Impl::BlockSize; static constexpr size_t RoundKeySize = Impl::RoundKeySize; private: Impl m_impl; public: AesEncryptor() { /* ... */ } void Initialize(const void *key, size_t key_size) { m_impl.Initialize(key, key_size, true); } void EncryptBlock(void *dst, size_t dst_size, const void *src, size_t src_size) const { return m_impl.EncryptBlock(dst, dst_size, src, src_size); } const u8 *GetRoundKey() const { return m_impl.GetRoundKey(); } }; using AesEncryptor128 = AesEncryptor<16>; using AesEncryptor192 = AesEncryptor<24>; using AesEncryptor256 = AesEncryptor<32>; }
1,905
C++
.h
49
32.040816
99
0.654762
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,033
crypto_rsa_oaep_sha256_decoder.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_rsa_oaep_sha256_decoder.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_rsa_oaep_impl.hpp> #include <vapours/crypto/crypto_sha256_generator.hpp> namespace ams::crypto { inline size_t DecodeRsa2048OaepSha256(void *dst, size_t dst_size, const void *label_digest, size_t label_digest_size, const void *src, size_t src_size) { constexpr size_t BlockSize = 2048 / BITSIZEOF(u8); AMS_ABORT_UNLESS(src_size == BlockSize); impl::RsaOaepImpl<Sha256Generator> oaep; u8 enc[BlockSize]; ON_SCOPE_EXIT { ClearMemory(enc, sizeof(enc)); }; std::memcpy(enc, src, src_size); return oaep.Decode(dst, dst_size, label_digest, label_digest_size, enc, sizeof(enc)); } inline size_t DecodeRsa4096OaepSha256(void *dst, size_t dst_size, const void *label_digest, size_t label_digest_size, const void *src, size_t src_size) { constexpr size_t BlockSize = 4096 / BITSIZEOF(u8); AMS_ABORT_UNLESS(src_size == BlockSize); impl::RsaOaepImpl<Sha256Generator> oaep; u8 enc[BlockSize]; ON_SCOPE_EXIT { ClearMemory(enc, sizeof(enc)); }; std::memcpy(enc, src, src_size); return oaep.Decode(dst, dst_size, label_digest, label_digest_size, enc, sizeof(enc)); } }
1,963
C++
.h
41
43.195122
157
0.70988
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,034
crypto_gcm_encryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_gcm_encryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_gcm_mode_impl.hpp> namespace ams::crypto { /* TODO: C++20 BlockCipher concept */ template<typename BlockCipher> class GcmEncryptor { NON_COPYABLE(GcmEncryptor); NON_MOVEABLE(GcmEncryptor); private: using Impl = impl::GcmModeImpl<BlockCipher>; public: static constexpr size_t KeySize = Impl::KeySize; static constexpr size_t BlockSize = Impl::BlockSize; static constexpr size_t MacSize = Impl::MacSize; private: Impl m_impl; public: GcmEncryptor() { /* ... */ } void Initialize(const BlockCipher *cipher, const void *iv, size_t iv_size) { m_impl.Initialize(cipher); m_impl.Reset(iv, iv_size); } void Reset(const void *iv, size_t iv_size) { m_impl.Reset(iv, iv_size); } size_t Update(void *dst, size_t dst_size, const void *src, size_t src_size) { return m_impl.Update(dst, dst_size, src, src_size); } void UpdateAad(const void *aad, size_t aad_size) { return m_impl.UpdateAad(aad, aad_size); } void GetMac(void *dst, size_t dst_size) { return m_impl.GetMac(dst, dst_size); } }; }
2,118
C++
.h
54
31.259259
89
0.624635
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,035
crypto_ctr_decryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_ctr_decryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_ctr_mode_impl.hpp> namespace ams::crypto { /* TODO: C++20 BlockCipher concept */ template<typename BlockCipher> class CtrDecryptor { NON_COPYABLE(CtrDecryptor); NON_MOVEABLE(CtrDecryptor); private: using Impl = impl::CtrModeImpl<BlockCipher>; public: static constexpr size_t KeySize = Impl::KeySize; static constexpr size_t BlockSize = Impl::BlockSize; static constexpr size_t IvSize = Impl::IvSize; private: Impl m_impl; public: CtrDecryptor() { /* ... */ } void Initialize(const BlockCipher *cipher, const void *iv, size_t iv_size) { m_impl.Initialize(cipher, iv, iv_size); } void Initialize(const BlockCipher *cipher, const void *iv, size_t iv_size, s64 offset) { m_impl.Initialize(cipher, iv, iv_size, offset); } void SwitchMessage(const void *iv, size_t iv_size) { m_impl.SwitchMessage(iv, iv_size); } size_t Update(void *dst, size_t dst_size, const void *src, size_t src_size) { return m_impl.Update(dst, dst_size, src, src_size); } }; }
2,027
C++
.h
50
33.16
100
0.643293
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,036
crypto_xts_decryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_xts_decryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_xts_mode_impl.hpp> namespace ams::crypto { /* TODO: C++20 BlockCipher concept */ template<typename BlockCipher> class XtsDecryptor { NON_COPYABLE(XtsDecryptor); NON_MOVEABLE(XtsDecryptor); private: using Impl = impl::XtsModeImpl; public: static constexpr size_t BlockSize = Impl::BlockSize; static constexpr size_t IvSize = Impl::IvSize; private: Impl m_impl; public: XtsDecryptor() { /* ... */ } template<typename BlockCipher2> void Initialize(const BlockCipher *cipher1, const BlockCipher2 *cipher2, const void *iv, size_t iv_size) { m_impl.InitializeDecryption(cipher1, cipher2, iv, iv_size); } size_t Update(void *dst, size_t dst_size, const void *src, size_t src_size) { return m_impl.template Update<BlockCipher>(dst, dst_size, src, src_size); } size_t Finalize(void *dst, size_t dst_size) { return m_impl.FinalizeDecryption(dst, dst_size); } }; }
1,894
C++
.h
47
33.382979
118
0.65851
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,037
crypto_sha1_generator.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_sha1_generator.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_sha1_impl.hpp> namespace ams::crypto { class Sha1Generator { NON_COPYABLE(Sha1Generator); NON_MOVEABLE(Sha1Generator); private: using Impl = impl::Sha1Impl; public: static constexpr size_t HashSize = Impl::HashSize; static constexpr size_t BlockSize = Impl::BlockSize; static constexpr inline u8 Asn1Identifier[] = { 0x30, 0x21, /* Sequence, size 0x21 */ 0x30, 0x09, /* Sequence, size 0x09 */ 0x06, 0x05, /* Object Identifier */ 0x2B, 0x0E, 0x03, 0x02, 0x1A, /* SHA-1 */ 0x05, 0x00, /* Null */ 0x04, 0x14, /* Octet string, size 0x14 */ }; static constexpr size_t Asn1IdentifierSize = util::size(Asn1Identifier); private: Impl m_impl; public: Sha1Generator() { /* ... */ } void Initialize() { m_impl.Initialize(); } void Update(const void *data, size_t size) { m_impl.Update(data, size); } void GetHash(void *dst, size_t size) { m_impl.GetHash(dst, size); } }; void GenerateSha1(void *dst, size_t dst_size, const void *src, size_t src_size); ALWAYS_INLINE void GenerateSha1Hash(void *dst, size_t dst_size, const void *src, size_t src_size) { return GenerateSha1(dst, dst_size, src, src_size); } }
2,304
C++
.h
57
31.561404
103
0.604381
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,038
crypto_hmac_sha256_generator.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_hmac_sha256_generator.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/crypto/crypto_sha256_generator.hpp> #include <vapours/crypto/crypto_hmac_generator.hpp> namespace ams::crypto { using HmacSha256Generator = HmacGenerator<Sha256Generator>; void GenerateHmacSha256(void *dst, size_t dst_size, const void *data, size_t data_size, const void *key, size_t key_size); ALWAYS_INLINE void GenerateHmacSha256Mac(void *dst, size_t dst_size, const void *data, size_t data_size, const void *key, size_t key_size) { return GenerateHmacSha256(dst, dst_size, data, data_size, key, key_size); } }
1,210
C++
.h
25
45.64
144
0.753181
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,039
crypto_rsa_pss_sha256_verifier.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_rsa_pss_sha256_verifier.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_rsa_calculator.hpp> #include <vapours/crypto/crypto_rsa_pss_verifier.hpp> #include <vapours/crypto/crypto_sha256_generator.hpp> namespace ams::crypto { namespace impl { template<size_t Bits> using RsaNPssSha256Verifier = ::ams::crypto::RsaPssVerifier<Bits / BITSIZEOF(u8), ::ams::crypto::Sha256Generator>; } using Rsa2048PssSha256Verifier = ::ams::crypto::impl::RsaNPssSha256Verifier<2048>; using Rsa4096PssSha256Verifier = ::ams::crypto::impl::RsaNPssSha256Verifier<4096>; inline bool VerifyRsa2048PssSha256(const void *sig, size_t sig_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size) { return Rsa2048PssSha256Verifier::Verify(sig, sig_size, mod, mod_size, exp, exp_size, msg, msg_size); } inline bool VerifyRsa2048PssSha256(const void *sig, size_t sig_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size, void *work_buf, size_t work_buf_size) { return Rsa2048PssSha256Verifier::Verify(sig, sig_size, mod, mod_size, exp, exp_size, msg, msg_size, work_buf, work_buf_size); } inline bool VerifyRsa2048PssSha256WithHash(const void *sig, size_t sig_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *hash, size_t hash_size) { return Rsa2048PssSha256Verifier::VerifyWithHash(sig, sig_size, mod, mod_size, exp, exp_size, hash, hash_size); } inline bool VerifyRsa2048PssSha256WithHash(const void *sig, size_t sig_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *hash, size_t hash_size, void *work_buf, size_t work_buf_size) { return Rsa2048PssSha256Verifier::VerifyWithHash(sig, sig_size, mod, mod_size, exp, exp_size, hash, hash_size, work_buf, work_buf_size); } inline bool VerifyRsa4096PssSha256(const void *sig, size_t sig_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size) { return Rsa4096PssSha256Verifier::Verify(sig, sig_size, mod, mod_size, exp, exp_size, msg, msg_size); } inline bool VerifyRsa4096PssSha256(const void *sig, size_t sig_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size, void *work_buf, size_t work_buf_size) { return Rsa4096PssSha256Verifier::Verify(sig, sig_size, mod, mod_size, exp, exp_size, msg, msg_size, work_buf, work_buf_size); } inline bool VerifyRsa4096PssSha256WithHash(const void *sig, size_t sig_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *hash, size_t hash_size) { return Rsa4096PssSha256Verifier::VerifyWithHash(sig, sig_size, mod, mod_size, exp, exp_size, hash, hash_size); } inline bool VerifyRsa4096PssSha256WithHash(const void *sig, size_t sig_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *hash, size_t hash_size, void *work_buf, size_t work_buf_size) { return Rsa4096PssSha256Verifier::VerifyWithHash(sig, sig_size, mod, mod_size, exp, exp_size, hash, hash_size, work_buf, work_buf_size); } }
3,959
C++
.h
54
68.814815
224
0.729306
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,040
crypto_rsa_pss_verifier.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_rsa_pss_verifier.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_rsa_calculator.hpp> #include <vapours/crypto/impl/crypto_rsa_pss_impl.hpp> namespace ams::crypto { template<size_t _ModulusSize, typename Hash> requires impl::HashFunction<Hash> class RsaPssVerifier { NON_COPYABLE(RsaPssVerifier); NON_MOVEABLE(RsaPssVerifier); public: static constexpr size_t HashSize = Hash::HashSize; static constexpr size_t SaltSize = Hash::HashSize; static constexpr size_t ModulusSize = _ModulusSize; static constexpr size_t SignatureSize = ModulusSize; static constexpr size_t MaximumExponentSize = 3; static constexpr size_t RequiredWorkBufferSize = RsaCalculator<ModulusSize, MaximumExponentSize>::RequiredWorkBufferSize; private: enum class State { None, Initialized, Done, }; private: RsaCalculator<ModulusSize, MaximumExponentSize> m_calculator; Hash m_hash; State m_state; public: RsaPssVerifier() : m_state(State::None) { /* ... */ } ~RsaPssVerifier() { } bool Initialize(const void *mod, size_t mod_size, const void *exp, size_t exp_size) { m_hash.Initialize(); if (m_calculator.Initialize(mod, mod_size, exp, exp_size)) { m_state = State::Initialized; return true; } else { return false; } } void Update(const void *data, size_t size) { AMS_ASSERT(m_state == State::Initialized); return m_hash.Update(data, size); } bool Verify(const void *signature, size_t size) { AMS_ASSERT(m_state == State::Initialized); AMS_ASSERT(size == SignatureSize); AMS_UNUSED(size); ON_SCOPE_EXIT { m_state = State::Done; }; impl::RsaPssImpl<Hash> impl; u8 message[SignatureSize]; ON_SCOPE_EXIT { ClearMemory(message, sizeof(message)); }; if (!m_calculator.ExpMod(message, signature, SignatureSize)) { return false; } u8 calc_hash[Hash::HashSize]; m_hash.GetHash(calc_hash, sizeof(calc_hash)); ON_SCOPE_EXIT { ClearMemory(calc_hash, sizeof(calc_hash)); }; return impl.Verify(message, sizeof(message), calc_hash, sizeof(calc_hash)); } bool Verify(const void *signature, size_t size, void *work_buf, size_t work_buf_size) { AMS_ASSERT(m_state == State::Initialized); AMS_ASSERT(size == SignatureSize); AMS_UNUSED(size); ON_SCOPE_EXIT { m_state = State::Done; }; impl::RsaPssImpl<Hash> impl; u8 message[SignatureSize]; ON_SCOPE_EXIT { ClearMemory(message, sizeof(message)); }; if (!m_calculator.ExpMod(message, signature, SignatureSize, work_buf, work_buf_size)) { return false; } u8 calc_hash[Hash::HashSize]; m_hash.GetHash(calc_hash, sizeof(calc_hash)); ON_SCOPE_EXIT { ClearMemory(calc_hash, sizeof(calc_hash)); }; return impl.Verify(message, sizeof(message), calc_hash, sizeof(calc_hash)); } bool VerifyWithHash(const void *signature, size_t size, const void *hash, size_t hash_size) { AMS_ASSERT(m_state == State::Initialized); AMS_ASSERT(size == SignatureSize); AMS_UNUSED(size); ON_SCOPE_EXIT { m_state = State::Done; }; impl::RsaPssImpl<Hash> impl; u8 message[SignatureSize]; ON_SCOPE_EXIT { ClearMemory(message, sizeof(message)); }; if (!m_calculator.ExpMod(message, signature, SignatureSize)) { return false; } return impl.Verify(message, sizeof(message), static_cast<const u8 *>(hash), hash_size); } bool VerifyWithHash(const void *signature, size_t size, const void *hash, size_t hash_size, void *work_buf, size_t work_buf_size) { AMS_ASSERT(m_state == State::Initialized); AMS_ASSERT(size == SignatureSize); AMS_UNUSED(size); ON_SCOPE_EXIT { m_state = State::Done; }; impl::RsaPssImpl<Hash> impl; u8 message[SignatureSize]; ON_SCOPE_EXIT { ClearMemory(message, sizeof(message)); }; if (!m_calculator.ExpMod(message, signature, SignatureSize, work_buf, work_buf_size)) { return false; } return impl.Verify(message, sizeof(message), static_cast<const u8 *>(hash), hash_size); } static bool Verify(const void *sig, size_t sig_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size) { RsaPssVerifier<ModulusSize, Hash> verifier; if (!verifier.Initialize(mod, mod_size, exp, exp_size)) { return false; } verifier.Update(msg, msg_size); return verifier.Verify(sig, sig_size); } static bool Verify(const void *sig, size_t sig_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size, void *work_buf, size_t work_buf_size) { RsaPssVerifier<ModulusSize, Hash> verifier; if (!verifier.Initialize(mod, mod_size, exp, exp_size)) { return false; } verifier.Update(msg, msg_size); return verifier.Verify(sig, sig_size, work_buf, work_buf_size); } static bool VerifyWithHash(const void *sig, size_t sig_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *hash, size_t hash_size) { RsaPssVerifier<ModulusSize, Hash> verifier; if (!verifier.Initialize(mod, mod_size, exp, exp_size)) { return false; } return verifier.VerifyWithHash(sig, sig_size, hash, hash_size); } static bool VerifyWithHash(const void *sig, size_t sig_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *hash, size_t hash_size, void *work_buf, size_t work_buf_size) { RsaPssVerifier<ModulusSize, Hash> verifier; if (!verifier.Initialize(mod, mod_size, exp, exp_size)) { return false; } return verifier.VerifyWithHash(sig, sig_size, hash, hash_size, work_buf, work_buf_size); } }; }
7,818
C++
.h
149
38.812081
216
0.570606
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,041
crypto_rsa_oaep_sha256_decryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_rsa_oaep_sha256_decryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_rsa_calculator.hpp> #include <vapours/crypto/crypto_rsa_oaep_decryptor.hpp> #include <vapours/crypto/crypto_sha256_generator.hpp> namespace ams::crypto { namespace impl { template<size_t Bits> using RsaNOaepSha256Decryptor = ::ams::crypto::RsaOaepDecryptor<Bits / BITSIZEOF(u8), ::ams::crypto::Sha256Generator>; } using Rsa2048OaepSha256Decryptor = ::ams::crypto::impl::RsaNOaepSha256Decryptor<2048>; using Rsa4096OaepSha256Decryptor = ::ams::crypto::impl::RsaNOaepSha256Decryptor<4096>; inline size_t DecryptRsa2048OaepSha256(void *dst, size_t dst_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size, const void *lab, size_t lab_size) { return Rsa2048OaepSha256Decryptor::Decrypt(dst, dst_size, mod, mod_size, exp, exp_size, msg, msg_size, lab, lab_size); } inline size_t DecryptRsa2048OaepSha256(void *dst, size_t dst_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size, const void *lab, size_t lab_size, void *work_buf, size_t work_buf_size) { return Rsa2048OaepSha256Decryptor::Decrypt(dst, dst_size, mod, mod_size, exp, exp_size, msg, msg_size, lab, lab_size, work_buf, work_buf_size); } inline size_t DecryptRsa4096OaepSha256(void *dst, size_t dst_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size, const void *lab, size_t lab_size) { return Rsa4096OaepSha256Decryptor::Decrypt(dst, dst_size, mod, mod_size, exp, exp_size, msg, msg_size, lab, lab_size); } inline size_t DecryptRsa4096OaepSha256(void *dst, size_t dst_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size, const void *lab, size_t lab_size, void *work_buf, size_t work_buf_size) { return Rsa4096OaepSha256Decryptor::Decrypt(dst, dst_size, mod, mod_size, exp, exp_size, msg, msg_size, lab, lab_size, work_buf, work_buf_size); } }
2,795
C++
.h
42
62.666667
246
0.731218
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,042
crypto_sha3_generator.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_sha3_generator.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_sha3_impl.hpp> namespace ams::crypto { struct Sha3Context { u32 hash_size; u32 buffered_bytes; u64 internal_state[25]; }; namespace impl { template<size_t HashSize> struct Sha3Asn1IdentifierByte; template<> struct Sha3Asn1IdentifierByte<224 / BITSIZEOF(u8)> { static constexpr u8 Value = 0x07; }; template<> struct Sha3Asn1IdentifierByte<256 / BITSIZEOF(u8)> { static constexpr u8 Value = 0x08; }; template<> struct Sha3Asn1IdentifierByte<384 / BITSIZEOF(u8)> { static constexpr u8 Value = 0x09; }; template<> struct Sha3Asn1IdentifierByte<512 / BITSIZEOF(u8)> { static constexpr u8 Value = 0x0A; }; } template <size_t _HashSize> class Sha3Generator { NON_COPYABLE(Sha3Generator); NON_MOVEABLE(Sha3Generator); private: using Impl = impl::Sha3Impl<_HashSize>; public: static constexpr size_t HashSize = Impl::HashSize; static constexpr size_t BlockSize = Impl::BlockSize; static constexpr inline u8 Asn1Identifier[] = { 0x30, 0x31, /* Sequence, size 0x31 */ 0x30, 0x0D, /* Sequence, size 0x0D */ 0x06, 0x09, /* Object Identifier */ 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, impl::Sha3Asn1IdentifierByte<HashSize>::Value, /* SHA3-*** */ 0x05, 0x00, /* Null */ 0x04, 0x20, /* Octet string, size 0x20 */ }; static constexpr size_t Asn1IdentifierSize = util::size(Asn1Identifier); private: Impl m_impl; public: Sha3Generator() { /* ... */ } void Initialize() { m_impl.Initialize(); } void Update(const void *data, size_t size) { m_impl.Update(data, size); } void GetHash(void *dst, size_t size) { m_impl.GetHash(dst, size); } void InitializeWithContext(const Sha3Context *context) { m_impl.InitializeWithContext(context); } void GetContext(Sha3Context *context) const { m_impl.GetContext(context); } }; using Sha3224Generator = Sha3Generator<224 / BITSIZEOF(u8)>; using Sha3256Generator = Sha3Generator<256 / BITSIZEOF(u8)>; using Sha3384Generator = Sha3Generator<384 / BITSIZEOF(u8)>; using Sha3512Generator = Sha3Generator<512 / BITSIZEOF(u8)>; inline void GenerateSha3224(void *dst, size_t dst_size, const void *src, size_t src_size) { Sha3224Generator generator; generator.Initialize(); generator.Update(src, src_size); generator.GetHash(dst, dst_size); } inline void GenerateSha3256(void *dst, size_t dst_size, const void *src, size_t src_size) { Sha3256Generator generator; generator.Initialize(); generator.Update(src, src_size); generator.GetHash(dst, dst_size); } inline void GenerateSha3384(void *dst, size_t dst_size, const void *src, size_t src_size) { Sha3384Generator generator; generator.Initialize(); generator.Update(src, src_size); generator.GetHash(dst, dst_size); } inline void GenerateSha3512(void *dst, size_t dst_size, const void *src, size_t src_size) { Sha3512Generator generator; generator.Initialize(); generator.Update(src, src_size); generator.GetHash(dst, dst_size); } }
4,353
C++
.h
101
34.277228
138
0.631977
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,043
crypto_rsa_pkcs1_sha256_verifier.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_rsa_pkcs1_sha256_verifier.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_rsa_calculator.hpp> #include <vapours/crypto/crypto_rsa_pkcs1_verifier.hpp> #include <vapours/crypto/crypto_sha256_generator.hpp> namespace ams::crypto { namespace impl { template<size_t Bits> using RsaNPkcs1Sha256Verifier = ::ams::crypto::RsaPkcs1Verifier<Bits / BITSIZEOF(u8), ::ams::crypto::Sha256Generator>; } using Rsa2048Pkcs1Sha256Verifier = ::ams::crypto::impl::RsaNPkcs1Sha256Verifier<2048>; using Rsa4096Pkcs1Sha256Verifier = ::ams::crypto::impl::RsaNPkcs1Sha256Verifier<4096>; inline bool VerifyRsa2048Pkcs1Sha256(const void *sig, size_t sig_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size) { return Rsa2048Pkcs1Sha256Verifier::Verify(sig, sig_size, mod, mod_size, exp, exp_size, msg, msg_size); } inline bool VerifyRsa2048Pkcs1Sha256(const void *sig, size_t sig_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size, void *work_buf, size_t work_buf_size) { return Rsa2048Pkcs1Sha256Verifier::Verify(sig, sig_size, mod, mod_size, exp, exp_size, msg, msg_size, work_buf, work_buf_size); } inline bool VerifyRsa4096Pkcs1Sha256(const void *sig, size_t sig_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size) { return Rsa4096Pkcs1Sha256Verifier::Verify(sig, sig_size, mod, mod_size, exp, exp_size, msg, msg_size); } inline bool VerifyRsa4096Pkcs1Sha256(const void *sig, size_t sig_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size, void *work_buf, size_t work_buf_size) { return Rsa4096Pkcs1Sha256Verifier::Verify(sig, sig_size, mod, mod_size, exp, exp_size, msg, msg_size, work_buf, work_buf_size); } }
2,611
C++
.h
42
58.285714
216
0.73534
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,044
crypto_memory_compare.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_memory_compare.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> namespace ams::crypto { bool IsSameBytes(const void *lhs, const void *rhs, size_t size); }
835
C++
.h
22
35.954545
76
0.756489
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,045
crypto_xts_encryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_xts_encryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_xts_mode_impl.hpp> namespace ams::crypto { /* TODO: C++20 BlockCipher concept */ template<typename BlockCipher> class XtsEncryptor { NON_COPYABLE(XtsEncryptor); NON_MOVEABLE(XtsEncryptor); private: using Impl = impl::XtsModeImpl; public: static constexpr size_t BlockSize = Impl::BlockSize; static constexpr size_t IvSize = Impl::IvSize; private: Impl m_impl; public: XtsEncryptor() { /* ... */ } template<typename BlockCipher2> void Initialize(const BlockCipher *cipher1, const BlockCipher2 *cipher2, const void *iv, size_t iv_size) { m_impl.InitializeEncryption(cipher1, cipher2, iv, iv_size); } size_t Update(void *dst, size_t dst_size, const void *src, size_t src_size) { return m_impl.template Update<BlockCipher>(dst, dst_size, src, src_size); } size_t Finalize(void *dst, size_t dst_size) { return m_impl.FinalizeEncryption(dst, dst_size); } }; }
1,894
C++
.h
47
33.382979
118
0.65851
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,046
crypto_rsa_oaep_encryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_rsa_oaep_encryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_rsa_calculator.hpp> #include <vapours/crypto/impl/crypto_rsa_oaep_impl.hpp> namespace ams::crypto { template<size_t ModulusSize, typename Hash> requires impl::HashFunction<Hash> class RsaOaepEncryptor { NON_COPYABLE(RsaOaepEncryptor); NON_MOVEABLE(RsaOaepEncryptor); public: static constexpr size_t HashSize = Hash::HashSize; static constexpr size_t BlockSize = ModulusSize; static constexpr size_t MaximumExponentSize = 3; static constexpr size_t RequiredWorkBufferSize = RsaCalculator<ModulusSize, MaximumExponentSize>::RequiredWorkBufferSize; private: enum class State { None, Initialized, Done, }; private: RsaCalculator<ModulusSize, MaximumExponentSize> m_calculator; Hash m_hash; bool m_set_label_digest; u8 m_label_digest[HashSize]; State m_state; public: RsaOaepEncryptor() : m_set_label_digest(false), m_state(State::None) { std::memset(m_label_digest, 0, sizeof(m_label_digest)); } ~RsaOaepEncryptor() { ClearMemory(m_label_digest, sizeof(m_label_digest)); } bool Initialize(const void *mod, size_t mod_size, const void *exp, size_t exp_size) { m_hash.Initialize(); m_set_label_digest = false; if (m_calculator.Initialize(mod, mod_size, exp, exp_size)) { m_state = State::Initialized; return true; } else { return false; } } void UpdateLabel(const void *data, size_t size) { AMS_ASSERT(m_state == State::Initialized); m_hash.Update(data, size); } void SetLabelDigest(const void *digest, size_t digest_size) { AMS_ASSERT(m_state == State::Initialized); AMS_ABORT_UNLESS(digest_size == sizeof(m_label_digest)); std::memcpy(m_label_digest, digest, digest_size); m_set_label_digest = true; } bool Encrypt(void *dst, size_t dst_size, const void *src, size_t src_size, const void *salt, size_t salt_size) { AMS_ASSERT(m_state == State::Initialized); impl::RsaOaepImpl<Hash> impl; if (!m_set_label_digest) { m_hash.GetHash(m_label_digest, sizeof(m_label_digest)); } impl.Encode(dst, dst_size, m_label_digest, sizeof(m_label_digest), src, src_size, salt, salt_size); if (!m_calculator.ExpMod(dst, dst, dst_size)) { std::memset(dst, 0, dst_size); return false; } m_state = State::Done; return true; } bool Encrypt(void *dst, size_t dst_size, const void *src, size_t src_size, const void *salt, size_t salt_size, void *work, size_t work_size) { AMS_ASSERT(m_state == State::Initialized); impl::RsaOaepImpl<Hash> impl; if (!m_set_label_digest) { m_hash.GetHash(m_label_digest, sizeof(m_label_digest)); } impl.Encode(dst, dst_size, m_label_digest, sizeof(m_label_digest), src, src_size, salt, salt_size); if (!m_calculator.ExpMod(dst, dst, dst_size, work, work_size)) { std::memset(dst, 0, dst_size); return false; } m_state = State::Done; return true; } static bool Encrypt(void *dst, size_t dst_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size, const void *seed, size_t seed_size, const void *lab, size_t lab_size) { RsaOaepEncryptor<ModulusSize, Hash> oaep; if (!oaep.Initialize(mod, mod_size, exp, exp_size)) { return false; } oaep.UpdateLabel(lab, lab_size); return oaep.Encrypt(dst, dst_size, msg, msg_size, seed, seed_size); } static bool Encrypt(void *dst, size_t dst_size, const void *mod, size_t mod_size, const void *exp, size_t exp_size, const void *msg, size_t msg_size, const void *seed, size_t seed_size, const void *lab, size_t lab_size, void *work, size_t work_size) { RsaOaepEncryptor<ModulusSize, Hash> oaep; if (!oaep.Initialize(mod, mod_size, exp, exp_size)) { return false; } oaep.UpdateLabel(lab, lab_size); return oaep.Encrypt(dst, dst_size, msg, msg_size, seed, seed_size, work, work_size); } }; }
5,706
C++
.h
114
37.289474
263
0.572634
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,047
crypto_hmac_generator.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_hmac_generator.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_hmac_impl.hpp> namespace ams::crypto { template<typename Hash> /* requires HashFunction<Hash> */ class HmacGenerator { NON_COPYABLE(HmacGenerator); NON_MOVEABLE(HmacGenerator); private: using Impl = impl::HmacImpl<Hash>; public: static constexpr size_t HashSize = Impl::HashSize; static constexpr size_t BlockSize = Impl::BlockSize; private: Impl m_impl; public: HmacGenerator() { /* ... */ } void Initialize(const void *key, size_t key_size) { return m_impl.Initialize(key, key_size); } void Update(const void *data, size_t size) { return m_impl.Update(data, size); } void GetMac(void *dst, size_t dst_size) { return m_impl.GetMac(dst, dst_size); } }; }
1,675
C++
.h
45
30.444444
76
0.647783
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,048
crypto_cbc_decryptor.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_cbc_decryptor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_cbc_mode_impl.hpp> namespace ams::crypto { /* TODO: C++20 BlockCipher concept */ template<typename BlockCipher> class CbcDecryptor { NON_COPYABLE(CbcDecryptor); NON_MOVEABLE(CbcDecryptor); private: using Impl = impl::CbcModeImpl<BlockCipher>; public: static constexpr size_t KeySize = Impl::KeySize; static constexpr size_t BlockSize = Impl::BlockSize; static constexpr size_t IvSize = Impl::IvSize; private: Impl m_impl; public: CbcDecryptor() { /* ... */ } void Initialize(const BlockCipher *cipher, const void *iv, size_t iv_size) { m_impl.Initialize(cipher, iv, iv_size); } size_t Update(void *dst, size_t dst_size, const void *src, size_t src_size) { return m_impl.UpdateDecryption(dst, dst_size, src, src_size); } size_t GetBufferedDataSize() const { return m_impl.GetBufferedDataSize(); } }; }
1,843
C++
.h
47
32.297872
89
0.653244
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,049
crypto_memory_clear.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_memory_clear.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> namespace ams::crypto { void ClearMemory(void *mem, size_t size); }
812
C++
.h
22
34.909091
76
0.756997
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,050
crypto_sha256_generator.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/crypto_sha256_generator.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_sha256_impl.hpp> #include <vapours/crypto/impl/crypto_sha256_impl_constexpr.hpp> namespace ams::crypto { struct Sha256Context { u32 intermediate_hash[impl::Sha256Impl::HashSize / sizeof(u32)]; u64 bits_consumed; }; class Sha256Generator { NON_COPYABLE(Sha256Generator); NON_MOVEABLE(Sha256Generator); private: using Impl = impl::Sha256Impl; public: static constexpr size_t HashSize = Impl::HashSize; static constexpr size_t BlockSize = Impl::BlockSize; static constexpr inline u8 Asn1Identifier[] = { 0x30, 0x31, /* Sequence, size 0x31 */ 0x30, 0x0D, /* Sequence, size 0x0D */ 0x06, 0x09, /* Object Identifier */ 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, /* SHA-256 */ 0x05, 0x00, /* Null */ 0x04, 0x20, /* Octet string, size 0x20 */ }; static constexpr size_t Asn1IdentifierSize = util::size(Asn1Identifier); private: Impl m_impl{}; public: Sha256Generator() = default; void Initialize() { m_impl.Initialize(); } void Update(const void *data, size_t size) { m_impl.Update(data, size); } void GetHash(void *dst, size_t size) { m_impl.GetHash(dst, size); } void InitializeWithContext(const Sha256Context *context) { m_impl.InitializeWithContext(context); } size_t GetContext(Sha256Context *context) const { return m_impl.GetContext(context); } size_t GetBufferedDataSize() const { return m_impl.GetBufferedDataSize(); } void GetBufferedData(void *dst, size_t dst_size) const { return m_impl.GetBufferedData(dst, dst_size); } }; void GenerateSha256(void *dst, size_t dst_size, const void *src, size_t src_size); ALWAYS_INLINE void GenerateSha256Hash(void *dst, size_t dst_size, const void *src, size_t src_size) { return GenerateSha256(dst, dst_size, src, src_size); } template<typename T, typename = typename std::enable_if<std::same_as<T, u8> || std::same_as<T, s8> || std::same_as<T, char> || std::same_as<T, unsigned char>>::type> constexpr ALWAYS_INLINE void GenerateSha256(u8 *dst, size_t dst_size, const T *src, size_t src_size) { if (std::is_constant_evaluated()) { impl::Sha256CompileTimeImpl sha; sha.Initialize(); sha.Update(src, src_size); sha.GetHash(dst, dst_size); } else { return GenerateSha256(static_cast<void *>(dst), dst_size, static_cast<const void *>(src), src_size); } } }
3,700
C++
.h
85
33.894118
169
0.607391
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,051
crypto_cbc_mode_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_cbc_mode_impl.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_memory_clear.hpp> #include <vapours/crypto/crypto_aes_encryptor.hpp> namespace ams::crypto::impl { template<typename BlockCipher> class CbcModeImpl { NON_COPYABLE(CbcModeImpl); NON_MOVEABLE(CbcModeImpl); public: static constexpr size_t KeySize = BlockCipher::KeySize; static constexpr size_t BlockSize = BlockCipher::BlockSize; static constexpr size_t IvSize = BlockCipher::BlockSize; private: enum State { State_None, State_Initialized, }; private: const BlockCipher *m_block_cipher; u8 m_iv[IvSize]; u8 m_buffer[BlockSize]; size_t m_buffered_bytes; State m_state; public: CbcModeImpl() : m_state(State_None) { /* ... */ } ~CbcModeImpl() { ClearMemory(this, sizeof(*this)); } void Initialize(const BlockCipher *block_cipher, const void *iv, size_t iv_size) { AMS_ASSERT(iv_size == IvSize); AMS_UNUSED(iv_size); m_block_cipher = block_cipher; std::memcpy(m_iv, iv, IvSize); m_buffered_bytes = 0; m_state = State_Initialized; } size_t GetBufferedDataSize() const { return m_buffered_bytes; } size_t UpdateEncryption(void *dst, size_t dst_size, const void *src, size_t src_size) { AMS_ASSERT(dst_size >= ((src_size + this->GetBufferedDataSize()) / BlockSize) * BlockSize); AMS_ASSERT(m_state == State_Initialized); return this->Update(dst, dst_size, src, src_size, [&] (u8 *d, u8 *i, const u8 *s, size_t n) ALWAYS_INLINE_LAMBDA { this->EncryptBlocks(d, i, s, n); }); } size_t UpdateDecryption(void *dst, size_t dst_size, const void *src, size_t src_size) { AMS_ASSERT(dst_size >= ((src_size + this->GetBufferedDataSize()) / BlockSize) * BlockSize); AMS_ASSERT(m_state == State_Initialized); return this->Update(dst, dst_size, src, src_size, [&] (u8 *d, u8 *i, const u8 *s, size_t n) ALWAYS_INLINE_LAMBDA { this->DecryptBlocks(d, i, s, n); }); } private: size_t Update(void *_dst, size_t dst_size, const void *_src, size_t src_size, auto ProcessBlocks) { AMS_UNUSED(dst_size); u8 *dst = static_cast<u8 *>(_dst); const u8 *src = static_cast<const u8 *>(_src); size_t remaining = src_size; size_t processed = 0; if (m_buffered_bytes > 0) { const size_t copy_size = std::min(BlockSize - m_buffered_bytes, remaining); std::memcpy(m_buffer + m_buffered_bytes, src, copy_size); src += copy_size; remaining -= copy_size; m_buffered_bytes += copy_size; if (m_buffered_bytes == BlockSize) { ProcessBlocks(dst, m_iv, m_buffer, 1); processed += BlockSize; dst += BlockSize; m_buffered_bytes = 0; } } if (remaining >= BlockSize) { const size_t num_blocks = remaining / BlockSize; ProcessBlocks(dst, m_iv, src, num_blocks); const size_t processed_size = num_blocks * BlockSize; dst += processed_size; src += processed_size; remaining -= processed_size; processed += processed_size; } if (remaining > 0) { std::memcpy(m_buffer, src, remaining); m_buffered_bytes = remaining; } return processed; } void EncryptBlocks(u8 *dst, u8 *iv, const u8 *src, size_t num_blocks) { const u8 *cur_iv = iv; u8 block[BlockSize]; while (num_blocks--) { for (size_t i = 0; i < BlockSize; ++i) { block[i] = src[i] ^ cur_iv[i]; } m_block_cipher->EncryptBlock(dst, BlockSize, block, BlockSize); cur_iv = dst; src += BlockSize; dst += BlockSize; } if (iv != cur_iv) { std::memcpy(iv, cur_iv, BlockSize); } } void DecryptBlocks(u8 *dst, u8 *iv, const u8 *src, size_t num_blocks) { u8 next_iv[BlockSize]; std::memcpy(next_iv, src + ((num_blocks - 1) * BlockSize), BlockSize); if (src == dst) { src = src + ((num_blocks - 1) * BlockSize); dst = dst + ((num_blocks - 1) * BlockSize); const u8 *cur_iv = (num_blocks == 1) ? iv : src - BlockSize; while (num_blocks-- > 1) { m_block_cipher->DecryptBlock(dst, BlockSize, src, BlockSize); for (size_t i = 0; i < BlockSize; ++i) { dst[i] ^= cur_iv[i]; } cur_iv -= BlockSize; src -= BlockSize; dst -= BlockSize; } m_block_cipher->DecryptBlock(dst, BlockSize, src, BlockSize); for (size_t i = 0; i < BlockSize; ++i) { dst[i] ^= iv[i]; } } else { const u8 *cur_iv = iv; while (num_blocks-- > 0) { m_block_cipher->DecryptBlock(dst, BlockSize, src, BlockSize); for (size_t i = 0; i < BlockSize; ++i) { dst[i] ^= cur_iv[i]; } cur_iv = src; src += BlockSize; dst += BlockSize; } } std::memcpy(iv, next_iv, BlockSize); } }; /* TODO: Optimized AES cbc impl specializations. */ }
7,314
C++
.h
159
30.339623
130
0.480039
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,052
crypto_xts_mode_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_xts_mode_impl.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_memory_clear.hpp> #include <vapours/crypto/crypto_aes_encryptor.hpp> namespace ams::crypto::impl { class XtsModeImpl { NON_COPYABLE(XtsModeImpl); NON_MOVEABLE(XtsModeImpl); public: /* TODO: More generic support. */ static constexpr size_t BlockSize = 16; static constexpr size_t IvSize = 16; private: enum State { State_None, State_Initialized, State_Processing, State_Done }; private: u8 m_buffer[BlockSize]; u8 m_tweak[BlockSize]; u8 m_last_block[BlockSize]; size_t m_num_buffered; const void *m_cipher_ctx; void (*m_cipher_func)(void *dst_block, const void *src_block, const void *cipher_ctx); State m_state; public: XtsModeImpl() : m_num_buffered(0), m_state(State_None) { /* ... */ } ~XtsModeImpl() { ClearMemory(this, sizeof(*this)); } private: template<typename BlockCipher> static void EncryptBlockCallback(void *dst_block, const void *src_block, const void *cipher) { return static_cast<const BlockCipher *>(cipher)->EncryptBlock(dst_block, BlockCipher::BlockSize, src_block, BlockCipher::BlockSize); } template<typename BlockCipher> static void DecryptBlockCallback(void *dst_block, const void *src_block, const void *cipher) { return static_cast<const BlockCipher *>(cipher)->DecryptBlock(dst_block, BlockCipher::BlockSize, src_block, BlockCipher::BlockSize); } template<typename BlockCipher> void Initialize(const BlockCipher *cipher, const void *tweak, size_t tweak_size) { AMS_ASSERT(tweak_size == IvSize); AMS_UNUSED(tweak_size); cipher->EncryptBlock(m_tweak, IvSize, tweak, IvSize); m_num_buffered = 0; m_state = State_Initialized; } void ProcessBlock(u8 *dst, const u8 *src); public: template<typename BlockCipher1, typename BlockCipher2> void InitializeEncryption(const BlockCipher1 *cipher1, const BlockCipher2 *cipher2, const void *tweak, size_t tweak_size) { static_assert(BlockCipher1::BlockSize == BlockSize); static_assert(BlockCipher2::BlockSize == BlockSize); m_cipher_ctx = cipher1; m_cipher_func = EncryptBlockCallback<BlockCipher1>; this->Initialize(cipher2, tweak, tweak_size); } template<typename BlockCipher1, typename BlockCipher2> void InitializeDecryption(const BlockCipher1 *cipher1, const BlockCipher2 *cipher2, const void *tweak, size_t tweak_size) { static_assert(BlockCipher1::BlockSize == BlockSize); static_assert(BlockCipher2::BlockSize == BlockSize); m_cipher_ctx = cipher1; m_cipher_func = DecryptBlockCallback<BlockCipher1>; this->Initialize(cipher2, tweak, tweak_size); } template<typename BlockCipher> size_t Update(void *dst, size_t dst_size, const void *src, size_t src_size) { return this->UpdateGeneric(dst, dst_size, src, src_size); } template<typename BlockCipher> size_t ProcessBlocks(u8 *dst, const u8 *src, size_t num_blocks) { return this->ProcessBlocksGeneric(dst, src, num_blocks); } size_t GetBufferedDataSize() const { return m_num_buffered; } constexpr size_t GetBlockSize() const { return BlockSize; } size_t FinalizeEncryption(void *dst, size_t dst_size); size_t FinalizeDecryption(void *dst, size_t dst_size); size_t UpdateGeneric(void *dst, size_t dst_size, const void *src, size_t src_size); size_t ProcessBlocksGeneric(u8 *dst, const u8 *src, size_t num_blocks); size_t ProcessPartialData(u8 *dst, const u8 *src, size_t size); size_t ProcessRemainingData(u8 *dst, const u8 *src, size_t size); }; #if defined(ATMOSPHERE_ARCH_ARM64) template<> size_t XtsModeImpl::Update<AesEncryptor128>(void *dst, size_t dst_size, const void *src, size_t src_size); template<> size_t XtsModeImpl::Update<AesEncryptor192>(void *dst, size_t dst_size, const void *src, size_t src_size); template<> size_t XtsModeImpl::Update<AesEncryptor256>(void *dst, size_t dst_size, const void *src, size_t src_size); template<> size_t XtsModeImpl::Update<AesDecryptor128>(void *dst, size_t dst_size, const void *src, size_t src_size); template<> size_t XtsModeImpl::Update<AesDecryptor192>(void *dst, size_t dst_size, const void *src, size_t src_size); template<> size_t XtsModeImpl::Update<AesDecryptor256>(void *dst, size_t dst_size, const void *src, size_t src_size); #endif }
5,898
C++
.h
114
40.894737
148
0.629688
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,053
crypto_sha1_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_sha1_impl.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_hash_function.hpp> #include <vapours/crypto/crypto_memory_clear.hpp> namespace ams::crypto::impl { class Sha1Impl { public: static constexpr size_t HashSize = 0x14; static constexpr size_t BlockSize = 0x40; private: enum State { State_None, State_Initialized, State_Done, }; private: u32 m_intermediate_hash[HashSize / sizeof(u32)]; u8 m_buffer[BlockSize]; size_t m_buffered_bytes; u64 m_bits_consumed; State m_state; public: Sha1Impl() : m_state(State_None) { /* ... */ } ~Sha1Impl() { ClearMemory(this, sizeof(*this)); } void Initialize(); void Update(const void *data, size_t size); void GetHash(void *dst, size_t size); private: void ProcessBlock(const void *data); void ProcessBlocks(const u8 *data, size_t block_count); void ProcessLastBlock(); }; static_assert(HashFunction<Sha1Impl>); }
1,908
C++
.h
53
28.339623
76
0.628247
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,054
crypto_ccm_mode_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_ccm_mode_impl.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_memory_clear.hpp> #include <vapours/crypto/impl/crypto_ctr_mode_impl.hpp> #include <vapours/crypto/impl/crypto_cbc_mac_impl.hpp> namespace ams::crypto::impl { template<typename BlockCipher> class CcmModeImpl { NON_COPYABLE(CcmModeImpl); NON_MOVEABLE(CcmModeImpl); public: static constexpr size_t KeySize = BlockCipher::KeySize; static constexpr size_t BlockSize = BlockCipher::BlockSize; private: enum State { State_None, State_ProcessingAad, State_ProcessingData, State_DataInputDone, State_Done, }; private: u8 m_mac[BlockSize]; s64 m_given_data_size; s64 m_given_aad_size; size_t m_given_mac_size; s64 m_processed_data_size; s64 m_processed_aad_size; State m_state; CtrModeImpl<BlockCipher> m_ctr_mode_impl; CbcMacImpl m_cbc_mac_impl; public: CcmModeImpl() : m_state(State_None) { /* ... */ } ~CcmModeImpl() { ClearMemory(this, sizeof(*this)); } void Initialize(const BlockCipher *cipher, const void *nonce, size_t nonce_size, s64 aad_size, s64 data_size, size_t mac_size) { /* Check pre-conditions. */ AMS_ASSERT(7 <= nonce_size && nonce_size <= 13); AMS_ASSERT(4 <= mac_size && mac_size <= 16 && (mac_size % 2) == 0); AMS_ASSERT(aad_size >= 0); AMS_ASSERT(data_size >= 0); if (nonce_size == 7) { AMS_ASSERT(data_size <= std::numeric_limits<s64>::max()); } else { AMS_ASSERT(data_size < (INT64_C(1) << ((15 - nonce_size) * 8))); } /* Set various size fields. */ m_given_aad_size = aad_size; m_given_data_size = data_size; m_given_mac_size = mac_size; m_processed_aad_size = 0; m_processed_data_size = 0; /* Make the initial counter. */ u8 tmp[BlockSize]; MakeInitialCounter(tmp, nonce, nonce_size); /* Encrypt the block. */ cipher->EncryptBlock(m_mac, BlockSize, tmp, BlockSize); /* Initialize our ctr mode impl. */ m_ctr_mode_impl.Initialize(cipher, tmp, BlockSize); m_ctr_mode_impl.IncrementCounter(); /* Make the header block. */ MakeHeaderBlock(tmp, nonce, nonce_size, aad_size, data_size, mac_size); /* Initialize our cbc mac impl. */ m_cbc_mac_impl.Initialize(cipher); m_cbc_mac_impl.template Update<BlockCipher>(tmp, BlockSize); /* Process aad size block. */ if (aad_size > 0) { this->ProcessEncodedAadSize(); m_state = State_ProcessingAad; } else { m_state = State_ProcessingData; } } void UpdateAad(const void *aad, size_t aad_size) { /* Check pre-conditions. */ AMS_ASSERT(m_state == State_ProcessingAad); AMS_ASSERT(m_processed_aad_size + static_cast<s64>(aad_size) <= m_given_aad_size); /* Update on the aad. */ m_cbc_mac_impl.template Update<BlockCipher>(aad, aad_size); m_processed_aad_size += aad_size; /* Check if we're done with aad. */ if (m_processed_aad_size == m_given_aad_size) { /* Pad the aad to block size. */ this->ProcessPadding(); /* Update our state. */ if (m_given_data_size > 0) { m_state = State_ProcessingData; } else { m_state = State_DataInputDone; } } } size_t UpdateEncryption(void *dst, size_t dst_size, const void *src, size_t src_size) { /* Check pre-conditions. */ AMS_ASSERT(m_state == State_ProcessingData); AMS_ASSERT(m_processed_data_size + static_cast<s64>(src_size) <= m_given_data_size); AMS_ASSERT(dst_size >= src_size); /* Update mac on decrypted data. */ m_cbc_mac_impl.template Update<BlockCipher>(src, src_size); /* Encrypt. */ const size_t processed = m_ctr_mode_impl.Update(dst, dst_size, src, src_size); m_processed_data_size += src_size; /* Check if we're done with data. */ if (m_processed_data_size == m_given_data_size) { /* Pad the data to block size. */ this->ProcessPadding(); m_state = State_DataInputDone; } return processed; } size_t UpdateDecryption(void *dst, size_t dst_size, const void *src, size_t src_size) { /* Check pre-conditions. */ AMS_ASSERT(m_state == State_ProcessingData); AMS_ASSERT(m_processed_data_size + static_cast<s64>(src_size) <= m_given_data_size); AMS_ASSERT(dst_size >= src_size); /* Decrypt. */ const size_t processed = m_ctr_mode_impl.Update(dst, dst_size, src, src_size); m_processed_data_size += src_size; /* Update mac on decrypted data. */ m_cbc_mac_impl.template Update<BlockCipher>(dst, dst_size); /* Check if we're done with data. */ if (m_processed_data_size == m_given_data_size) { /* Pad the data to block size. */ this->ProcessPadding(); m_state = State_DataInputDone; } return processed; } void GetMac(void *mac, size_t mac_size) { /* Check pre-conditions. */ AMS_ASSERT(m_state == State_DataInputDone || m_state == State_Done); AMS_ASSERT(mac_size >= m_given_mac_size); AMS_UNUSED(mac_size); /* Generate the mac, if we haven't already. */ if (m_state == State_DataInputDone) { this->GenerateMac(); m_state = State_Done; } /* Copy out the mac. */ std::memcpy(mac, m_mac, m_given_mac_size); } private: void MakeInitialCounter(void *dst, const void *nonce, size_t nonce_size) { /* Clear the counter. */ u8 *ctr = static_cast<u8 *>(dst); std::memset(ctr, 0, BlockSize); /* Set the nonce. */ ctr[0] = (((BlockSize - 1 - nonce_size) & 0xFF) - 1) & 0x07; std::memcpy(ctr + 1, nonce, nonce_size); } void MakeHeaderBlock(void *dst, const void *nonce, size_t nonce_size, s64 aad_size, s64 data_size, size_t mac_size) { /* Clear the block. */ u8 *hdr = static_cast<u8 *>(dst); std::memset(hdr, 0, BlockSize); /* Encode the flags. */ hdr[0] = (((BlockSize - 1 - nonce_size) & 0xFF) - 1) & 0x07; hdr[0] |= (((mac_size - 2) / 2) & 0x07) << 3; hdr[0] |= (aad_size > 0) ? 0x40 : 0x00; /* Encode the data size. */ for (size_t i = 0; i < sizeof(s64); ++i) { hdr[BlockSize - 1 - i] = static_cast<u64>(data_size) >> (BITSIZEOF(u8) * i); } /* Copy the nonce. */ std::memcpy(hdr + 1, nonce, nonce_size); } void ProcessEncodedAadSize() { u8 encoded_aad[10]; size_t encoded_aad_size; if (m_given_aad_size < ((1 << 16) - (1 << 8))) { encoded_aad[0] = (m_given_aad_size >> (BITSIZEOF(u8) * 1)) & 0xFF; encoded_aad[1] = (m_given_aad_size >> (BITSIZEOF(u8) * 0)) & 0xFF; encoded_aad_size = 2; } else if (m_given_aad_size <= 0xFFFFFFFFu) { encoded_aad[0] = 0xFF; encoded_aad[1] = 0xFE; encoded_aad[2] = (m_given_aad_size >> (BITSIZEOF(u8) * 3)) & 0xFF; encoded_aad[3] = (m_given_aad_size >> (BITSIZEOF(u8) * 2)) & 0xFF; encoded_aad[4] = (m_given_aad_size >> (BITSIZEOF(u8) * 1)) & 0xFF; encoded_aad[5] = (m_given_aad_size >> (BITSIZEOF(u8) * 0)) & 0xFF; encoded_aad_size = 6; } else { encoded_aad[0] = 0xFF; encoded_aad[1] = 0xFE; encoded_aad[2] = (static_cast<u64>(m_given_aad_size) >> (BITSIZEOF(u8) * 7)) & 0xFF; encoded_aad[3] = (static_cast<u64>(m_given_aad_size) >> (BITSIZEOF(u8) * 6)) & 0xFF; encoded_aad[4] = (static_cast<u64>(m_given_aad_size) >> (BITSIZEOF(u8) * 5)) & 0xFF; encoded_aad[5] = (static_cast<u64>(m_given_aad_size) >> (BITSIZEOF(u8) * 4)) & 0xFF; encoded_aad[6] = (static_cast<u64>(m_given_aad_size) >> (BITSIZEOF(u8) * 3)) & 0xFF; encoded_aad[7] = (static_cast<u64>(m_given_aad_size) >> (BITSIZEOF(u8) * 2)) & 0xFF; encoded_aad[8] = (static_cast<u64>(m_given_aad_size) >> (BITSIZEOF(u8) * 1)) & 0xFF; encoded_aad[9] = (static_cast<u64>(m_given_aad_size) >> (BITSIZEOF(u8) * 0)) & 0xFF; encoded_aad_size = 10; } m_cbc_mac_impl.template Update<BlockCipher>(encoded_aad, encoded_aad_size); } void ProcessPadding() { /* Process any remaining padding. */ if (const auto buffered = m_cbc_mac_impl.GetBufferedDataSize(); buffered > 0) { u8 zeros[BlockSize] = {}; m_cbc_mac_impl.template Update<BlockCipher>(zeros, BlockSize - buffered); } } void GenerateMac() { /* Get the cbc mac. */ u8 tmp[BlockSize]; m_cbc_mac_impl.GetMac(tmp, BlockSize); /* Xor into our mac. */ for (size_t i = 0; i < BlockSize; ++i) { m_mac[i] ^= tmp[i]; } } }; }
11,533
C++
.h
231
34.532468
140
0.495337
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,055
crypto_rsa_pss_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_rsa_pss_impl.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_hash_function.hpp> namespace ams::crypto::impl { template<HashFunction Hash> class RsaPssImpl { NON_COPYABLE(RsaPssImpl); NON_MOVEABLE(RsaPssImpl); public: static constexpr size_t HashSize = Hash::HashSize; private: static constexpr u8 TailMagic = 0xBC; private: static void ComputeHashWithPadding(void *dst, const u8 *user_hash, size_t user_hash_size, const void *salt, size_t salt_size) { AMS_ASSERT(user_hash_size == HashSize); AMS_UNUSED(user_hash_size); /* Initialize our buffer. */ u8 buf[8 + HashSize]; std::memset(buf, 0, 8); std::memcpy(buf + 8, user_hash, HashSize); ON_SCOPE_EXIT { ClearMemory(buf, sizeof(buf)); }; /* Calculate our hash. */ Hash hash; hash.Initialize(); hash.Update(buf, sizeof(buf)); hash.Update(salt, salt_size); hash.GetHash(dst, HashSize); } static void ApplyMGF1(u8 *dst, size_t dst_size, const void *src, size_t src_size) { u8 buf[HashSize]; ON_SCOPE_EXIT { ClearMemory(buf, sizeof(buf)); }; const size_t required_iters = (dst_size + HashSize - 1) / HashSize; for (size_t i = 0; i < required_iters; i++) { Hash hash; hash.Initialize(); hash.Update(src, src_size); const u32 tmp = util::ConvertToBigEndian(static_cast<u32>(i)); hash.Update(std::addressof(tmp), sizeof(tmp)); hash.GetHash(buf, HashSize); const size_t start = HashSize * i; const size_t end = std::min(dst_size, start + HashSize); for (size_t j = start; j < end; j++) { dst[j] ^= buf[j - start]; } } } public: RsaPssImpl() { /* ... */ } bool Verify(u8 *buf, size_t size, const u8 *hash, size_t hash_size) { /* Validate sanity byte. */ bool is_valid = buf[size - 1] == TailMagic; /* Decrypt maskedDB */ const size_t db_len = size - HashSize - 1; u8 *db = buf; u8 *h = db + db_len; ApplyMGF1(db, db_len, h, HashSize); /* Apply lmask. */ db[0] &= 0x7F; /* Verify that DB is of the form 0000...0001 */ s32 salt_ofs = 0; { int looking_for_one = 1; int invalid_db_padding = 0; int is_zero; int is_one; for (size_t i = 0; i < db_len; /* ... */) { is_zero = (db[i] == 0); is_one = (db[i] == 1); salt_ofs += (looking_for_one & is_one) * (static_cast<s32>(++i)); looking_for_one &= ~is_one; invalid_db_padding |= (looking_for_one & ~is_zero); } is_valid &= (invalid_db_padding == 0); } /* Verify salt. */ const u8 *salt = db + salt_ofs; const size_t salt_size = db_len - salt_ofs; is_valid &= (salt_size != 0); is_valid &= (salt_size != db_len); /* Verify hash. */ u8 cmp_hash[HashSize]; ON_SCOPE_EXIT { ClearMemory(cmp_hash, sizeof(cmp_hash)); }; ComputeHashWithPadding(cmp_hash, hash, hash_size, salt, salt_size); is_valid &= IsSameBytes(cmp_hash, h, HashSize); /* Succeed if all our checks succeeded. */ return is_valid; } }; }
4,758
C++
.h
106
30.915094
139
0.50054
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,056
crypto_md5_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_md5_impl.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_hash_function.hpp> #include <vapours/crypto/crypto_memory_clear.hpp> namespace ams::crypto::impl { class Md5Impl { public: static constexpr size_t HashSize = 0x10; static constexpr size_t BlockSize = 0x40; private: enum State { State_None = 0, State_Initialized = 1, State_Done = 2, }; private: union { struct { u32 a, b, c, d; } p; u32 state[4]; } m_x; alignas(8) u8 m_y[BlockSize]; size_t m_size; State m_state; public: Md5Impl() : m_state(State_None) { /* ... */ } ~Md5Impl() { ClearMemory(this, sizeof(*this)); } void Initialize(); void Update(const void *data, size_t size); void GetHash(void *dst, size_t size); private: void ProcessBlock(); void ProcessLastBlock(); }; static_assert(HashFunction<Md5Impl>); }
1,881
C++
.h
54
26.777778
76
0.590659
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,057
crypto_cbc_mac_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_cbc_mac_impl.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_memory_clear.hpp> #include <vapours/crypto/crypto_aes_encryptor.hpp> namespace ams::crypto::impl { class CbcMacImpl { NON_COPYABLE(CbcMacImpl); NON_MOVEABLE(CbcMacImpl); public: static constexpr size_t BlockSize = 0x10; private: enum State { State_None, State_Initialized, State_Done, }; private: u8 m_mac[BlockSize]; u8 m_buffer[BlockSize]; size_t m_buffered_bytes; const void *m_cipher_context; void (*m_cipher_function)(void *dst, const void *src, const void *ctx); State m_state; public: CbcMacImpl() : m_buffered_bytes(0), m_state(State_None) { /* ... */ } ~CbcMacImpl() { ClearMemory(this, sizeof(*this)); } template<typename BlockCipher> void Initialize(const BlockCipher *block_cipher) { static_assert(BlockCipher::BlockSize == BlockSize); /* Set our context. */ m_cipher_context = block_cipher; m_cipher_function = &EncryptBlockCallback<BlockCipher>; m_buffered_bytes = 0; std::memset(m_mac, 0, sizeof(m_mac)); m_state = State_Initialized; } template<typename BlockCipher> void Update(const void *data, size_t size) { this->UpdateGeneric(data, size); } template<typename BlockCipher> void ProcessBlocks(const void *data, size_t size) { this->ProcessBlocksGeneric(data, size); } size_t GetBlockSize() const { return BlockSize; } size_t GetBufferedDataSize() const { return m_buffered_bytes; } void UpdateGeneric(const void *data, size_t size); void ProcessBlocksGeneric(const void *data, size_t num_blocks); void ProcessPartialData(const void *data, size_t size); void ProcessRemainingData(const void *data, size_t size); void GetMac(void *mac, size_t mac_size); void MaskBufferedData(const void *data, size_t size); private: void ProcessBlock(const void *data); template<typename BlockCipher> static void EncryptBlockCallback(void *dst, const void *src, const void *cipher) { static_assert(BlockCipher::BlockSize == BlockSize); static_cast<const BlockCipher *>(cipher)->EncryptBlock(dst, BlockCipher::BlockSize, src, BlockCipher::BlockSize); } }; template<> void CbcMacImpl::Update<AesEncryptor128>(const void *data, size_t size); }
3,593
C++
.h
86
31.534884
129
0.606017
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,058
crypto_aes_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_aes_impl.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_block_cipher.hpp> namespace ams::crypto::impl { template<size_t _KeySize> class AesImpl { public: static constexpr size_t KeySize = _KeySize; static constexpr size_t BlockSize = 16; static constexpr s32 RoundCount = (KeySize / 4) + 6; static constexpr size_t RoundKeySize = BlockSize * (RoundCount + 1); private: #ifdef ATMOSPHERE_IS_EXOSPHERE int m_slot; #endif #ifdef ATMOSPHERE_IS_STRATOSPHERE u32 m_round_keys[RoundKeySize / sizeof(u32)]; #endif public: ~AesImpl(); void Initialize(const void *key, size_t key_size, bool is_encrypt); void EncryptBlock(void *dst, size_t dst_size, const void *src, size_t src_size) const; void DecryptBlock(void *dst, size_t dst_size, const void *src, size_t src_size) const; #ifdef ATMOSPHERE_IS_STRATOSPHERE const u8 *GetRoundKey() const { return reinterpret_cast<const u8 *>(m_round_keys); } #endif }; static_assert(BlockCipher<AesImpl<16>>); static_assert(BlockCipher<AesImpl<24>>); static_assert(BlockCipher<AesImpl<32>>); }
2,015
C++
.h
50
33.76
98
0.664454
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,059
crypto_sha3_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_sha3_impl.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_hash_function.hpp> #include <vapours/crypto/crypto_memory_clear.hpp> namespace ams::crypto { struct Sha3Context; } namespace ams::crypto::impl { template<size_t _HashSize> class Sha3Impl { public: static constexpr size_t InternalStateSize = 200; static constexpr size_t HashSize = _HashSize; static constexpr size_t BlockSize = InternalStateSize - 2 * HashSize; private: enum State { State_None, State_Initialized, State_Done, }; private: u64 m_internal_state[InternalStateSize / sizeof(u64)]; size_t m_buffered_bytes; State m_state; public: Sha3Impl() : m_state(State_None) { /* ... */ } ~Sha3Impl() { ClearMemory(this, sizeof(*this)); } void Initialize(); void Update(const void *data, size_t size); void GetHash(void *dst, size_t size); void InitializeWithContext(const Sha3Context *context); void GetContext(Sha3Context *context) const; private: void ProcessBlock(); void ProcessLastBlock(); }; static_assert(HashFunction<Sha3Impl<224 / BITSIZEOF(u8)>>); static_assert(HashFunction<Sha3Impl<256 / BITSIZEOF(u8)>>); static_assert(HashFunction<Sha3Impl<384 / BITSIZEOF(u8)>>); static_assert(HashFunction<Sha3Impl<512 / BITSIZEOF(u8)>>); }
2,277
C++
.h
60
30.683333
81
0.650657
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,060
crypto_cmac_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_cmac_impl.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_hash_function.hpp> #include <vapours/crypto/impl/crypto_cbc_mac_impl.hpp> #include <vapours/crypto/crypto_memory_clear.hpp> namespace ams::crypto::impl { template<typename BlockCipher> class CmacImpl { NON_COPYABLE(CmacImpl); NON_MOVEABLE(CmacImpl); public: static constexpr size_t BlockSize = BlockCipher::BlockSize; static constexpr size_t MacSize = BlockSize; static_assert(BlockSize == 0x10); /* TODO: Should this be supported? */ private: enum State { State_None = 0, State_Initialized = 1, State_Done = 2, }; private: CbcMacImpl m_cbc_mac_impl; u8 m_sub_key[BlockSize]; State m_state; public: CmacImpl() : m_state(State_None) { /* ... */ } ~CmacImpl() { /* Clear everything. */ ClearMemory(this, sizeof(*this)); } void Initialize(const BlockCipher *cipher); void Update(const void *data, size_t data_size); void GetMac(void *dst, size_t dst_size); private: static void MultiplyOneOverGF128(u8 *data) { /* Determine the carry bit. */ const u8 carry = data[0] & 0x80; /* Shift all bytes by one bit. */ for (size_t i = 0; i < BlockSize - 1; ++i) { data[i] = (data[i] << 1) | (data[i + 1] >> 7); } data[BlockSize - 1] <<= 1; /* Adjust based on carry. */ if (carry) { data[BlockSize - 1] ^= 0x87; } } }; template<typename BlockCipher> inline void CmacImpl<BlockCipher>::Initialize(const BlockCipher *cipher) { /* Clear the key storage. */ std::memset(m_sub_key, 0, sizeof(m_sub_key)); /* Set the key storage. */ cipher->EncryptBlock(m_sub_key, BlockSize, m_sub_key, BlockSize); MultiplyOneOverGF128(m_sub_key); /* Initialize the cbc-mac impl. */ m_cbc_mac_impl.Initialize(cipher); /* Mark initialized. */ m_state = State_Initialized; } template<typename BlockCipher> inline void CmacImpl<BlockCipher>::Update(const void *data, size_t data_size) { AMS_ASSERT(m_state == State_Initialized); m_cbc_mac_impl.template Update<BlockCipher>(data, data_size); } template<typename BlockCipher> inline void CmacImpl<BlockCipher>::GetMac(void *dst, size_t dst_size) { AMS_ASSERT(m_state == State_Initialized || m_state == State_Done); AMS_ASSERT(dst_size >= MacSize); AMS_UNUSED(dst_size); /* If we're not already finalized, get the final mac. */ if (m_state == State_Initialized) { /* Process padding as needed. */ if (m_cbc_mac_impl.GetBufferedDataSize() != BlockSize) { /* Determine the remaining size. */ const size_t remaining = BlockSize - m_cbc_mac_impl.GetBufferedDataSize(); /* Update with padding. */ static constexpr u8 s_padding[BlockSize] = { 0x80, /* ... */ }; m_cbc_mac_impl.template Update<BlockCipher>(s_padding, remaining); /* Update our subkey. */ MultiplyOneOverGF128(m_sub_key); } /* Mask the subkey. */ m_cbc_mac_impl.MaskBufferedData(m_sub_key, BlockSize); /* Set our state as done. */ m_state = State_Done; } /* Get the mac. */ m_cbc_mac_impl.GetMac(dst, dst_size); } }
4,500
C++
.h
108
31.944444
90
0.580512
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,061
crypto_rsa_pkcs1_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_rsa_pkcs1_impl.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_hash_function.hpp> namespace ams::crypto::impl { template<HashFunction Hash> class RsaPkcs1Impl { NON_COPYABLE(RsaPkcs1Impl); NON_MOVEABLE(RsaPkcs1Impl); public: static constexpr size_t HashSize = Hash::HashSize; public: RsaPkcs1Impl() { /* ... */ } ~RsaPkcs1Impl() { /* ... */ } void BuildPad(void *out_block, size_t block_size, Hash *hash) { AMS_ASSERT(block_size >= 2 + 1 + sizeof(Hash::Asn1Identifier) + HashSize); u8 *dst = static_cast<u8 *>(out_block); *(dst++) = 0x00; *(dst++) = 0x01; const size_t pad_len = block_size - (2 + 1 + sizeof(Hash::Asn1Identifier) + HashSize); std::memset(dst, 0xFF, pad_len); dst += pad_len; *(dst++) = 0x00; std::memcpy(dst, Hash::Asn1Identifier, sizeof(Hash::Asn1Identifier)); dst += sizeof(Hash::Asn1Identifier); hash->GetHash(dst, HashSize); } bool CheckPad(const u8 *src, size_t block_size, Hash *hash) { /* Check that block size is minimally big enough. */ if (block_size < 2 + 1 + sizeof(Hash::Asn1Identifier) + HashSize) { return false; } /* Check that the padding if correctly of form 0001FF..FF00 */ if (*(src++) != 0x00) { return false; } if (*(src++) != 0x01) { return false; } const size_t pad_len = block_size - (2 + 1 + sizeof(Hash::Asn1Identifier) + HashSize); for (size_t i = 0; i < pad_len; ++i) { if (*(src++) != 0xFF) { return false; } } if (*(src++) != 0x00) { return false; } /* Check that the asn1 identifier matches. */ if (std::memcmp(src, Hash::Asn1Identifier, sizeof(Hash::Asn1Identifier)) != 0) { return false; } src += sizeof(Hash::Asn1Identifier); /* Check the hash. */ u8 calc_hash[HashSize]; hash->GetHash(calc_hash, sizeof(calc_hash)); return std::memcmp(calc_hash, src, HashSize) == 0; } }; }
3,259
C++
.h
76
30.881579
102
0.530806
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,062
crypto_rsa_oaep_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_rsa_oaep_impl.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_hash_function.hpp> namespace ams::crypto::impl { template<HashFunction Hash> class RsaOaepImpl { NON_COPYABLE(RsaOaepImpl); NON_MOVEABLE(RsaOaepImpl); public: static constexpr size_t HashSize = Hash::HashSize; private: static constexpr u8 HeadMagic = 0x00; private: static void ComputeHashWithPadding(void *dst, Hash *hash, const void *salt, size_t salt_size) { /* Initialize our buffer. */ u8 buf[8 + HashSize]; std::memset(buf, 0, 8); hash->GetHash(buf + 8, HashSize); ON_SCOPE_EXIT { ClearMemory(buf, sizeof(buf)); }; /* Calculate our hash. */ hash->Initialize(); hash->Update(buf, sizeof(buf)); hash->Update(salt, salt_size); hash->GetHash(dst, HashSize); } static void ApplyMGF1(u8 *dst, size_t dst_size, const void *src, size_t src_size) { u8 buf[HashSize]; ON_SCOPE_EXIT { ClearMemory(buf, sizeof(buf)); }; const size_t required_iters = (dst_size + HashSize - 1) / HashSize; for (size_t i = 0; i < required_iters; i++) { Hash hash; hash.Initialize(); hash.Update(src, src_size); const u32 tmp = util::ConvertToBigEndian(static_cast<u32>(i)); hash.Update(std::addressof(tmp), sizeof(tmp)); hash.GetHash(buf, HashSize); const size_t start = HashSize * i; const size_t end = std::min(dst_size, start + HashSize); for (size_t j = start; j < end; j++) { dst[j] ^= buf[j - start]; } } } public: RsaOaepImpl() { /* ... */ } void Encode(void *dst, size_t dst_size, Hash *hash, const void *src, size_t src_size, const void *salt, size_t salt_size) { u8 label_digest[HashSize]; ON_SCOPE_EXIT { ClearMemory(label_digest, HashSize); }; hash->GetHash(label_digest, HashSize); return this->Encode(dst, dst_size, label_digest, sizeof(label_digest), src, src_size, salt, salt_size); } void Encode(void *dst, size_t dst_size, const void *label_digest, size_t label_digest_size, const void *src, size_t src_size, const void *salt, size_t salt_size) { /* Check our preconditions. */ AMS_ASSERT(dst_size >= 2 * HashSize + 2 + src_size); AMS_ASSERT(salt_size > 0); AMS_ASSERT(salt_size == HashSize); AMS_ASSERT(label_digest_size == HashSize); AMS_UNUSED(salt_size, label_digest_size); u8 *buf = static_cast<u8 *>(dst); buf[0] = HeadMagic; u8 *seed = buf + 1; std::memcpy(seed, salt, HashSize); u8 *db = seed + HashSize; std::memcpy(db, label_digest, HashSize); std::memset(db + HashSize, 0, dst_size - 2 * HashSize - 2 - src_size); u8 *msg = buf + dst_size - src_size - 1; *(msg++) = 0x01; std::memcpy(msg, src, src_size); ApplyMGF1(db, dst_size - (1 + HashSize), seed, HashSize); ApplyMGF1(seed, HashSize, db, dst_size - (1 + HashSize)); } size_t Decode(void *dst, size_t dst_size, const void *label_digest, size_t label_digest_size, u8 *buf, size_t buf_size) { /* Check our preconditions. */ AMS_ABORT_UNLESS(dst_size > 0); AMS_ABORT_UNLESS(buf_size >= 2 * HashSize + 3); AMS_ABORT_UNLESS(label_digest_size == HashSize); AMS_UNUSED(label_digest_size); /* Validate sanity byte. */ bool is_valid = buf[0] == HeadMagic; /* Decrypt seed and masked db. */ size_t db_len = buf_size - HashSize - 1; u8 *seed = buf + 1; u8 *db = seed + HashSize; ApplyMGF1(seed, HashSize, db, db_len); ApplyMGF1(db, db_len, seed, HashSize); /* Check the label digest. */ is_valid &= IsSameBytes(label_digest, db, HashSize); /* Skip past the label digest. */ db += HashSize; db_len -= HashSize; /* Verify that DB is of the form 0000...0001 < message > */ s32 msg_ofs = 0; { int looking_for_one = 1; int invalid_db_padding = 0; int is_zero; int is_one; for (size_t i = 0; i < db_len; /* ... */) { is_zero = (db[i] == 0); is_one = (db[i] == 1); msg_ofs += (looking_for_one & is_one) * (static_cast<s32>(++i)); looking_for_one &= ~is_one; invalid_db_padding |= (looking_for_one & ~is_zero); } is_valid &= (invalid_db_padding == 0); } /* If we're invalid, return zero size. */ const size_t valid_msg_size = db_len - msg_ofs; const size_t msg_size = std::min(dst_size, static_cast<size_t>(is_valid) * valid_msg_size); /* Copy to output. */ std::memcpy(dst, db + msg_ofs, msg_size); /* Return copied size. */ return msg_size; } }; }
6,563
C++
.h
133
34.81203
175
0.509375
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,063
crypto_sha256_impl_constexpr.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_sha256_impl_constexpr.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> namespace ams::crypto::impl { class Sha256CompileTimeImpl { public: static constexpr size_t HashSize = 0x20; static constexpr size_t BlockSize = 0x40; private: enum State { State_None, State_Initialized, State_Done, }; private: u32 m_intermediate_hash[HashSize / sizeof(u32)]; u8 m_buffer[BlockSize]; size_t m_buffered_bytes; u64 m_bits_consumed; State m_state; public: constexpr Sha256CompileTimeImpl() : m_intermediate_hash(), m_buffer(), m_buffered_bytes(), m_bits_consumed(), m_state(State_None) { /* ... */ } constexpr void Initialize() { /* Reset buffered bytes/bits. */ m_buffered_bytes = 0; m_bits_consumed = 0; /* Set intermediate hash. */ m_intermediate_hash[0] = 0x6A09E667; m_intermediate_hash[1] = 0xBB67AE85; m_intermediate_hash[2] = 0x3C6EF372; m_intermediate_hash[3] = 0xA54FF53A; m_intermediate_hash[4] = 0x510E527F; m_intermediate_hash[5] = 0x9B05688C; m_intermediate_hash[6] = 0x1F83D9AB; m_intermediate_hash[7] = 0x5BE0CD19; /* Set state. */ m_state = State_Initialized; } template<typename T, typename = typename std::enable_if<std::same_as<T, u8> || std::same_as<T, s8> || std::same_as<T, char> || std::same_as<T, unsigned char>>::type> constexpr void Update(const T *data, size_t size) { static_assert(sizeof(T) == 1); /* Verify we're in a state to update. */ AMS_ASSERT(m_state == State_Initialized); /* Advance our input bit count. */ m_bits_consumed += BITSIZEOF(u8) * (((m_buffered_bytes + size) / BlockSize) * BlockSize); /* Process anything we have buffered. */ size_t remaining = size; if (m_buffered_bytes > 0) { const size_t copy_size = std::min(BlockSize - m_buffered_bytes, remaining); for (size_t i = 0; i < copy_size; ++i) { m_buffer[m_buffered_bytes + i] = static_cast<u8>(data[i]); } data += copy_size; remaining -= copy_size; m_buffered_bytes += copy_size; /* Process a block, if we filled one. */ if (m_buffered_bytes == BlockSize) { this->ProcessBlock(m_buffer); m_buffered_bytes = 0; } } /* Process blocks, if we have any. */ while (remaining >= BlockSize) { u8 block[BlockSize] = {}; for (size_t i = 0; i < BlockSize; ++i) { block[i] = static_cast<u8>(data[i]); } this->ProcessBlock(block); data += BlockSize; remaining -= BlockSize; } /* Copy any leftover data to our buffer. */ if (remaining > 0) { m_buffered_bytes = remaining; for (size_t i = 0; i < remaining; ++i) { m_buffer[i] = static_cast<u8>(data[i]); } } } constexpr void GetHash(u8 *dst, size_t size) { /* Verify we're in a state to get hash. */ AMS_ASSERT(m_state == State_Initialized || m_state == State_Done); AMS_ASSERT(size >= HashSize); AMS_UNUSED(size); /* If we need to, process the last block. */ if (m_state == State_Initialized) { this->ProcessLastBlock(); m_state = State_Done; } /* Copy the output hash. */ for (size_t i = 0; i < HashSize / sizeof(u32); ++i) { const u32 v = m_intermediate_hash[i]; dst[sizeof(u32) * i + 3] = static_cast<u8>(v >> (BITSIZEOF(u8) * 0)); dst[sizeof(u32) * i + 2] = static_cast<u8>(v >> (BITSIZEOF(u8) * 1)); dst[sizeof(u32) * i + 1] = static_cast<u8>(v >> (BITSIZEOF(u8) * 2)); dst[sizeof(u32) * i + 0] = static_cast<u8>(v >> (BITSIZEOF(u8) * 3)); } } constexpr size_t GetBufferedDataSize() const { return m_buffered_bytes; } constexpr void GetBufferedData(u8 *dst, size_t dst_size) const { AMS_ASSERT(dst_size >= this->GetBufferedDataSize()); AMS_UNUSED(dst_size); for (size_t i = 0; i < m_buffered_bytes; ++i) { dst[i] = m_buffer[i]; } } private: static constexpr ALWAYS_INLINE u32 Choose(u32 x, u32 y, u32 z) { return (x & y) ^ ((~x) & z); } static constexpr ALWAYS_INLINE u32 Majority(u32 x, u32 y, u32 z) { return (x & y) ^ (x & z) ^ (y & z); } static constexpr ALWAYS_INLINE u32 LargeSigma0(u32 x) { return util::RotateRight<u32>(x, 2) ^ util::RotateRight<u32>(x, 13) ^ util::RotateRight<u32>(x, 22); } static constexpr ALWAYS_INLINE u32 LargeSigma1(u32 x) { return util::RotateRight<u32>(x, 6) ^ util::RotateRight<u32>(x, 11) ^ util::RotateRight<u32>(x, 25); } static constexpr ALWAYS_INLINE u32 SmallSigma0(u32 x) { return util::RotateRight<u32>(x, 7) ^ util::RotateRight<u32>(x, 18) ^ (x >> 3); } static constexpr ALWAYS_INLINE u32 SmallSigma1(u32 x) { return util::RotateRight<u32>(x, 17) ^ util::RotateRight<u32>(x, 19) ^ (x >> 10); } constexpr void ProcessBlock(const u8 *data) { /* Load work variables. */ u32 a = m_intermediate_hash[0]; u32 b = m_intermediate_hash[1]; u32 c = m_intermediate_hash[2]; u32 d = m_intermediate_hash[3]; u32 e = m_intermediate_hash[4]; u32 f = m_intermediate_hash[5]; u32 g = m_intermediate_hash[6]; u32 h = m_intermediate_hash[7]; u32 tmp[2]{}; size_t i = 0; /* Copy the input. */ u32 w[64]{}; for (size_t i = 0; i < BlockSize / sizeof(u32); ++i) { u32 v = 0; v |= static_cast<u32>(data[sizeof(u32) * i + 0]) << (BITSIZEOF(u8) * 3); v |= static_cast<u32>(data[sizeof(u32) * i + 1]) << (BITSIZEOF(u8) * 2); v |= static_cast<u32>(data[sizeof(u32) * i + 2]) << (BITSIZEOF(u8) * 1); v |= static_cast<u32>(data[sizeof(u32) * i + 3]) << (BITSIZEOF(u8) * 0); w[i] = v; } /* Initialize the rest of w. */ for (i = BlockSize / sizeof(u32); i < util::size(w); ++i) { const u32 *prev = w + (i - BlockSize / sizeof(u32)); w[i] = prev[0] + SmallSigma0(prev[1]) + prev[9] + SmallSigma1(prev[14]); } /* Perform rounds. */ { const u32 RoundConstants[0x40] = { 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC, 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967, 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2, }; for (i = 0; i < 64; ++i) { tmp[0] = h + LargeSigma1(e) + Choose(e, f, g) + RoundConstants[i] + w[i]; tmp[1] = LargeSigma0(a) + Majority(a, b, c); h = g; g = f; f = e; e = d + tmp[0]; d = c; c = b; b = a; a = tmp[0] + tmp[1]; } } /* Update intermediate hash. */ m_intermediate_hash[0] += a; m_intermediate_hash[1] += b; m_intermediate_hash[2] += c; m_intermediate_hash[3] += d; m_intermediate_hash[4] += e; m_intermediate_hash[5] += f; m_intermediate_hash[6] += g; m_intermediate_hash[7] += h; } constexpr void ProcessLastBlock() { /* Setup the final block. */ constexpr const auto BlockSizeWithoutSizeField = BlockSize - sizeof(u64); /* Increment our bits consumed. */ m_bits_consumed += BITSIZEOF(u8) * m_buffered_bytes; /* Add 0x80 terminator. */ m_buffer[m_buffered_bytes++] = 0x80; /* If we can process the size field directly, do so, otherwise set up to process it. */ if (m_buffered_bytes <= BlockSizeWithoutSizeField) { /* Clear up to size field. */ for (size_t i = 0; i < BlockSizeWithoutSizeField - m_buffered_bytes; ++i) { m_buffer[m_buffered_bytes + i] = 0; } } else { /* Consume full block */ for (size_t i = 0; i < BlockSize - m_buffered_bytes; ++i) { m_buffer[m_buffered_bytes + i] = 0; } this->ProcessBlock(m_buffer); /* Clear up to size field. */ for (size_t i = 0; i < BlockSizeWithoutSizeField; ++i) { m_buffer[i] = 0; } } /* Store the size field. */ m_buffer[BlockSizeWithoutSizeField + 0] = static_cast<u8>((m_bits_consumed >> (BITSIZEOF(u8) * 7)) & 0xFF); m_buffer[BlockSizeWithoutSizeField + 1] = static_cast<u8>((m_bits_consumed >> (BITSIZEOF(u8) * 6)) & 0xFF); m_buffer[BlockSizeWithoutSizeField + 2] = static_cast<u8>((m_bits_consumed >> (BITSIZEOF(u8) * 5)) & 0xFF); m_buffer[BlockSizeWithoutSizeField + 3] = static_cast<u8>((m_bits_consumed >> (BITSIZEOF(u8) * 4)) & 0xFF); m_buffer[BlockSizeWithoutSizeField + 4] = static_cast<u8>((m_bits_consumed >> (BITSIZEOF(u8) * 3)) & 0xFF); m_buffer[BlockSizeWithoutSizeField + 5] = static_cast<u8>((m_bits_consumed >> (BITSIZEOF(u8) * 2)) & 0xFF); m_buffer[BlockSizeWithoutSizeField + 6] = static_cast<u8>((m_bits_consumed >> (BITSIZEOF(u8) * 1)) & 0xFF); m_buffer[BlockSizeWithoutSizeField + 7] = static_cast<u8>((m_bits_consumed >> (BITSIZEOF(u8) * 0)) & 0xFF); /* Process the final block. */ this->ProcessBlock(m_buffer); } }; }
13,047
C++
.h
251
35.079681
177
0.482001
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,064
crypto_sha256_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_sha256_impl.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_hash_function.hpp> #include <vapours/crypto/crypto_memory_clear.hpp> namespace ams::crypto { struct Sha256Context; } namespace ams::crypto::impl { class Sha256Impl { public: static constexpr size_t HashSize = 0x20; static constexpr size_t BlockSize = 0x40; private: enum State { State_None, State_Initialized, State_Done, }; private: u32 m_intermediate_hash[HashSize / sizeof(u32)]; u8 m_buffer[BlockSize]; size_t m_buffered_bytes; u64 m_bits_consumed; State m_state; public: Sha256Impl() : m_state(State_None) { /* ... */ } ~Sha256Impl() { ClearMemory(this, sizeof(*this)); } void Initialize(); void Update(const void *data, size_t size); void GetHash(void *dst, size_t size); void InitializeWithContext(const Sha256Context *context); size_t GetContext(Sha256Context *context) const; size_t GetBufferedDataSize() const { return m_buffered_bytes; } void GetBufferedData(void *dst, size_t dst_size) const { AMS_ASSERT(dst_size >= this->GetBufferedDataSize()); AMS_UNUSED(dst_size); std::memcpy(dst, m_buffer, m_buffered_bytes); } private: void ProcessBlock(const void *data); void ProcessBlocks(const u8 *data, size_t block_count); void ProcessLastBlock(); }; static_assert(HashFunction<Sha256Impl>); }
2,433
C++
.h
64
29.65625
76
0.626486
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,065
crypto_ctr_mode_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_ctr_mode_impl.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_memory_clear.hpp> #include <vapours/crypto/crypto_aes_encryptor.hpp> namespace ams::crypto::impl { template<typename BlockCipher> class CtrModeImpl { NON_COPYABLE(CtrModeImpl); NON_MOVEABLE(CtrModeImpl); public: static constexpr size_t KeySize = BlockCipher::KeySize; static constexpr size_t BlockSize = BlockCipher::BlockSize; static constexpr size_t IvSize = BlockCipher::BlockSize; private: enum State { State_None, State_Initialized, }; private: const BlockCipher *m_block_cipher; u8 m_counter[IvSize]; u8 m_encrypted_counter[BlockSize]; size_t m_buffer_offset; State m_state; public: CtrModeImpl() : m_state(State_None) { /* ... */ } ~CtrModeImpl() { ClearMemory(this, sizeof(*this)); } void Initialize(const BlockCipher *block_cipher, const void *iv, size_t iv_size) { this->Initialize(block_cipher, iv, iv_size, 0); } void Initialize(const BlockCipher *block_cipher, const void *iv, size_t iv_size, s64 offset) { AMS_ASSERT(iv_size == IvSize); AMS_ASSERT(offset >= 0); m_block_cipher = block_cipher; m_state = State_Initialized; this->SwitchMessage(iv, iv_size); if (offset >= 0) { u64 ctr_offset = offset / BlockSize; if (ctr_offset > 0) { this->IncrementCounter(ctr_offset); } if (size_t remaining = static_cast<size_t>(offset % BlockSize); remaining != 0) { m_block_cipher->EncryptBlock(m_encrypted_counter, sizeof(m_encrypted_counter), m_counter, sizeof(m_counter)); this->IncrementCounter(); m_buffer_offset = remaining; } } } void SwitchMessage(const void *iv, size_t iv_size) { AMS_ASSERT(m_state == State_Initialized); AMS_ASSERT(iv_size == IvSize); std::memcpy(m_counter, iv, iv_size); m_buffer_offset = 0; } void IncrementCounter() { for (s32 i = IvSize - 1; i >= 0; --i) { if (++m_counter[i] != 0) { break; } } } size_t Update(void *_dst, size_t dst_size, const void *_src, size_t src_size) { AMS_ASSERT(m_state == State_Initialized); AMS_ASSERT(dst_size >= src_size); AMS_UNUSED(dst_size); u8 *dst = static_cast<u8 *>(_dst); const u8 *src = static_cast<const u8 *>(_src); size_t remaining = src_size; if (m_buffer_offset > 0) { const size_t xor_size = std::min(BlockSize - m_buffer_offset, remaining); const u8 *ctr = m_encrypted_counter + m_buffer_offset; for (size_t i = 0; i < xor_size; i++) { dst[i] = src[i] ^ ctr[i]; } src += xor_size; dst += xor_size; remaining -= xor_size; m_buffer_offset += xor_size; if (m_buffer_offset == BlockSize) { m_buffer_offset = 0; } } if (remaining >= BlockSize) { const size_t num_blocks = remaining / BlockSize; this->ProcessBlocks(dst, src, num_blocks); const size_t processed_size = num_blocks * BlockSize; dst += processed_size; src += processed_size; remaining -= processed_size; } if (remaining > 0) { this->ProcessBlock(dst, src, remaining); m_buffer_offset = remaining; } return src_size; } private: void IncrementCounter(u64 count) { u64 _block[IvSize / sizeof(u64)] = {}; util::StoreBigEndian(std::addressof(_block[(IvSize / sizeof(u64)) - 1]), count); u16 acc = 0; const u8 *block = reinterpret_cast<const u8 *>(_block); for (s32 i = IvSize - 1; i >= 0; --i) { acc += (m_counter[i] + block[i]); m_counter[i] = acc & 0xFF; acc >>= 8; } } void ProcessBlock(u8 *dst, const u8 *src, size_t src_size) { m_block_cipher->EncryptBlock(m_encrypted_counter, BlockSize, m_counter, IvSize); this->IncrementCounter(); for (size_t i = 0; i < src_size; i++) { dst[i] = src[i] ^ m_encrypted_counter[i]; } } void ProcessBlocks(u8 *dst, const u8 *src, size_t num_blocks); }; template<typename BlockCipher> inline void CtrModeImpl<BlockCipher>::ProcessBlocks(u8 *dst, const u8 *src, size_t num_blocks) { while (num_blocks--) { this->ProcessBlock(dst, src, BlockSize); dst += BlockSize; src += BlockSize; } } template<> void CtrModeImpl<AesEncryptor128>::ProcessBlocks(u8 *dst, const u8 *src, size_t num_blocks); /* TODO: Optimized x64 CTR-192/256? */ #if defined(ATMOSPHERE_ARCH_ARM64) template<> void CtrModeImpl<AesEncryptor192>::ProcessBlocks(u8 *dst, const u8 *src, size_t num_blocks); template<> void CtrModeImpl<AesEncryptor256>::ProcessBlocks(u8 *dst, const u8 *src, size_t num_blocks); #endif }
6,804
C++
.h
151
31.298013
133
0.515559
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,066
crypto_block_cipher.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_block_cipher.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_memory_compare.hpp> #include <vapours/crypto/crypto_memory_clear.hpp> namespace ams::crypto::impl { template<typename T> concept BlockCipher = requires(T &t, const void *cv, void *v, size_t sz, bool b) { { T::BlockSize } -> std::convertible_to<size_t>; { t.EncryptBlock(v, sz, cv, sz) } -> std::same_as<void>; { t.DecryptBlock(v, sz, cv, sz) } -> std::same_as<void>; }; }
1,197
C++
.h
29
38.413793
86
0.704467
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,067
crypto_hmac_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_hmac_impl.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/impl/crypto_hash_function.hpp> #include <vapours/crypto/crypto_memory_clear.hpp> namespace ams::crypto::impl { template<HashFunction Hash> class HmacImpl { NON_COPYABLE(HmacImpl); NON_MOVEABLE(HmacImpl); public: static constexpr size_t MacSize = Hash::HashSize; static constexpr size_t BlockSize = Hash::BlockSize; private: static constexpr u32 IpadMagic = 0x36363636; static constexpr u32 OpadMagic = 0x5c5c5c5c; static constexpr u32 IpadMagicXorOpadMagic = IpadMagic ^ OpadMagic; static_assert(IpadMagicXorOpadMagic == 0x6a6a6a6a); private: enum State { State_None = 0, State_Initialized = 1, State_Done = 2, }; private: Hash m_hash_function; u32 m_key[BlockSize / sizeof(u32)]; u32 m_mac[MacSize / sizeof(u32)]; State m_state; public: HmacImpl() : m_state(State_None) { /* ... */ } ~HmacImpl() { static_assert(AMS_OFFSETOF(HmacImpl, m_hash_function) == 0); /* Clear everything except for the hash function. */ ClearMemory(reinterpret_cast<u8 *>(this) + sizeof(m_hash_function), sizeof(*this) - sizeof(m_hash_function)); } void Initialize(const void *key, size_t key_size); void Update(const void *data, size_t data_size); void GetMac(void *dst, size_t dst_size); }; template<HashFunction Hash> inline void HmacImpl<Hash>::Initialize(const void *key, size_t key_size) { /* Clear the key storage. */ std::memset(m_key, 0, sizeof(m_key)); /* Set the key storage. */ if (key_size > BlockSize) { m_hash_function.Initialize(); m_hash_function.Update(key, key_size); m_hash_function.GetHash(m_key, m_hash_function.HashSize); } else { std::memcpy(m_key, key, key_size); } /* Xor the key with the ipad. */ for (size_t i = 0; i < util::size(m_key); i++) { m_key[i] ^= IpadMagic; } /* Update the hash function with the xor'd key. */ m_hash_function.Initialize(); m_hash_function.Update(m_key, BlockSize); /* Mark initialized. */ m_state = State_Initialized; } template<HashFunction Hash> inline void HmacImpl<Hash>::Update(const void *data, size_t data_size) { AMS_ASSERT(m_state == State_Initialized); m_hash_function.Update(data, data_size); } template<HashFunction Hash> inline void HmacImpl<Hash>::GetMac(void *dst, size_t dst_size) { AMS_ASSERT(m_state == State_Initialized || m_state == State_Done); AMS_ASSERT(dst_size >= MacSize); AMS_UNUSED(dst_size); /* If we're not already finalized, get the final mac. */ if (m_state == State_Initialized) { /* Get the hash of ((key ^ ipad) || data). */ m_hash_function.GetHash(m_mac, MacSize); /* Xor the key with the opad. */ for (size_t i = 0; i < util::size(m_key); i++) { m_key[i] ^= IpadMagicXorOpadMagic; } /* Calculate the final mac as hash of ((key ^ opad) || hash((key ^ ipad) || data)) */ m_hash_function.Initialize(); m_hash_function.Update(m_key, BlockSize); m_hash_function.Update(m_mac, MacSize); m_hash_function.GetHash(m_mac, MacSize); /* Set our state as done. */ m_state = State_Done; } std::memcpy(dst, m_mac, MacSize); } }
4,501
C++
.h
107
33.084112
125
0.595565
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,068
crypto_bignum.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_bignum.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_memory_compare.hpp> #include <vapours/crypto/crypto_memory_clear.hpp> namespace ams::crypto::impl { class BigNum { NON_COPYABLE(BigNum); NON_MOVEABLE(BigNum); public: using HalfWord = u16; using Word = u32; using DoubleWord = u64; static constexpr size_t MaxBits = 4096; static constexpr size_t BitsPerWord = sizeof(Word) * CHAR_BIT; static constexpr Word MaxWord = std::numeric_limits<Word>::max(); static constexpr Word MaxHalfWord = std::numeric_limits<HalfWord>::max(); class WordAllocator { NON_COPYABLE(WordAllocator); NON_MOVEABLE(WordAllocator); public: class Allocation { NON_COPYABLE(Allocation); NON_MOVEABLE(Allocation); private: friend class WordAllocator; private: WordAllocator *m_allocator; Word *m_buffer; size_t m_count; private: constexpr ALWAYS_INLINE Allocation(WordAllocator *a, Word *w, size_t c) : m_allocator(a), m_buffer(w), m_count(c) { /* ... */ } public: ALWAYS_INLINE ~Allocation() { if (m_allocator) { m_allocator->Free(m_buffer, m_count); } } constexpr ALWAYS_INLINE Word *GetBuffer() const { return m_buffer; } constexpr ALWAYS_INLINE size_t GetCount() const { return m_count; } constexpr ALWAYS_INLINE bool IsValid() const { return m_buffer != nullptr; } }; friend class Allocation; private: Word *m_buffer; size_t m_count; size_t m_max_count; size_t m_min_count; private: ALWAYS_INLINE void Free(void *words, size_t num) { m_buffer -= num; m_count += num; AMS_ASSERT(words == m_buffer); AMS_UNUSED(words); } public: constexpr ALWAYS_INLINE WordAllocator(Word *buf, size_t c) : m_buffer(buf), m_count(c), m_max_count(c), m_min_count(c) { /* ... */ } ALWAYS_INLINE Allocation Allocate(size_t num) { if (num <= m_count) { Word *allocated = m_buffer; m_buffer += num; m_count -= num; m_min_count = std::min(m_count, m_min_count); return Allocation(this, allocated, num); } else { return Allocation(nullptr, nullptr, 0); } } constexpr ALWAYS_INLINE size_t GetMaxUsedSize() const { return (m_max_count - m_min_count) * sizeof(Word); } }; private: Word *m_words; size_t m_num_words; size_t m_max_words; private: static void ImportImpl(Word *out, size_t out_size, const u8 *src, size_t src_size); static void ExportImpl(u8 *out, size_t out_size, const Word *src, size_t src_size); public: constexpr BigNum() : m_words(), m_num_words(), m_max_words() { /* ... */ } ~BigNum() { /* ... */ } constexpr void ReserveStatic(Word *buf, size_t capacity) { m_words = buf; m_max_words = capacity; } bool Import(const void *src, size_t src_size); void Export(void *dst, size_t dst_size); size_t GetSize() const; bool IsZero() const { return m_num_words == 0; } bool ExpMod(void *dst, const void *src, size_t size, const BigNum &exp, u32 *work_buf, size_t work_buf_size) const; void ClearToZero(); void UpdateCount(); public: /* Utility. */ static bool IsZero(const Word *w, size_t num_words); static int Compare(const Word *lhs, const Word *rhs, size_t num_words); static size_t CountWords(const Word *w, size_t num_words); static size_t CountSignificantBits(Word w); static void ClearToZero(Word *w, size_t num_words); static void SetToWord(Word *w, size_t num_words, Word v); static void Copy(Word *dst, const Word *src, size_t num_words); /* Arithmetic. */ static bool ExpMod(Word *dst, const Word *src, const Word *exp, size_t exp_num_words, const Word *mod, size_t mod_num_words, WordAllocator *allocator); static bool MultMod(Word *dst, const Word *src, const Word *mult, const Word *mod, size_t num_words, WordAllocator *allocator); static bool Mod(Word *dst, const Word *src, size_t src_words, const Word *mod, size_t mod_words, WordAllocator *allocator); static bool DivMod(Word *quot, Word *rem, const Word *top, size_t top_words, const Word *bot, size_t bot_words, WordAllocator *allocator); static bool Mult(Word *dst, const Word *lhs, const Word *rhs, size_t num_words, WordAllocator *allocator); static Word LeftShift(Word *dst, const Word *w, size_t num_words, const size_t shift); static Word RightShift(Word *dst, const Word *w, size_t num_words, const size_t shift); static Word Add(Word *dst, const Word *lhs, const Word *rhs, size_t num_words); static Word Sub(Word *dst, const Word *lhs, const Word *rhs, size_t num_words); static Word MultAdd(Word *dst, const Word *w, size_t num_words, Word mult); static Word MultSub(Word *dst, const Word *w, const Word *v, size_t num_words, Word mult); }; template<size_t Bits> class StaticBigNum : public BigNum { public: static constexpr size_t NumBits = Bits; static constexpr size_t NumWords = util::AlignUp(NumBits, BitsPerWord) / BitsPerWord; static constexpr size_t NumBytes = NumWords * sizeof(Word); private: Word m_word_buf[NumWords]; public: constexpr StaticBigNum() : m_word_buf() { this->ReserveStatic(m_word_buf, NumWords); } }; }
7,483
C++
.h
143
37.601399
165
0.542697
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,069
crypto_gcm_mode_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_gcm_mode_impl.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_memory_clear.hpp> #include <vapours/crypto/crypto_aes_encryptor.hpp> namespace ams::crypto::impl { template<typename BlockCipher> class GcmModeImpl { NON_COPYABLE(GcmModeImpl); NON_MOVEABLE(GcmModeImpl); public: static constexpr size_t KeySize = BlockCipher::KeySize; static constexpr size_t BlockSize = BlockCipher::BlockSize; static constexpr size_t MacSize = BlockCipher::BlockSize; private: enum State { State_None, State_Initialized, State_ProcessingAad, State_Encrypting, State_Decrypting, State_Done, }; struct Block128 { u64 hi; u64 lo; ALWAYS_INLINE void Clear() { this->hi = 0; this->lo = 0; } }; static_assert(util::is_pod<Block128>::value); static_assert(sizeof(Block128) == 0x10); union Block { Block128 block_128; u32 block_32[4]; u8 block_8[16]; }; static_assert(util::is_pod<Block>::value); static_assert(sizeof(Block) == 0x10); using CipherFunction = void (*)(void *dst_block, const void *src_block, const void *ctx); private: State m_state; const BlockCipher *m_block_cipher; CipherFunction m_cipher_func; u8 m_pad[sizeof(u64)]; Block m_block_x; Block m_block_y; Block m_block_ek; Block m_block_ek0; Block m_block_tmp; size_t m_aad_size; size_t m_msg_size; u32 m_aad_remaining; u32 m_msg_remaining; u32 m_counter; Block m_h_mult_blocks[16]; public: GcmModeImpl() : m_state(State_None) { /* ... */ } ~GcmModeImpl() { ClearMemory(this, sizeof(*this)); } void Initialize(const BlockCipher *block_cipher); void Reset(const void *iv, size_t iv_size); void UpdateAad(const void *aad, size_t aad_size); size_t UpdateEncrypt(void *dst, size_t dst_size, const void *src, size_t src_size); size_t UpdateDecrypt(void *dst, size_t dst_size, const void *src, size_t src_size); void GetMac(void *dst, size_t dst_size); private: static void ProcessBlock(void *dst_block, const void *src_block, const void *ctx) { static_cast<const BlockCipher *>(ctx)->EncryptBlock(dst_block, BlockSize, src_block, BlockSize); } void InitializeHashKey(); void ComputeMac(bool encrypt); }; }
3,638
C++
.h
92
28.978261
112
0.575028
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
9,070
crypto_hash_function.hpp
Atmosphere-NX_Atmosphere/libraries/libvapours/include/vapours/crypto/impl/crypto_hash_function.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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 <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours/common.hpp> #include <vapours/assert.hpp> #include <vapours/util.hpp> #include <vapours/crypto/crypto_memory_compare.hpp> #include <vapours/crypto/crypto_memory_clear.hpp> namespace ams::crypto::impl { template<typename T> concept HashFunction = requires(T &t, const void *cv, void *v, size_t sz) { { T::HashSize } -> std::convertible_to<size_t>; { T::BlockSize } -> std::convertible_to<size_t>; { t.Initialize() } -> std::same_as<void>; { t.Update(cv, sz) } -> std::same_as<void>; { t.GetHash(v, sz) } -> std::same_as<void>; }; }
1,264
C++
.h
31
37.516129
79
0.693247
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false