aboutsummaryrefslogtreecommitdiff
path: root/crypto.c
diff options
context:
space:
mode:
authorFranklin Wei <me@fwei.tk>2018-06-20 13:37:47 -0400
committerFranklin Wei <me@fwei.tk>2018-06-20 13:37:47 -0400
commita9315b1f9e01097e4fedff446912db8d5fd5e422 (patch)
tree2b91e217031d985debf842b6fcc077139ba6f030 /crypto.c
parentd9ad082de324eb5fb0b4f03454c630dfe18dc8a3 (diff)
downloadcsaa-a9315b1f9e01097e4fedff446912db8d5fd5e422.zip
csaa-a9315b1f9e01097e4fedff446912db8d5fd5e422.tar.gz
csaa-a9315b1f9e01097e4fedff446912db8d5fd5e422.tar.bz2
csaa-a9315b1f9e01097e4fedff446912db8d5fd5e422.tar.xz
Adapt service provider for tracking container build and compose files
Diffstat (limited to 'crypto.c')
-rw-r--r--crypto.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/crypto.c b/crypto.c
index 3af40d9..10576a0 100644
--- a/crypto.c
+++ b/crypto.c
@@ -418,6 +418,31 @@ hash_t crypt_secret(hash_t encrypted_secret,
return hash_xor(encrypted_secret, pad);
}
+/* 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 buildcode_root = hash_null, composefile_root = hash_null;
+ if(buildcode)
+ buildcode_root = buildcode->mt_nodes[0];
+ if(composefile)
+ composefile_root = composefile->mt_nodes[0];
+
+ SHA256_CTX ctx;
+ hash_t h;
+
+ SHA256_Init(&ctx);
+
+ SHA256_Update(&ctx, gamma.hash, sizeof(gamma.hash));
+ SHA256_Update(&ctx, buildcode_root.hash, sizeof(buildcode_root.hash));
+ SHA256_Update(&ctx, composefile_root.hash, sizeof(composefile_root.hash));
+ SHA256_Update(&ctx, kf.hash, sizeof(kf.hash));
+
+ SHA256_Final(h.hash, &ctx);
+
+ return h;
+}
+
void crypto_test(void)
{
int *orders;