2
$\begingroup$

Is it safer to give a non zero value to the most significant byte (MSB) of a cryptographic key to ensure its length (not 31 instead of 32 for an EC private key on a 256-bit curve for example)?

Or is it counterproductive because it decreases the entropy?

I ask the question for the MSB but it could be for several of the first bytes.

$\endgroup$
5
$\begingroup$

Many keys do not consist of a single value. Other key types, such as most symmetric keys, don't have a most significant bit or byte as the key value isn't interpreted as an integer. So this question would be different for each key type and encoding.

In general though you would just decrease the "entropy" or key size. This is certainly the case for ECC, and probably most other schemes that use groups theory / modular arithmetic. So yes, that's certainly counterproductive.

Note that if you view the key value as a number that you would only have to set the MSB bit to 1 to ensure that the key value is at least $2^{(n-1)}$ - assuming that the key uses unsigned values of course.

Cryptosystems should define how keys are created. You'd better make sure you keep to the rules of the cryptosystem or security may well go down the drain.

$\endgroup$
  • $\begingroup$ If a cryptosystem does not "define how keys should be created", it's not a cryptosystem... $\endgroup$ – fkraiem Jan 29 '16 at 2:54
3
$\begingroup$

If a cryptosystem is expecting a 16-byte key, making the first byte nonzero simply reduces the number of possible keys. It is better to allow all bytes to be all values.

$\endgroup$

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.