File: //opt/alt/python27/lib/python2.7/site-packages/beaker/crypto/jcecrypto.pyc
�
7Y�Kc           @   sl   d  Z  d d l m Z d d l m Z m Z d d l Z e e j d d � � Z d �  Z	 e	 Z
 d �  Z d S(	   s�  
Encryption module that uses the Java Cryptography Extensions (JCE).
Note that in default installations of the Java Runtime Environment, the
maximum key length is limited to 128 bits due to US export
restrictions. This makes the generated keys incompatible with the ones
generated by pycryptopp, which has no such restrictions. To fix this,
download the "Unlimited Strength Jurisdiction Policy Files" from Sun,
which will allow encryption using 256 bit AES keys.
i����(   t   Cipher(   t
   SecretKeySpect   IvParameterSpecNi   t   bc         C   sG   t  j d � } t | d � } | j t  j | t � | j |  � j �  S(   Ns   AES/CTR/NoPaddingt   AES(   R    t   getInstanceR   t   initt   ENCRYPT_MODEt   _ivt   doFinalt   tostring(   t   datat   keyt   ciphert   skeySpec(    (    sH   /opt/alt/python27/lib/python2.7/site-packages/beaker/crypto/jcecrypto.pyt
   aesEncrypt   s    c          C   s    t  j d � }  t |  d � d S(   Ns   AES/CTR/NoPaddingi   i   (   R    t   getMaxAllowedKeyLengtht   min(   t   maxlen(    (    sH   /opt/alt/python27/lib/python2.7/site-packages/beaker/crypto/jcecrypto.pyt   getKeyLength   s    (   t   __doc__t   javax.cryptoR    t   javax.crypto.specR   R   t   jarrayt   zerosR   R   t
   aesDecryptR   (    (    (    sH   /opt/alt/python27/lib/python2.7/site-packages/beaker/crypto/jcecrypto.pyt   <module>
   s