2

For context, I'm assuming the attacker knows the format of the key.

Do these two keys have the same strength, or by leaving the hyphens in the key am I reducing the security by a partly-known-key attack?

A: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
B: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Both keys have the same amount of entropy, 'a' is a hex digit, so 'aa' represents one byte of CSPRNG data.

I guess this is the same question as, 'is there a weakness in using a hex-string key versus the raw version of it, given that the key space is reduced to 0-9a-f characters if left in hex format?'


There is a similar question that exists: Does knowing part of the key make encryption weaker?

But that question assumes a variable length key, which is itself a secret, whereby the security of that key is reduced by the attacker knowing existing parts of it, thus reducing the overall unknown parts. My question is if the key is weakened by the structure of the key itself, when the number of CSPRNG characters always remains the same and the attacker knows none of them.


Another similar question: Does padding an AES key hurt security (besides lowering the strength of the key)?

This is closer to what I'm asking, but is now 7 years old, and I'm wondering if there has been any more recent research or weaknesses identified that might be relevant? The dashes in my example key shown above could technically be considered padding, but is there a distinction when the padding is used within the key, instead of at the start or end?

1
  • 1
    The difference between A & B is like the difference between writing your phone number as "555123456" and "555-123-456", or writing an IP address as "0xdeadbeef" instead of "222.173.190.239" (you can ping 0xdeadbeef). Same thing, just different representations. – John Zhau Oct 22 '20 at 3:08
3

Do these two keys have the same strength, or by leaving the hyphens in the key am I reducing the security by a partly-known-key attack?

A: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
B: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

These are not different keys. These are only different representations of the same key. It does not matter if one represents a key as binary, hexadecimal, base64, with hyphens or without etc. At the end the key itself gets used for encryption and decryption and not its specific representation. That means to do the actual processing it gets converted from the specific representation to the actual (binary) key.

And since it is the same key it also does not make a difference in security.

3
  • I guess I was asking in the context that the keys I mentioned above would be used as the 'raw' ascii values for the key, without using a KDF. I missed out that bit. I agree that using a KDF against the above strings would mean they have equivalent strength. – StampyCode Oct 21 '20 at 17:11
  • @StampyCode: A KDF derives a key from some password or passphrase. But if I understand your question correctly you are basically talking about different representations (i.e. encodings) of the same key. And for encryption and decryption the decoded key is used and not the encoded version. And the decoded key is the same for all possible encodings. – Steffen Ullrich Oct 21 '20 at 17:20
  • Let's assume instead then that the keys above are hex interpretations and the dashes are replaced with \x00 characters. So both keys still have the same entropy and keyspace, but are fundamentally not the same key and no KDF is used. – StampyCode Oct 22 '20 at 17:10
1

There is still no problem as long as the key strength is good enough. The format of the key is strange here. You can remove the dashes and they are the same. Known values don't add to the strength of the key. Both have the same strength (or entropy!). We already assume the attackers know this kind of knowledge.

The usual way to process such information is applying a KDF to derive a key from your input material. For example, the HKDF can take salt and info to derive more than one key and nonces/IVs. However, keep in mind that KDF cannot change the entropy of the key. If the input material is weak then any KDF is not going to increase the strength. The attacker can still use the salt and info and process the space and check the derived keys. The strength must be at least 120 bits. This can change in the future.

Conclusion: You can put as many as possible known characters between your keys/passwords to format or fun, it doesn't change the strength!

In the end, what matters is that you have generated a uniform random key that has at least the same strength as the target key length of your cipher.

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.