ciphertext1 = hmac-sha256(key, counter1) ⊕ (plaintext1 with plaintext1 sha1 hash)
ciphertext2 = hmac-sha256(key, counter2) ⊕ (plaintext2 with plaintext2 sha1 hash)
ciphertext3 = hmac-sha256(key ,counter3) ⊕ (plaintext3 with plaintext3 sha1 hash)

Note: counterN is increasing while (plaintextN with plaintextN sha1 hash) is longer than hmac-sha256(key, counterN). So it is a while function to continue hmac-sha256 with increased counters

Lets say Eve know counters and ciphertexts. Can Eve do anything other than bruteforce to find key? Is hiding counter from Eve necessary? Or can Eve break this cipher without key? What is the usage limit of this algorithm to continue use same key for hmac-sha256?

Note-2: I am not cryptographer. It is just curiosity

Note-3: key length is 256 bit

  • $\begingroup$ Why do you encrypt with HMAC? it will be way slower than using KMAC or BLAKE2b as keyed MAC... you just seem to use HMAC as CTR mode. Instead, you can use Hash this way $\endgroup$
    – kelalaka
    Apr 6, 2022 at 20:57
  • $\begingroup$ Yes it seems like you are right about speed. And of course in link the part of "AES has been far more extensively analyzed" is confusing. But also this part is clearly right. I think i should study on BLAKE or KMAC. Thank you! $\endgroup$ Apr 6, 2022 at 21:18
  • $\begingroup$ I would not use SHA-1 this way. If an attacker knows the plaintext and hash they could perform a bit flip attack. So I guess the answer is no. You could replace the SHA-1 with a HMAC over the counter + ciphertext instead. I'm also not sure that the algorithm is described well, due to the counter being used both as nonce and to encrypt more of the message, but that's more of a problem with the description than the cipher I suppose. $\endgroup$
    – Maarten Bodewes
    Apr 6, 2022 at 21:44
  • $\begingroup$ Yes... You are right. So i can say "hmac-sha256(key, counter) ⊕ (plaintext with hmac-sha1(plaintext, maybe_another_key))" right? And probably i didn't describe well but i don't know where did i make confusing description... If "with" part is confusing i mean put space between plaintext and hmac-sha1 result then xor it with hmac-sha256 result $\endgroup$ Apr 6, 2022 at 22:05
  • $\begingroup$ I am stupid :p "hmac-sha1(plaintext, maybe_another_key)" part is unnecessary. And i decided to use this: "ciphertext1 = blake3(counter, key) ⊕ plaintext" and "hash = blake3(ciphertext1, another_key)" send ciphertext1 and hash. Thank you Maarten and kelalaka. I think i did now true isn't it? (sorry for bothering) $\endgroup$ Apr 7, 2022 at 2:23


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.