python-crypto: RSA cer public key

hide@deb1:~/java$ more pub.txt
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCd1WeRsOaTTsWbQFmIEpcishsP
HntJnVKuFDjme4kzWhyfFIgW/nNLHX2cKSafriAyCzCrNJzwshn3DmgicI7tUB7U
jHEkSC6wHsEfnRnhCPXTJHbvyy8JWXNRlTUGoN7LwIwNPSfNCmWXjXrXGpcWxMBu
5NhybvRz0Yd9CcLDQwIDAQAB
-----END PUBLIC KEY-----



hide@deb1:~/java$ python
Python 2.4.4 (#2, Apr 15 2008, 23:43:20)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re,base64
>>> from Crypto.PublicKey import RSA
>>> pks=''.join([ x.replace('\n','') for x  in open('pri.txt','r').readlines() if re.search('^^-',x) == None ])
>>> pkb=base64.b64decode(pks)
>>> pk=RSA.construct(pkb)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.4/site-packages/Crypto/PublicKey/RSA.py", line 70, in construct
    raise error, 'argument for construct() wrong length'
Crypto.PublicKey.RSA.error: argument for construct() wrong length
>>> pks
'MIICLDCCAZUCBEg+UVcwDQYJKoZIhvcNAQEEBQAwXTELMAkGA1UEBhMCSlAxDjAMBgNVBAgTBVRva3lvMQ4wDAYDVQQHEwVUb2t5bzEOMAwGA1UEChMFaGRrbnIxDjAMBgNVBAsTBWhka25yMQ4wDAYDVQQDEwVoZGtucjAeFw0wODA1MjkwNjQ2NDdaFw0wODA4MjcwNjQ2NDdaMF0xCzAJBgNVBAYTAkpQMQ4wDAYDVQQIEwVUb2t5bzEOMAwGA1UEBxMFVG9reW8xDjAMBgNVBAoTBWhka25yMQ4wDAYDVQQLEwVoZGtucjEOMAwGA1UEAxMFaGRrbnIwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAJ3VZ5Gw5pNOxZtAWYgSlyKyGw8ee0mdUq4UOOZ7iTNaHJ8UiBb+c0sdfZwpJp+uIDILMKs0nPCyGfcOaCJwju1QHtSMcSRILrAewR+dGeEI9dMkdu/LLwlZc1GVNQag3svAjA09J80KZZeNetcalxbEwG7k2HJu9HPRh30JwsNDAgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAUYP1UpsoKrK7hEpsAg6PrL9ZsFTOcAv9kLrVThXO4ffoPGaUlZ38MhNlCPJLjSvX+2qrWlhOgGsweox07UEGFvS/g943nttp3XLlKobJVCJcSTelEz9Td5bvqpVwrTzh+FmYZAu0QEy5s0TCatYXHCasqCFvttwh11/3d8isuGk='
>>> pkb
'0\x82\x02,0\x82\x01\x95\x02\x04H>QW0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x04\x05\x000]1\x0b0\t\x06\x03U\x04\x06\x13\x02JP1\x0e0\x0c\x06\x03U\x04\x08\x13\x05Tokyo1\x0e0\x0c\x06\x03U\x04\x07\x13\x05Tokyo1\x0e0\x0c\x06\x03U\x04\n\x13\x05hdknr1\x0e0\x0c\x06\x03U\x04\x0b\x13\x05hdknr1\x0e0\x0c\x06\x03U\x04\x03\x13\x05hdknr0\x1e\x17\r080529064647Z\x17\r080827064647Z0]1\x0b0\t\x06\x03U\x04\x06\x13\x02JP1\x0e0\x0c\x06\x03U\x04\x08\x13\x05Tokyo1\x0e0\x0c\x06\x03U\x04\x07\x13\x05Tokyo1\x0e0\x0c\x06\x03U\x04\n\x13\x05hdknr1\x0e0\x0c\x06\x03U\x04\x0b\x13\x05hdknr1\x0e0\x0c\x06\x03U\x04\x03\x13\x05hdknr0\x81\x9f0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x81\x8d\x000\x81\x89\x02\x81\x81\x00\x9d\xd5g\x91\xb0\xe6\x93N\xc5\x9b@Y\x88\x12\x97"\xb2\x1b\x0f\x1e{I\x9dR\xae\x148\xe6{\x893Z\x1c\x9f\x14\x88\x16\xfesK\x1d}\x9c)&\x9f\xae 2\x0b0\xab4\x9c\xf0\xb2\x19\xf7\x0eh"p\x8e\xedP\x1e\xd4\x8cq$H.\xb0\x1e\xc1\x1f\x9d\x19\xe1\x08\xf5\xd3$v\xef\xcb/\tYsQ\x955\x06\xa0\xde\xcb\xc0\x8c\r=\'\xcd\ne\x97\x8dz\xd7\x1a\x97\x16\xc4\xc0n\xe4\xd8rn\xf4s\xd1\x87}\t\xc2\xc3C\x02\x03\x01\x00\x010\r\x06\t*\x86H\x86\xf7\r\x01\x01\x04\x05\x00\x03\x81\x81\x00Q\x83\xf5R\x9b(*\xb2\xbb\x84Jl\x02\x0e\x8f\xac\xbfY\xb0T\xcep\x0b\xfd\x90\xba\xd5N\x15\xce\xe1\xf7\xe8<f\x94\x95\x9d\xfc2\x13e\x08\xf2K\x8d+\xd7\xfbj\xabZXN\x80k0z\x8ct\xedA\x06\x16\xf4\xbf\x83\xde7\x9e\xdbi\xddr\xe5*\x86\xc9T"\\I7\xa5\x13?Sw\x96\xef\xaa\x95p\xad<\xe1\xf8Y\x98d\x0b\xb4@L\xb9\xb3D\xc2j\xd6\x17\x1c&\xac\xa8!o\xb6\xdc!\xd7_\xf7w\xc8\xac\xb8i'
>>> t= '0x'+ ''.join([ ('0'+hex(ord(c))[2:])[-2:] for c in pkb]) + 'L'
>>> t
'0x30819f300d06092a864886f70d010101050003818d00308189028181009dd56791b0e6934ec59b405988129722b21b0f1e7b499d52ae1438e67b89335a1c9f148816fe734b1d7d9c29269fae20320b30ab349cf0b219f70e6822708eed501ed48c7124482eb01ec11f9d19e108f5d32476efcb2f09597351953506a0decbc08c0d3d27cd0a65978d7ad71a9716c4c06ee4d8726ef473d1877d09c2c3430203010001L'
>>> pkl=long(t,16)
>>> k=RSA.construct(pkl,65537)

 

うまくいっているのか???????わからん。

カテゴリー: 未分類 パーマリンク

python-crypto: RSA cer public key への3件のフィードバック

  1. Unknown より:

    Hi,Do you need ad players, advertisement player and LCD advertisings? Please go Here:www.amberdigital.com.hk(Amberdigital).we have explored and developed the international market with professionalism. We have built a widespread marketing network, and set up a capable management team dedicated to provide beyond-expectation services to our customers.
    amberdigital Contact Us

    E-mail:sstar@netvigator.com
    website:www.amberdigital.com.hk
    alibaba:amberdigital.en.alibaba.com[efififfdhfgfab]

  2. Unknown より:

    Hi,Do you have used LCDs, used flat screens and secondhand LCDs? Please go here:www.sstar-hk.com(Southern Stars).We are constantly buying re-usable LCD panels and working for LCD recycling.The re-usable panels go through strictly designed process of categorizing, checking, testing, repairing and refurbishing before they are re-used to make remanufactured LCD displays and TV sets.Due to our recent breakthrough in testing and repairing technology of LCD, we can improve the value for your LCD panels.
    website:www.sstar-hk.com[dgfjaejdhafcidi]

  3. Unknown より:

    Hi,Do you need digital signages, advertising displays, digital sign, advertisement displays and advertising players? Please go Here:www.amberdigital.com.hk(Amberdigital).we have explored and developed the international market with professionalism. We have built a widespread marketing network, and set up a capable management team dedicated to provide beyond-expectation services to our customers.
    amberdigital Contact Us
    website:www.amberdigital.com.hk
    alibaba:amberdigital.en.alibaba.com[cbcccccaacbdgc]

コメントを残す

以下に詳細を記入するか、アイコンをクリックしてログインしてください。

WordPress.com ロゴ

WordPress.com アカウントを使ってコメントしています。 ログアウト / 変更 )

Twitter 画像

Twitter アカウントを使ってコメントしています。 ログアウト / 変更 )

Facebook の写真

Facebook アカウントを使ってコメントしています。 ログアウト / 変更 )

Google+ フォト

Google+ アカウントを使ってコメントしています。 ログアウト / 変更 )

%s と連携中