diff options
author | Franklin Wei <me@fwei.tk> | 2018-09-18 22:26:00 -0400 |
---|---|---|
committer | Franklin Wei <me@fwei.tk> | 2018-09-18 22:26:00 -0400 |
commit | 8728118e3911fccdf652c27c33edf517cbc39207 (patch) | |
tree | 2849e2b1a315ce1c7bf3bb3461d82406a74d38e0 /service_provider.c | |
parent | 8a174f04e8b3e5517eccd672df680898e80e5c85 (diff) | |
download | csaa-8728118e3911fccdf652c27c33edf517cbc39207.zip csaa-8728118e3911fccdf652c27c33edf517cbc39207.tar.gz csaa-8728118e3911fccdf652c27c33edf517cbc39207.tar.bz2 csaa-8728118e3911fccdf652c27c33edf517cbc39207.tar.xz |
Change profiling breakdown
Coarser intervals across the board; also profiles F_verify() for both
file and info retrievals.
Diffstat (limited to 'service_provider.c')
-rw-r--r-- | service_provider.c | 59 |
1 files changed, 22 insertions, 37 deletions
diff --git a/service_provider.c b/service_provider.c index 0959155..3e82fad 100644 --- a/service_provider.c +++ b/service_provider.c @@ -108,8 +108,6 @@ struct tm_cert cert_eq(struct service_provider *sp, int *enc_orders; hash_t *enc_comp = merkle_complement(sp->iomt, encloser_leafidx, &enc_orders); - prof_add(&sp->profile, "EQGenComputeHashes"); - /* we need two NU certificates */ hash_t nu1_hmac, nu2_hmac; @@ -118,27 +116,21 @@ struct tm_cert cert_eq(struct service_provider *sp, enc_comp, enc_orders, sp->iomt->mt_logleaves, &nu1_hmac); - prof_add(&sp->profile, "EQGenNUGeneration1"); /* We now update the ancestors of the encloser node. */ hash_t *old_depvalues = malloc(sizeof(hash_t) * sp->iomt->mt_logleaves); merkle_update(sp->iomt, encloser_leafidx, h_encmod, old_depvalues); - prof_add(&sp->profile, "EQGenEncloserInsert"); int *ins_orders; hash_t *ins_comp = merkle_complement(sp->iomt, placeholder_leafidx, &ins_orders); - prof_add(&sp->profile, "EQGenComplementCalculation"); struct tm_cert nu2 = tm_cert_node_update(sp->tm, hash_null, h_ins, ins_comp, ins_orders, sp->iomt->mt_logleaves, &nu2_hmac); - - prof_add(&sp->profile, "EQGenNUGeneration2"); /* restore the tree */ uint64_t *dep_indices = bintree_ancestors(encloser_leafidx, sp->iomt->mt_logleaves); restore_nodes(sp->iomt, dep_indices, old_depvalues, sp->iomt->mt_logleaves); - prof_add(&sp->profile, "EQGenRestoreTree"); free(dep_indices); free(old_depvalues); @@ -599,6 +591,8 @@ struct tm_cert sp_request(struct service_provider *sp, /* execute the request */ struct tm_cert fr = tm_request(sp->tm, req, req_hmac, &fr_hmac, &vr, &vr_hmac, &ack_hmac); + prof_add(&sp->profile, "ExecModuleRequest"); + /* now update our databases based on the result */ if(fr.type == FR) { @@ -780,13 +774,12 @@ struct tm_request sp_createfile(struct service_provider *sp, i, i + 1, &hmac); - prof_add(&sp->profile, "FinishEQGen"); + prof_add(&sp->profile, "EQGeneration"); assert(eq.type == EQ); /* update previous leaf's index */ iomt_update_leaf_nextidx(sp->iomt, i - 1, i + 1); - prof_add(&sp->profile, "UpdatePrevLeaf"); /* next_idx is set to 1 to keep everything circularly linked; * in the next iteration it will be updated to point to the @@ -794,15 +787,13 @@ struct tm_request sp_createfile(struct service_provider *sp, /* for random indices, recall the encloser's old next index, * and use that here */ iomt_update_leaf_full(sp->iomt, i, i + 1, 1, hash_null); - prof_add(&sp->profile, "UpdateNewLeaf"); assert(tm_set_equiv_root(sp->tm, &eq, hmac)); - prof_add(&sp->profile, "RootTransition"); sp->n_placeholders++; } - prof_add(&sp->profile, "FinishPlaceholderInsert"); + prof_add(&sp->profile, "PlaceholderInsert"); printf("Allocated leaf index %lu\n", i); @@ -826,7 +817,7 @@ struct tm_request sp_createfile(struct service_provider *sp, hash_t req_hmac = sign_request(userdata, &req); hash_t fr_hmac; - prof_add(&sp->profile, "FinishFillRequest"); + prof_add(&sp->profile, "FillRequestStructure"); struct tm_cert fr_cert = sp_request(sp, &req, req_hmac, @@ -839,8 +830,6 @@ struct tm_request sp_createfile(struct service_provider *sp, NULL, 0, acl); - prof_add(&sp->profile, "FinishExecutingRequest"); - sp->n_placeholders--; /* sp_request() has made a copy of the ACL */ @@ -929,8 +918,6 @@ struct tm_request sp_modifyfile(struct service_provider *sp, /* modification */ struct file_record *rec = lookup_record(sp, file_idx); - prof_add(&sp->profile, "FinishDBLookupRecord"); - if(!rec) { printf("Could not find file with index %lu\n", file_idx); @@ -941,8 +928,6 @@ struct tm_request sp_modifyfile(struct service_provider *sp, uint64_t file_leafidx; struct iomt_node file_node = iomt_find_leaf(sp->iomt, file_idx, &file_leafidx); - prof_add(&sp->profile, "FinishIOMTFindLeaf"); - if(!file_node.idx) { printf("Couldn't find file node???\n"); @@ -953,22 +938,20 @@ struct tm_request sp_modifyfile(struct service_provider *sp, file_leafidx, &file_orders); - prof_add(&sp->profile, "FinishComplementCalculation"); - uint64_t acl_leafidx; struct iomt_node acl_node = iomt_find_leaf(rec->acl, user_id, &acl_leafidx); hash_t *acl_comp = merkle_complement(rec->acl, acl_leafidx, &acl_orders); - prof_add(&sp->profile, "FinishACLComplementCalculation"); + prof_add(&sp->profile, "LookupRecordAndComplements"); hash_t gamma = sha256(encrypted_file, filelen); hash_t h_bc = buildcode ? sha256(buildcode, buildcode_len) : hash_null; hash_t h_cf = composefile ? sha256(composefile, composefile_len) : hash_null; hash_t lambda = calc_lambda(gamma, h_bc, h_cf, kf); - prof_add(&sp->profile, "FinishCalculateLambda"); + prof_add(&sp->profile, "CalculateLambda"); struct tm_request req = req_filemodify(sp->tm, &rec->fr_cert, rec->fr_hmac, @@ -986,7 +969,7 @@ struct tm_request sp_modifyfile(struct service_provider *sp, hash_t req_hmac = sign_request(userdata, &req); - prof_add(&sp->profile, "FinishFillRequestStructure"); + prof_add(&sp->profile, "FillRequestStructure"); struct tm_cert vr; hash_t vr_hmac, fr_hmac; @@ -1004,8 +987,6 @@ struct tm_request sp_modifyfile(struct service_provider *sp, composefile, composefile_len, NULL); - prof_add(&sp->profile, "FinishExecuteRequest"); - /* We return the request because that is how the module's * authentication is done. */ if(new_fr.type == FR) @@ -1027,6 +1008,13 @@ struct version_info sp_fileinfo(struct service_provider *sp, struct iomt **acl_out) { struct file_record *rec = lookup_record(sp, file_idx); + + if(!version) + version = rec->version; + + struct file_version *ver = lookup_version(sp, rec->idx, version); + + prof_add(&sp->profile, "VerifyLookupRecords"); /* RV1 indicates counter */ hash_t rv1_hmac; @@ -1056,14 +1044,11 @@ struct version_info sp_fileinfo(struct service_provider *sp, user_id, &rv2_hmac); - if(!version) - version = rec->version; - - struct file_version *ver = lookup_version(sp, rec->idx, version); + prof_add(&sp->profile, "VerifyRVGen"); if(acl_out) *acl_out = iomt_dup(rec->acl); - + struct version_info ret = tm_verify_fileinfo(sp->tm, user_id, &rv1, rv1_hmac, @@ -1072,6 +1057,7 @@ struct version_info sp_fileinfo(struct service_provider *sp, ver ? &ver->vr_cert : NULL, ver ? ver->vr_hmac : hash_null, nonce, hmac); + free_record(rec); free_version(ver); @@ -1099,8 +1085,6 @@ void *sp_retrieve_file(struct service_provider *sp, { struct file_record *rec = lookup_record(sp, file_idx); - prof_add(&sp->profile, "FinishDBLookup"); - if(!rec || !rec->version) { /* Newly created file, no contents. We don't bother to set @@ -1115,7 +1099,6 @@ void *sp_retrieve_file(struct service_provider *sp, version = rec->version; struct file_version *ver = lookup_version(sp, file_idx, version); - prof_add(&sp->profile, "FinishDBLookupVersion"); if(!ver) { @@ -1124,11 +1107,13 @@ void *sp_retrieve_file(struct service_provider *sp, return NULL; } + prof_add(&sp->profile, "LookupRecords"); + hash_t rv1_hmac, rv2_hmac; struct tm_cert rv1 = cert_rv_by_idx(sp->tm, sp->iomt, file_idx, &rv1_hmac); struct tm_cert rv2 = cert_rv_by_idx(sp->tm, rec->acl, user_id, &rv2_hmac); - prof_add(&sp->profile, "FinishGenerateRVCerts"); + prof_add(&sp->profile, "RVGeneration"); if(hash_to_u64(rv2.rv.val) < 1) { @@ -1147,7 +1132,7 @@ void *sp_retrieve_file(struct service_provider *sp, &rec->fr_cert, rec->fr_hmac, ver->encrypted_secret, ver->kf); } - prof_add(&sp->profile, "FinishRetrieveSecret"); + prof_add(&sp->profile, "RetrieveSecret"); if(kf) *kf = ver->kf; |