Skip to content

Commit

Permalink
Cleanup pass (#41)
Browse files Browse the repository at this point in the history
* Removed old satp checks, that check is now handled by tracking hart state and enforcement in the driver. Standardized the sbi function style

* Removed all definition of _t types, as they are reserved. All structs are now referenced explictly as structs, not typedefd. See keystone-enclave/keystone#76 .

* Removed extraneous aes implementation
  • Loading branch information
dkohlbre authored May 6, 2019
2 parents a280c5f + a60a876 commit fc2441e
Show file tree
Hide file tree
Showing 20 changed files with 194 additions and 855 deletions.
567 changes: 0 additions & 567 deletions sm/aes/aes.c

This file was deleted.

90 changes: 0 additions & 90 deletions sm/aes/aes.h

This file was deleted.

10 changes: 5 additions & 5 deletions sm/attest.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

/* This will walk the entire vaddr space in the enclave, validating
linear at-most-once paddr mappings, and then hashing valid pages */
int validate_and_hash_epm(hash_ctx_t* hash_ctx, int level,
int validate_and_hash_epm(hash_ctx* hash_ctx, int level,
pte_t* tb, uintptr_t vaddr, int contiguous,
struct keystone_sbi_create_t* cargs,
struct keystone_sbi_create* cargs,
uintptr_t* runtime_max_seen,
uintptr_t* user_max_seen)
{
Expand Down Expand Up @@ -154,10 +154,10 @@ int validate_and_hash_epm(hash_ctx_t* hash_ctx, int level,
return -1;
}

enclave_ret_t validate_and_hash_enclave(struct enclave_t* enclave,
struct keystone_sbi_create_t* cargs){
enclave_ret_code validate_and_hash_enclave(struct enclave* enclave,
struct keystone_sbi_create* cargs){

hash_ctx_t hash_ctx;
hash_ctx hash_ctx;
int ptlevel = RISCV_PGLEVEL_TOP;
int i;

Expand Down
4 changes: 2 additions & 2 deletions sm/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//------------------------------------------------------------------------------
#include "cpu.h"

static struct cpu_state_t cpus[MAX_HARTS];
static struct cpu_state cpus[MAX_HARTS];

int cpu_is_enclave_context()
{
Expand All @@ -16,7 +16,7 @@ int cpu_get_enclave_id()
return cpus[read_csr(mhartid)].eid;
}

void cpu_enter_enclave_context(eid_t eid)
void cpu_enter_enclave_context(enclave_id eid)
{
cpus[read_csr(mhartid)].is_enclave = 1;
cpus[read_csr(mhartid)].eid = eid;
Expand Down
6 changes: 3 additions & 3 deletions sm/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
#include "enclave.h"

/* hart state for regulating SBI */
struct cpu_state_t
struct cpu_state
{
int is_enclave;
eid_t eid;
enclave_id eid;
};

/* external functions */
int cpu_is_enclave_context();
int cpu_get_enclave_id();
void cpu_enter_enclave_context(eid_t eid);
void cpu_enter_enclave_context(enclave_id eid);
void cpu_exit_enclave_context();

#endif
8 changes: 4 additions & 4 deletions sm/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
#include "crypto.h"
#include "page.h"

void hash_init(hash_ctx_t* hash_ctx)
void hash_init(hash_ctx* hash_ctx)
{
sha3_init(hash_ctx, MDSIZE);
}

void hash_extend(hash_ctx_t* hash_ctx, const void* ptr, size_t len)
void hash_extend(hash_ctx* hash_ctx, const void* ptr, size_t len)
{
sha3_update(hash_ctx, ptr, len);
}

void hash_extend_page(hash_ctx_t* hash_ctx, const void* ptr)
void hash_extend_page(hash_ctx* hash_ctx, const void* ptr)
{
sha3_update(hash_ctx, ptr, RISCV_PGSIZE);
}

void hash_finalize(void* md, hash_ctx_t* hash_ctx)
void hash_finalize(void* md, hash_ctx* hash_ctx)
{
sha3_final(md, hash_ctx);
}
Expand Down
10 changes: 5 additions & 5 deletions sm/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "sha3/sha3.h"
#include "ed25519/ed25519.h"

typedef sha3_ctx_t hash_ctx_t;
typedef sha3_ctx_t hash_ctx;
#define MDSIZE 64

#define SIGNATURE_SIZE 64
Expand All @@ -23,10 +23,10 @@ extern byte sm_signature[SIGNATURE_SIZE];
extern byte sm_public_key[PUBLIC_KEY_SIZE];
extern byte sm_private_key[PRIVATE_KEY_SIZE];

void hash_init(hash_ctx_t* hash_ctx);
void hash_extend(hash_ctx_t* hash_ctx, const void* ptr, size_t len);
void hash_extend_page(hash_ctx_t* hash_ctx, const void* ptr);
void hash_finalize(void* md, hash_ctx_t* hash_ctx);
void hash_init(hash_ctx* hash_ctx);
void hash_extend(hash_ctx* hash_ctx, const void* ptr, size_t len);
void hash_extend_page(hash_ctx* hash_ctx, const void* ptr);
void hash_finalize(void* md, hash_ctx* hash_ctx);

void sign(void* sign, const void* data, size_t len, const byte* public_key, const byte* private_key);
#endif /* crypto.h */
Loading

0 comments on commit fc2441e

Please sign in to comment.