aboutsummaryrefslogtreecommitdiff
path: root/src/core/hw/rsa/rsa.h
blob: 0c94171a9c98e9c5c4b17b55cf46cbd8c06c7a9d (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 2020 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#pragma once

#include <span>
#include <vector>
#include "common/common_types.h"

namespace HW::RSA {

class RsaSlot {
public:
    RsaSlot() = default;
    RsaSlot(std::vector<u8> exponent, std::vector<u8> modulus)
        : init(true), exponent(std::move(exponent)), modulus(std::move(modulus)) {}
    std::vector<u8> GetSignature(std::span<const u8> message) const;

    explicit operator bool() const {
        // TODO(B3N30): Maybe check if exponent and modulus are vailid
        return init;
    }

private:
    bool init = false;
    std::vector<u8> exponent;
    std::vector<u8> modulus;
};

void InitSlots();

RsaSlot GetSlot(std::size_t slot_id);

std::vector<u8> CreateASN1Message(std::span<const u8> data);

} // namespace HW::RSA