Re: Using the SSL module.
Chris Angelico <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <CAPTjJmr1LQGBGY7m--mzp9afyEprojsa0L1bZ8Swyzckj3G7cA@mail.gmail.com> |
On Tue, Jun 30, 2015 at 2:36 AM, Henrik Grubbström <[email protected]> wrote: > It looks like a simple SSH-specific encoding. From looking at your example, > I believe that something like the following might work: > > Stdio.Buffer buf = Stdio.Buffer(MIME.decode_base64(encoded_key)); > > string tag = buf->read_hstring(4); > > if (tag == "ssh-rsa") { > int modulo = buf->read_hint(4); > > int pub = buf->read_hint(4); > > Crypto.RSA rsa = Crypto.RSA(); > > rsa->set_public_key(modulo, pub); > > return rsa; > > } Thanks! I don't know much about crypto, so all I can do is try it out. It seems that the public exponent comes first in the encoded version, so I switched those two read_hint() lines, and then it appears to work - the key can successfully verify signatures created with the corresponding private key. This looks a lot better than "rip these bytes off, shove those bytes on, and see how it goes". ChrisA