From: Sylvain Le Gall <sylvain@le-gall.net>
To: caml-list@inria.fr
Subject: [Caml-list] Re: PEM to Cryptokit
Date: Tue, 28 Dec 2010 10:54:58 +0000 (UTC) [thread overview]
Message-ID: <slrnihjgg1.ut5.sylvain@gallu.homelinux.org> (raw)
In-Reply-To: <E2D1EBD7-190C-4141-A1B9-6E4B5CEFBE09@mykola.org>
On 28-12-2010, Микола Стрєбков <nick@mykola.org> wrote:
> Hi, list
>
> I had to convert a private key in PEM format to Cryptokit.RSA.key.
> First of all, I found pem2cryptokit from oauth project:
> http://code.google.com/p/ooauth/source/browse/trunk/pem2cryptokit.c.
> But it didn't work (see issue@googlecode reported).
>
> So, I wrote my own variant: https://gist.github.com/756823.
>
> Comments and suggestions are welcomed.
>
Using pcre for this task is maybe a little bit overkilling. I think a
simple Scanf should do.
Maybe even simple, split the string at ':' and match the first part:
match split_colon line with
| "Private-Key", data ->
Scanf.sscanf data "%d bit" (set_size key)
| "modulus", data -> ...
...
| "-----BEGIN RSA PRIVATE KEY-----" ->
...
| _ ->
It should make your code a little more compact.
Regards,
Sylvain Le Gall
prev parent reply other threads:[~2010-12-28 10:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-28 2:45 [Caml-list] " Микола Стрєбков
2010-12-28 10:54 ` Sylvain Le Gall [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=slrnihjgg1.ut5.sylvain@gallu.homelinux.org \
--to=sylvain@le-gall.net \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox