mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-21 14:07:53 +00:00
Fixed bugs with importing files using user-supplied manifest
(was not decoding BKs)
This commit is contained in:
parent
c2dfefe764
commit
5c40edb55d
@ -1196,14 +1196,27 @@ int app_rhizome_add_file(int argc, const char *const *argv, struct command_line_
|
||||
Then finalise the manifest.
|
||||
|
||||
But if the manifest already contains an ID, don't override it. */
|
||||
if (rhizome_manifest_get(m, "id", NULL, 0)==NULL)
|
||||
if (rhizome_manifest_bind_id(m,authorSid))
|
||||
if (rhizome_manifest_get(m, "id", NULL, 0)==NULL) {
|
||||
if (rhizome_manifest_bind_id(m,authorSid)) {
|
||||
rhizome_manifest_free(m); m=NULL;
|
||||
return WHY("Could not bind manifest to an ID");
|
||||
}
|
||||
} else {
|
||||
/* User supplied manifest has a BID, so see if we can extract the
|
||||
private key from a BK entry */
|
||||
if (rhizome_extract_privatekey(m,authorSid))
|
||||
{
|
||||
rhizome_manifest_free(m); m=NULL;
|
||||
return WHY("Could not extract BID secret key. Does the manifest have a BK, did you supply the correct author SID?");
|
||||
}
|
||||
}
|
||||
#warning need to sanely determine whether to encrypt a file
|
||||
#warning payload encryption disabled for now
|
||||
int encryptP=0;
|
||||
if (rhizome_manifest_bind_file(m,filepath,encryptP))
|
||||
if (rhizome_manifest_bind_file(m,filepath,encryptP)) {
|
||||
rhizome_manifest_free(m);
|
||||
return WHYF("Could not bind manifest to file '%s'",filepath);
|
||||
}
|
||||
|
||||
/* Add the manifest and its associated file to the Rhizome database, generating an "id" in the
|
||||
* process */
|
||||
|
@ -148,6 +148,12 @@ int rhizome_read_manifest_file(rhizome_manifest *m, const char *filename, int bu
|
||||
*/
|
||||
m->vars[m->var_count]=strdup(var);
|
||||
m->values[m->var_count]=strdup(value);
|
||||
if (!strcasecmp(var,"ID"))
|
||||
{
|
||||
/* Parse hex string of ID into public key */
|
||||
rhizome_hex_to_bytes(value,m->cryptoSignPublic,
|
||||
crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES*2);
|
||||
}
|
||||
m->var_count++;
|
||||
}
|
||||
} else {
|
||||
|
@ -170,7 +170,7 @@ int rhizome_extract_privatekey(rhizome_manifest *m,const char *authorHex)
|
||||
ge25519_pack(pk, &gepk);
|
||||
bzero(&scsk,sizeof(scsk));
|
||||
if (memcmp(pk, m->cryptoSignPublic, crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES)) {
|
||||
if (0) {
|
||||
if (1) {
|
||||
char hex[17];
|
||||
rhizome_bytes_to_hex_upper(m->cryptoSignPublic, hex, 8);
|
||||
WHYF(" stored public key = %s*", hex);
|
||||
@ -178,8 +178,10 @@ int rhizome_extract_privatekey(rhizome_manifest *m,const char *authorHex)
|
||||
WHYF("computed public key = %s*", hex);
|
||||
}
|
||||
return WHY("BID secret key decoded from BK was not valid");
|
||||
} else
|
||||
} else {
|
||||
m->haveSecret=1;
|
||||
return 0;
|
||||
}
|
||||
#else //!ge25519
|
||||
/* XXX Need to test key by signing and testing signature validity. */
|
||||
/* For the time being barf so that the caller does not think we have a validated BK
|
||||
|
Loading…
Reference in New Issue
Block a user