Re: Help with hashing and signatures

"Schanzenbach, Martin" <[email protected]> Tue, 4 Aug 2020 18:15:25 +0200
Newsgroups gmane.network.gnunet.general
Message-ID <[email protected]>
Is your struct packed as specified in the comment?

> On 4. Aug 2020, at 18:00, Alessio Vanni <[email protected]> wrote:
> 
> TheJackiMonster <[email protected]> writes:
> 
>> Does the `sd` variable contain the the same data in the verify function
>> as in the sign function? You wrote you would hash again but the
>> documentation mentions also:
>> 
>> "The size field in ps->purpose must correctly indicate the number of
>> bytes of the data structure, including its header."
>> 
>> and
>> 
>> "purpose of the signature, must match 'ps->purpose.purpose' (except in
>> host byte order)"
>> 
>> So maybe these points are the root of your problem.
> 
> The verify function doesn't have the same informations as the signing
> function, only the container that is passed to it.  It hashes the data
> because it doesn't have the hash used by the signing function.  Because
> this signature's purpose is to catch corruptions or unwanted changes in
> the data, even if I include the hash in the container I'd still have to
> generate a new hash to make sure the embedded hash is correct...
> 
> The problem of the documentation is that it also says this:
> 
> * @param purp purpose of the signature, must match 'ps->purpose.purpose'
> *              (except in host byte order)
> * @param priv private key to use for the signing
> * @param ps packed struct with what to sign, MUST begin with a purpose
> * @param sig where to write the signature
> 
> which wouldn't be an issue if the macro's signature wasn't
> 
> #define GNUNET_CRYPTO_ecdsa_verify(purp,ps,sig,pub)
> 
> i.e. there are differences in what's being documented.
> 
> The host byte order might or might not be relevant.  I'll try it and
> report back.
> 
>> Do you have memory limitations?
> 
> Yes.
> 
> Thanks,
> A.V.
>
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEPREGPBD5jRS9JNFHCwmY74b1m2oFAl8piZ0ACgkQCwmY74b1
m2o9QA/+MjRlW2sAprNA0UcIfXcFXTmopwnhUpm7LRMt4ZpQAG5TD9WrsPR4+h8U
c7moTdgM/zxNNX12oN/zBR9HnYu6IkIZECiO25kWQaA4Xhq8z+c/uw4G+YYSXlJk
AzWWs3SOH/DY3CleCK+kX3Su9I0ipkNcB5ZfhC5X6H21a9CkLHz7es/rTtt1DOvB
cPHNo4byV2DTn1wUTj8iJJl3gH1mEUMN7IfcM4ZHMl0msrqQ2AHKCW92nVcI7g2i
2bMBRuIMcsgsUuq/8sU6yy4KGeC8+M8QDKdeT3Yh6ezCEEiRVFcqAFbfPZjB9DTY
RgI4Ziw6vyKoW2QyoFEszqsJ/s641NKmDPWbj9xxh6Yog+AQFT3fcRIUzzelfXxW
7SoQZKWIUXCYz4xmGOJHsHZXww5iYEhwFa73AEJxH4vpat68dRLYxjAVWuiyYEgt
Cf6EhoCNP7cdihIHC0LFuECfgEgRNxOfY6kCWLAHHH4dA6pkQMzldHbymXg4AxFj
gunm3c5jsi2zlOF3EIJ2KACazFU853cUWV/9sgqNs8TcKhyjhkaT4nkCFEuxG6iG
lSasDzezSyH1y9zQ8f1D9Ho19Y0ueTNoFVTxFjy04BjWAFFcT/3NcOjr3+cHaJsM
88gOM95UTb3wJE6XUWnnwf8qbQka+frtoPgOvoA7hiaEpsz5WcE=
=PpvB
-----END PGP SIGNATURE-----