1
$\begingroup$

Suppose I want to send a message, but not privately; I want everybody to see it, even an attacker in the middle. I would do this by appending a public key to the start of the data, which could be used to decrypt an HMAC attachment, and verify that I sent it. Is this feasible? Would this still ensure the integrity of the message?

Edit: The goal of this would be to create some sort of P2P message-board where posts are publicly readable, yet their authenticity and integrity is protected. Would using HMAC be the best way of going about this? Is it possible altogether?

$\endgroup$
3
  • 2
    $\begingroup$ What stops someone from replacing the public key and HMAC altogether and changing the message in any way they like? The core issue being, how can the world distinguish you specifically from everyone else? Also, decrypting with a public key doesn't really make sense. $\endgroup$
    – yyyyyyy
    Jun 14, 2022 at 13:35
  • 1
    $\begingroup$ Why not just sign the message? $\endgroup$ Jun 14, 2022 at 15:21
  • 1
    $\begingroup$ Could you explain clearly your aim? $\endgroup$
    – kelalaka
    Jun 15, 2022 at 12:42

1 Answer 1

1
$\begingroup$

You can use HMAC to protect the integrity of an unencrypted message, but you have to make sure the HMAC key is not revealed (or at least not revealed prior to integrity verification). There's no need to encrypt it. Only a party with access to the HMAC key will be able to modify the protected data in such a way that it does not fail verification.

$\endgroup$
3
  • 1
    $\begingroup$ The OP needs non-repudiation and transfer of the HMAC key. They may use RSA-KEM for HMAC key and RSA signatures for non-repudiation. $\endgroup$
    – kelalaka
    Jun 14, 2022 at 11:33
  • $\begingroup$ @kelalaka Can you write that as an answer? I'll delete mine if it is obsolete then. $\endgroup$
    – forest
    Jun 14, 2022 at 19:01
  • $\begingroup$ To be honest, Q is not clear for me. You can update your answer on this path.... $\endgroup$
    – kelalaka
    Jun 14, 2022 at 19:18

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