From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id oBSAtKpv015775 for ; Tue, 28 Dec 2010 11:55:21 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap4FAFtQGU1QW+UMgWdsb2JhbACDb5ImjhoVAQEWIiSvVZAigSCDNnQEiwQ X-IronPort-AV: E=Sophos;i="4.60,238,1291590000"; d="scan'208";a="71434477" Received: from lo.gmane.org ([80.91.229.12]) by mail3-smtp-sop.national.inria.fr with ESMTP; 28 Dec 2010 11:55:15 +0100 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PXXCx-0004pq-71 for caml-list@inria.fr; Tue, 28 Dec 2010 11:55:11 +0100 Received: from avelizy-155-1-59-132.w86-217.abo.wanadoo.fr ([86.217.90.132]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 28 Dec 2010 11:55:11 +0100 Received: from sylvain by avelizy-155-1-59-132.w86-217.abo.wanadoo.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 28 Dec 2010 11:55:11 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Sylvain Le Gall Date: Tue, 28 Dec 2010 10:54:58 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: avelizy-155-1-59-132.w86-217.abo.wanadoo.fr User-Agent: slrn/pre1.0.0-18 (Linux) Subject: [Caml-list] Re: PEM to Cryptokit On 28-12-2010, Микола Стрєбков 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