B d @s2dZddlZddlmZddlZddddZdS)zUtility functions.N) OptionParser)returnc Cstddd}|jdddddd |jd d d dd d |jdddddd|jdddddd|tj\}}|jrtd|j|jftjdt |jd}| }WdQRXn$td|jtjdtj d}t |tkstt |tjj||j}tj|j|j}||j}|jr`td|j|jftjdt |jd}||WdQRXn&td|jtjdtj|ddS) 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 PEM)PEMZDERr )rr 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)r add_option parse_argssysargvrprintr stderropenreadstdinencoder bytesAssertionErrorrsakeyZ PrivateKeyZ load_pkcs1Z PublicKeyneZ save_pkcs1rr writestdoutdecode) parsercliZcli_argsinfileZin_dataZpriv_keyZpub_keyZout_dataoutfiler,//tmp/pip-target-jj3kjtpb/lib/python/rsa/util.pyprivate_to_publicsB         r.)__doc__roptparserZrsa.keyr!r.r,r,r,r-s