eA'dZddlZddlZddlZddlmZmZddlmZddl m Z m Z m Z m Z mZmZmZmZddlmZmZddlmZde d efd ZGd d ZGd dZGddeZGddeZeddZGddeeZGddeeZGddZ eee ejBe"ejBe"<y)zJOSE utilities.N)HashableMapping) ModuleType)AnyCallableIteratorListTupleTypeVarUnioncast)ecrsa)cryptofuncreturnc>ttj|SN) classmethodabcabstractmethod)rs -/usr/lib/python3/dist-packages/josepy/util.pyabstractclassmethodrs s))$/ 00ceZdZdZdeej ejfddfdZde de fdZ ejfde defd Zd e defd Zde fd Zde fd Zy)ComparableX509zWrapper for OpenSSL.crypto.X509** objects that supports __eq__. :ivar wrapped: Wrapped certificate or certificate request. :type wrapped: `OpenSSL.crypto.X509` or `OpenSSL.crypto.X509Req`. wrappedrNc~t|tjst|tjsJ||_yr) isinstancerX509X509Reqrselfrs r__init__zComparableX509.__init__s*'6;;/:gv~~3VVV rnamec.t|j|Sr)getattrrr#r%s r __getattr__zComparableX509.__getattr__st||T**rfiletypect|jtjr tj||jStj ||jS)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 )rrrr dump_certificatedump_certificate_request)r#r*s r_dumpzComparableX509._dump!sF dllFKK 0**8T\\B B..xFFrotherc|t||jstS|j|jk(Sr)r __class__NotImplementedr.r#r/s r__eq__zComparableX509.__eq__3s-%0! !zz|u{{},,rcLt|j|jfSr)hashr1r.r#s r__hash__zComparableX509.__hash__8sT^^TZZ\233rcbdj|jj|jSNz <{0}({1!r})>)formatr1__name__rr7s r__repr__zComparableX509.__repr__;s#$$T^^%<%>&A Bt+++%+$8$8GcGUG$-C-D- 4#4L#LrrceZdZUdZeZegefed<de e je je je jffdZdedefdZdedefd Zdefd Zd d Zy ) ComparableKeyznComparable wrapper for ``cryptography`` keys. See https://github.com/pyca/cryptography/issues/2122. r8rc||_yr)_wrappedr"s rr$zComparableKey.__init__Hs   rr%rc.t|j|Sr)r'rJr(s rr)zComparableKey.__getattr__Sst}}d++rr/czt||jr,|jj|jjurtSt |jdr!|j |j k(St |jdr!|j |j k(StS)Nprivate_numberspublic_numbers)rr1rJr2hasattrrMrNr3s rr4zComparableKey.__eq__Vs5$..1}}&&enn.F.FF! ! T]]$5 6'')U-B-B-DD D T]]$4 5&&(E,@,@,BB B! !rcbdj|jj|jSr:)r;r1r<rJr7s rr=zComparableKey.__repr__cs#$$T^^%<%r?r@r2r8rrC__annotations__r rRSAPrivateKeyWithSerializationrRr(EllipticCurvePrivateKeyWithSerializationrSr$rArr)rEr4r=rTrFrrrHrH?s #1Hhr3w0    . .  - -  7 7  6 6 8   ,,, "C "D "M#M:rrHceZdZdZdefdZy)ComparableRSAKeyzWrapper for ``cryptography`` RSA keys. Wraps around: - :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey` - :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` rc t|jtjr|j }|j }t |j|j|j|j|j|j|j|jfSt|jtjr<|j }t |j|j|jfSt!r)rrJrrVrMrNr6r1pqdmp1dmq1iqmpnerRNotImplementedErrorr#privpubs rr8zComparableRSAKey.__hash__{s dmmS%G%G H'')D%%CDIItyyRURWRWY\Y^Y^_  s'H'H I%%'C67 7!##rNr<r>r?r@rCr8rFrrrYrYqs $# $rrYceZdZdZdefdZy)ComparableECKeyzWrapper for ``cryptography`` EC keys. Wraps around: - :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey` - :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey` rct|jtjrh|j }|j }t |j|jj|j|j|jfSt|jtjrQ|j }t |j|jj|j|jfStr)rrJrrWrMrNr6r1curver%xy private_valuerSrbrcs rr8zComparableECKey.__hash__s dmmR%P%P Q'')D%%CtGYGYZ[ [  r'Q'Q R%%'CFG G!##rNrfrFrrrhrhs $# $rrhGenericImmutableMap ImmutableMap)boundceZdZUdZdZeedfed< deddfdZ d e dede fd Z d edefd Z de efd ZdefdZdefdZdededdfdZdefdZy)roz5Immutable key to value mapping with attribute access.rF. __slots__kwargsrNc Rt|t|jk7rOtdjdj |j|rdj |d|jD](}t j |||j|*y)NzA__init__() takes exactly the following arguments: {0} ({1} given), none)setrr TypeErrorr;joinobject __setattr__pop)r#rsslots rr$zImmutableMap.__init__s v;#dnn- -$fIIdnn-Ftyy/@ QW  NN =D   tT6::d+; < =rr#c 0i||}t|di|S)zReturn updated map.rF)type)r#rsitemss rupdatezImmutableMap.updates%#5d#5f#5tDz"E""rkeycL t||S#t$r t|wxYwr)r'AttributeErrorKeyErrorr#rs r __getitem__zImmutableMap.__getitem__s- 4% % 3-  s #c,t|jSr)iterrrr7s r__iter__zImmutableMap.__iter__sDNN##rc,t|jSr)lenrrr7s r__len__zImmutableMap.__len__s4>>""rcRttfdjDS)Nc36K|]}t|ywr)r').0r}r#s r z(ImmutableMap.__hash__..sI$'$-Is)r6tuplerrr7s`rr8zImmutableMap.__hash__sEI$..IIJJrr%valuectdNzcan't set attributerr#r%rs rr{zImmutableMap.__setattr__233rcdj|jjdjd|j DS)Nz{0}({1})ruc3FK|]\}}dj||ywz {0}={1!r}Nr;rrrs rrz(ImmutableMap.__repr__..s!Tek((e4T!)r;r1r<ryrr7s rr=zImmutableMap.__repr__s:  NN # # IITtzz|T T  r)r<r>r?r@rrr rArUrr$rnrrrrrCrr8r{r=rFrrroros?!#IuS#X#+ = = =#(#C#.s<#c49%.s!\ek((e4\r)r;ryrr7s rr=zfrozendict.__repr__s0 '' II\tGYGYG[\ \  r)r<r>r?r@rrrr$rArrrrCrr rr8r)r{r=rFrrrrs#I Gc GS GT G s s  (3-   =uU38_c%9:=*#*''' 44C4D4 # rrcfeZdZdZdeddfdZdedefdZdededdfd Z deddfd Z de efd Z y) _UtilDeprecationModulez Internal class delegating to a module, and displaying warnings when attributes related to the deprecated "abstractclassmethod" attributes in the josepy.util module. modulerNc"||jd<yN_module)__dict__)r#rs rr$z_UtilDeprecationModule.__init__ s#) i rattrcp|dk(rtjdtdt|j|S)NrzThe 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)warningswarnDeprecationWarningr'rr#rs rr)z"_UtilDeprecationModule.__getattr__s7 ( ( MM8#  t||T**rrc2t|j||yr)setattrr)r#rrs rr{z"_UtilDeprecationModule.__setattr__s dE*rc0t|j|yr)delattrrrs r __delattr__z"_UtilDeprecationModule.__delattr__s d#rc4dgt|jzSr)dirrr7s r__dir__z_UtilDeprecationModule.__dir__s{S...r) r<r>r?r@rr$rArr)r{rr rrFrrrrsj *z*d* + + +++C+D+$$$/c/rr)#r@rsysrcollections.abcrrtypesrtypingrrrr r r r r )cryptography.hazmat.primitives.asymmetricrrOpenSSLrrrrrHrYrhrnrorrmodulesr<rFrrrs -MMM=1h1;1*L*LZ/:/:d$}$4$m$*3>J, 7H, ^- (- f//>Z)? H@U)VW Hr