auth/asn12rsa: also convert ASN.1 encoded public key to plan9 format
This commit is contained in:
parent
58914b4b0b
commit
d06196ab87
2 changed files with 16 additions and 10 deletions
|
@ -149,7 +149,7 @@ attributes if they are missing,
|
||||||
and prints a full key.
|
and prints a full key.
|
||||||
.PP
|
.PP
|
||||||
.I Asn12rsa
|
.I Asn12rsa
|
||||||
reads an RSA private key stored as ASN.1
|
reads an RSA private or public key stored as ASN.1
|
||||||
encoded in the binary Distinguished Encoding Rules (DER)
|
encoded in the binary Distinguished Encoding Rules (DER)
|
||||||
and prints a Plan 9 RSA key,
|
and prints a Plan 9 RSA key,
|
||||||
inserting
|
inserting
|
||||||
|
|
|
@ -20,6 +20,7 @@ main(int argc, char **argv)
|
||||||
long n, tot;
|
long n, tot;
|
||||||
char *tag, *file;
|
char *tag, *file;
|
||||||
RSApriv *key;
|
RSApriv *key;
|
||||||
|
RSApub *pub;
|
||||||
|
|
||||||
fmtinstall('B', mpfmt);
|
fmtinstall('B', mpfmt);
|
||||||
|
|
||||||
|
@ -54,16 +55,21 @@ main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
tot += n;
|
tot += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
key = asn1toRSApriv(buf, tot);
|
key = asn1toRSApriv(buf, tot);
|
||||||
if(key == nil)
|
if(key != nil){
|
||||||
sysfatal("couldn't parse asn1 key");
|
s = smprint("key proto=rsa %s%ssize=%d ek=%B !dk=%B n=%B !p=%B !q=%B !kp=%B !kq=%B !c2=%B\n",
|
||||||
|
tag ? tag : "", tag ? " " : "",
|
||||||
s = smprint("key proto=rsa %s%ssize=%d ek=%B !dk=%B n=%B !p=%B !q=%B !kp=%B !kq=%B !c2=%B\n",
|
mpsignif(key->pub.n), key->pub.ek,
|
||||||
tag ? tag : "", tag ? " " : "",
|
key->dk, key->pub.n, key->p, key->q,
|
||||||
mpsignif(key->pub.n), key->pub.ek,
|
key->kp, key->kq, key->c2);
|
||||||
key->dk, key->pub.n, key->p, key->q,
|
} else {
|
||||||
key->kp, key->kq, key->c2);
|
pub = asn1toRSApub(buf, tot);
|
||||||
|
if(pub == nil)
|
||||||
|
sysfatal("couldn't parse asn1 key");
|
||||||
|
s = smprint("key proto=rsa %s%ssize=%d ek=%B n=%B\n",
|
||||||
|
tag ? tag : "", tag ? " " : "",
|
||||||
|
mpsignif(pub->n), pub->ek, pub->n);
|
||||||
|
}
|
||||||
if(s == nil)
|
if(s == nil)
|
||||||
sysfatal("smprint: %r");
|
sysfatal("smprint: %r");
|
||||||
write(1, s, strlen(s));
|
write(1, s, strlen(s));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue