libs: add ongoing work to facilitate hactool rewrite

This commit is contained in:
Michael Scire
2022-03-08 10:05:32 -08:00
parent a4895a1e79
commit 100bead52b
34 changed files with 1829 additions and 216 deletions

View File

@@ -0,0 +1,27 @@
/*
* 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/>.
*/
#include <stratosphere.hpp>
#include <ntstatus.h>
#include <bcrypt.h>
namespace ams::crypto {
void GenerateCryptographicallyRandomBytes(void *dst, size_t dst_size) {
const auto status = ::BCryptGenRandom(nullptr, static_cast<PUCHAR>(dst), dst_size, BCRYPT_USE_SYSTEM_PREFERRED_RNG);
AMS_ABORT_UNLESS(status == STATUS_SUCCESS);
}
}