aboutsummaryrefslogtreecommitdiff
path: root/helper.c
diff options
context:
space:
mode:
authorFranklin Wei <me@fwei.tk>2018-06-17 21:57:37 -0400
committerFranklin Wei <me@fwei.tk>2018-06-17 21:57:37 -0400
commitf7d0c06fe723fe8be799935238136e2a57a40d36 (patch)
tree15d5e94ccaf03525a59bb6752e472d30b75a138a /helper.c
parent94c91e9f2d74680f9c71e98cfcc9c9f51d8363b3 (diff)
downloadcsaa-f7d0c06fe723fe8be799935238136e2a57a40d36.zip
csaa-f7d0c06fe723fe8be799935238136e2a57a40d36.tar.gz
csaa-f7d0c06fe723fe8be799935238136e2a57a40d36.tar.bz2
csaa-f7d0c06fe723fe8be799935238136e2a57a40d36.tar.xz
Some refactoring; file info retrieval in service provider as well
Diffstat (limited to '')
-rw-r--r--helper.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/helper.c b/helper.c
index 617e8d0..64785b7 100644
--- a/helper.c
+++ b/helper.c
@@ -47,6 +47,45 @@ struct tm_cert cert_rv(const struct trusted_module *tm,
b, nonexist, hmac_nonexist);
}
+struct tm_cert cert_rv_by_idx(const struct trusted_module *tm,
+ const struct iomt *tree,
+ uint64_t idx,
+ hash_t *hmac_out)
+{
+ struct iomt_node *node = iomt_find_leaf_or_encloser(tree, idx);
+
+ if(!node)
+ return cert_null;
+
+ /* find the complement */
+ int *orders;
+ hash_t *comp = merkle_complement(tree, node - tree->mt_leaves, &orders);
+
+ struct tm_cert cert;
+
+ if(idx == node->idx)
+ {
+ /* node exists */
+ cert = cert_rv(tm,
+ node,
+ comp, orders, tree->mt_logleaves,
+ hmac_out,
+ 0, NULL, NULL);
+ }
+ else
+ {
+ /* node does not exist */
+ cert_rv(tm,
+ node,
+ comp, orders, tree->mt_logleaves,
+ NULL,
+ idx,
+ &cert, hmac_out);
+ }
+
+ return cert;
+}
+
/* Fill out a user_request struct to create a file with the index
* given in file_node->idx with the user added with level 3 access in
* the ACL. */