Current File : //usr/lib/python2.7/site-packages/keyczar/util.pyo
�
N�Pc@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	yddl
mZWn!ek
r�ddl
m
ZnXyddlmZWn'ek
r�defd��YZnXddlmZdd	lmZdd
lmZddlZy ddlmZmZmZWn9ek
rdefd
��YZd�Zd�ZnXe�jZejd�ZddddddddgZ ejd�Z!dddgZ"ejd�Z#ejd�Z$dZ%dZ&d�Z'd �Z(d!�Z)d"�Z*d#�Z+d$�Z,d%�Z-d&�Z.d'�Z/d(�Z0d)�Z1d*�Z2d+�Z3d,�Z4d-�Z5d.�Z6d/�Z7d0�Z8d1�Z9d2�Z:d3�Z;d4�Z<d5�Z=d6�Z>d7�Z?d8�Z@d9�ZAd:�ZBd;ZCd<ZDd=�ZEd>�ZFd?�ZGd@�ZHdA�ZIdB�ZJdC�ZKdDejLfdE��YZMdFejNeOfdG��YZPdHejQfdI��YZRdJejSeOfdK��YZTdL�ZUdM�ZVdN�ZWdS(OsV
Utility functions for keyczar package.

@author: arkajit.dey@gmail.com (Arkajit Dey)
i����N(tsha1(tsha(tBlockingIOErrorRcBseZdZdd�ZRS(sCException raised when I/O would block on a non-blocking I/O stream.icCsJtt|�j||�t|ttf�s=td��n||_dS(Ns$characters_written must be a integer(tsupertIOErrort__init__t
isinstancetinttlongt	TypeErrortcharacters_written(tselfterrnotstrerrorR
((s0/usr/lib/python2.7/site-packages/keyczar/util.pyR.s(t__name__t
__module__t__doc__R(((s0/usr/lib/python2.7/site-packages/keyczar/util.pyR*s(tdecoder(tencoder(tuniv(tABCMetatabstractmethodtabstractpropertyRcBseZRS((RR(((s0/usr/lib/python2.7/site-packages/keyczar/util.pyR>scCs|S(N((tfuncobj((s0/usr/lib/python2.7/site-packages/keyczar/util.pyRAscCs
t|�S(N(tproperty(R((s0/usr/lib/python2.7/site-packages/keyczar/util.pyRDss1.2.840.113549.1.1.1tntetdtptqtdptdqtinvqs1.2.840.10040.4.1tgs1.2.840.113549.1.1.5s
1.3.14.3.2.26itKEYCZAR_BACKEND_PATHScGsAtj�}x.tt|��D]}|j|||�qW|S(N(RtSequencetrangetlentsetComponentByPosition(tvalstseqti((s0/usr/lib/python2.7/site-packages/keyczar/util.pytASN1SequencebscCs,gtt|��D]}|j|�^qS(N(R$R%tgetComponentByPosition(R(R)((s0/usr/lib/python2.7/site-packages/keyczar/util.pytParseASN1SequencehscCs�ttjt|��d�}t|�dkrCtjd��nt|d�}|dkrqtjd��nt|d�\}}tj|d�d}i}|tkr&t|�}t|d�}|dkr�tjd��nx�t	tt
��D]"}t||d�|t
|<q�Wno|tkr�t|�}x2t	tt
��D]}t||�|t
|<qQWt|�|d<ntjd	��|S(
NiisIllegal PKCS8 String.sUnrecognized PKCS8 Versioniis$Unrecognized RSA Private Key Versiontxs-Unrecognized AlgorithmIdentifier: not RSA/DSA(R,RtdecodetBase64WSDecodeR%terrorstKeyczarErrorRtRSA_OIDR$t
RSA_PARAMSRtDSA_OIDt
DSA_PARAMS(tpkcs8R(tversiontoidt
alg_paramstkeytparamsR)((s0/usr/lib/python2.7/site-packages/keyczar/util.pyt
ParsePkcs8ys.#cCs�tttj��}tj�jdtjd��}x?ttt	��D]+}|j|dtj|t	|��qIWt
j|�}ttjd�|tj|��}t
t
j|��S(Nii(R*R2RtNullR#R&tIntegerR$R%R3RtencodetOctetStringtBase64WSEncode(R;R8R:R)toctkeyR(((s0/usr/lib/python2.7/site-packages/keyczar/util.pytExportRsaPkcs8�s!)$cCs�tj�}x;ttt��D]'}|j|tj|t|��qWtt|�}t	j
tj|d��}ttjd�|tj|��}tt	j
|��S(NR-i(
RR#R$R%R5R&R>R*R4RR?R@RA(R;R9R)R8RBR(((s0/usr/lib/python2.7/site-packages/keyczar/util.pytExportDsaPkcs8�s%$c	CsZttjt|��d�}t|�dkrCtjd��nt|d�\}}tjtjt	|dj
�dd!���d}i}|tkr�gt|�D]}t|�^q�\|d<|d<n�|t
krGgt|�D]}t|�^q�}x,ttt��D]}|||t|<qWt|�|d<ntjd	��|S(
NiisIllegal X.509 String.ii����RRtys-Unrecognized AlgorithmIdentifier: not RSA/DSA(R,RR.R/R%R0R1RR@t
BinToBytestprettyPrintR2RR4R$R5(	tx509R(R8R9tpubkeyR;R-R'R)((s0/usr/lib/python2.7/site-packages/keyczar/util.pyt	ParseX509�s 6%cCs�tttj��}ttj|d�tj|d��}ttj|��}tjd|�}t||�}t	tj|��S(NRRs'%s'B(
R*R2RR=R>t
BytesToBinRR?t	BitStringRA(R;R8R:tbinkeyRIR(((s0/usr/lib/python2.7/site-packages/keyczar/util.pyt
ExportRsaX509�s)cCs�ttj|d�tj|d�tj|d��}tt|�}ttjtj|d���}tjd|�}t||�}ttj|��S(NRRR!REs'%s'B(	R*RR>R4RKRR?RLRA(R;R9R8RMRIR(((s0/usr/lib/python2.7/site-packages/keyczar/util.pyt
ExportDsaX509�s"cCs.ttj|�tj|��}tj|�S(s 
  Given the raw parameters of a DSA signature, return a Base64 signature.

  @param r: parameter r of DSA signature
  @type r: long int

  @param s: parameter s of DSA signature
  @type s: long int

  @return: raw byte string formatted as an ASN.1 sequence of r and s
  @rtype: string
  (R*RR>RR?(trtsR(((s0/usr/lib/python2.7/site-packages/keyczar/util.pyt
MakeDsaSig�s
!cCsktj|�d}t|�dkr7tjd��nt|jd��}t|jd��}||fS(s
  Given a raw byte string, return tuple of DSA signature parameters.

  @param sig: byte string of ASN.1 representation
  @type sig: string

  @return: parameters r, s as a tuple
  @rtype: tuple

  @raise KeyczarErrror: if the DSA signature format is invalid
  iisIllegal DSA signature.i(RR.R%R0R1RR+(tsigR(RPRQ((s0/usr/lib/python2.7/site-packages/keyczar/util.pytParseDsaSig�scCs�dddddddddd	d
dddd
g}djg|D]}t|�^q@�t|�}td�|dt|�d}td�|td�|S(s/Algorithm EMSA_PKCS1-v1_5 from PKCS 1 version 2i0i!i	iii+iiiiiiiti�ii(tjointchrtHashR%(tmsgtmodulus_sizetmagic_sha1_headertctencodedt
pad_string((s0/usr/lib/python2.7/site-packages/keyczar/util.pytMakeEmsaMessage�s
2"cCswt|�}gtt|�d�D]}|d|d|d!^q#}djg|D]}tt|d��^qU�S(s"Convert bit string to byte string.iiRUi(t_PadByteR$R%RVRWR(tbitsR)toctetsR-((s0/usr/lib/python2.7/site-packages/keyczar/util.pyRF�s<cCs2djg|D]}ttt|���^q
�S(s"Convert byte string to bit string.RU(RVR`tIntToBintord(tbyte_stringtbyte((s0/usr/lib/python2.7/site-packages/keyczar/util.pyRKscCs$t|�d}d|dd|S(sCPad a string of bits with zeros to make its length a multiple of 8.it0(R%(RaRP((s0/usr/lib/python2.7/site-packages/keyczar/util.pyR`scCsZ|dks|dkr"t|�S|ddkrDt|d�dSt|d�dSdS(NiiiRgt1(tstrRc(R((s0/usr/lib/python2.7/site-packages/keyczar/util.pyRcs

cCsQg}x1|dkr9|jt|d��|d?}q	W|j�dj|�S(sHReturn a big-endian byte string representation of an arbitrary length n.iiiRU(tappendRWtreverseRV(Rtchars((s0/usr/lib/python2.7/site-packages/keyczar/util.pyt
BigIntToBytess
cCs[g|d?|d?|d?|gD]}|d^q}djg|D]}t|�^qB�S(sEReturn byte string of 4 big-endian ordered byte_array representing n.iiiiRU(RVRW(Rtmt
byte_arraytb((s0/usr/lib/python2.7/site-packages/keyczar/util.pyt
IntToBytess5cCsOt|�}ttgt|�D]&}t||�d|d|^q��S(Nii(R%RtsumR$Rd(RetlR)((s0/usr/lib/python2.7/site-packages/keyczar/util.pytBytesToLong!scCs�tt|�t|��}|t|�krIt||t|��}n.|t|�krwt||t|��}ng|D]}t|�^q~}g|D]}t|�^q�}gt|�D]}t||||A�^q�}dj|�S(s=Return a ^ b as a byte string where a and b are byte strings.RU(tmaxR%tPadBytesRdR$RWRV(taRpRnR\R-RER)tz((s0/usr/lib/python2.7/site-packages/keyczar/util.pytXor%s1cCs|d|S(s(Prepend a byte string with n zero bytes.t((ReR((s0/usr/lib/python2.7/site-packages/keyczar/util.pyRv2scCs3|jtd��}|dkr+td�S|SdS(sTrim leading zero bytes.iRUN(tlstripRW(Rettrimmed((s0/usr/lib/python2.7/site-packages/keyczar/util.pyt	TrimBytes6s
cCs
tj|�S(sReturn n random bytes.(tosturandom(R((s0/usr/lib/python2.7/site-packages/keyczar/util.pyt	RandBytes>scGs1t�}x|D]}|j|�qW|j�S(s5Return a SHA-1 hash over a variable number of inputs.(Rtupdatetdigest(tinputstmdR)((s0/usr/lib/python2.7/site-packages/keyczar/util.pyRXCs	
cGsJt�}x4|D],}|jtt|���|j|�qW|j�S(s5Return a SHA-1 hash over a variable number of inputs.(RR�RqR%R�(R�R�R)((s0/usr/lib/python2.7/site-packages/keyczar/util.pyt
PrefixHashJs
	
cCstjdt�t|�S(Ns4Encode() is deprecated, use Base64WSEncode() instead(twarningstwarntDeprecationWarningRA(RQ((s0/usr/lib/python2.7/site-packages/keyczar/util.pytEncodeSscCstjt|��jdd�S(s-
  Return Base64 web safe encoding of s. Suppress padding characters (=).

  Uses URL-safe alphabet: - replaces +, _ replaces /. Will convert s of type
  unicode to string type first.

  @param s: string to encode as Base64
  @type s: string

  @return: Base64 representation of s.
  @rtype: string
  t=RU(tbase64turlsafe_b64encodeRitreplace(RQ((s0/usr/lib/python2.7/site-packages/keyczar/util.pyRAXs
cCstjdt�t|�S(Ns4Decode() is deprecated, use Base64WSDecode() instead(R�R�R�R/(RQ((s0/usr/lib/python2.7/site-packages/keyczar/util.pytDecodehscCs�dj|j��}t|jdd��}t|�d}|dkrXtj��n2|dkrq|d7}n|dkr�|d7}nytj|�SWnt	k
r�tj��nXd	S(
s�
  Return decoded version of given Base64 string. Ignore whitespace.

  Uses URL-safe alphabet: - replaces +, _ replaces /. Will convert s of type
  unicode to string type first.

  @param s: Base64 string to decode
  @type s: string

  @return: original string that was encoded as Base64
  @rtype: string

  @raise Base64DecodingError: If length of string (ignoring whitespace) is one
    more than a multiple of four.
  RUt iiis==iR�N(
RVt
splitlinesRiR�R%R0tBase64DecodingErrorR�turlsafe_b64decodeR	(RQR((s0/usr/lib/python2.7/site-packages/keyczar/util.pyR/ms


s>iRQcCs*|s
dStjtt|��}||S(s�
  Packs the given array into a structure composed of a four-byte, big-endian
  integer containing the array length, followed by the array contents.
  RU(tstructtpacktBIG_ENDIAN_INT_SPECIFIERR%(tarraytarray_length_header((s0/usr/lib/python2.7/site-packages/keyczar/util.pyt
PackByteArray�scGsHtjtt|��}djg|D]}t|�^q%�}||S(s
  Packs the provided variable number of byte arrays into one array.  The
  returned array is prefixed with a count of the arrays contained, in a
  four-byte big-endian integer, followed by the arrays in sequence, each
  length-prefixed by PackByteArray().
  RU(R�R�R�R%RVR�(tarraystarray_count_headerRwtarray_contents((s0/usr/lib/python2.7/site-packages/keyczar/util.pytPackMultipleByteArrays�s(cCsDtjt|||d!�d}|d7}||||!||fS(s�
  Unpacks a length-prefixed byte array packed by PackByteArray() from 'data',
  starting from position 'offset'.  Returns a tuple of the data array and the
  offset of the first byte after the end of the extracted array.
  ii(R�tunpackR�(tdatatoffsett	array_len((s0/usr/lib/python2.7/site-packages/keyczar/util.pytUnpackByteArray�s!
cCsKd}g}x8|t|�krFt||�\}}|j|�qW|S(s`
  Extracts and returns a list of byte arrays that were packed by
  PackMultipleByteArrays().
  i(R%R�Rj(R�tpositiontresultR�((s0/usr/lib/python2.7/site-packages/keyczar/util.pytUnpackMultipleByteArrays�scCsUy*t|d�}|j|�|j�Wn$tk
rPtjd|��nXdS(s�
  Writes data to file at given location.

  @param data: contents to be written to file
  @type data: string

  @param loc: name of file to write to
  @type loc: string

  @raise KeyczarError: if unable to write to file because of IOError
  twsUnable to write to file %s.N(topentwritetcloseRR0R1(R�tloctf((s0/usr/lib/python2.7/site-packages/keyczar/util.pyt	WriteFile�s

cCs?yt|�j�SWn$tk
r:tjd|��nXdS(s�
  Read data from file at given location.

  @param loc: name of file to read from
  @type loc: string

  @return: contents of the file
  @rtype: string

  @raise KeyczarError: if unable to read from file because of IOError
  sUnable to read file %s.N(R�treadRR0R1(R�((s0/usr/lib/python2.7/site-packages/keyczar/util.pytReadFile�s
cCsy|dtkr"tjd��nd}xFtttj|tt����D]}|t|t	|��7}qNW|| S(sD
  Mask Generation Function (MGF1) with SHA-1 as hash.

  @param seed: used to generate mask, a byte string
  @type seed: string

  @param mlen: desired length of mask
  @type mlen: integer

  @return: mask, byte string of length mlen
  @rtype: string

  @raise KeyczarError: if mask length too long, > 2^32 * hash_length
  ii sMGF1 mask length too long.RUI(
tHLENR0R1R$RtmathtceiltfloatRXRq(tseedtmlentoutputR)((s0/usr/lib/python2.7/site-packages/keyczar/util.pytMGF�s,t"BufferedIncrementalBase64WSEncodercBs,eZdZd�Zed�Zd�ZRS(s�
  Web-safe Base64 encodes an input in multiple steps. Each step bar the final
  one will be sized to ensure no Base64 padding is required. Any unencoded data
  outside this optimal size will be buffered.
  cCs=|sdt|�d}nt|�}t|| �|fS(s 
    Encodes input and returns the resulting object, buffering any data that is
    beyond the optimal no-padding length unless final is True
    Implementation of abstract method in parent.

    @param input: string to encode as Base64
    @type input: string

    @param errors: required error handling scheme (see
    IncrementalBase64WSStreamWriter)

    @param final: force all data to be encoded, possibly resulting in padding
    #type final: boolean

    @return: (Base64 representation of input, length consumed)
    @rtype: tuple
    i(R%RA(RtinputR0tfinaltlen_to_write((s0/usr/lib/python2.7/site-packages/keyczar/util.pyt_buffer_encodescCs;tt|�j|d|�}|t|�t|j�fS(s
    Encodes input and returns the resulting object.
    Note that unless final is True the returned data may not encode all the
    supplied input as it encodes the maximum length that will not result in
    padding. The remaining data is buffered for subsequent calls to encode().

    @param input: string to encode as Base64
    @type input: string

    @param final: force all data to be encoded, possibly resulting in padding
    #type final: boolean

    @return: (Base64 representation of input, length consumed)
    @rtype: tuple
    R�(RR�R?R%tbuffer(RR�R�R�((s0/usr/lib/python2.7/site-packages/keyczar/util.pyR?s	cCs>d}|jr6|j|j|jt�}d|_n|dS(s�
    Flush this encoder, returning any buffered data

    @return: Base64 representation of buffered data
    @rtype: string
    RUi(RUi(R�R�R0tTrue(RR�((s0/usr/lib/python2.7/site-packages/keyczar/util.pytflush/s
	(RRRR�tFalseR?R�(((s0/usr/lib/python2.7/site-packages/keyczar/util.pyR��s	tIncrementalBase64WSStreamWritercBs8eZdZdd�Zd�Zd�Zdd�ZRS(s
  Web-safe Base64 encodes a stream in multiple steps to an output stream. Each
  step bar the final one will be sized to ensure no Base64 padding is required.
  Any unencoded data outside this optimal size will be buffered and output when
  flush() is called.

  tstrictcCs/tt|�j||�td|�|_dS(s� 
    Creates an IncrementalBase64WSStreamWriter instance.

    @param stream: a file-like object open for writing (binary) data.

    @param errors: required error handling scheme

    The reader may use different error handling
    schemes by providing the errors keyword argument. These
    parameters are predefined:

     'strict' - raise a ValueError (or a subclass)
     'ignore' - ignore the character and continue with the next
     'replace'- replace with a suitable replacement character
     'xmlcharrefreplace' - Replace with the appropriate XML
                           character reference.
     'backslashreplace'  - Replace with backslashed escape
                           sequences (only for encoding).

    R0N(RR�RR�R(RtstreamR0((s0/usr/lib/python2.7/site-packages/keyczar/util.pyREscCs!|j�tt|�j�dS(s Flushes and closes the stream N(R�RR�R�(R((s0/usr/lib/python2.7/site-packages/keyczar/util.pyR�]s
cCs9|jj�}|r5|jj|�|jj�ndS(sK
    Flush this stream, writing any buffered data to the output stream
    N(RR�R�R�(RR�((s0/usr/lib/python2.7/site-packages/keyczar/util.pyR�bscCs|jj|�S(s	
    Base64 Encodes input and returns the resulting object.

    @param input: string to encode as Base64
    @type input: string

    @param errors: required error handling scheme (see __init__)

    @return: Base64 representation of input.
    @rtype: string
    (RR?(RR�R0((s0/usr/lib/python2.7/site-packages/keyczar/util.pyR?ks(RRRRR�R�R?(((s0/usr/lib/python2.7/site-packages/keyczar/util.pyR�<s
			t"BufferedIncrementalBase64WSDecodercBs,eZdZd�Zed�Zd�ZRS(s�
  Web-safe Base64 decodes an input in multiple steps. Each step bar the final
  one will be sized to a length so that no Base64 padding is required. Any
  undecoded data outside this optimal size will be buffered.
  cCs=|sdt|�d}nt|�}t|| �|fS(s
    Decodes input and returns the resulting object, buffering any data that is
    beyond the optimal no-padding length unless final is True
    Implementation of abstract method in parent.

    @param input: string to decode from Base64
    @type input: string

    @param errors: required error handling scheme (see
    IncrementalBase64WSStreamReader)

    @param final: force all data to be decoded, possibly resulting in padding
    #type final: boolean

    @return: (plaintext version of input, length consumed)
    @rtype: tuple
    i(R%R/(RR�R0R�tlen_to_read((s0/usr/lib/python2.7/site-packages/keyczar/util.pyt_buffer_decode�scCs.tt|�j|d|�}|t|�fS(s
    Decodes input and returns the resulting object.
    Note that unless final is True the returned data may not decode all the
    supplied input as it uses the maximum length that would not require padding.
    The remaining data is buffered for subsequent calls to decode().

    @param input: string to decode from Base64
    @type input: string

    @param final: force all data to be decoded, possibly resulting in padding
    #type final: boolean

    @return: plaintext representation of input.
    @rtype: string
    R�(RR�R.R%(RR�R�R�((s0/usr/lib/python2.7/site-packages/keyczar/util.pyR.�s	cCs>d}|jr6|j|j|jt�}d|_n|dS(s�
    Flush this decoder, returning any buffered data

    @return: plaintext representation of buffered data
    @rtype: string
    RUi(RUi(R�R�R0R�(RR�((s0/usr/lib/python2.7/site-packages/keyczar/util.pyR��s
	(RRRR�R�R.R�(((s0/usr/lib/python2.7/site-packages/keyczar/util.pyR�ys	tIncrementalBase64WSStreamReadercBs8eZdZdd�Zdded�Zdd�ZRS(s
  Web-safe Base64 decodes a stream in multiple steps. Each step bar the final
  one will be sized to a length so that no Base64 padding is required. Any
  undecoded data outside this optimal size will be buffered and decoded on a
  final call to read().
  R�cCs/tt|�j||�td|�|_dS(s� 
    Creates an IncrementalBase64WSStreamReader instance.

    @param stream: a file-like object open for reading (binary) data.

    @param errors: required error handling scheme

    The reader may use different error handling
    schemes by providing the errors keyword argument. These
    parameters are predefined:

     'strict' - raise a ValueError (or a subclass)
     'ignore' - ignore the character and continue with the next
     'replace'- replace with a suitable replacement character
     'xmlcharrefreplace' - Replace with the appropriate XML
                           character reference.
     'backslashreplace'  - Replace with backslashed escape
                           sequences (only for encoding).

    R0N(RR�RR�R(RR�R0((s0/usr/lib/python2.7/site-packages/keyczar/util.pyR�si����cCsF|jr*dj|j�|_d|_nd}x�tr�|dkr}|dkra|jrzPqzq�t|j�|kr�Pq�nt|j�|kr�Pny4|dkr�|jj�}n|jj|�}Wntk
r�d}nX|dk	r3|j	|}y|j
||j�\}}Wnhtk
r�}|r�|j
||j
 |j�\}}|jt�}	t|	�dkr��q�q��nX|||_	|j|7_|s�Pq�q3q3W|dkr�|j}
d|_n|j| }
|j||_|
r|dkrd}
n|
rB|dkrB|dkrB|jj�}
qBn|
S(s� 
    Decodes data from the input stream and returns the resulting object.

    @param chars: the number of characters to read from the stream. read() will
    never return more than chars characters, but it might return less, if there
    are not enough characters available.
    Will return None if the underlying stream does i.e. is non-blocking and no
    data is available.
    @type chars: integer

    @param size: indicates the approximate maximum number of bytes to read from
    the stream for decoding purposes. The decoder can modify this setting as
    appropriate. The default value -1 indicates to read and decode as much as
    possible.  size is intended to prevent having to decode huge files in one
    step.
    @type size: integer

    @param firstline: if firstline is true, and a UnicodeDecodeError happens
    after the first line terminator in the input only the first line will be
    returned, the rest of the input will be kept until the next call to read().
    @type firstline: boolean

    @return: plaintext representation of input. Returns an empty string when the
    end of the input data has been reached.
    @rtype: string
    RUiiN(t
linebufferRVt
charbuffertNoneR�R%R�R�Rt
bytebufferR.R0tUnicodeDecodeErrortstartR�RR�(RtsizeRlt	firstlinetnewdataR�tnewcharstdecodedbytestexctlinesR�((s0/usr/lib/python2.7/site-packages/keyczar/util.pyR��sZ#			


"	
	
	cCs|jj|�S(s
    Decodes Base64 input and returns the resulting object.

    @param input: string to decode from Base64
    @type input: string

    @param errors: required error handling scheme (see __init__)

    @return: plaintext representation of input.
    @rtype: string
    (RR.(RR�R0((s0/usr/lib/python2.7/site-packages/keyczar/util.pyR.Bs(RRRRR�R�R.(((s0/usr/lib/python2.7/site-packages/keyczar/util.pyR��sfcsRi�tj����fd��}|jrNdj|jdg�|_n|S(s|
  General-purpose memoization decorator.  Handles functions with any number of arguments,
  including keyword arguments.
  csKtj|t|j��f�}|�krC�||��|<n�|S(N(tcPickletdumpstsortedt	iteritems(targstkwargstpickled_args(tfunctmemory(s0/usr/lib/python2.7/site-packages/keyczar/util.pytmemoXs!s
sThis function is memoized.(t	functoolstwrapsRRV(R�R�((R�R�s0/usr/lib/python2.7/site-packages/keyczar/util.pytMemoizeQs
!		cCs�tjj|�r�gtj|�D]}|jd�r"|d ^q"}|tjkritjj|�ng|D]}td|�^qp}ndS(s�
  Simple plugin importer - imports from the specified subdirectory under the
  util.py directory

  @param subdir: the subdirectory to load from
  @type subdir: string
  s.pyi����s%sN(R~tpathtexiststlistdirtendswithtsysRjt
__import__(t
pluginpathtfnametpluginfilestimported_modules((s0/usr/lib/python2.7/site-packages/keyczar/util.pyt	ImportAllescCsttjjtjjt�d�}t|�tjjtd�}|rpx'|j	tj
�D]}t|�qYWndS(s�
  Simple backend plugin importer - imports from the 'backends' subdirectory 
  under the util.py directory and any directories in the environment variable
  'KEYCZAR_BACKEND_PATHS', which can contain >=1 paths joined using the o/s
  tbackendsRUN(R~R�RVtdirnamet__file__R�tenvirontgettBACKEND_PATHS_ENV_VARtsplittpathsep(R�t
xtra_pathsR�((s0/usr/lib/python2.7/site-packages/keyczar/util.pytImportBackendsts!
(XRR�R�tcodecsR�R�R~R�R�R�thashlibRtImportErrorRtioRRtpyasn1.codec.derRRtpyasn1.typeRR0tabcRRRttypetdigest_sizeR�tObjectIdentifierR2R3R4R5tSHA1RSA_OIDtSHA1_OIDtDEFAULT_STREAM_BUFF_SIZER�R*R,R<RCRDRJRNRORRRTR_RFRKR`RcRmRqRtRyRvR}R�RXR�R�RAR�R/R�tSTRING_SPECIFIERR�R�R�R�R�R�R�tBufferedIncrementalEncoderR�tStreamWritertobjectR�tBufferedIncrementalDecoderR�tStreamReaderR�R�R�R�(((s0/usr/lib/python2.7/site-packages/keyczar/util.pyt<module>s�


 
	
						
			
												
										 	
		
				D=B�