aboutsummaryrefslogtreecommitdiff
path: root/service_provider.c
diff options
context:
space:
mode:
authorFranklin Wei <me@fwei.tk>2018-06-24 13:19:54 -0400
committerFranklin Wei <me@fwei.tk>2018-06-24 13:19:54 -0400
commit68932344b45fb8938e86513220eb39b3b7306c5b (patch)
tree82e7dd1be81469232e2aac00f98a0263b58debb9 /service_provider.c
parent54cffee43a62dcb176bbd0fb7525598d275cfde4 (diff)
downloadcsaa-68932344b45fb8938e86513220eb39b3b7306c5b.zip
csaa-68932344b45fb8938e86513220eb39b3b7306c5b.tar.gz
csaa-68932344b45fb8938e86513220eb39b3b7306c5b.tar.bz2
csaa-68932344b45fb8938e86513220eb39b3b7306c5b.tar.xz
Implement file info and content retrieval in client
Encryption hasn't been implemented yet.
Diffstat (limited to 'service_provider.c')
-rw-r--r--service_provider.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/service_provider.c b/service_provider.c
index eb47ab3..2ee4a12 100644
--- a/service_provider.c
+++ b/service_provider.c
@@ -641,15 +641,19 @@ struct version_info sp_fileinfo(struct service_provider *sp,
user_id,
&rv2_hmac);
- struct file_version *ver = &rec->versions[version ? version - 1 : rec->nversions - 1];
+ struct file_version *ver;
+ if(rec->nversions > 0)
+ ver = &rec->versions[version ? version - 1 : rec->nversions - 1];
+ else
+ ver = NULL;
return tm_verify_fileinfo(sp->tm,
- user_id,
- &rv1, rv1_hmac,
- &rv2, rv2_hmac,
- &rec->fr_cert, rec->fr_hmac,
- &ver->vr_cert, ver->vr_hmac,
- hmac);
+ user_id,
+ &rv1, rv1_hmac,
+ &rv2, rv2_hmac,
+ &rec->fr_cert, rec->fr_hmac,
+ ver ? &ver->vr_cert : NULL, ver ? ver->vr_hmac : hash_null,
+ hmac);
}
/* This file retrieves the file given by file_idx for a given
@@ -771,6 +775,7 @@ static void sp_handle_client(struct service_provider *sp, int cl)
size_t filelen;
recv(cl, &filelen, sizeof(filelen), MSG_WAITALL);
+ printf("File is %lu bytes.\n", filelen);
void *filebuf = malloc(filelen);
recv(cl, filebuf, filelen, MSG_WAITALL);
@@ -850,7 +855,7 @@ int sp_main(int sockfd)
signal(SIGPIPE, SIG_IGN);
- int logleaves = 8;
+ int logleaves = 10;
struct service_provider *sp = sp_new("a", 1, logleaves);
while(1)