3 rsagen, rsafill, asn12rsa, rsa2asn1, rsa2pub, rsa2ssh, rsa2x509, rsa2csr \- generate and format rsa keys
67 Plan 9 represents an RSA key as an attribute-value pair list
68 prefixed with the string
70 this is the generic key format used by
72 A full RSA private key has the following attributes:
81 the number of significant bits in
85 the encryption exponent
94 the decryption exponent
102 .B "!kp\fR, \fL!kq\fR, \fL!c2
103 parameters derived from the other attributes, cached to speed decryption
106 All the numbers are in hexadecimal except
109 An RSA public key omits the attributes beginning with
111 A key may have other attributes as well (for example, a
113 attribute identifying how this key is typically used),
114 but to these utilities such attributes are merely comments.
116 For example, a very small (and thus insecure) private key and corresponding
120 key proto=rsa size=8 ek=7 n=8F !dk=67 !p=B !q=D !kp=3 !kq=7 !c2=6
121 key proto=rsa size=8 ek=7 n=8F
124 Note that the order of the attributes does not matter.
127 prints a randomly generated RSA private key
136 is specified, it is printed between
142 is a sequence of attribute-value comments describing the key.
151 attributes if they are missing,
152 and prints a full key.
155 reads an RSA private or public key stored as ASN.1
156 encoded in the binary Distinguished Encoding Rules (DER)
157 and prints a Plan 9 RSA key,
163 ASN.1/DER is a popular key format on Unix and Windows;
164 it is often encoded in text form using the Privacy Enhanced Mail (PEM) format
165 in a section labeled as an
172 auth/pemdecode 'RSA PRIVATE KEY' | auth/asn12rsa
175 extracts the key section from a textual ASN.1/DER/PEM key
176 into binary ASN.1/DER format and then
177 converts it to a Plan 9 RSA key.
180 reads a Plan 9 RSA public or private key,
181 removes the private attributes, and prints the resulting public key.
182 Comment attributes are preserved.
187 but outputs the public key in ASN.1/DER format.
190 flag a private key is read and encoded in ANS.1/DER format.
193 reads a Plan 9 RSA public or private key and prints the public portion
194 in the format used by SSH2. The
196 option will set the comment.
199 reads a Plan 9 RSA private key and writes a self-signed X.509 certificate
200 encoded in ASN.1/DER format to standard output.
201 (Note that ASN.1/DER X.509 certificates are different from ASN.1/DER private keys).
202 The certificate uses the current time as its start time and expires
207 It contains the public half of the key
210 as the issuer/subject string (also known as a ``Distinguished Name'').
211 This info is typically in the form:
214 C=US ST=NJ L=07974 O=Lucent OU='Bell Labs' CN=G.R.Emlin
217 One can append further Distinguished Names, DNS Names and
218 E-Mail addresses as a ``Subject Alternative Name'' separated
219 with a comma after the main subject.
221 The X.509 ASN.1/DER format is often encoded in text using a PEM section
223 .RB `` CERTIFICATE .''
227 auth/rsa2x509 'C=US OU=''Bell Labs''' file |
228 auth/pemencode CERTIFICATE
231 generates such a textual certificate.
232 Applications that serve TLS-encrypted sessions (for example,
237 expect certificates in ASN.1/DER/PEM format.
239 The Plan 9 RSA private key needs to be loaded into factotum
240 for TLS server applications. It is recommended to put the key into
242 avoiding it being stored unencrypted on the filesystem.
247 and a RSA private key and outputs a signing request in ASN.1 format.
249 Generate a fresh key and use it to start a TLS-enabled web server:
252 auth/rsagen -t 'service=tls owner=*' >key
253 auth/rsa2x509 'C=US CN=*.cs.bell-labs.com' key |
254 auth/pemencode CERTIFICATE >cert
255 cat key >/mnt/factotum/ctl
256 ip/httpd/httpd -c cert
259 Generate a fresh key and configure a remote Unix system to
260 allow use of that key for logins:
263 auth/rsagen -t 'service=ssh' >key
264 auth/rsa2ssh key | ssh unix 'cat >>.ssh/authorized_keys'
265 cat key >/mnt/factotum/ctl
269 Convert a private key in PEM format (as generated by OpenSSL)
270 and load it into factotum:
273 auth/pemdecode 'PRIVATE KEY' key.pem |
274 auth/asn12rsa -t 'service=tls' >/mnt/factotum/ctl
277 Generate a certificate signing request (CSR) in PEM format:
280 auth/rsa2csr 'CN=example.com' key |
281 auth/pemencode 'CERTIFICATE REQUEST'
284 Generate a tinc host key:
287 auth/rsagen -t 'service=tinc role=client host=myhost' > myhost.key
288 auth/rsa2pub < myhost.key |
289 auth/rsa2asn1 | auth/pemencode 'RSA PUBLIC KEY' > hosts/myhost
297 There are too many key formats.