2

I have the following scenario : Two parties want to exchange files.

First party publishes a file on a secure server

First party sends to the second, a hash of the file in order to be able to verify integrity.

Second party downloads the file from the secure server

Second party computes the hash of the downloaded file and sends the hash to the first party to confirm integrity.

What is the best way to implement this scenario? -what is the best hash function to compute for file integrity?

-what is the best way to exchange the hash between the two parties?

2

The scenario you describe is a "common download secenario". The "first party" simply has to publish the hash of the file on the same server where the "second party" can download the file.

The second party can then calculate the hash of the file and verify it with the published hash on the server.

If your assumption of an "secure server" implied that information on the server cannot be manipulated or replaced by an attacker and the communication is secured by TLS, then this workflow is secure.

There are many examples of this practise e.g. look at https://www.openssl.org/source/, where the sha256 hash of each .tar file is published.

what is the best hash function to compute for file integrity

common used hash functions like sha256

what is the best way to exchange the hash between the two parties

already answered above, just publish the hash of the file on the server.

  • Thanks @phl. What if the 1st party wants to send the Hash over the wire, instead of storing it on the server? Is PKI the best solution in this case? Or HMAC? – Shtoak Mar 3 at 6:47
  • The hash could be send together with the downloaded file. The connection muste be secured with TLS. TLS is based on PKI. But you just need a server certificate and dont have to set up a PKI yourself. If the server is public you have to buy a certificate. – phl Mar 3 at 8:45
0

It is very simple to encrypt or just sign the file using public key cryptography. One such well-known toolset is Gnu Privacy Guard

Both party one and party two generate a certificate and exchange public keys. Party one either signs a file or encrypts with its private key and shares the file. Party two verifies the signature/hash with party one's shared public key.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.