a ‚oeA'ã@s$dZddlZddlZddlZddlmZmZddlmZddl m Z m Z m Z m Z mZmZmZmZddlmZmZddlmZe edœd d „ZGd d „d ƒZGd d„dƒZGdd„deƒZGdd„deƒZeddd�ZGdd„deeƒZGdd„deeƒZGdd„dƒZ eee ej!e"ƒƒej!e"<dS)zJOSE utilities.éN)ÚHashableÚMapping)Ú ModuleType)ÚAnyÚCallableÚIteratorÚListÚTupleÚTypeVarÚUnionÚcast)ÚecÚrsa)Úcrypto)ÚfuncÚreturncCstt |¡ƒS©N)Ú classmethodÚabcÚabstractmethod)r©rú,C:\Program Files\Certbot\pkgs\josepy\util.pyÚabstractclassmethodsrc@s~eZdZdZeejejfddœdd„Ze e dœdd„Z ej fe ed œd d „Ze ed œd d„Ze dœdd„Ze dœdd„ZdS)ÚComparableX509zËWrapper for OpenSSL.crypto.X509** objects that supports __eq__. :ivar wrapped: Wrapped certificate or certificate request. :type wrapped: `OpenSSL.crypto.X509` or `OpenSSL.crypto.X509Req`. N)ÚwrappedrcCs&t|tjƒst|tjƒsJ‚||_dSr)Ú isinstancerÚX509ÚX509Reqr©ÚselfrrrrÚ__init__szComparableX509.__init__©ÚnamercCs t|j|ƒSr)Úgetattrr©rr"rrrÚ __getattr__szComparableX509.__getattr__)ÚfiletypercCs*t|jtjƒrt ||j¡St ||j¡S)aNDumps the object into a buffer with the specified encoding. :param int filetype: The desired encoding. Should be one of `OpenSSL.crypto.FILETYPE_ASN1`, `OpenSSL.crypto.FILETYPE_PEM`, or `OpenSSL.crypto.FILETYPE_TEXT`. :returns: Encoded X509 object. :rtype: bytes )rrrrZdump_certificateZdump_certificate_request)rr&rrrÚ_dump!s zComparableX509._dump©ÚotherrcCs t||jƒstS| ¡| ¡kSr)rÚ __class__ÚNotImplementedr'©rr)rrrÚ__eq__3s zComparableX509.__eq__©rcCst|j| ¡fƒSr)Úhashr*r'©rrrrÚ__hash__8szComparableX509.__hash__cCsd |jj|j¡S©Nz <{0}({1!r})>)Úformatr*Ú__name__rr0rrrÚ__repr__;szComparableX509.__repr__)r4Ú __module__Ú __qualname__Ú__doc__r rrrr Ústrrr%Z FILETYPE_ASN1ÚintÚbytesr'Úboolr-r1r5rrrrrsrc@s„eZdZUdZeZegefed<e e j e j e je jfdœdd„Zeedœdd„Zeed œd d „Zed œd d„Zdd œdd„ZdS)Ú ComparableKeyznComparable wrapper for ``cryptography`` keys. See https://github.com/pyca/cryptography/issues/2122. r1)rcCs ||_dSr)Ú_wrappedrrrrr Hs zComparableKey.__init__r!cCs t|j|ƒSr)r#r>r$rrrr%SszComparableKey.__getattr__r(cCs`t||jƒr|jj|jjur tSt|jdƒr<| ¡| ¡kSt|jdƒrX| ¡| ¡kStSdS)NÚprivate_numbersÚpublic_numbers)rr*r>r+Úhasattrr?r@r,rrrr-Vs ÿþ  zComparableKey.__eq__r.cCsd |jj|j¡Sr2)r3r*r4r>r0rrrr5cszComparableKey.__repr__cCs(t|jtjtjfƒr|S| |j ¡¡S)zGet wrapped public key.)rr>rÚRSAPublicKeyWithSerializationr Ú'EllipticCurvePublicKeyWithSerializationr*Ú public_keyr0rrrrDfs  þzComparableKey.public_keyN)r4r6r7r8r+r1rr:Ú__annotations__r rÚRSAPrivateKeyWithSerializationrBr Ú(EllipticCurvePrivateKeyWithSerializationrCr r9rr%r<r-r5rDrrrrr=?s ýÿþ  r=c@seZdZdZedœdd„ZdS)ÚComparableRSAKeyz×Wrapper for ``cryptography`` RSA keys. Wraps around: - :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey` - :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` r.c Csxt|jtjƒrD| ¡}|j}t|j|j|j |j |j |j |j |jfƒSt|jtjƒrn| ¡}t|j|j |jfƒStƒ‚dSr)rr>rrFr?r@r/r*ÚpÚqZdmp1Zdmq1ZiqmpÚnÚerBÚNotImplementedError©rZprivZpubrrrr1{s"ÿzComparableRSAKey.__hash__N©r4r6r7r8r:r1rrrrrHqs rHc@seZdZdZedœdd„ZdS)ÚComparableECKeyzåWrapper for ``cryptography`` EC keys. Wraps around: - :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey` - :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey` r.cCstt|jtjƒr:| ¡}|j}t|j|jj |j |j |j fƒSt|jtj ƒrj| ¡}t|j|jj |j |j fƒStƒ‚dSr)rr>r rGr?r@r/r*Zcurver"ÚxÚyZ private_valuerCrMrNrrrr1’szComparableECKey.__hash__NrOrrrrrP‹srPÚGenericImmutableMapÚ ImmutableMap)Úboundc@s¦eZdZUdZdZeedfed<eddœdd„Z e ee d œd d „Z eed œd d„Z e edœdd„Zedœdd„Zedœdd„Zeeddœdd„Zedœdd„ZdS)rTz5Immutable key to value mapping with attribute access.r.Ú __slots__N)ÚkwargsrcKs\t|ƒt|jƒkr8td d |j¡|r0d |¡nd¡ƒ‚|jD]}t ||| |¡¡q>dS)NzA__init__() takes exactly the following arguments: {0} ({1} given)ú, Znone)ÚsetrVÚ TypeErrorr3ÚjoinÚobjectÚ __setattr__Úpop)rrWÚslotrrrr ©sþÿ zImmutableMap.__init__)rrWrcKsi|¥|¥}t|ƒfi|¤ŽS)zReturn updated map.)Útype)rrWÚitemsrrrÚupdate´s zImmutableMap.update©ÚkeyrcCs,z t||ƒWSty&t|ƒ‚Yn0dSr)r#ÚAttributeErrorÚKeyError©rrdrrrÚ __getitem__¹s  zImmutableMap.__getitem__r.cCs t|jƒSr)ÚiterrVr0rrrÚ__iter__¿szImmutableMap.__iter__cCs t|jƒSr)ÚlenrVr0rrrÚ__len__ÂszImmutableMap.__len__cstt‡fdd„ˆjDƒƒƒS)Nc3s|]}tˆ|ƒVqdSr)r#)Ú.0r_r0rrÚ Æóz(ImmutableMap.__hash__..)r/ÚtuplerVr0rr0rr1ÅszImmutableMap.__hash__©r"ÚvaluercCs tdƒ‚dS©Nzcan't set attribute©re©rr"rrrrrr]ÈszImmutableMap.__setattr__cCs$d |jjd dd„| ¡Dƒ¡¡S)Nz{0}({1})rXcss|]\}}d ||¡VqdS©z {0}={1!r}N©r3©rmrdrrrrrrnÎroz(ImmutableMap.__repr__..)r3r*r4r[rar0rrrr5ËsþzImmutableMap.__repr__)r4r6r7r8rVr r9rErr rSrbrhrrjr:rlr1r]r5rrrrrT£s  c@s²eZdZdZdZeeddœdd„Zeedœdd „Ze ed œd d „Z e d œd d„Z e e eefdfd œdd„Ze d œdd„Zeedœdd„Zeeddœdd„Zed œdd„ZdS)Ú frozendictzFrozen dictionary.)Ú_itemsÚ_keysN)ÚargsrWrcOsh|r|st|ƒ}n*t|ƒdkr6t|dtƒr6|d}ntƒ‚t |d|¡t |dtt|  ¡ƒƒ¡dS)Nérrzr{) ÚdictrkrrrZr\r]rpÚsortedÚkeys)rr|rWrarrrr ×s  zfrozendict.__init__rccCs |j|Sr)rzrgrrrrhäszfrozendict.__getitem__r.cCs t|jƒSr)rir{r0rrrrjçszfrozendict.__iter__cCs t|jƒSr)rkrzr0rrrrlêszfrozendict.__len__.cst‡fdd„ˆjDƒƒS)Nc3s|]}|ˆ|fVqdSrr)rmrdr0rrrnîroz+frozendict._sorted_items..)rpr{r0rr0rÚ _sorted_itemsíszfrozendict._sorted_itemscCs t| ¡ƒSr)r/r�r0rrrr1ðszfrozendict.__hash__r!cCs,z |j|WSty&t|ƒ‚Yn0dSr)rzrfrer$rrrr%ós  zfrozendict.__getattr__rqcCs tdƒ‚dSrsrtrurrrr]ùszfrozendict.__setattr__cCsd d dd„| ¡Dƒ¡¡S)Nzfrozendict({0})rXcss|]\}}d ||¡VqdSrvrwrxrrrrnþroz&frozendict.__repr__..)r3r[r�r0rrrr5üsÿzfrozendict.__repr__)r4r6r7r8rVrr r9rhrrjr:rlr r�r1r%r]r5rrrrryÒs ryc@sdeZdZdZeddœdd„Zeedœdd„Zeedd œd d „Z eddœd d „Z e edœdd„Z dS)Ú_UtilDeprecationModulez² Internal class delegating to a module, and displaying warnings when attributes related to the deprecated "abstractclassmethod" attributes in the josepy.util module. N)ÚmodulercCs||jd<dS©NÚ_module)Ú__dict__)rrƒrrrr sz_UtilDeprecationModule.__init__)ÚattrrcCs$|dkrtjdtdd�t|j|ƒS)Nrz²The abstractclassmethod attribute in josepy.util is deprecated and will be removed soon. Please use the built-in decorators @classmethod and @abc.abstractmethod together instead.é)Ú stacklevel)ÚwarningsÚwarnÚDeprecationWarningr#r…©rr‡rrrr%sûz"_UtilDeprecationModule.__getattr__)r‡rrrcCst|j||ƒdSr)Úsetattrr…)rr‡rrrrrr]sz"_UtilDeprecationModule.__setattr__cCst|j|ƒdSr)Údelattrr…r�rrrÚ __delattr__sz"_UtilDeprecationModule.__delattr__r.cCsdgt|jƒSr„)Údirr…r0rrrÚ__dir__sz_UtilDeprecationModule.__dir__) r4r6r7r8rr r9rr%r]r�rr’rrrrr‚s  r‚)#r8rÚsysrŠÚcollections.abcrrÚtypesrÚtypingrrrrr r r r Z)cryptography.hazmat.primitives.asymmetricr rZOpenSSLrrrrr=rHrPrSrTryr‚Úmodulesr4rrrrÚs$ ( -2 /3