forked from cloud-security-research/sgx-ra-tls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wolfssl-ra.c
33 lines (28 loc) · 837 Bytes
/
wolfssl-ra.c
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
#include <assert.h>
#include <stdint.h>
#include <wolfssl/options.h>
#include <wolfssl/wolfcrypt/asn_public.h>
#include <wolfssl/wolfcrypt/rsa.h>
#include "wolfssl-ra.h"
void sha256_rsa_pubkey
(
unsigned char hash[SHA256_DIGEST_SIZE],
RsaKey* key
)
{
// Expect a 2048 bit RSA key.
assert(key->n.used == 32);
uint8_t buf[1024];
/* SetRsaPublicKey() only exports n and e without wrapping them in
additional ASN.1 (PKCS#1). */
int pub_rsa_key_der_len = SetRsaPublicKey(buf, key, sizeof(buf), 0);
assert(pub_rsa_key_der_len == 270);
Sha256 sha;
wc_InitSha256(&sha);
wc_Sha256Update(&sha, buf, pub_rsa_key_der_len);
wc_Sha256Final(&sha, hash);
}
/* This function only exists to make edger8r happy. There must be at
least one trusted (ECALL) function. */
void dummy(void) {
}