diff options
author | Franklin Wei <me@fwei.tk> | 2018-07-10 19:55:36 +0000 |
---|---|---|
committer | Franklin Wei <me@fwei.tk> | 2018-07-10 19:55:36 +0000 |
commit | 7f4cd7a5065ca29d4644b301b54f2db3e71b1647 (patch) | |
tree | 4ab1322ffa45c61297c28209ad6282b262ee5cb8 /crypto.c | |
parent | 1ad0b326b1d9f780b9189383bcc271e2b74b4358 (diff) | |
download | csaa-7f4cd7a5065ca29d4644b301b54f2db3e71b1647.zip csaa-7f4cd7a5065ca29d4644b301b54f2db3e71b1647.tar.gz csaa-7f4cd7a5065ca29d4644b301b54f2db3e71b1647.tar.bz2 csaa-7f4cd7a5065ca29d4644b301b54f2db3e71b1647.tar.xz |
Track build code/compose file as a hash
Diffstat (limited to 'crypto.c')
-rw-r--r-- | crypto.c | 35 |
1 files changed, 28 insertions, 7 deletions
@@ -299,14 +299,8 @@ hash_t crypt_secret(hash_t encrypted_secret, /* These are all fixed-length fields, so we can safely append them and * forgo any HMAC. */ -hash_t calc_lambda(hash_t gamma, const struct iomt *buildcode, const struct iomt *composefile, hash_t kf) +hash_t calc_lambda(hash_t gamma, hash_t buildcode_root, hash_t composefile_root, hash_t kf) { - hash_t buildcode_root = hash_null, composefile_root = hash_null; - if(buildcode) - buildcode_root = iomt_getroot(buildcode); - if(composefile) - composefile_root = iomt_getroot(composefile); - SHA256_CTX ctx; hash_t h; @@ -491,6 +485,33 @@ void commit_transaction(void *db) sqlite3_exec(handle, "COMMIT;", 0, 0, 0); } +void *deserialize_file(int cl, size_t *len) +{ + recv(cl, len, sizeof(*len), MSG_WAITALL); + + printf("File is %lu bytes.\n", *len); + + if(!*len) + return NULL; + + void *buf = malloc(*len); + recv(cl, buf, *len, MSG_WAITALL); + + return buf; +} + +void serialize_file(int cl, const void *buf, size_t len) +{ + if(!buf) + len = 0; + write(cl, &len, sizeof(len)); + + if(!buf || !len) + return; + + write(cl, buf, len); +} + void crypto_test(void) { #if 1 |