Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
proc
/
thread-self
/
root
/
usr
/
lib
/
python2.7
/
site-packages
/
rsa
/
File Content:
key.pyc
� 5��Vc @ s� d Z d d l Z d d l m Z d d l Z d d l Z d d l Z d d l Z d d l Z e j e � Z d Z d e f d � � YZ d e f d � � YZ d e f d � � YZ e j j e d � Z d � Z d � Z e e d � Z e d e d � Z d d d g Z e d k r�d d l Z ye x^ e d � D]P Z e j � \ Z Z e rVPn e rle d d k sxe d k r4d e GHq4q4WWn e! k r�d GHq�Xd GHn d S( sj RSA key generation code. Create new keys with the newkeys() function. It will give you a PublicKey and a PrivateKey object. Loading and saving keys requires the pyasn1 module. This module is imported as late as possible, such that other functionality will remain working in absence of pyasn1. .. note:: Storing public and private keys via the `pickle` module is possible. However, it is insecure to load a key from an untrusted source. The pickle module is not secure against erroneous or maliciously constructed data. Never unpickle data received from an untrusted or unauthenticated source. i����N( t bi t AbstractKeyc B s\ e Z d Z d Z d � Z e d d � � Z e d � � Z d d � Z d � Z d � Z RS( s0 Abstract superclass for private and public keys.t nt ec C s | | _ | | _ d S( N( R R ( t selfR R ( ( s+ /usr/lib/python2.7/site-packages/rsa/key.pyt __init__6 s t PEMc C s6 i | j d 6| j d 6} | j | | � } | | � S( s Loads a key in PKCS#1 DER or PEM format. :param keyfile: contents of a DER- or PEM-encoded file that contains the public key. :param format: the format of the file to load; 'PEM' or 'DER' :return: a PublicKey object R t DER( t _load_pkcs1_pemt _load_pkcs1_dert _assert_format_exists( t clst keyfilet formatt methodst method( ( s+ /usr/lib/python2.7/site-packages/rsa/key.pyt load_pkcs1: s c C sU y | | SWnB t k rP d j t | j � � � } t d | | f � � n Xd S( sB Checks whether the given file format exists in 'methods'. s , s% Unsupported format: %r, try one of %sN( t KeyErrort joint sortedt keyst ValueError( t file_formatR t formats( ( s+ /usr/lib/python2.7/site-packages/rsa/key.pyR M s c C s3 i | j d 6| j d 6} | j | | � } | � S( s� Saves the public key in PKCS#1 DER or PEM format. :param format: the format to save; 'PEM' or 'DER' :returns: the DER- or PEM-encoded public key. R R ( t _save_pkcs1_pemt _save_pkcs1_derR ( R R R R ( ( s+ /usr/lib/python2.7/site-packages/rsa/key.pyt save_pkcs1Y s c C s! | t | | j | j � | j S( s� Performs blinding on the message using random number 'r'. :param message: the message, as integer, to blind. :type message: int :param r: the random number to blind with. :type r: int :return: the blinded message. :rtype: int The blinding is such that message = unblind(decrypt(blind(encrypt(message))). See https://en.wikipedia.org/wiki/Blinding_%28cryptography%29 ( t powR R ( R t messaget r( ( s+ /usr/lib/python2.7/site-packages/rsa/key.pyt blindh s c C s! t j j | | j � | | j S( s� Performs blinding on the message using random number 'r'. :param blinded: the blinded message, as integer, to unblind. :param r: the random number to unblind with. :return: the original message. The blinding is such that message = unblind(decrypt(blind(encrypt(message))). See https://en.wikipedia.org/wiki/Blinding_%28cryptography%29 ( t rsat commont inverseR ( R t blindedR ( ( s+ /usr/lib/python2.7/site-packages/rsa/key.pyt unblindy s ( R R ( t __name__t __module__t __doc__t __slots__R t classmethodR t staticmethodR R R R# ( ( ( s+ /usr/lib/python2.7/site-packages/rsa/key.pyR 1 s t PublicKeyc B s� e Z d Z d Z d � Z d � Z d � Z d � Z d � Z d � Z e d � � Z d � Z e d � � Z d � Z e d � � Z e d � � Z RS( s� Represents a public RSA key. This key is also known as the 'encryption key'. It contains the 'n' and 'e' values. Supports attributes as well as dictionary-like access. Attribute accesss is faster, though. >>> PublicKey(5, 3) PublicKey(5, 3) >>> key = PublicKey(5, 3) >>> key.n 5 >>> key['n'] 5 >>> key.e 3 >>> key['e'] 3 R R c C s t | | � S( N( t getattr( R t key( ( s+ /usr/lib/python2.7/site-packages/rsa/key.pyt __getitem__� s c C s d | j | j f S( Ns PublicKey(%i, %i)( R R ( R ( ( s+ /usr/lib/python2.7/site-packages/rsa/key.pyt __repr__� s c C s | j | j f S( s&