caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] PEM to Cryptokit
@ 2010-12-28  2:45 Микола Стрєбков
  2010-12-28 10:54 ` [Caml-list] " Sylvain Le Gall
  0 siblings, 1 reply; 2+ messages in thread
From: Микола Стрєбков @ 2010-12-28  2:45 UTC (permalink / raw)
  To: OCaml Mailing List

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.

-- 
Mykola Stryebkov
Public key: http://mykola.org/pubkey.txt
fpr: 0226 54EE C1FF 8636 36EF  2AC9 BCE9 CFC7 9CF4 6747

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Caml-list] Re: PEM to Cryptokit
  2010-12-28  2:45 [Caml-list] PEM to Cryptokit Микола Стрєбков
@ 2010-12-28 10:54 ` Sylvain Le Gall
  0 siblings, 0 replies; 2+ messages in thread
From: Sylvain Le Gall @ 2010-12-28 10:54 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-12-28 10:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-28  2:45 [Caml-list] PEM to Cryptokit Микола Стрєбков
2010-12-28 10:54 ` [Caml-list] " Sylvain Le Gall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).