Changed rhizome manifest signature block type code semantics to

allow signature blocks of 256 bytes, and to allow multiple
signature types with same length. #34
This commit is contained in:
gardners 2012-10-29 16:07:42 +10:30
parent a4b392d693
commit b23b28b16d
3 changed files with 11 additions and 14 deletions

View File

@ -96,7 +96,7 @@ typedef struct rhizome_manifest {
/* Parties who have signed this manifest (raw byte format) */
unsigned char *signatories[MAX_MANIFEST_VARS];
/*
0x61 = crypto_sign_edwards25519sha512batch()
0x17 = crypto_sign_edwards25519sha512batch()
*/
unsigned char signatureTypes[MAX_MANIFEST_VARS];

View File

@ -355,7 +355,7 @@ int rhizome_sign_hash_with_key(rhizome_manifest *m,const unsigned char *sk,
bcopy(signatureBuffer, &out->signature[1], 64);
bcopy(pk, &out->signature[65], crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES);
out->signatureLength = 65 + crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES;
out->signature[0] = out->signatureLength;
out->signature[0] = 0x17; // CryptoSign
RETURN(0);
}
@ -430,21 +430,17 @@ int rhizome_manifest_extract_signature(rhizome_manifest *m,int *ofs)
if ((*ofs)>=m->manifest_all_bytes) { RETURN(0); }
int len=m->manifestdata[*ofs];
if (!len) {
(*ofs)=m->manifest_bytes;
m->errors++;
RETURN(WHY("Zero byte signature blocks are not allowed, assuming signature section corrupt."));
}
int sigType=m->manifestdata[*ofs];
int len=(sigType&0x3f)*4+4+1;
/* Each signature type is required to have a different length to detect it.
At present only crypto_sign_edwards25519sha512batch() signatures are
supported. */
int r;
if (m->sig_count<MAX_MANIFEST_VARS)
switch(len)
switch(sigType)
{
case 0x61: /* crypto_sign_edwards25519sha512batch() */
case 0x17: /* crypto_sign_edwards25519sha512batch() */
/* Reconstitute signature block */
r=rhizome_manifest_lookup_signature_validity
(m->manifesthash,&m->manifestdata[(*ofs)+1],96);
@ -481,7 +477,7 @@ int rhizome_manifest_extract_signature(rhizome_manifest *m,int *ofs)
default:
(*ofs)+=len;
m->errors++;
RETURN(WHY("Encountered illegal or malformed signature block"));
RETURN(WHYF("Encountered illegal or malformed signature block (unknown type=0x%02x @ offset 0x%x)",sigType,(*ofs)-len));
}
else
{

View File

@ -383,9 +383,10 @@ int isOverlayPacket(XPRINTF xpf, const unsigned char *packet, size_t *ofs, size_
xprintf(xpf,"%sManifest signature blocks\n",indent(12));
for(;j<manifest_len;)
{
int sigLen=frame[i+j];
switch(sigLen) {
case 0x61: /* cryptosign signature */
int sigType=frame[i+j];
int sigLen=(sigType&0x3f)*4+4+1;
switch(sigType) {
case 0x17: /* cryptosign signature */
xprintf(xpf,"%sNaCl CryptoSign Generated Signature\n",indent(14));
xprintf(xpf,"%sPublic key of signatory = ",indent(16));
for(k=0;k<32;k++) xprintf(xpf,"%02X",frame[i+j+1+64+k]);