-
Notifications
You must be signed in to change notification settings - Fork 0
/
sev-cert.h
76 lines (64 loc) · 1.57 KB
/
sev-cert.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef _SEV_CERT_H
#define _SEV_CERT_H
#include <stdint.h>
typedef enum pubkey_usage_t {
PUBKEY_ARK = 0x0,
PUBKEY_ASK = 0x13,
PUBKEY_INVD = 0x1000,
PUBKEY_OCA = 0x1001,
PUBKEY_PEK = 0x1002,
PUBKEY_PDH = 0x1003,
PUBKEY_CEK = 0x1004
} pubkey_usage_t;
enum pubkey_algo_t {
PUBKEY_ALGO_INVALID = 0x0,
PUBKEY_ALGO_RSA_SHA_256 = 0x1,
PUBKEY_ALGO_ECDSA_SHA_256 = 0x2,
PUBKEY_ALGO_ECDH_SHA_256 = 0x3,
PUBKEY_ALGO_RSA_SHA_384 = 0x101,
PUBKEY_ALGO_ECDSA_SHA_384 = 0x102,
PUBKEY_ALGO_ECDH_SHA_384 = 0x103,
};
typedef struct __attribute__((__packed__)) rsa_sig_t {
uint8_t s[512];
} rsa_sig_t;
typedef struct __attribute__((__packed__)) ecdsa_sig_t {
uint8_t r[72];
uint8_t s[72];
} ecdsa_sig_t;
typedef struct __attribute__((__packed__)) rsa_key_t {
uint32_t modulus_sz;
uint8_t pubexp[512];
uint8_t modulus[512];
} rsa_key_t;
typedef struct __attribute__((__packed__)) ecdsa_key_t {
uint32_t curve;
uint8_t qx[72];
uint8_t qy[72];
} ecdsa_key_t;
typedef struct __attribute__((__packed__)) ecdh_key_t {
uint32_t curve;
uint8_t qx[72];
uint8_t qy[72];
} ecdh_key_t;
typedef struct __attribute__((__packed__)) cert_data_t {
uint32_t version;
uint8_t major;
uint8_t minor;
uint16_t reserved;
uint32_t pubkey_usage;
uint32_t pubkey_algo;
uint8_t pubkey[1028];
uint32_t sig1_usage;
uint32_t sig1_algo;
uint8_t sig1[512];
uint32_t sig2_usage;
uint32_t sig2_algo;
uint8_t sig2[512];
} cert_data_t;
enum {
SIG_USAGE_NOT_PRESENT = 0x1000
};
void dump_cert_data(void *buf, int len);
char* extract_cert(const char *buf, size_t len, pubkey_usage_t type);
#endif