# RSASSA-PSS-SIGN modBits size

In RFC 8017 modBits is the length in bits of the RSA modulus n
I am using 2048 RSA key
modBits = 2048?
modBits = 2048 % n?
lets say n = 10 decimal = 1010 binary
then modBits = 4?
in my 2048 RSA key DER file n uses 257 bytes
then modBits = 257 *8 ?
which modBits = ... is true?

• did you convert the PEM to DER to see 257 bytes? In short, how you get this value? – kelalaka Oct 26 '19 at 8:26
• yes in DER format – porente Oct 26 '19 at 8:33
• Did you count the leading zero? Or did you use an online converter? – kelalaka Oct 26 '19 at 8:38
• the DER file says n uses 257 bytes and yes n has a 00 in the left most byte – porente Oct 26 '19 at 8:40
• Could you post your public key? – kelalaka Oct 26 '19 at 8:48

• $$\text{modBits}$$ is the length of RSA modulus $$n$$ for example if you have 17 as RSA modulus than it has $$\texttt{10001}$$ as base two representation and has $$\text{modBits} = 5$$

• If you generate a modulus $$n$$ which is 2048-bit than the $$\text{modBits} = 2048$$. Keep in mind that, we say a number $$n$$ is 2048-bit when it is between $$2^{2047} \leq n \leq 2^{2048}-1$$

lets say n = 10 decimal = 1010 binary then modBits = 4?

Yes 4.

in my 2048 RSA key PEM file n uses 257 bytes then modBits = 257 *8 ?

The leading 00 is coming from ASN.1 encoding of integers. Therefore you have 256-byte key.

which one is the value of modBits?

8*256

• this question which one is the value of modBits? is referring to which of all modBits = ? is the true one, not which DER file data defines n – porente Oct 26 '19 at 19:15
• Isn't clear? One byte is 00, this is part of the encoding. – kelalaka Oct 26 '19 at 19:31
• my question shows different values that modBits can have based on the RFC definition, then at the end asks which value is true, in your answer modBits = 8*256 if n uses 256 bytes and modBits = 4 if n = 10 but modBits = 8*256 if n uses 256 bytes is not true because the exact value of n isn't known, only if you know the exact value of n you can know modBits – porente Oct 26 '19 at 19:54
• That is why I've asked your file. – kelalaka Oct 26 '19 at 19:55
• @porente If you know it all so well, then why post a question? Kelalaka is right, to show how the encoded key is structured, you should post an example private key that contains the modulus. – Maarten Bodewes Oct 26 '19 at 20:23