mirror of
https://github.com/jakcron/nstool
synced 2024-11-15 02:06:40 +00:00
[nx] Add AesKegen class for generating Keks and Keys.
This commit is contained in:
parent
bfb9d87c95
commit
2573ad4b47
2 changed files with 38 additions and 0 deletions
19
lib/libnx/include/nx/AesKeygen.h
Normal file
19
lib/libnx/include/nx/AesKeygen.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <crypto/aes.h>
|
||||
|
||||
namespace nx
|
||||
{
|
||||
class AesKeygen
|
||||
{
|
||||
public:
|
||||
|
||||
// 1 stage key generation dst = src_key.decrypt(src)
|
||||
static void generateKey(byte_t* dst, const byte_t* src, const byte_t* src_key);
|
||||
// 2 stage key generation dst = (src1_key.decrypt(src1)).decrypt(src2)
|
||||
static void generateKey(byte_t* dst, const byte_t* src1, const byte_t* src2, const byte_t* src1_key);
|
||||
// 3 stage key generation dst = ((src1_key.decrypt(src1)).decrypt(src2)).decrypt(src3)
|
||||
static void generateKey(byte_t* dst, const byte_t* src1, const byte_t* src2, const byte_t* src3, const byte_t* src1_key);
|
||||
};
|
||||
}
|
19
lib/libnx/source/AesKeygen.cpp
Normal file
19
lib/libnx/source/AesKeygen.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include <nx/AesKeygen.h>
|
||||
|
||||
void nx::AesKeygen::generateKey(byte_t* dst, const byte_t* src, const byte_t* src_key)
|
||||
{
|
||||
crypto::aes::AesEcbDecrypt(src, sizeof(crypto::aes::sAes128Key), src_key, dst);
|
||||
}
|
||||
|
||||
void nx::AesKeygen::generateKey(byte_t* dst, const byte_t* src1, const byte_t* src2, const byte_t* src1_key)
|
||||
{
|
||||
crypto::aes::sAes128Key src2_key;
|
||||
generateKey(src2_key.key, src1, src1_key);
|
||||
generateKey(dst, src2, src2_key.key);
|
||||
}
|
||||
void nx::AesKeygen::generateKey(byte_t* dst, const byte_t* src1, const byte_t* src2, const byte_t* src3, const byte_t* src1_key)
|
||||
{
|
||||
crypto::aes::sAes128Key src3_key;
|
||||
generateKey(src3_key.key, src1, src2, src1_key);
|
||||
generateKey(dst, src3, src3_key.key);
|
||||
}
|
Loading…
Reference in a new issue