3 M(Y @s<dZddlmZmZddlZddlmZddlZddZ dS)zUtility functions.)with_statementprint_functionN) OptionParserc Cstddd}|jdddddd |jd d d dd d |jdddd dd|jdddd!dd|jtj\}}|jrtd|j|jftjdt |jd}|j }WdQRXn$td|jtjdtj j j d}t |tkstt |tjjj||j}tjj|j|j}|j|j}|jr`td|j|jftjdt |jd}|j|WdQRXn&td|jtjdtjj|jddS)"z=Reads a private key and outputs the corresponding public key.zusage: %prog [options]zReads a private key and outputs the corresponding public key. Both private and public keys use the format described in PKCS#1 v1.5)usage descriptionz-iz--input infilenamestringz1Input filename. Reads from stdin if not specified)desttypehelpz-oz--output outfilenamez2Output filename. Writes to stdout of not specifiedz--informinformz!key format of input - default PEMPEMDER)r r choicesdefaultz --outformoutformz"key format of output - default PEMz(Reading private key from %s in %s format)filerbNz+Reading private key from stdin in %s formatasciiz%Writing public key to %s in %s formatwbz)Writing public key to stdout in %s format)rr)rr)r add_option parse_argssysargvrprintr stderropenreadstdinencoder bytesAssertionErrorrsakeyZ PrivateKeyZ load_pkcs1Z PublicKeyneZ save_pkcs1rr writestdoutdecode) parsercliZcli_argsinfileZin_dataZpriv_keyZpub_keyZout_dataoutfiler.//private/tmp/pip-build-nl73fm5q/rsa/rsa/util.pyprivate_to_publicsB         r0) __doc__ __future__rrroptparserZrsa.keyr#r0r.r.r.r/s