hyb
2026-01-30 44480e71b27aa9d4cb8441f50c873f1b110e9691
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
Ë
ž¬`i!DãóÜ—ddlZddlmZddlmZddlmZddlmZm    Z    ddl
m Z m Z m Z ddlmZdd    lmZdd
lmZdd lmZmZmZdd lmZmZGd „de«ZGd„de«ZGd„de«ZGd„de«ZddefddefddefddefddefdœZ de!de!de!d e!d!ef
d"„Z"d#e!de!d$e!d%e#d e!d!ef d&„Z$d'e!d(e!d e!d!efd)„Z%Gd*„d+«Z&ddddd,œd-ed.ed/ee!d0eed1ee'e!e!fd$ee!d2e&fd3„Z(y)4éN)ÚIntEnum)Ú
ModuleType)ÚOptionalé)Ú _HKDF_extractÚ _HKDF_expand)Ú key_agreementÚimport_x25519_public_keyÚimport_x448_public_key)Ústrxor)ÚECC)ÚEccKey)ÚSHA256ÚSHA384ÚSHA512)ÚAESÚChaCha20_Poly1305có —eZdZdZdZdZdZdZy)ÚMODEz
HPKE modesrrééN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__ÚBASEÚPSKÚAUTHÚAUTH_PSK©óõgH:\项目\archive\测试组\脚本\Change_password\venv_build\Lib\site-packages\Crypto/Protocol/HPKE.pyrrs„ÙØ €DØ
€CØ €D؁Hr!rcó—eZdZdZdZdZdZy)ÚAEADz>Authenticated Encryption with Associated Data (AEAD) FunctionsrrrN)rrrrÚ
AES128_GCMÚ
AES256_GCMÚCHACHA20_POLY1305r r!r"r$r$s„ÙHØ€JØ€JØÑr!r$có —eZdZy)ÚDeserializeErrorN©rrrr r!r"r)r)ó„Ør!r)có —eZdZy)ÚMessageLimitReachedErrorNr*r r!r"r-r-"r+r!r-ééréré é!©z
NIST P-256z
NIST P-384z
NIST P-521Ú
Curve25519ÚCurve448ÚsaltÚlabelÚikmÚsuite_idÚhashmodcó2—d|z|z|z}t|||«S)NóHPKE-v1)r)r6r7r8r9r:Ú labeled_ikms      r"Ú_labeled_extractr>/s'€ð
˜xÑ'¨%Ñ/°#Ñ5€KÜ ˜˜{¨GÓ 4Ð4r!ÚprkÚinfoÚLcób—tjd|«dz|z|z|z}t||||«S)Nú>Hr<)ÚstructÚpackr)r?r7r@rAr9r:Ú labeled_infos       r"Ú_labeled_expandrG8s?€ô —;‘;˜t QÓ'¨*Ñ4°xÑ?ØñØñ €Lä ˜˜\¨1¨gÓ 6Ð6r!ÚdhÚ kem_contextcó\—|j}tdd|||«}t|d||||«}|S)Nr!seae_prks shared_secret)Ú digest_sizer>rG)rHrIr9r:ÚNsecretÚeae_prkÚ shared_secrets       r"Ú_extract_and_expandrOCsL€ð×!Ñ!€Gä˜sØ)Ø!Ø'Ø&ó    (€Gô $ GØ$4Ø$/Ø$+Ø$,Ø$+ó -€Mð Ðr!có —eZdZdedeedeedeeefdededefd„Z    e
        dded
e d e deed eef
d „«Z e
    ddeded
e d e deef
d„«Ze
dedeeeffd„«Zdedededefd„Zd„Zddedeefd„Zddedeefd„Zy    )Ú HPKE_CipherÚ receiver_keyÚencÚ
sender_keyÚpsk_pairr@Úaead_idÚmodecó’—|€dn||_    |j||«|j|_||_||_    t |j\|_|_|_    |jtjk(rdnd|_d|_d|_|jj$|_|j)« |_|j*r>| td«‚|j-||j|j|«\}    |_n6|€ td«‚|j/|||j|j|«}    d|_d    d
|j zzd    z
|_|j4|    |g|¢­Ž\|_|_|_y#t$r*}tdj|j««|‚d}~wwxYw) Nr!z!Curve {} is not supported by HPKEr.r1é z0Parameter 'enc' cannot be an input  when sealingz'Parameter 'enc' required when unsealingrré)rSÚ_verify_psk_inputsÚcurveÚ_curveÚ_aead_idÚ_modeÚ _Curve_ConfigÚ_kem_idÚ_kdf_idÚ_hashmodÚKeyErrorÚ
ValueErrorÚformatr$r%Ú_NkÚ_NnÚ_NtrKÚ_NhÚ has_privateÚ_encryptÚ_encapÚ_decapÚ    _sequenceÚ _max_sequenceÚ _key_scheduleÚ_keyÚ _base_nonceÚ_export_secret)
ÚselfrRrSrTrUr@rVrWÚkerNs
          r"Ú__init__zHPKE_Cipher.__init__Zsµ€ð"% ™#°#ˆŒØ+à ×Ñ  hÔ/à"×(Ñ(ˆŒ ؈Œ ؈Œ
ð    ^ô+¨4¯;©;Ñ7ñ ˆDŒLØ Œ\Ø Œ]🙬$¯/©/Ò9‘2¸rˆŒØˆŒØˆŒØ—=‘=×,Ñ,ˆŒà(×4Ñ4Ó6Ð6ˆŒ à =Š=àˆÜ Ð!SÓTÐTØ&*§k¡k°,Ø26·,±,Ø26·-±-Ø2<ó'>Ñ #ˆM˜48ð ˆ{Ü Ð!JÓKÐKØ ŸK™K¨Ø(4Ø(,¯ © Ø(,¯ © Ø(2ó    4ˆM𠈌ؠA¨¯©¡LÑ1°QÑ6ˆÔð#5 $×"4Ñ"4°]Ø59ð#@à6>ò#@ñ     ˆŒ    Ø Ô Ø Õ øôCò    ^ÜÐ@×GÑGÈÏ É ÓTÓUÐ[]Ð ]ûð    ^ús¿&FÆ    GÆ%GÇGNÚkem_idr:Úeph_keycóÜ—||j«sJ‚||j«sJ‚|€ tj|j¬«}|j    «j d¬«}|j    «j d¬«}||z}i}|r'||j    «j d¬«z }d|i}dt jd|«z}    ||    |fd„}
td    |||
dœ|¤Ž} | |fS)
N)r\Úraw©rfÚ static_privóKEMrCcó—t||||«S©N©rO©rHrIr9r:s    r"ÚkdfzHPKE_Cipher._encap.<locals>.kdf¬ó€ô' r¨;¸À'ÓJÐ Jr!)Úeph_privÚ
static_pubrƒr )    rkr Úgenerater\Ú
public_keyÚ
export_keyrDrEr    ) rRrxr:rTryrSÚpkRmrIÚ extra_paramr9rƒrNs             r"rmzHPKE_Cipher._encap•s€ðÐ" z×'=Ñ'=Ô'?Ð?Ð?ؐ G×$7Ñ$7Ô$9Ð9Ð9à ˆ?Ü—l‘l¨×);Ñ);Ô<ˆGØ× Ñ Ó"×-Ñ-°UÐ-Ó;ˆà×&Ñ&Ó(×3Ñ3¸5Ð3ÓAˆØ˜D‘jˆ ؈ Ù Ø ˜:×0Ñ0Ó2×=Ñ=ÀUÐ=ÓKÑ KˆKØ(¨*Ð5ˆKàœFŸK™K¨¨fÓ5Ñ5ˆð(Ø!Øó    Kô &ð5¨wØ1=Ø*-ñ5ð)4ñ5ˆ ð˜cÐ!Ð!r!có—|j«sJ‚    |jdk(r t|«}n<|jdk(r t|«}n!t    j
||j¬«}|j«jd¬«}||z}i}    |r'||j«jd¬«z }d|i}    dtjd    |«z}
||
|fd
„} td ||| d œ|    ¤Ž} | S#t $r}td«|‚d}~wwxYw) Nr4r5)Ú
curve_namez*'enc' is not a valid encapsulated HPKE keyr{r|r†r~rCcó—t||||«Sr€rr‚s    r"rƒzHPKE_Cipher._decap.<locals>.kdfÔr„r!)Úeph_pubr}rƒr ) rkr\r
r r Ú
import_keyrer)rˆr‰rDrEr    ) rSrRrxr:rTÚpkEÚverŠrIr‹r9rƒrNs              r"rnzHPKE_Cipher._decap¸s0€ð×'Ñ'Ô)Ð)Ð)ð    YØ×!Ñ! \Ò1Ü.¨sÓ3‘Ø×#Ñ# zÒ1Ü,¨SÓ1‘ä—n‘n S°\×5GÑ5GÔHð×&Ñ&Ó(×3Ñ3¸5Ð3ÓAˆØ˜D‘jˆ ؈ Ù Ø ˜:×0Ñ0Ó2×=Ñ=ÀUÐ=ÓKÑ KˆKØ'¨Ð4ˆKàœFŸK™K¨¨fÓ5Ñ5ˆð(Ø!Øó    Kô &ð5¨cØ2>Ø*-ñ5ð)4ñ5ˆ ðÐøô-ò    YÜ"Ð#OÓPÐVXÐ Xûð    Yús”AC,Ã,    DÃ5 DÄDcóF—|\}}|dk(|dk(z r td«‚|dk(r;|tjtjfvrtd|j›«‚yt |«dkr td«‚|tj tjfvr td«‚y)Nr!zInconsistent PSK inputszPSK is required with mode r1z!PSK must be at least 32 byte longz$PSK is not compatible with this mode)rerrrÚnameÚlenrr)rWrUÚpsk_idÚpsks    r"r[zHPKE_Cipher._verify_psk_inputsàsž€à‰ ˆà 3‰J˜6 S™=Ò )ÜÐ6Ó7Ð 7à 3ŠJØœŸ™¤$§-¡-Ð0Ñ0Ü Ð#=¸d¿i¹i¸[Ð!IÓJÐJð1ô3‹x˜"Š}Ü Ð!DÓEÐEØœŸ    ™    ¤4§9¡9Ð-Ñ-Ü Ð!GÓHÐHð.r!rNr–r—có0—dtjd|j|j|j«z}t dd|||j «}t dd|||j «}|jjdd«|z|z}t |d|||j «}    t|    d    ||j||j «}
t|    d
||j||j «} t|    d ||j||j «} |
| | fS) NsHPKEz>HHHr!s psk_id_hashs    info_hashrÚbigssecretskeys
base_noncesexp) rDrErarbr^r>rcr_Úto_bytesrGrgrhrj) rurNr@r–r—r9Ú psk_id_hashÚ    info_hashÚkey_schedule_contextÚsecretÚkeyÚ
base_nonceÚexporter_secrets              r"rqzHPKE_Cipher._key_scheduleðs)€ð œVŸ[™[¨Ø)-¯©Ø)-¯©Ø)-¯©ó8ñ8ˆô
' sØ'5Ø'-Ø'/Ø'+§}¡}ó    6ˆ ô % SØ%1Ø%)Ø%-Ø%)§]¡]ó    4ˆ    ð  $Ÿz™z×2Ñ2°1°eÓ<¸{ÑJÈYÑVÐä! -Ø"+Ø"%Ø"*Ø"&§-¡-ó    1ˆô ˜fØ$Ø2Ø"Ÿh™hØ&Ø"Ÿm™mó -ˆô% VØ%2Ø%9Ø%)§X¡XØ%-Ø%)§]¡]ó 4ˆ
ô*¨&Ø*0Ø*>Ø*.¯(©(Ø*2Ø*.¯-©-ó 9ˆðJ Ð/Ð/r!cój—t|j|jj|jd««}|j
t jt jfvr<tj|jtj||j¬«}nX|j
t jk(r"tj|j|¬«}nt!d|j
d›«‚|j|j"k\r
t%«‚|xjdz c_|S)Nr™)ÚnonceÚmac_len)rŸr£úUnknown AEAD cipher ID ú#xr)r rsroršrhr^r$r%r&rÚnewrrÚMODE_GCMrir'rrerpr-)rur£Úciphers   r"Ú _new_cipherzHPKE_Cipher._new_cipher&sҀܐt×'Ñ'¨¯©×)@Ñ)@ÀÇÁÈ5Ó)QÓRˆØ =‰=œTŸ_™_¬d¯o©oÐ>Ñ >Ü—W‘W˜TŸY™Y¬¯ © ¸EÈ4Ï8É8ÔT‰FØ ]‰]œd×4Ñ4Ò 4Ü&×*Ñ*¨t¯y©yÀÔF‰FäÐ6°t·}±}ÀRÐ6HÐIÓJÐ JØ >‰>˜T×/Ñ/Ò /Ü*Ó,Ð ,Ø Š˜!э؈ r!Ú    plaintextÚ    auth_datacó¨—|js td«‚|j«}|r|j|«|j    |«\}}||zS)aæEncrypt and authenticate a message.
 
        This method can be invoked multiple times
        to seal an ordered sequence of messages.
 
        Arguments:
          plaintext: bytes
            The message to seal.
          auth_data: bytes
            Optional. Additional Authenticated data (AAD) that is not encrypted
            but that will be also covered by the authentication tag.
 
        Returns:
           The ciphertext concatenated with the authentication tag.
        z$This cipher can only be used to seal)rlrerªÚupdateÚencrypt_and_digest)rur«r¬r©ÚctÚtags      r"ÚsealzHPKE_Cipher.seal3sQ€ð"}Š}ÜÐCÓDÐ DØ×!Ñ!Ó#ˆÙ Ø M‰M˜)Ô $Ø×+Ñ+¨IÓ6‰ˆˆCؐC‰xˆr!Ú
ciphertextcó‚—|jr td«‚t|«|jkr td«‚|j    «}|r|j |«    |j |d|j ||j d«}|S#t$r&|jdk(r td«‚td«‚wxYw)aðDecrypt a message and validate its authenticity.
 
        This method can be invoked multiple times
        to unseal an ordered sequence of messages.
 
        Arguments:
          cipertext: bytes
            The message to unseal.
          auth_data: bytes
            Optional. Additional Authenticated data (AAD) that
            was also covered by the authentication tag.
 
        Returns:
           The original plaintext.
 
        Raises: ValueError
           If the ciphertext (in combination with the AAD) is not valid.
 
           But if it is the first time you call ``unseal()`` this
           exception may also mean that any of the parameters or keys
           used to establish the session is wrong or that one is missing.
        z&This cipher can only be used to unsealzCiphertext is too smallNrzAIncorrect HPKE keys/parameters or invalid message (wrong MAC tag)zInvalid message (wrong MAC tag))rlrer•rirªr®Údecrypt_and_verifyro)rur³r¬r©Úpts     r"ÚunsealzHPKE_Cipher.unsealLsĀð0 =Š=ÜÐEÓFÐ FÜ ˆz‹?˜TŸX™XÒ %ÜÐ6Ó7Ð 7Ø×!Ñ!Ó#ˆÙ Ø M‰M˜)Ô $ð    @Ø×*Ñ*¨:°j¸¿¹°yÐ+AØ+5°t·x±x°i°jÐ+AóCˆBð ˆ    øô    ò    @؏~‰~ Ò"Ü Ð!dÓeÐeÜÐ>Ó?Ð ?ð    @ús Á.BÂ/B>)NNr€)rrrrrÚbytesÚtupler$rrwÚ staticmethodÚintrrmrnr[rqrªr²r·r r!r"rQrQXsŒ„ð9@Ø%ð9@à˜u‘oð9@ð& fÑ-ð9@ð! ¨ Ñ.ð    9@ð
ð 9@ð ð 9@ðó9@ðvð/3Ø+/ñ     "˜Vð "Øð "à"ð "ð$ FÑ+ð "ð! Ñ(ò     "óð "ðDð
/3ñ    %Eð%Ø#ð%àð%ð#ð%ð$ FÑ+ò    %óð%ðNð I ð I°°u¸e°|Ñ1Dò Ióð Ið40Ø%*ð40à!ð40ð$ð40ð!ó    40òl ñ˜e𰸱óñ2' ð'°8¸E±?ô'r!rQ)rSrTr—r@rRrVrSrTr—Úreturnc    ó—|tvrtd|d›«‚|j}|dvrtd|›«‚|ršt|j    ««t|j    ««z}|dk7r td«‚|j|k7r%tdj |j|««‚|€t jnt j}n"|€t jnt j}|€d}|€d    }t|||||||«S)
aŽ    Create an HPKE context which can be used:
 
    - by the sender to seal (encrypt) a message or
    - by the receiver to unseal (decrypt) it.
 
    As a minimum, the two parties agree on the receiver's asymmetric key
    (of which the sender will only know the public half).
 
    Additionally, for authentication purposes, they may also agree on:
 
    * the sender's asymmetric key (of which the receiver will only know the public half)
 
    * a shared secret (e.g., a symmetric key derived from a password)
 
    Args:
      receiver_key:
        The ECC key of the receiver.
        It must be on one of the following curves: ``NIST P-256``,
        ``NIST P-384``, ``NIST P-521``, ``X25519`` or ``X448``.
 
        If this is a **public** key, the HPKE context can only be used to
        **seal** (**encrypt**).
 
        If this is a **private** key, the HPKE context can only be used to
        **unseal** (**decrypt**).
 
      aead_id:
        The HPKE identifier of the symmetric cipher.
        The possible values are:
 
        * ``HPKE.AEAD.AES128_GCM``
        * ``HPKE.AEAD.AES256_GCM``
        * ``HPKE.AEAD.CHACHA20_POLY1305``
 
      enc:
        The encapsulated session key (i.e., the KEM shared secret).
 
        The receiver must always specify this parameter.
 
        The sender must always omit this parameter.
 
      sender_key:
        The ECC key of the sender.
        It must be on the same curve as the ``receiver_key``.
        If the ``receiver_key`` is a public key, ``sender_key`` must be a
        private key, and vice versa.
 
      psk:
        A Pre-Shared Key (PSK) as a 2-tuple of non-empty
        byte strings: the identifier and the actual secret value.
        Sender and receiver must use the same PSK (or none).
 
        The secret value must be at least 32 bytes long,
        but it  must not be a low-entropy password
        (use a KDF like PBKDF2 or scrypt to derive a secret
        from a password).
 
      info:
        A non-secret parameter that contributes
        to the generation of all session keys.
        Sender and receive must use the same **info** parameter (or none).
 
    Returns:
        An object that can be used for
        sealing (if ``receiver_key`` is a public key) or
        unsealing (if ``receiver_key`` is a private key).
        In the latter case,
        correctness of all the keys and parameters will only
        be assessed with the first call to ``unseal()``.
    r¥r¦r3zUnsupported curve rzExactly 1 private key requiredz'Sender key uses {} but recipient key {})r!r!r!) r$rer\r»rkrfrrrrrrQ)    rRrVrSrTr—r@r\Úcount_private_keysrWs             r"r§r§vs€ðZ”dÑÜÐ2°7¸2°,Ð?Ó@Ð@à × Ñ €EØ ð/ñ/äÐ-¨e¨WÐ5Ó6Ð6áÜ  ×!9Ñ!9Ó!;Ó<Ü  ×!7Ñ!7Ó!9Ó:ñ;Ðà  Ò "ÜÐ=Ó>Ð >Ø × Ñ ˜uÒ $ÜÐFß#™V J×$4Ñ$4°eÓ<ó>ð >à˜KŒtyŠy¬T¯]©]‰à˜KŒtyŠy¬T¯X©Xˆà
€{Øˆà €|Øˆä |ØØ!ØØØØó  ðr!))rDÚenumrÚtypesrÚtypingrÚKDFrrÚDHr    r
r ÚCrypto.Util.strxorr ÚCrypto.PublicKeyr ÚCrypto.PublicKey.ECCrÚ Crypto.HashrrrÚ Crypto.Cipherrrrr$rer)r-r`r¸r>r»rGrOrQr¹r§r r!r"ú<module>rÉs©ðÛ ÝåÝç,ßOÑOÝ%Ý Ý'ß.Ñ.ß0ôˆ7ôôˆ7ôô    zô    ô    ˜zô    ð
˜ Ð(ؘ Ð(ؘ Ð(ؘ Ð(ؘ Ð(ñ € ð5˜5ð5Ø!ð5àð5ð %ð5ð)ó    5ð7˜ð7Ø ð7àð7ðð7ð$ð    7ð
(ó 7ð˜EðØ%*ðà"'ðð",ó÷*[ñ[ð@     $Ø'+Ø-1Ø $ò m˜ðmØðmà e‰_ðmð˜VÑ$ðmðe˜E 5˜LÑ)Ñ *ð    mð
u‰oð mð
*5ô mr!