%PDF- %PDF-
| Direktori : /lib/python3.9/site-packages/passlib/handlers/__pycache__/ |
| Current File : //lib/python3.9/site-packages/passlib/handlers/__pycache__/oracle.cpython-39.opt-1.pyc |
a
f�Wc# � @ s� d Z ddlmZmZ ddlmZ ddlZddlZe�e �Z
ddlmZm
Z
ddlmZmZmZmZmZ ddlmZ ddlm mZ dd gZddd
�ZdZG dd� dejej�ZG dd� dej ej!�Z"dS )z3passlib.handlers.oracle - Oracle DB Password Hashes� )�hexlify� unhexlify)�sha1N)�
to_unicode� xor_bytes)�irange�u�
uascii_to_str�unicode�
str_to_uascii)�des_encrypt_blockZ oracle10gZ oracle11g� � c C sT ||t |� d 7 }|}tdt |�d�D ]$}t||||d � �}t| |�}q*|S )a� 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.
� r )�lenr r r )�key�valueZivZpad�hash�offset�chunk� r �;/usr/lib/python3.9/site-packages/passlib/handlers/oracle.py�des_cbc_encrypt s r s #Eg����c @ s2 e Zd ZdZd ZejZdZe dd� �Z
dd� ZdS )�oracle10a� 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.
� c C s |� � S )N)�upper)�clsr r r r �
_norm_hashI s zoracle10._norm_hashc C s\ t |t�r|�d�}t| jddd�}|| �� �d�}tt|�}t||�}t |��d��� S )N�utf-8�user)Zparamz utf-16-be�ascii)
�
isinstance�bytes�decoder r r �encoder �ORACLE10_MAGICr )�self�secretr �inputr r r r �_calc_checksumM s
zoracle10._calc_checksumN)�__name__�
__module__�__qualname__�__doc__�name�uhZ HEX_CHARS�checksum_chars�
checksum_size�classmethodr r) r r r r r 4 s
r c @ s^ e Zd ZdZd ZdZdZejZ d Z
ZejZe
�ed�e
j�Zedd� �Zdd � Zd
d� ZdS )
�oracle11aE This 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
)�salt�( � z/^S:(?P<chk>[0-9a-f]{40})(?P<salt>[0-9a-f]{20})$c C sH t |dd�}| j�|�}|s(tj�| ��|�dd�\}}| ||�� d�S )Nr r r4 �chk)r4 �checksum)r �_hash_regex�matchr/ �excZInvalidHashError�groupr )r r �mr4 r7 r r r �from_string� s zoracle11.from_stringc C s( | j }td�|�� | j�� f }t|�S )NzS:%s%s)r8 r r r4 r )r&