0
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ did you convert the PEM to DER to see 257 bytes? In short, how you get this value? $\endgroup$ – kelalaka Oct 26 at 8:26
  • $\begingroup$ yes in DER format $\endgroup$ – porente Oct 26 at 8:33
  • $\begingroup$ Did you count the leading zero? Or did you use an online converter? $\endgroup$ – kelalaka Oct 26 at 8:38
  • $\begingroup$ the DER file says n uses 257 bytes and yes n has a 00 in the left most byte $\endgroup$ – porente Oct 26 at 8:40
  • $\begingroup$ Could you post your public key? $\endgroup$ – kelalaka Oct 26 at 8:48
2
$\begingroup$
  • $\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

$\endgroup$
  • $\begingroup$ 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 $\endgroup$ – porente Oct 26 at 19:15
  • $\begingroup$ Isn't clear? One byte is 00, this is part of the encoding. $\endgroup$ – kelalaka Oct 26 at 19:31
  • $\begingroup$ 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 $\endgroup$ – porente Oct 26 at 19:54
  • $\begingroup$ That is why I've asked your file. $\endgroup$ – kelalaka Oct 26 at 19:55
  • 1
    $\begingroup$ @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. $\endgroup$ – Maarten - reinstate Monica Oct 26 at 20:23

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.