ó ö 5Xc@sdZddlmZmZddlmZddlZddlZeje ƒZ ddl m Z m Z ddlmZmZmZmZmZddlmZddljjZdd gZdd d „Zd Zdejejfd„ƒYZdej ej!fd„ƒYZ"dS(s3passlib.handlers.oracle - Oracle DB Password Hashesiÿÿÿÿ(thexlifyt unhexlify(tsha1N(t to_unicodet xor_bytes(tirangetut uascii_to_strtunicodet str_to_uascii(tdes_encrypt_blockt oracle10gt oracle11gticCso||t|ƒ d7}|}xItdt|ƒdƒD]/}t||||d!ƒ}t||ƒ}q8W|S(séperforms des-cbc encryption, returns only last block. this performs a specific DES-CBC encryption implementation as needed by the Oracle10 hash. it probably won't be useful for other purposes as-is. input value is null-padded to multiple of 8 bytes. :arg key: des key as bytes :arg value: value to encrypt, as bytes. :param iv: optional IV :param pad: optional pad byte :returns: last block of DES-CBC encryption of all ``value``'s byte blocks. ii(tlenRRR (tkeytvaluetivtpadthashtoffsettchunk((s;/usr/lib/python2.7/site-packages/passlib/handlers/oracle.pytdes_cbc_encrypts s#Eg‰«Íïtoracle10cBs;eZdZdZejZdZed„ƒZ d„Z RS(sûThis class implements the password hash used by Oracle up to version 10g, and follows the :ref:`password-hash-api`. It does a single round of hashing, and relies on the username as the salt. The :meth:`~passlib.ifc.PasswordHash.hash`, :meth:`~passlib.ifc.PasswordHash.genhash`, and :meth:`~passlib.ifc.PasswordHash.verify` methods all require the following additional contextual keywords: :type user: str :param user: name of oracle user account this password is associated with. RicCs |jƒS(N(tupper(tclsR((s;/usr/lib/python2.7/site-packages/passlib/handlers/oracle.pyt _norm_hashIscCs‰t|tƒr!|jdƒ}nt|jdddƒ}||jƒjdƒ}tt|ƒ}t||ƒ}t |ƒjdƒjƒS(Nsutf-8tparamtusers utf-16-betascii( t isinstancetbytestdecodeRRRtencodeRtORACLE10_MAGICR(tselftsecretRtinputR((s;/usr/lib/python2.7/site-packages/passlib/handlers/oracle.pyt_calc_checksumMs ( t__name__t __module__t__doc__tnametuht HEX_CHARStchecksum_charst checksum_sizet classmethodRR&(((s;/usr/lib/python2.7/site-packages/passlib/handlers/oracle.pyR4s   toracle11cBsxeZdZdZd ZdZejZdZ Z ejZ e j edƒe jƒZed„ƒZd„Zd„ZRS( sEThis class implements the Oracle11g password hash, and follows the :ref:`password-hash-api`. It supports a fixed-length salt. The :meth:`~passlib.ifc.PasswordHash.using` method accepts the following optional keywords: :type salt: str :param salt: Optional salt string. If not specified, one will be autogenerated (this is recommended). If specified, it must be 20 hexadecimal characters. :type relaxed: bool :param relaxed: By default, providing an invalid value for one of the other keywords will result in a :exc:`ValueError`. If ``relaxed=True``, and the error can be corrected, a :exc:`~passlib.exc.PasslibHashWarning` will be issued instead. Correctable errors include ``salt`` strings that are too long. .. versionadded:: 1.6 R0tsalti(is/^S:(?P[0-9a-f]{40})(?P[0-9a-f]{20})$cCspt|ddƒ}|jj|ƒ}|s?tjj|ƒ‚n|jddƒ\}}|d|d|jƒƒS(NRRR1tchktchecksum(Rt _hash_regextmatchR+texctInvalidHashErrortgroupR(RRtmR1R2((s;/usr/lib/python2.7/site-packages/passlib/handlers/oracle.pyt from_string’s cCs8|j}tdƒ|jƒ|jjƒf}t|ƒS(NsS:%s%s(R3RRR1R(R#R2R((s;/usr/lib/python2.7/site-packages/passlib/handlers/oracle.pyt to_string›s %cCsYt|tƒr!|jdƒ}nt|t|jjdƒƒƒjƒ}t|ƒjƒS(Nsutf-8R( RRR!RRR1t hexdigestR R(R#R$R2((s;/usr/lib/python2.7/site-packages/passlib/handlers/oracle.pyR& s((ssalt(R'R(R)R*t setting_kwdsR.R+tUPPER_HEX_CHARSR-t min_salt_sizet max_salt_sizet salt_charstretcompileRtIR4R/R:R;R&(((s;/usr/lib/python2.7/site-packages/passlib/handlers/oracle.pyR0hs    t(#R)tbinasciiRRthashlibRRBtloggingt getLoggerR'tlogt passlib.utilsRRtpasslib.utils.compatRRRRR tpasslib.crypto.desR tpasslib.utils.handlerstutilsthandlersR+t__all__RR"tHasUserContextt StaticHandlerRtHasSalttGenericHandlerR0(((s;/usr/lib/python2.7/site-packages/passlib/handlers/oracle.pyts  ( 4