Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.043 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'python': 0.09; 'subject:using': 0.09; 'cc:addr:python-list': 0.10; 'thread': 0.11; '[2].': 0.16; 'grasp': 0.16; 'subject:key': 0.16; 'url:ftp': 0.16; 'wrote:': 0.17; 'jan': 0.18; '(or': 0.18; 'keys': 0.22; 'libraries': 0.22; 'parse': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; '[1]': 0.27; 'am,': 0.27; 'updating': 0.27; '[2]': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'marc': 0.29; 'writes:': 0.29; 'van': 0.29; "i'm": 0.29; 'related': 0.30; 'fri,': 0.30; 'received:209.85.215.46': 0.30; 'code': 0.31; 'could': 0.32; 'values.': 0.33; 'handle': 0.33; 'anyone': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'received:209.85': 0.35; 'but': 0.36; 'level.': 0.36; 'method': 0.36; 'thank': 0.36; 'possible': 0.37; 'uses': 0.37; 'previous': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'your': 0.60; 'different': 0.63; 'helping': 0.63; 'more': 0.63; 'url:a': 0.72; 'sharing': 0.74; 'low': 0.83; '2013': 0.84; 'url:api': 0.84; 'cryptography': 0.91; 'to:none': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:cc:content-type:content-transfer-encoding; bh=qEcT991S9XS+L3r+fdDopI8fsjax14ptLzqCQA1OrjA=; b=W7KzPboMBTsI1drhl00lQ6IX0Z0OJf8ela2S3HJGldtd+y+yXWYeU7G26WCWf/jmLm U1ll7r7cZITYqLipen0qPSoPngUB84fGglZe93BuAghQLm4KUsKy4AJp61CgrmEVDBTP AIWDKY3rb8m9ouwVgMKlli+NBQF2VjDjOKcfNWHlkJGTuNUQcmgbftXGFRUCtPjwM9Hq ETI4KB2N3mQr85P3n6ztuWYoUpfWh1CXaw+PKd+ktuTf3NU0u54PNeo949qhKErqg1Hl JcksIB6yxsdQyv0Nvvcaw658bEZwfm8xKUVHGdrQb390eI/dxkvwaQrZ9MvZ84PHfChm 2Iaw== X-Received: by 10.112.27.33 with SMTP id q1mr3543674lbg.78.1358500401768; Fri, 18 Jan 2013 01:13:21 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <922c97d0-77cf-4e68-8edc-d65c6d7e7831@googlegroups.com> <58e8a6c7-d512-4f44-b41f-a4f7efacf14f@googlegroups.com> From: Marc Aymerich Date: Fri, 18 Jan 2013 10:13:01 +0100 Subject: Re: Loading a PKCS#1 public key using M2Crypto Cc: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358500404 news.xs4all.nl 6990 [2001:888:2000:d::a6]:43517 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:36983 On Fri, Jan 18, 2013 at 12:10 AM, Piet van Oostrum wr= ote: > Marc Aymerich writes: > >> Thank you very much Piet, >> I'm just starting to grasp these cryptography related concepts and your = code is helping me a lot to understand how to handle these keys in a low le= vel. >> >> I'm updating my code incorporating your new contribution! >> >> Just to let you know, during my previous research I had found a python-C= rypto related solution that also uses DER and ASN.1 [1], but it uses a diff= erent approach (I guess). I suspect that this approach is also possible wit= h M2Crypto because it has a method for constructing RSA keys [2]. >> >> [1] http://stackoverflow.com/a/10574723 >> [2] http://www.heikkitoivonen.net/m2crypto/api/M2Crypto.RSA-module.html#= new_pub_key >> > new_pub_key could be used but then you would have to do an ASN.1 parse > of the DER format of your key to get the n and e values. AFAICT M2Crypto > doesn't have methods to do this, so you would need to use one of the > python ASN.1 libraries (or write that part yourself). Thanks for the clarifications, Just sharing the document I'm reading right now, in case anyone found this thread and want to know more about ASN.1 and DER: ftp://ftp.rsasecurity.com/pub/pkcs/ascii/layman.asc --=20 Marc