관리-도구
편집 파일: ECC.cpython-311.pyc
� O�Dg�� � � � d dl mZ d dlZd dlZd dlZd dlmZ d dlmZm Z m Z mZmZ d dl mZmZ d dlmZ d dlmZmZmZmZ d dlmZmZmZmZmZmZmZ d d lm Z m!Z!m"Z" d d l#m$Z$m%Z% d dl&m'Z' d dl(m)Z) ed d� � Z* edd� � Z+ edd� � Z,d� Z- edd� � Z.i Z/g d�a0d� Z1 e1� � [1g d�a2d� Z3 e3� � [3g d�a4d� Z5 e5� � [5g d�a6d� Z7 e7� � [7g d�a8d� Z9 e9� � [9d d!ga:d"� Z; e;� � [;d#d$ga<d%� Z= e=� � [= G d&� d'e>� � Z? G d(� d)e@� � ZA eAe/d* jB e/d* jC d*� � ZDe/d* �E eD�+� � ZFe/�G eH�I t` eF� � � � [D[Fb0 eAe/d, jB e/d, jC d,� � ZJe/d, �E eJ�+� � ZKe/�G eH�I td eK� � � � [J[Kb2 eAe/d- jB e/d- jC d-� � ZLe/d- �E eL�+� � ZMe/�G eH�I th eM� � � � [L[Mb4 eAe/d. jB e/d. jC d.� � ZNe/d. �E eN�+� � ZOe/�G eH�I tl eO� � � � [N[Ob6 eAe/d/ jB e/d/ jC d/� � ZPe/d/ �E eP�+� � ZQe/�G eH�I tp eQ� � � � [P[Qb8 eAe/d! jB e/d! jC d!� � ZRe/d! �E eR�+� � ZSe/�G eH�I tt eS� � � � [R[Sb: eAe/d$ jB e/d$ jC d$� � ZTe/d$ �E eT�+� � ZUe/�G eH�I tx eU� � � � [T[Ub< G d0� d1e@� � ZVd2� ZWd3� ZXdFd4�ZYd5� ZZdGd6�Z[d7� Z\d8� Z]d9� Z^d:� Z_d;� Z`d<� Zad=� ZbdFd>�Zcedd?k r�d dleZed@Zfe/d- jg �h � � ZidAZj eeje � � Zk elej� � D ]Zmeiefz Zn� eodB eeje � � ekz ejz dCz dD� � eeje � � Zk elej� � D ]Zmenefz Zn� eodE eeje � � ekz ejz dCz dD� � dS dS )H� )�print_functionN)� namedtuple)�bord�tobytes�tostr�bchr� is_string)� bytes_to_long� long_to_bytes)�Integer)�DerObjectId�DerOctetString�DerSequence�DerBitString)�load_pycryptodome_raw_lib�VoidPointer�SmartPointer�c_size_t�c_uint8_ptr�c_ulonglong�null_pointer)�_expand_subject_public_key_info�_create_subject_public_key_info� _extract_subject_public_key_info)�SHA512�SHAKE256)�get_random_bytes)�getrandbitszCrypto.PublicKey._ec_wsa typedef void EcContext; typedef void EcPoint; int ec_ws_new_context(EcContext **pec_ctx, const uint8_t *modulus, const uint8_t *b, const uint8_t *order, size_t len, uint64_t seed); void ec_free_context(EcContext *ec_ctx); int ec_ws_new_point(EcPoint **pecp, const uint8_t *x, const uint8_t *y, size_t len, const EcContext *ec_ctx); void ec_ws_free_point(EcPoint *ecp); int ec_ws_get_xy(uint8_t *x, uint8_t *y, size_t len, const EcPoint *ecp); int ec_ws_double(EcPoint *p); int ec_ws_add(EcPoint *ecpa, EcPoint *ecpb); int ec_ws_scalar(EcPoint *ecp, const uint8_t *k, size_t len, uint64_t seed); int ec_ws_clone(EcPoint **pecp2, const EcPoint *ecp); int ec_ws_cmp(const EcPoint *ecp1, const EcPoint *ecp2); int ec_ws_neg(EcPoint *p); zCrypto.PublicKey._ed25519ai typedef void Point; int ed25519_new_point(Point **out, const uint8_t x[32], const uint8_t y[32], size_t modsize, const void *context); int ed25519_clone(Point **P, const Point *Q); void ed25519_free_point(Point *p); int ed25519_cmp(const Point *p1, const Point *p2); int ed25519_neg(Point *p); int ed25519_get_xy(uint8_t *xb, uint8_t *yb, size_t modsize, Point *p); int ed25519_double(Point *p); int ed25519_add(Point *P1, const Point *P2); int ed25519_scalar(Point *P, const uint8_t *scalar, size_t scalar_len, uint64_t seed); zCrypto.PublicKey._ed448a* typedef void EcContext; typedef void PointEd448; int ed448_new_context(EcContext **pec_ctx); void ed448_context(EcContext *ec_ctx); void ed448_free_context(EcContext *ec_ctx); int ed448_new_point(PointEd448 **out, const uint8_t x[56], const uint8_t y[56], size_t len, const EcContext *context); int ed448_clone(PointEd448 **P, const PointEd448 *Q); void ed448_free_point(PointEd448 *p); int ed448_cmp(const PointEd448 *p1, const PointEd448 *p2); int ed448_neg(PointEd448 *p); int ed448_get_xy(uint8_t *xb, uint8_t *yb, size_t len, const PointEd448 *p); int ed448_double(PointEd448 *p); int ed448_add(PointEd448 *P1, const PointEd448 *P2); int ed448_scalar(PointEd448 *P, const uint8_t *scalar, size_t scalar_len, uint64_t seed); c �� � | j j dk rt t d|z � � }nA| j j dk rt t d|z � � }nt t d|z � � }|S )N�Ed25519�ed25519_�Ed448�ed448_�ec_ws_)�_curve�desc�getattr�_ed25519_lib� _ed448_lib�_ec_lib)�ecc_obj� func_name�results �v/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/PublicKey/ECC.py�lib_funcr/ � sg � ��~��i�'�'���z�I�'=�>�>��� �� �� '� '���X� �%9�:�:�����(�Y�"6�7�7���M� �_Curvez<p b order Gx Gy G modulus_bits oid context desc openssh name)�p192� NIST P-192zP-192� prime192v1� secp192r1�nistp192c �T � d} d}d}d}d}t | d� � }t |d� � }t |d� � }t � � }t � |� � � t |� � t |� � t |� � t t |� � � � t t d� � � � � � } | rt d| z � � �t |� � � t j � � } t t | � � t |� � t |� � t |� � t |� � d d d | ddd � � }t � t$ � t( |� � � � d S )Nl �������������l �9��{�u��D�j�Sg9�g(Bl 1(�i�&^#a�;�������l ��+�' 1t�:�_|v!a�:@m�l H�<�^�W]�dZ{cx��W\Iq � �@ z#Error %d initializing P-192 context� z1.2.840.10045.3.1.1r3 zecdsa-sha2-nistp192r2 )r r r* �ec_ws_new_context� address_ofr r �lenr r �ImportErrorr �get�ec_free_contextr1 r �_curves�update�dict�fromkeys� p192_names)�p�b�order�Gx�Gy�p192_modulus�p192_b� p192_order�ec_p192_contextr- �contextr2 s r. � init_p192rP � sn � �:�A�:�A�>�E� ;�B� ;�B� ��B�'�'�L� �1�b� !� !�F��u�b�)�)�J�!�m�m�O� � &� &��'A�'A�'C�'C�'2�<�'@�'@�'2�6�':�':�'2�:�'>�'>�'/��L�0A�0A�'B�'B�'2�;�r�?�?�'C�'C�)� )�F� � J��?�&�H�I�I�I��?�.�.�0�0�'�2I�J�J�G��'�!�*�*��!�*�*��%�.�.��"�+�+��"�+�+���'���'��� �D� �N�N�4�=�=��T�2�2�3�3�3�3�3r0 )�p224� NIST P-224zP-224� prime224v1� secp224r1�nistp224c �T � d} d}d}d}d}t | d� � }t |d� � }t |d� � }t � � }t � |� � � t |� � t |� � t |� � t t |� � � � t t d� � � � � � } | rt d| z � � �t |� � � t j � � } t t | � � t |� � t |� � t |� � t |� � d d d | ddd � � }t � t$ � t( |� � � � d S )Nl ���������?l ��FeY8��w�-X"PVd�/�%�PP!-l =*�8%���(��������?l !�"X�!#BX�t�J9!'�|�%�V�A�-l 4~ f�&Dv�@h�!�f�E0m9_qlM/� r9 z#Error %d initializing P-224 context�� z1.3.132.0.33rR zecdsa-sha2-nistp224rQ )r r r* r; r<