summaryrefslogtreecommitdiffstats
path: root/src/core/hw/aes/key.h
blob: c9f1342f4f7afbe4b441fd442a08925e5d212662 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2017 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#pragma once

#include <array>
#include <cstddef>
#include "common/common_types.h"

namespace HW {
namespace AES {

enum KeySlotID : size_t {
    // AES Keyslot used to generate the UDS data frame CCMP key.
    UDSDataKey = 0x2D,
    APTWrap = 0x31,

    MaxKeySlotID = 0x40,
};

constexpr size_t AES_BLOCK_SIZE = 16;

using AESKey = std::array<u8, AES_BLOCK_SIZE>;

void InitKeys();

void SetGeneratorConstant(const AESKey& key);
void SetKeyX(size_t slot_id, const AESKey& key);
void SetKeyY(size_t slot_id, const AESKey& key);
void SetNormalKey(size_t slot_id, const AESKey& key);

bool IsNormalKeyAvailable(size_t slot_id);
AESKey GetNormalKey(size_t slot_id);

} // namspace AES
} // namespace HW