Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[common] Refactor Protected Files, part 1 #1866

Merged
merged 1 commit into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions common/src/protected_files/protected_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -1356,11 +1356,3 @@ pf_status_t pf_flush(pf_context_t* pf) {

return PF_STATUS_SUCCESS;
}

pf_status_t pf_get_handle(pf_context_t* pf, pf_handle_t* handle) {
if (!g_initialized)
return PF_STATUS_UNINITIALIZED;

*handle = pf->file;
return PF_STATUS_SUCCESS;
}
15 changes: 0 additions & 15 deletions common/src/protected_files/protected_files.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ typedef uint8_t pf_mac_t[PF_MAC_SIZE];
typedef uint8_t pf_key_t[PF_KEY_SIZE];
typedef uint8_t pf_keyid_t[32]; /* key derivation material */

extern pf_key_t g_pf_mrenclave_key;
extern pf_key_t g_pf_mrsigner_key;
extern pf_key_t g_pf_wrap_key;
extern bool g_pf_wrap_key_set;

typedef enum _pf_status_t {
PF_STATUS_SUCCESS = 0,
PF_STATUS_UNKNOWN_ERROR = -1,
Expand Down Expand Up @@ -296,16 +291,6 @@ pf_status_t pf_set_size(pf_context_t* pf, uint64_t size);
*/
pf_status_t pf_rename(pf_context_t* pf, const char* new_path);

/*!
* \brief Get underlying handle of a PF.
*
* \param pf PF context.
* \param[out] handle Handle to the backing file.
*
* \returns PF status.
*/
pf_status_t pf_get_handle(pf_context_t* pf, pf_handle_t* handle);

/*!
* \brief Flush any pending data of a protected file to disk.
*
Expand Down
12 changes: 3 additions & 9 deletions common/src/protected_files/protected_files_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include <limits.h>

#include "list.h"
#include "protected_files.h"

#define PF_FILE_ID 0x46505f5346415247 /* GRAFS_PF */
Expand Down Expand Up @@ -53,9 +52,7 @@ typedef struct _metadata_encrypted {

typedef uint8_t metadata_encrypted_blob_t[sizeof(metadata_encrypted_t)];

#define METADATA_NODE_SIZE PF_NODE_SIZE

typedef uint8_t metadata_padding_t[METADATA_NODE_SIZE -
typedef uint8_t metadata_padding_t[PF_NODE_SIZE -
(sizeof(metadata_plain_t) + sizeof(metadata_encrypted_blob_t))];

typedef struct _metadata_node {
Expand Down Expand Up @@ -102,18 +99,16 @@ static_assert(sizeof(encrypted_node_t) == PF_NODE_SIZE, "sizeof(encrypted_node_t

#define MAX_PAGES_IN_CACHE 48

typedef enum {
enum {
FILE_MHT_NODE_TYPE = 1,
FILE_DATA_NODE_TYPE = 2,
} mht_node_type_e;
};

// make sure these are the same size
static_assert(sizeof(mht_node_t) == sizeof(data_node_t),
"sizeof(mht_node_t) == sizeof(data_node_t)");

DEFINE_LIST(_file_node);
typedef struct _file_node {
LIST_TYPE(_file_node) list;
uint8_t type;
uint64_t node_number;
struct _file_node* parent;
Expand All @@ -127,7 +122,6 @@ typedef struct _file_node {
data_node_t data;
} decrypted;
} file_node_t;
DEFINE_LISTP(_file_node);

typedef struct {
uint32_t index;
Expand Down
1 change: 0 additions & 1 deletion common/src/protected_files/protected_files_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include <limits.h>

#include "list.h"
#include "lru_cache.h"
#include "protected_files.h"
#include "protected_files_format.h"
Expand Down