auth/rsa2ssh: add SSH2 RSA output format (from plan9port)
This commit is contained in:
parent
420ed37c57
commit
8c9e7ded17
2 changed files with 38 additions and 2 deletions
|
@ -33,6 +33,13 @@ rsagen, rsafill, asn12rsa, rsa2pub, rsa2ssh, rsa2x509 \- generate and format rsa
|
||||||
.PP
|
.PP
|
||||||
.B rsa2ssh
|
.B rsa2ssh
|
||||||
[
|
[
|
||||||
|
.B -2
|
||||||
|
]
|
||||||
|
[
|
||||||
|
.B -c
|
||||||
|
.I comment
|
||||||
|
]
|
||||||
|
[
|
||||||
.I file
|
.I file
|
||||||
]
|
]
|
||||||
.PP
|
.PP
|
||||||
|
@ -170,6 +177,11 @@ in the format used by SSH: three space-separated decimal numbers
|
||||||
.BR ek ,
|
.BR ek ,
|
||||||
and
|
and
|
||||||
.BR n .
|
.BR n .
|
||||||
|
The
|
||||||
|
.B -2
|
||||||
|
option will change the output to SSH2 RSA public key format. The
|
||||||
|
.B -c
|
||||||
|
option will set the comment.
|
||||||
For compatibility with external SSH implementations, the public keys in
|
For compatibility with external SSH implementations, the public keys in
|
||||||
.B /sys/lib/ssh/keyring
|
.B /sys/lib/ssh/keyring
|
||||||
and
|
and
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
void
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprint(2, "usage: auth/rsa2ssh [file]\n");
|
fprint(2, "usage: auth/rsa2ssh [-2] [-c comment] [file]\n");
|
||||||
exits("usage");
|
exits("usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,10 +16,21 @@ void
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
RSApriv *k;
|
RSApriv *k;
|
||||||
|
int ssh2;
|
||||||
|
char *comment;
|
||||||
|
|
||||||
fmtinstall('B', mpfmt);
|
fmtinstall('B', mpfmt);
|
||||||
|
fmtinstall('[', encodefmt);
|
||||||
|
|
||||||
|
comment = "";
|
||||||
|
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
|
case 'c':
|
||||||
|
comment = EARGF(usage());
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
ssh2 = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}ARGEND
|
}ARGEND
|
||||||
|
@ -30,6 +41,19 @@ main(int argc, char **argv)
|
||||||
if((k = getkey(argc, argv, 0, nil)) == nil)
|
if((k = getkey(argc, argv, 0, nil)) == nil)
|
||||||
sysfatal("%r");
|
sysfatal("%r");
|
||||||
|
|
||||||
print("%d %.10B %.10B\n", mpsignif(k->pub.n), k->pub.ek, k->pub.n);
|
if(ssh2) {
|
||||||
|
uchar buf[8192], *p;
|
||||||
|
|
||||||
|
p = buf;
|
||||||
|
p = put4(p, 7);
|
||||||
|
p = putn(p, "ssh-rsa", 7);
|
||||||
|
p = putmp2(p, k->pub.ek);
|
||||||
|
p = putmp2(p, k->pub.n);
|
||||||
|
|
||||||
|
print("ssh-rsa %.*[ %s\n", p-buf, buf, comment);
|
||||||
|
} else {
|
||||||
|
print("%d %.10B %.10B %s\n", mpsignif(k->pub.n), k->pub.ek, k->pub.n, comment);
|
||||||
|
}
|
||||||
|
|
||||||
exits(nil);
|
exits(nil);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue