aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Wei <me@fwei.tk>2018-06-08 00:45:45 +0000
committerFranklin Wei <me@fwei.tk>2018-06-08 21:53:14 -0400
commitcae99b638f54748e52a10ca613c1758c9646e2d0 (patch)
tree6fa50ef1148b53de5ceeebee8febf686f8f28db7
parent040a9bab4cafb4dd6ec44485a5c421d99a00cffe (diff)
downloadcsaa-cae99b638f54748e52a10ca613c1758c9646e2d0.zip
csaa-cae99b638f54748e52a10ca613c1758c9646e2d0.tar.gz
csaa-cae99b638f54748e52a10ca613c1758c9646e2d0.tar.bz2
csaa-cae99b638f54748e52a10ca613c1758c9646e2d0.tar.xz
Finish testing file modification in sp_test()
-rw-r--r--helper.c19
-rw-r--r--helper.h5
-rw-r--r--service_provider.c37
3 files changed, 61 insertions, 0 deletions
diff --git a/helper.c b/helper.c
index 1a751e1..20b6ac9 100644
--- a/helper.c
+++ b/helper.c
@@ -23,3 +23,22 @@ struct tm_cert cert_ru(struct trusted_module *tm,
return tm_cert_record_update(tm, &nu, nu_hmac, node, new_val, hmac_out);
}
+
+struct tm_cert cert_rv(struct trusted_module *tm,
+ const struct iomt_node *node,
+ const hash_t *comp, const int *orders, size_t n,
+ hash_t *hmac_out)
+{
+ hash_t nu_hmac;
+ struct tm_cert nu = tm_cert_node_update(tm,
+ hash_node(node),
+ hash_node(node),
+ comp, orders, n,
+ &nu_hmac);
+
+ return tm_cert_record_verify(tm,
+ &nu, nu_hmac,
+ node,
+ hmac_out,
+ 0, NULL, NULL);
+}
diff --git a/helper.h b/helper.h
index 1eb0113..bc74442 100644
--- a/helper.h
+++ b/helper.h
@@ -7,3 +7,8 @@ struct tm_cert cert_ru(struct trusted_module *tm,
hash_t *hmac_out,
int b,
struct tm_cert *nonexist, hash_t *hmac_nonexist);
+
+struct tm_cert cert_rv(struct trusted_module *tm,
+ const struct iomt_node *node,
+ const hash_t *comp, const int *orders, size_t n,
+ hash_t *hmac_out);
diff --git a/service_provider.c b/service_provider.c
index 4faf43f..34f8027 100644
--- a/service_provider.c
+++ b/service_provider.c
@@ -66,6 +66,7 @@ struct tm_cert sp_request(struct service_provider *sp,
return tm_request(sp->tm, req, req_hmac, hmac_out, vr_out, vr_hmac, ack_hmac);
}
+/* in trusted_module.c */
void check(int condition);
void sp_test(void)
@@ -122,4 +123,40 @@ void sp_test(void)
check(fr_cert.type == FR &&
fr_cert.fr.counter == 1 &&
fr_cert.fr.version == 0);
+
+ /* modification */
+ struct user_request mod;
+ mod.type = FILE_UPDATE;
+ mod.idx = 1;
+ mod.user_id = 1;
+ mod.counter = 1;
+ mod.modify.fr_cert = fr_cert;
+ mod.modify.fr_hmac = fr_hmac;
+
+ mod.modify.rv_cert = cert_rv(sp->tm,
+ &acl_node,
+ NULL, NULL, 0,
+ &mod.modify.rv_hmac);
+
+ struct iomt_node node2;
+ node2.idx = 1;
+ node2.val = one;
+ node2.next_idx = 1;
+
+ hash_t two;
+ memset(&two, 0, sizeof(two));
+ two.hash[0] = 2;
+ mod.modify.ru_cert = cert_ru(sp->tm, &node2, two,
+ NULL, NULL, 0,
+ &mod.modify.ru_hmac,
+ 0, NULL, NULL);
+
+ req_hmac = hmac_sha256(&mod, sizeof(mod), "a", 1);
+
+ struct tm_cert vr;
+ hash_t vr_hmac;
+
+ struct tm_cert new_fr = sp_request(sp, &mod, req_hmac, &fr_hmac, &vr, &vr_hmac, &ack_hmac);
+ printf("File modification: ");
+ check(new_fr.type == FR);
}