TL;DR;
Assuming I'm calculating SHA256 for an ECDSA, does it make sense to do SHA256(item1 + SHA256(item1') + item2 + SHA256(item2') + itemN + SHA256(itemN'))
or it's the same (security-wise) as SHA256(item1 + item1' + item2 + item2' + itemN + itemN')
?
(hereunder +
refers to as binary concatenation of operands' content in binary format)
Details
I have a data structure similar to the one below (presenting in JSON format for readability)
{
"Lorem": 123,
"Ipsum": "qwerty",
"Items": [
{
"Id": 4321,
"Data": "SOME_DATA_HERE",
"ItemSig": "A_RELATIVELY_BIG_BINARY_STRUCTURE_AND_ECDSA_SIGNATURE_OF_HELLO_FIELD_CONTENT"
},
{
"Id": 8765,
"Data": "SOME_DATA_HERE",
"ItemSig": "A_RELATIVELY_BIG_BINARY_STRUCTURE_AND_ECDSA_SIGNATURE_OF_HELLO_FIELD_CONTENT"
}
],
"Sig": "A_PLACE_FOR_ECDSA_SIGNATURE"
}
I also have an ECC key pair. Now, I need to sign over each element within the "items" array and then over the entire structure itself.
When signing over the entire structure, I'm proving some data in that structure (contents of Lorem
and Ipsum
), and per each Item
, I'm proving that the item was in that structure (by including Id
in the signature) and proving that item's content (by including ItemSig
which includes the content).
I think it worth noting that I include ItemSig
instead of the item's content in the structure's signature to prove that the item was signed by the same ECC key as the structure itself. This is because there are multiple ECC keys that are valid for signing, but it's considered invalid to sign items with one ECC key while signing the structure with another.
So the question is, what's better option for structure's Sig field (and why?), ECDSA(SHA256(Content))
where
- Content =
Lorem + Ipsum + Items[0].Id + SHA256(Items[0].ItemSig) + Items[1].Id + SHA256(Items[1].ItemSig) + Items[n].Id + SHA256(Items[n].ItemSig)
, OR - Content =
Lorem + Ipsum + Items[0].Id + Items[0].ItemSig + Items[1].Id + Items[1].ItemSig + Items[n].Id + Items[n].ItemSig
.
SHA256(item1 + SHA256(item1') + item2 + SHA256(item2') + itemN + SHA256(itemN'))
orSHA256(item1 + item1' + item2 + item2' + itemN + itemN')
for ECDSA signing? $\endgroup$ – Nikita Kalinichenko Jan 13 at 21:24SHA256(content+SHA256(content2)+content3+SHA256(content4))
ORSHA256(content+content2+content3+content4)
, OR they are equivalently good? $\endgroup$ – Nikita Kalinichenko Jan 13 at 23:51