0

I know about key derivation functions such as PBKDF2 which derive keys from passwords.

Am I wrong in assuming AES-256 keys are essentially unsigned integers between 0 and 2^256-1 padded with zeros?

3
  • Yes, it's 256 random bits. So, if you map this to an unsigned integer, it would be an integer between 0 and 2^256 -1.
    – mti2935
    Aug 11, 2021 at 15:58
  • Thanks @mti2935. Is the “padded with zeros” part accurate?
    – sunknudsen
    Aug 11, 2021 at 16:05
  • No, "padded with zeros" is not accurate--it simply does not make sense to say such a thing in this context.
    – hft
    Aug 11, 2021 at 17:36

1 Answer 1

4

Am I wrong in assuming AES-256 keys are essentially unsigned integers between 0 and 2^256-1 ...

An AES-256 key is always 256 bit. Treating that 256 bit as a signed integer, unsigned integer, binary string ... is just an interpretation of the value but does not change the value nor does it change the meaning of the value for AES-256.

... padded with zeros?

An unsigned 256 bit integer is always 256 bit, i.e. there is no padding. The textual representation of the integer, i.e. the encoding of the integer as a sequence of bits, decimal numbers, hexadecimal values, as base64 or whatever is just the specific encoding.

For example a 16 bit key consisting of 1010101.. could be represented as decimal 16 bit unsigned integer 43690, decimal 32 bit signed integer -21846, hexadecimal aaaa, ...

In short: a AES-256 key can be displayed as an unsigned integer of 256 bit, as a binary string, as two 128 bit integers .... If this gets displayed with padding or not, as bits, hex, decimal or whatever are just different interpretation and representations of the value for consumption by a human or by a machine. These are only a property of the keys interpretation and representation, not the key value.

5
  • Thanks for helping out! I updated question to better reflect underlying question.
    – sunknudsen
    Aug 11, 2021 at 18:16
  • 1
    @sunknudsen: I've rolled your edit back since this resulted in a completely different question than originally asked, making any answers no longer fit the question. Please don't make your question a moving target and ask instead a new question. Aug 11, 2021 at 18:57
  • Thanks for heads-up Steffen. Created a separate question.
    – sunknudsen
    Aug 11, 2021 at 19:42
  • Can you please include examples of the different formats you mentioned for same key? I believe this would help me and other readers better understand answer.
    – sunknudsen
    Aug 11, 2021 at 19:53
  • @sunknudsen: I've added some examples Aug 11, 2021 at 20:14

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.