0
$\begingroup$

This might be a stupid question but: When RSA key pairs are generated, there is a pubkey and a private key file. Where is the modulus? Is it appended to the keys? I can't find any information about that.

$\endgroup$
  • $\begingroup$ Suppose that your folder to receive Key pair is "MyLoc" $ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/Users/MyLoc/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/MyLoc/.ssh/id_rsa. Your public key has been saved in /Users/MyLoc/.ssh/id_rsa.pub. ... You can't edit the key pair.The data is encrypted with the passphrase you entered. Take a look here: git-scm.com/book/fr/v1/… $\endgroup$ – Robert NACIRI Nov 5 '16 at 16:51
2
$\begingroup$

The modulus is part of the public key. For RSA, the public key consists of the pair $(n,e)$ where $n$ is the modulus and $e$ is the public exponent.

The SSH public key file contains both, typically one after the other. There's a number of ways to encode this information. The gory details of these encodings I leave to this in-depth answer (it includes a section on SSH).

The SSH private key file contains pretty much all numbers associated with the key generation process. If you want to take a look yourself, try running the following command

openssl rsa -in test.key -text

where test.key is your private key file.

$\endgroup$
  • $\begingroup$ Ah I see. The private key just stores the primes so the chinese remainder theorem can be applied. The layout is indeed gory. I wonder why they didn't just concatenate the values. Btw, what is the coefficient used for? $\endgroup$ – AdHominem Nov 5 '16 at 23:31
  • $\begingroup$ @AdHominem: 'coefficient' is $q^{-1} \mod p$ and used in the CRT calcuation; see en.wikipedia.org/wiki/RSA_%28cryptosystem%29#Example . Note this answer is about (locally) stored keys, as the body of your Q seems to be (but only for OpenSSH, other implementations are different); for keys sent in the (current) protocol as in the title of your Q, see tools.ietf.org/html/rfc4253#section-6.6 . $\endgroup$ – dave_thompson_085 Nov 6 '16 at 4:42
  • $\begingroup$ You could of course recalculate it, but I would say that the modulus is part of the private key as well. $\endgroup$ – Maarten Bodewes Nov 6 '16 at 12:44

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.