diff options
author | Franklin Wei <me@fwei.tk> | 2018-06-08 00:45:45 +0000 |
---|---|---|
committer | Franklin Wei <me@fwei.tk> | 2018-06-08 21:53:14 -0400 |
commit | cae99b638f54748e52a10ca613c1758c9646e2d0 (patch) | |
tree | 6fa50ef1148b53de5ceeebee8febf686f8f28db7 /service_provider.c | |
parent | 040a9bab4cafb4dd6ec44485a5c421d99a00cffe (diff) | |
download | csaa-cae99b638f54748e52a10ca613c1758c9646e2d0.zip csaa-cae99b638f54748e52a10ca613c1758c9646e2d0.tar.gz csaa-cae99b638f54748e52a10ca613c1758c9646e2d0.tar.bz2 csaa-cae99b638f54748e52a10ca613c1758c9646e2d0.tar.xz |
Finish testing file modification in sp_test()
Diffstat (limited to 'service_provider.c')
-rw-r--r-- | service_provider.c | 37 |
1 files changed, 37 insertions, 0 deletions
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); } |