ó
    ‘óýj4é  ã            	       ód  • S r SSKJr  SSKJr  \(       a   SSKrSSKr SSK	r	SSK
Jr  / SQrS\S\\   4S	 jrS
\S\S\4S jr " S S\5      r " S S\5      r " S S\5      rSrSrSr " S S5      r " S S5      r " S S\\5      r " S S\\5      r " S S\\5      r " S  S!\\5      r " S" S#\5      r  " S$ S%\\5      r! S/S&\S-  S'S(S\4S) jjr"S*\S\4S+ jr#  S/S*\S'S(S,\\   S-  S\4S- jjr$S\%\\\&\   \&\   -     4   4S. jr'\" 5       r(g! \ a     GNf = f! \ a     GN
f = f)0z8Signature vendors for signing and verifying Git objects.é    )ÚIterable)ÚTYPE_CHECKINGN)ÚConfig)ÚSIGNATURE_FORMAT_OPENPGPÚSIGNATURE_FORMAT_SSHÚSIGNATURE_FORMAT_X509ÚBadSignatureÚGPGCliSignatureVendorÚGPGSignatureVendorÚPySequoiaSignatureVendorÚSSHCliSignatureVendorÚSSHSigSignatureVendorÚSignatureSignerÚSignatureVerificationErrorÚSignatureVerifierÚUntrustedSignatureÚX509SignatureVendorÚdetect_signature_formatÚget_available_vendorsÚget_signature_vendorÚ"get_signature_vendor_for_signatureÚ
gpg_vendorÚstatusÚreturnc                 óH  • / nSnU R                  SSS9R                  5        H{  nUR                  U5      (       d  M  U[        U5      S R	                  5       n[        U5      S:¼  d  MH  US   S:X  d  MS  UR                  US	   5        UR                  US
   5        M}     U$ )aù  Extract signing key fingerprints from gpg/gpgsm --status-fd output.

Only the VALIDSIG status line is consulted. Its first argument is the
fingerprint of the signing key and its last argument is the primary key
fingerprint; both are produced by gpg and are not attacker-controlled,
unlike the human-readable "Good signature from <user id>" text on stderr.

Args:
  status: Raw bytes written by gpg/gpgsm to the status file descriptor.

Returns:
  List of fingerprints found (signing key and primary key).
z	[GNUPG:] úutf-8Úreplace©ÚerrorsNé   r   ÚVALIDSIGé   éÿÿÿÿ)ÚdecodeÚ
splitlinesÚ
startswithÚlenÚsplitÚappend)r   ÚfingerprintsÚprefixÚlineÚfieldss        Ú</usr/local/lib/python3.13/site-packages/dulwich/signature.pyÚ_parse_status_fingerprintsr/   @   s�   € ð !€LØ€FØ—‘˜g¨i�Ð8×CÑCÖEˆØ�‰˜v×&Ñ&ÙØ”c˜&“k�mÐ$×*Ñ*Ó,ˆÜˆv‹;˜!Õ  q¡	¨ZÕ 7Ø×Ñ  q¡	Ô*Ø×Ñ  r¡
Ö+ñ Fð Ðó    ÚfingerprintÚkeyidc                 óÔ   • U R                  SS5      R                  5       n UR                  SS5      R                  5       nU R                  U5      =(       d    UR                  U 5      $ )a&  Check whether a key ID or fingerprint refers to the given fingerprint.

A key ID is the trailing hex of a fingerprint, so the shorter value must
be a suffix of the longer one. Plain substring matching would accept a key
whose fingerprint merely contains the trusted ID somewhere in the middle.
Ú Ú )r   ÚupperÚendswith)r1   r2   s     r.   Ú_keyid_matchesr8   Z   sW   € ð ×%Ñ% c¨2Ó.×4Ñ4Ó6€KØ�M‰M˜#˜rÓ"×(Ñ(Ó*€EØ×Ñ Ó&×E¨%¯.©.¸Ó*EÐEr0   c                   ó   • \ rS rSrSrSrg)r   ég   z3Base exception for signature verification failures.© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r;   r0   r.   r   r   g   s   † Ü=r0   r   c                   óB   ^ • \ rS rSrSrSS\S\S-  4U 4S jjjrSrU =r$ )	r	   ék   zˆException raised when a signature is invalid or cannot be verified.

Attributes:
  detail: Optional additional detail about the failure
NÚmessageÚdetailc                 ó0   >• [         TU ]  U5        X l        g)zzInitialize BadSignature exception.

Args:
  message: Error message
  detail: Optional additional detail about the failure
N)ÚsuperÚ__init__rE   )ÚselfrD   rE   Ú	__class__s      €r.   rH   ÚBadSignature.__init__r   s   ø€ ô 	‰Ñ˜Ô!Ø�r0   )rE   ©N)	r<   r=   r>   r?   r@   ÚstrrH   rA   Ú__classcell__©rJ   s   @r.   r	   r	   k   s$   ø† ññ ð ¨S°4©Z÷ ö r0   r	   c                   ó\   ^ • \ rS rSrSr  S	S\S\\   S-  S\\   S-  4U 4S jjjrSrU =r	$ )
r   é}   zÓException raised when a signature is not from a trusted key.

Attributes:
  signing_keys: List of key IDs that signed the data (if determinable)
  trusted_keys: List of key IDs that were trusted (if applicable)
NrD   Úsigning_keysÚtrusted_keysc                 ód   >• [         TU ]  U5        U=(       d    / U l        U=(       d    / U l        g)zÒInitialize UntrustedSignature exception.

Args:
  message: Error message
  signing_keys: List of key IDs that signed the data (if determinable)
  trusted_keys: List of key IDs that were trusted (if applicable)
N)rG   rH   rR   rS   )rI   rD   rR   rS   rJ   s       €r.   rH   ÚUntrustedSignature.__init__…   s,   ø€ ô 	‰Ñ˜Ô!Ø(×.¨BˆÔØ(×.¨BˆÕr0   ©rR   rS   ©NN)
r<   r=   r>   r?   r@   rM   ÚlistrH   rA   rN   rO   s   @r.   r   r   }   sH   ø† ñð *.Ø)-ñ	/àð/ð ˜3‘i $Ñ&ð/ð ˜3‘i $Ñ&÷	/ö /r0   r   ÚopenpgpÚx509Ússhc                   óP   • \ rS rSrSr\S\4S j5       rS
S\S\	S-  S\4S jjr
S	rg)r   é�   z3A signature implementation for signing Git objects.r   c                 ó   • g)zzCheck if this signature signer is available.

Returns:
  True if the signer's dependencies are available, False otherwise
Tr;   ©Úclss    r.   Ú	availableÚSignatureSigner.available    ó   € ð r0   NÚdatar2   c                 ó,   • [        U R                  5      e)z¿Sign data with a key.

Args:
  data: The data to sign
  keyid: Optional key ID to use for signing. If not specified,
         the default key will be used.

Returns:
  The signature as bytes
)ÚNotImplementedErrorÚsign)rI   rd   r2   s      r.   rg   ÚSignatureSigner.sign©   s   € ô " $§)¡)Ó,Ð,r0   r;   rL   )r<   r=   r>   r?   r@   ÚclassmethodÚboolra   ÚbytesrM   rg   rA   r;   r0   r.   r   r   �   sA   † Ù=àð˜$ó ó ðñ-˜ð - s¨T¡zð -¸U÷ -ð -r0   r   c                   óh   • \ rS rSrSrSS\\   S-  SS4S jjr\S\	4S j5       r
S\S	\SS4S
 jrSrg)r   é·   z5A signature implementation for verifying Git objects.NÚkeyidsr   c                 ó:   • Ub  [        U5      U l        gSU l        g)z®Initialize the signature verifier.

Args:
  keyids: Optional iterable of trusted key IDs/fingerprints.
         If provided, only signatures from these keys will be trusted.
N)rX   rn   )rI   rn   s     r.   rH   ÚSignatureVerifier.__init__º   s   € ð '-Ñ&8”d˜6“lˆ�¸dˆ�r0   c                 ó   • g)z~Check if this signature verifier is available.

Returns:
  True if the verifier's dependencies are available, False otherwise
Tr;   r_   s    r.   ra   ÚSignatureVerifier.availableÃ   rc   r0   rd   Ú	signaturec                 ó,   • [        U R                  5      e)zÞVerify a signature.

Args:
  data: The data that was signed
  signature: The signature to verify

Raises:
  BadSignature: if signature verification fails
  UntrustedSignature: if signature was not created by a trusted key
)rf   Úverify)rI   rd   rs   s      r.   ru   ÚSignatureVerifier.verifyÌ   s   € ô " $§+¡+Ó.Ð.r0   )rn   rL   )r<   r=   r>   r?   r@   r   rM   rH   ri   rj   ra   rk   ru   rA   r;   r0   r.   r   r   ·   sY   † Ù?ñC˜x¨™}¨tÑ3ð C¸tõ Cð ð˜$ó ó ðð/˜5ð /¨Uð /°t÷ /r0   r   c                   óÈ   • \ rS rSrSr  SS\S-  S\\   S-  SS4S jjr\ SSS	S\\   S-  SS 4S
 jj5       r	\S\
4S j5       rSS\S\S-  S\4S jjrS\S\SS4S jrSrg)r   éÚ   z«Signature vendor that uses the GPG package for signing and verification.

Supports git config options:
- gpg.minTrustLevel: Minimum trust level for signature verification
NÚmin_trust_levelrn   r   c                 ó:   • [         R                  X5        Xl        g)aM  Initialize the GPG package vendor.

Args:
  min_trust_level: Minimum trust level required (undefined, never, marginal,
                  fully, ultimate). If None, any trust level is accepted.
  keyids: Optional iterable of trusted GPG key IDs for verification.
         If provided, only signatures from these keys will be trusted.
N)r   rH   ry   )rI   ry   rn   s      r.   rH   ÚGPGSignatureVendor.__init__á   s   € ô 	×"Ñ" 4Ô0Ø.Õr0   ÚconfigúConfig | Nonec                 óª   • SnUb9   UR                  SS5      nU(       a  UR                  S5      R                  5       nU " X2S9$ ! [         a     Nf = f)zìCreate a GPG vendor from git configuration.

Args:
  config: Git configuration to read settings from
  keyids: Optional iterable of trusted GPG key IDs for verification

Returns:
  GPGSignatureVendor instance configured from the config
N©ó   gpgs   minTrustLevelr   )ry   rn   )Úgetr$   ÚlowerÚKeyError)r`   r|   rn   ry   Útrust_levels        r.   Úfrom_configÚGPGSignatureVendor.from_configñ   sb   € ð ˆØÑðØ$Ÿj™j¨Ð4DÓE�ÞØ&1×&8Ñ&8¸Ó&A×&GÑ&GÓ&I�Oñ  ?ÑBÐBøô ó Ùðús   ‡8A Á
AÁAc                 óD   • SSK nUR                  R                  S5      SL$ )zoCheck if the gpg Python package is available.

Returns:
  True if gpg package can be imported, False otherwise
r   NÚgpg©Úimportlib.utilÚutilÚ	find_spec©r`   Ú	importlibs     r.   ra   ÚGPGSignatureVendor.available	  s!   € ó 	à�~‰~×'Ñ'¨Ó.°dÐ:Ð:r0   rd   r2   c                 óö  • SSK nUR                  SS9 nUbf  UR                  U5      nUR                  SU/S9 nUR                  UUR                  R
                  R                  R                  S9u  pxSSS5        O:UR                  UUR                  R
                  R                  R                  S9u  pxSSS5        [        W[        5      (       d   eU$ ! , (       d  f       N/= f! , (       d  f       N8= f)zËSign data with a GPG key.

Args:
  data: The data to sign
  keyid: Optional GPG key ID to use for signing. If not specified,
         the default GPG key will be used.

Returns:
  The signature as bytes
r   NT)Úarmor)r‘   Úsigners©Úmode)
rˆ   ÚContextÚget_keyrg   Ú	constantsÚsigr”   ÚDETACHÚ
isinstancerk   )	rI   rd   r2   rˆ   ÚcÚkeyÚctxrs   Ú_unused_results	            r.   rg   ÚGPGSignatureVendor.sign  sß   € ó 	à�[‰[˜tˆ[Ñ$¨ØÑ Ø—i‘i Ó&�Ø—[‘[ t°c°U�[Ñ;¸sØ03·±ØØ Ÿ]™]×.Ñ.×3Ñ3×:Ñ:ð 19ð 1Ñ-�I÷ <Ð;ð -.¯F©FØØŸ™×*Ñ*×/Ñ/×6Ñ6ð -3ð -Ñ)�	÷ %ô ˜)¤U×+Ñ+Ð+Ð+ØÐ÷ <Õ;ú÷ %Õ$ús#   ”&C*º;CÁ5AC*Ã
C'	Ã#C*Ã*
C8rs   c                 óH  • SSK nUR                  R                  R                  UR                  R                  R                  UR                  R                  R
                  UR                  R                  R                  UR                  R                  R                  S.n UR                  5        nUR                  UUS9u  pgUc   eUR                  (       d  [        S5      eU R                  bf  UR                  U R                  5      nUbH  UR                   H8  n	U	R                  U:  d  M  [        SU	R                   SU R                   35      e   U R                  (       aâ  U R                   V
s/ s H  o¥R!                  U
5      PM     nn
U Hb  n
U
R"                   HO  nUR                   H<  n	UR$                  (       d  M  UR&                  U	R&                  :X  d  M2        SSS5        g   MQ     Md     UR                   V	s/ s H  o™R&                  PM     nn	[        SU R                   3U[)        U R                  5      S	9e SSS5        gs  sn
f s  sn	f ! , (       d  f       g= f! UR*                  R,                   a  n[        S
U 35      UeSnAff = f)a  Verify a GPG signature.

Args:
  data: The data that was signed
  signature: The signature to verify

Raises:
  BadSignature: if GPG signature verification fails
  UntrustedSignature: if the signature was not created by a trusted key
                     or trust level is below minimum
r   N)Ú	undefinedÚneverÚmarginalÚfullyÚultimate©rs   z6GPG signature verification failed: no signatures foundzSignature trust level z! is below minimum required level z2Signature not created by any of the trusted keys: rV   ú#GPG signature verification failed: )rˆ   r—   ÚvalidityÚ	UNDEFINEDÚNEVERÚMARGINALÚFULLÚULTIMATEr•   ru   Ú
signaturesr	   ry   r�   r   rn   r–   ÚsubkeysÚcan_signÚfprrX   r   ÚGpgError)rI   rd   rs   rˆ   Útrust_level_mapr�   Ú_verified_dataÚresultÚmin_validityr˜   rœ   ÚkeysÚsubkeyÚsigning_fprsÚes                  r.   ru   ÚGPGSignatureVendor.verify1  sK  € ó 	ð Ÿ™×/Ñ/×9Ñ9Ø—]‘]×+Ñ+×1Ñ1ØŸ™×.Ñ.×7Ñ7Ø—]‘]×+Ñ+×0Ñ0ØŸ™×.Ñ.×7Ñ7ñ
ˆð(	QØ—‘” #Ø),¯©ØØ'ð *4ð *Ñ&�ð Ñ)Ð)Ð)ð ×(×(Ü&ØPóð ð
 ×'Ñ'Ñ3Ø#2×#6Ñ#6°t×7KÑ7KÓ#L�LØ#Ñ/Ø#)×#4Ô#4˜CØ"Ÿ|™|¨lÕ:Ü&8Ø&<¸S¿\¹\¸Nð K>Ø>B×>RÑ>RÐ=Sð%Uó'"ð !"ñ $5ð —;—;Ø8<¿ºÓDº°ŸK™K¨Ö,¹�DÐDÛ#˜Ø&)§k¤k˜FØ'-×'8Ô'8 Ø#)§?§?¡?°v·z±zÀSÇWÁWÕ7LÚ$*÷= �ó8 (9ó '2ñ  $ð 8>×7HÒ7HÓ#IÒ7H°§G¤GÑ7H�LÐ#IÜ,ØLÈTÏ[É[ÈMÐZØ%1Ü%)¨$¯+©+Ó%6ñð ð ÷1 �ùò2 Eùò $J÷A •ûðL �z‰z×"Ñ"ó 	QÜÐ!DÀQÀCÐHÓIÈqÐPûð	Qúst   Â$I3 Â4A<I"Ä4AI"Å:IÆ4I"ÇI"Ç(I"Ç+I3 Ç4I"ÈIÈ!-I"ÉI3 É
I"É"
I0É,I3 É0I3 É3J!ÊJÊJ!)ry   rW   rL   ©r<   r=   r>   r?   r@   rM   r   rH   ri   r…   rj   ra   rk   rg   ru   rA   r;   r0   r.   r   r   Ú   sÑ   † ñð '+Ø'+ñ/à˜t™ð/ð ˜‘ Ñ$ð/ð 
õ	/ð  àLPñCØ$ðCØ5=¸c±]ÀTÑ5IðCà	ôCó ðCð. ð;˜$ó ;ó ð;ñ˜ð  s¨T¡zð ¸Uõ ð:?Q˜5ð ?Q¨Uð ?Q°t÷ ?Qr0   r   c                   óÂ   • \ rS rSrSr  SS\S\\   S-  SS4S jjr\ SSS	S\\   S-  SS 4S
 jj5       r	\S\
4S j5       rSS\S\S-  S\4S jjrS\S\SS4S jrSrg)r
   is  zRSignature vendor that uses the GPG command-line tool for signing and verification.NÚgpg_commandrn   r   c                 ó:   • [         R                  X5        Xl        g)zêInitialize the GPG CLI vendor.

Args:
  gpg_command: Path to the GPG command (default: "gpg")
  keyids: Optional iterable of trusted GPG key IDs for verification.
         If provided, only signatures from these keys will be trusted.
N)r   rH   r¾   )rI   r¾   rn   s      r.   rH   ÚGPGCliSignatureVendor.__init__v  s   € ô 	×"Ñ" 4Ô0Ø&Õr0   r|   r}   c                 ó€   • SnUb$   UR                  SS5      nUR                  S5      nU " X2S9$ ! [         a     Nf = f)zóCreate a GPG CLI vendor from git configuration.

Args:
  config: Git configuration to read settings from
  keyids: Optional iterable of trusted GPG key IDs for verification

Returns:
  GPGCliSignatureVendor instance configured from the config
rˆ   r   ó   programr   )r¾   rn   ©r�   r$   rƒ   )r`   r|   rn   r¾   Úgpg_programs        r.   r…   Ú!GPGCliSignatureVendor.from_config…  sU   € ð ˆØÑðØ$Ÿj™j¨°JÓ?�Ø)×0Ñ0°Ó9�ñ ˜{Ñ:Ð:øô ó Ùðúó   ‡#0 °
=¼=c                 ó0   • SSK nUR                  S5      SL$ )zcCheck if the gpg command is available.

Returns:
  True if gpg command is in PATH, False otherwise
r   Nrˆ   ©ÚshutilÚwhich©r`   rÉ   s     r.   ra   ÚGPGCliSignatureVendor.availableœ  s   € ó 	à�|‰|˜EÓ"¨$Ð.Ð.r0   rd   r2   c                 ó�   • SSK nU R                  SS/nUb  UR                  SU/5        UR                  UUSSS9nUR                  $ )a&  Sign data with a GPG key using the command-line tool.

Args:
  data: The data to sign
  keyid: Optional GPG key ID to use for signing. If not specified,
         the default GPG key will be used.

Returns:
  The signature as bytes

Raises:
  subprocess.CalledProcessError: if GPG command fails
r   Nú--detach-signú--armorú--local-userT©ÚinputÚcapture_outputÚcheck)Ú
subprocessr¾   ÚextendÚrunÚstdout©rI   rd   r2   rÕ   Úargsrµ   s         r.   rg   ÚGPGCliSignatureVendor.sign§  s[   € ó 	à× Ñ  /°9Ð=ˆØÑØ�K‰K˜¨Ð/Ô0à—‘ØØØØð	  ð 
ˆð �}‰}Ðr0   rs   c                 óŒ  ^• SSK nSSKnUR                  SSS9 nUR                  SSS9 nUR                  U5        UR	                  5         UR                  U5        UR	                  5         U R
                  SSUR                  UR                  /n UR                  US	S	S
9nU R                  (       a�  [        UR                  5      n
U
(       d  [        S5      eU
 H9  m[!        U4S jU R                   5       5      (       d  M)    SSS5        SSS5        g   [        SU
 S[#        U R                  5       3U
[#        U R                  5      S9e SSS5        SSS5        g! UR                   a,  n	[        SU	R                  R                  SSS9 35      U	eSn	A	ff = f! , (       d  f       NV= f! , (       d  f       g= f)a  Verify a GPG signature using the command-line tool.

Args:
  data: The data that was signed
  signature: The signature to verify

Raises:
  BadSignature: if GPG signature verification fails
  UntrustedSignature: if signature was not created by a trusted key
r   NÚwbú.sig©r”   Úsuffixú.datú--status-fd=1ú--verifyT©rÓ   rÔ   r§   r   r   r   z6Could not determine signing key from GPG status outputc              3   ó<   >#   • U  H  n[        TU5      v •  M     g 7frL   ©r8   ©Ú.0ÚkÚ	signed_bys     €r.   Ú	<genexpr>Ú/GPGCliSignatureVendor.verify.<locals>.<genexpr>   ó   øé € ÐMÂ¸Aœ>¨)°Q×7Ð7Âùó   ƒú3Signature not created by a trusted key. Signed by: ú, trusted keys: rV   )rÕ   ÚtempfileÚNamedTemporaryFileÚwriteÚflushr¾   Únamer×   ÚCalledProcessErrorr	   Ústderrr$   rn   r/   rØ   r   ÚanyrX   )rI   rd   rs   rÕ   rñ   Úsig_fileÚ	data_filerÚ   rµ   rº   rR   rê   s              @r.   ru   ÚGPGCliSignatureVendor.verifyÃ  s·  ø€ ó 	Ûð ×'Ñ'¨T¸&Ð'ÑAÀXØ×'Ñ'¨T¸&Ð'ÑAÀYà�N‰N˜9Ô%Ø�N‰NÔà�O‰O˜DÔ!Ø�O‰OÔð × Ñ ØØØ—‘Ø—‘ðˆDð	Ø#Ÿ™ØØ#'Øð (ð �ð �{�{ô  :¸&¿-¹-ÓH�æ#Ü,ØPóð ó ".�IÜÔMÀÇÂÓM×MÓMØ÷[ B÷ BÐAñX ".ô
 )ð"Ø". Ð/?ÄÀTÇ[Á[Ó@QÐ?RðTà!-Ü!% d§k¡kÓ!2ñ	ð ð) ÷9 B÷ BÐAøð. ×0Ñ0ó Ü"Ø9¸!¿(¹(¿/¹/È'ÐZc¸/Ð:dÐ9eÐfóàðûðú÷- BÕAú÷ BÕAúóZ   šF5«A(F$ÂE%Â%AF$ÄF$Ä	F5Ä9F$ÅF5Å%F!Å5'FÆF!Æ!F$Æ$
F2	Æ.F5Æ5
G)r¾   )rˆ   NrW   rL   r¼   r;   r0   r.   r
   r
   s  sÆ   † Ù\ð !Ø'+ñ'àð'ð ˜‘ Ñ$ð'ð 
õ	'ð àLPñ;Ø$ð;Ø5=¸c±]ÀTÑ5Ið;à	 ô;ó ð;ð, ð/˜$ó /ó ð/ñ˜ð  s¨T¡zð ¸Uõ ð8F˜5ð F¨Uð F°t÷ Fr0   r
   c                   ó¢   • \ rS rSrSr    SSSSSS\S-  S	\\   S-  S
S4
S jjr\S
\	4S j5       r
SS\S\S-  S
\4S jjrS\S\S
S4S jrSrg)r   i  zòSignature vendor that uses the pysequoia package for OpenPGP signatures.

Unlike the GPG vendors, this does not use a GnuPG keyring; the secret keys
used for signing and the certificates used for verification have to be
passed in explicitly.
NÚsecret_keyszIterable[pysequoia.Tsk]ÚcertszIterable[pysequoia.Cert]Úpasswordrn   r   c                 óÚ   • [         R                  X5        [        U5      U l        [        U5      U R                   Vs/ s H  oUR	                  5       PM     sn-   U l        X0l        gs  snf )aÊ  Initialize the pysequoia vendor.

Args:
  secret_keys: Secret keys available for signing. Their public
         certificates are also used for verification.
  certs: Certificates used to verify signatures.
  password: Password used to unlock the secret keys, if they are
         password-protected.
  keyids: Optional iterable of trusted key IDs/fingerprints for
         verification. If provided, only signatures from these keys
         will be trusted.
N)r   rH   rX   rþ   Úextract_certificaterÿ   r   )rI   rþ   rÿ   r   rn   Útsks         r.   rH   Ú!PySequoiaSignatureVendor.__init__  s`   € ô& 	×"Ñ" 4Ô0Ü Ó,ˆÔÜ˜%“[Ø15×1AÒ1Aó$
Ú1A¨#×#Ñ#Ö%Ñ1Añ$
ñ 
ˆŒ
ð !�ùò$
s   ¾A(c                 óX   •  SSK n[        UR                  S5      $ ! [         a     gf = f)zˆCheck if a recent enough pysequoia package is available.

Returns:
  True if pysequoia 0.1.35 or later can be imported, False otherwise
r   NFr  )Ú	pysequoiaÚImportErrorÚhasattrÚTsk)r`   r  s     r.   ra   Ú"PySequoiaSignatureVendor.available.  s2   € ð	Ûô �y—}‘}Ð&;Ó<Ð<øô ó 	Ùð	ús   ‚ œ
)¨)rd   r2   c                 ó°  • SSK nUc,  U R                  (       d  [        S5      eU R                  S   nOLU R                   H.  n[        UR	                  5       R
                  U5      (       d  M.    O   [        SU 35      eUR                  " UR                  U R                  5      UUR                  R                  S9n[        U[        5      (       d   eU$ )aZ  Sign data with one of the configured secret keys.

Args:
  data: The data to sign
  keyid: Optional key ID or fingerprint of the primary key to sign
         with. If not specified, the first secret key is used.

Returns:
  The ASCII-armored detached signature as bytes

Raises:
  ValueError: if no secret key is available, or none matches keyid
r   Nz$No secret keys available for signingzNo secret key available for r“   )r  rþ   Ú
ValueErrorr8   r  r1   rg   Úsignerr   ÚSignatureModeÚDETACHEDrš   rk   )rI   rd   r2   r  r  rs   s         r.   rg   ÚPySequoiaSignatureVendor.sign<  sÀ   € ó 	à‰=Ø×#×#Ü Ð!GÓHÐHØ×"Ñ" 1Ñ%‰Cà×'Ô'�Ü! #×"9Ñ"9Ó";×"GÑ"GÈ×OÓOÙñ (ô !Ð#?À¸wÐ!GÓHÐHà—N’NØ�J‰J�t—}‘}Ó%ØØ×(Ñ(×1Ñ1ñ
ˆ	ô
 ˜)¤U×+Ñ+Ð+Ð+ØÐr0   rs   c                 óT  ^ ^	• SSK n UR                  R                  U5      nUR                  " UU 4S jUS9nUR                  (       d  [        S5      eT R                  (       a¢  / nUR                   H*  nUR                  UR                  UR                  /5        M,     U H)  m	[        U	4S jT R                   5       5      (       d  M)    g   [        SU S	[        T R                  5       3U[        T R                  5      S
9eg! [         a  n[        SU 35      UeSnAff = f)a  Verify an OpenPGP signature against the configured certificates.

Args:
  data: The data that was signed
  signature: The signature to verify

Raises:
  BadSignature: if signature verification fails
  UntrustedSignature: if signature was not created by a trusted key
r   Nc                 ó   >• TR                   $ rL   )rÿ   )rn   rI   s    €r.   Ú<lambda>Ú1PySequoiaSignatureVendor.verify.<locals>.<lambda>o  s	   ø€ °·²r0   )rk   Ústorers   z'OpenPGP signature verification failed: z:OpenPGP signature verification failed: no signatures foundc              3   ó<   >#   • U  H  n[        TU5      v •  M     g 7frL   ræ   )rè   r2   rê   s     €r.   rë   Ú2PySequoiaSignatureVendor.verify.<locals>.<genexpr>~  s   øé € ÐQÂ[¸E”~ i°×7Ð7Â[ùrî   rï   rð   rV   )r  ÚSigÚ
from_bytesru   ÚRuntimeErrorr	   Ú
valid_sigsrn   rÖ   Úsigning_keyÚcertificaterø   r   rX   )
rI   rd   rs   r  r˜   rµ   rº   rR   Ú	valid_sigrê   s
   `        @r.   ru   ÚPySequoiaSignatureVendor.verify_  s"  ù€ ó 	ð	UØ—-‘-×*Ñ*¨9Ó5ˆCØ×%Ò%ØÔ";ÀsñˆFð × × ÜØLóð ð �;�;Ø&(ˆLØ#×.Ô.�	Ø×#Ñ# Y×%:Ñ%:¸I×<QÑ<QÐ$RÖSñ /ã)�	ÜÔQÀTÇ[Â[ÓQ×QÓQÙñ *ô %ðØ*˜^Ð+;¼DÀÇÁÓ<MÐ;NðPà)Ü! $§+¡+Ó.ñ	ð ð øô ó 	UÜÐ!HÈÈÐLÓMÐSTÐTûð	Uús   ˆ1D	 Ä	
D'ÄD"Ä"D')rÿ   r   rþ   )r;   r;   NNrL   )r<   r=   r>   r?   r@   rM   r   rH   ri   rj   ra   rk   rg   ru   rA   r;   r0   r.   r   r     s«   † ñð 24Ø,.Ø#Ø'+ñ!à.ð!ð *ð!ð ˜‘*ð	!ð
 ˜‘ Ñ$ð!ð 
õ!ð4 ð=˜$ó =ó ð=ñ!˜ð ! s¨T¡zð !¸Uõ !ðF&˜5ð &¨Uð &°t÷ &r0   r   c                   óÂ   • \ rS rSrSr  SS\S\\   S-  SS4S jjr\ SSS	S\\   S-  SS 4S
 jj5       r	\S\
4S j5       rSS\S\S-  S\4S jjrS\S\SS4S jrSrg)r   iˆ  z¨Signature vendor that uses gpgsm (GnuPG for S/MIME) for X.509 signatures.

Supports git config options:
- gpg.x509.program: Path to gpgsm command (defaults to 'gpgsm')
NÚgpgsm_commandrn   r   c                 ó:   • [         R                  X5        Xl        g)a  Initialize the X.509 signature vendor.

Args:
  gpgsm_command: Path to the gpgsm command (default: "gpgsm")
  keyids: Optional iterable of trusted certificate IDs for verification.
         If provided, only signatures from these certificates will be trusted.
N)r   rH   r!  )rI   r!  rn   s      r.   rH   ÚX509SignatureVendor.__init__�  s   € ô 	×"Ñ" 4Ô0Ø*Õr0   r|   r}   c                 ó€   • SnUb$   UR                  SS5      nUR                  S5      nU " X2S9$ ! [         a     Nf = f)zôCreate an X.509 vendor from git configuration.

Args:
  config: Git configuration to read settings from
  keyids: Optional iterable of trusted certificate IDs for verification

Returns:
  X509SignatureVendor instance configured from the config
Úgpgsm)r€   s   x509rÂ   r   )r!  rn   rÃ   )r`   r|   rn   r!  Úgpgsm_programs        r.   r…   ÚX509SignatureVendor.from_configž  sV   € ð  ˆØÑðØ &§
¡
Ð+<¸jÓ I�Ø -× 4Ñ 4°WÓ =�ñ  Ñ>Ð>øô ó ÙðúrÆ   c                 ó0   • SSK nUR                  S5      SL$ )zgCheck if the gpgsm command is available.

Returns:
  True if gpgsm command is in PATH, False otherwise
r   Nr%  rÈ   rË   s     r.   ra   ÚX509SignatureVendor.availableµ  s   € ó 	à�|‰|˜GÓ$¨DÐ0Ð0r0   rd   r2   c                 ó�   • SSK nU R                  SS/nUb  UR                  SU/5        UR                  UUSSS9nUR                  $ )a+  Sign data with an X.509 certificate using gpgsm.

Args:
  data: The data to sign
  keyid: Optional certificate ID to use for signing. If not specified,
         the default certificate will be used.

Returns:
  The signature as bytes

Raises:
  subprocess.CalledProcessError: if gpgsm command fails
r   NrÎ   rÏ   rÐ   TrÑ   )rÕ   r!  rÖ   r×   rØ   rÙ   s         r.   rg   ÚX509SignatureVendor.signÀ  s[   € ó 	à×"Ñ" O°YÐ?ˆØÑØ�K‰K˜¨Ð/Ô0à—‘ØØØØð	  ð 
ˆð �}‰}Ðr0   rs   c                 óŒ  ^• SSK nSSKnUR                  SSS9 nUR                  SSS9 nUR                  U5        UR	                  5         UR                  U5        UR	                  5         U R
                  SSUR                  UR                  /n UR                  US	S	S
9nU R                  (       a�  [        UR                  5      n
U
(       d  [        S5      eU
 H9  m[!        U4S jU R                   5       5      (       d  M)    SSS5        SSS5        g   [        SU
 S[#        U R                  5       3U
[#        U R                  5      S9e SSS5        SSS5        g! UR                   a,  n	[        SU	R                  R                  SSS9 35      U	eSn	A	ff = f! , (       d  f       NV= f! , (       d  f       g= f)zÿVerify an X.509 signature using gpgsm.

Args:
  data: The data that was signed
  signature: The signature to verify

Raises:
  BadSignature: if gpgsm signature verification fails
  UntrustedSignature: if signature was not created by a trusted certificate
r   NrÝ   rÞ   rß   rá   râ   rã   Trä   z%X.509 signature verification failed: r   r   r   z@Could not determine signing certificate from gpgsm status outputc              3   ó<   >#   • U  H  n[        TU5      v •  M     g 7frL   ræ   rç   s     €r.   rë   Ú-X509SignatureVendor.verify.<locals>.<genexpr>  rí   rî   z;Signature not created by a trusted certificate. Signed by: z, trusted certs: rV   )rÕ   rñ   rò   ró   rô   r!  rõ   r×   rö   r	   r÷   r$   rn   r/   rØ   r   rø   rX   )rI   rd   rs   rÕ   rñ   rù   rú   rÚ   rµ   rº   Úsigning_certsrê   s              @r.   ru   ÚX509SignatureVendor.verifyÜ  s·  ø€ ó 	Ûð ×'Ñ'¨T¸&Ð'ÑAÀXØ×'Ñ'¨T¸&Ð'ÑAÀYà�N‰N˜9Ô%Ø�N‰NÔà�O‰O˜DÔ!Ø�O‰OÔð ×"Ñ"ØØØ—‘Ø—‘ðˆDð	Ø#Ÿ™ØØ#'Øð (ð �ð �{�{ô !;¸6¿=¹=Ó I�æ$Ü,ØZóð ó "/�IÜÔMÀÇÂÓM×MÓMØ÷W B÷ BÐAñT "/ô
 )ð"Ø"/ Ð0AÄ$ÀtÇ{Á{ÓBSÐATðVà!.Ü!% d§k¡kÓ!2ñ	ð ð% ÷9 B÷ BÐAøð. ×0Ñ0ó Ü"Ø;¸A¿H¹H¿O¹OÈGÐ\e¸OÐ<fÐ;gÐhóàðûðú÷- BÕAú÷ BÕAúrü   )r!  )r%  NrW   rL   r¼   r;   r0   r.   r   r   ˆ  sÈ   † ñð %Ø'+ñ+àð+ð ˜‘ Ñ$ð+ð 
õ	+ð àLPñ?Ø$ð?Ø5=¸c±]ÀTÑ5Ið?à	ô?ó ð?ð, ð1˜$ó 1ó ð1ñ˜ð  s¨T¡zð ¸Uõ ð8D˜5ð D¨Uð D°t÷ Dr0   r   c                   ón  • \ rS rSrSr    S$S\S-  S\S-  S\S-  S\\   S-  SS4
S	 jjr\ S%S
SS\\   S-  SS 4S jj5       r	\S\
4S j5       rS\S\S   4S jrS\S\\   S\
4S jrS\S   S\S   4S jrS\S\4S jrSSS\SS4S jrS\S\S   4S jrSSS\S   SS4S jrS \S!\SS4S" jrS#rg)&r   i#  aË  Signature verifier that uses the sshsig Python package for SSH signature verification.

Note: This vendor only supports verification, not signing. The sshsig package
does not provide signing functionality. For signing, use SSHCliSignatureVendor.

Supports git config options:
- gpg.ssh.allowedSignersFile: File containing allowed SSH public keys
- gpg.ssh.revocationFile: File containing revoked SSH public keys
- gpg.ssh.defaultKeyCommand: Command to get default SSH key (currently unused)

For SSH signatures, keyids are interpreted as principals (identities) like
"user@example.com", consistent with Git's SSH signature model. When keyids
are provided, the allowed_signers_file must also be configured, and only
signatures from keys associated with those principals will be trusted.

Security features:
- Key lifetime validation: Checks valid-after and valid-before options in allowed_signers
- Revocation checking: Verifies keys against revocation file if configured
NÚallowed_signers_fileÚrevocation_fileÚdefault_key_commandrn   r   c                 óR   • [         R                  X5        Xl        X l        X0l        g)a(  Initialize the SSH signature verifier.

Args:
  allowed_signers_file: Path to allowed signers file
  revocation_file: Path to file containing revoked SSH public keys
  default_key_command: Command to get default SSH key (currently unused)
  keyids: Optional iterable of trusted principals (identities) like
         "user@example.com". If provided, requires allowed_signers_file
         to be configured. Only signatures from keys associated with
         these principals will be trusted. This matches Git's -I flag
         in ssh-keygen -Y verify.
N)r   rH   r2  r3  r4  )rI   r2  r3  r4  rn   s        r.   rH   ÚSSHSigSignatureVendor.__init__8  s$   € ô& 	×"Ñ" 4Ô0Ø$8Ô!Ø.ÔØ#6Õ r0   r|   r}   c                 óˆ  • SnSnSnUb�   UR                  SS5      nU(       a  UR                  S5      n UR                  SS5      nU(       a  UR                  S5      n UR                  SS5      nU(       a  UR                  S5      nU " UUUUS9$ ! [         a     Nkf = f! [         a     NPf = f! [         a     N5f = f)a  Create an SSH signature verifier from git configuration.

Args:
  config: Git configuration to read settings from
  keyids: Optional iterable of trusted SSH key fingerprints for verification

Returns:
  SSHSigSignatureVendor instance configured from the config
N©r€   s   sshó   allowedSignersFiler   ó   revocationFileó   defaultKeyCommand)r2  r3  r4  rn   rÃ   )	r`   r|   rn   r2  r3  r4  Úsigners_fileÚ
revoc_fileÚkey_commands	            r.   r…   Ú!SSHSigSignatureVendor.from_configP  sð   € ð  $ÐØˆØ"ÐàÑðØ%Ÿz™zÐ*:Ð<QÓR�ÞØ+7×+>Ñ+>¸wÓ+GÐ(ðØ#ŸZ™ZÐ(8Ð:KÓL�
ÞØ&0×&7Ñ&7¸Ó&@�OðØ$Ÿj™jÐ)9Ð;OÓP�ÞØ*5×*<Ñ*<¸WÓ*EÐ'ñ Ø!5Ø+Ø 3Øñ	
ð 	
øô# ó Ùðûô ó Ùðûô ó Ùðús4   ‹*B ¶*B$ Á!*B4 Â
B!Â B!Â$
B1Â0B1Â4
CÃ Cc                 óD   • SSK nUR                  R                  S5      SL$ )zuCheck if the sshsig Python package is available.

Returns:
  True if sshsig package can be imported, False otherwise
r   NÚsshsigr‰   r�   s     r.   ra   ÚSSHSigSignatureVendor.available~  s!   € ó 	à�~‰~×'Ñ'¨Ó1¸Ð=Ð=r0   Úpathz$sshsig.allowed_signers.AllowedSignerc                 óL  • SSK nSSKn [        UR                  U5      5       n[	        UR
                  R                  U5      5      sSSS5        $ ! , (       d  f       g= f! [         a  n[        SU 35      UeSnAf[        [        4 a  n[        SU 35      UeSnAff = f)zÅLoad and parse an allowed_signers file.

Args:
  path: Path to the allowed_signers file

Returns:
  List of AllowedSigner objects

Raises:
  UntrustedSignature: if file not found or invalid format
r   Nz Allowed signers file not found: z%Invalid allowed signers file format: )ÚpathlibÚsshsig.allowed_signersÚopenÚPathrX   Úallowed_signersÚload_allowed_signers_fileÚFileNotFoundErrorr   r  ÚUnicodeDecodeError)rI   rC  rE  rA  Úfrº   s         r.   Ú_load_allowed_signers_fileÚ0SSHSigSignatureVendor._load_allowed_signers_file‰  s–   € ó 	ã%ð	Ü�g—l‘l 4Ó(Ô)¨QÜ˜F×2Ñ2×LÑLÈQÓOÓP÷ *×)×)ûä ó 	WÜ$Ð'GÈÀvÐ%NÓOÐUVÐVûÜÔ.Ð/ó 	Ü$Ø7¸°vÐ>óàðûð	ús@   ŠA# ¤$AÁ	A# Á
A ÁA# Á A# Á#
B#Á-A<Á<B#ÂBÂB#Úsigner_principalsÚallowed_principalsc                 ó¢   ^• US:X  a  gUR                  S5       Vs/ s H  o3R                  5       PM     nn[        U4S jU 5       5      $ s  snf )aŒ  Check if a signer's principals match any of the allowed principals.

Args:
  signer_principals: Comma-separated principals from allowed_signers file
                    (e.g., "user1@example.com,user2@example.com" or "*")
  allowed_principals: List of principals to match against

Returns:
  True if any signer principal matches any allowed principal, or if
  signer_principals is "*" (wildcard)
Ú*TÚ,c              3   ó,   >#   • U  H	  oT;   v •  M     g 7frL   r;   )rè   ÚsprQ  s     €r.   rë   Ú;SSHSigSignatureVendor._principal_matches.<locals>.<genexpr>º  s   øé € ÐLÒ6K°Ð+Ö+Ò6Kùs   ƒ)r(   Ústriprø   )rI   rP  rQ  ÚpÚsigner_principal_lists     `  r.   Ú_principal_matchesÚ(SSHSigSignatureVendor._principal_matches¥  sS   ø€ ð  Ó#Øð 5F×4KÑ4KÈCÔ4PÓ QÒ4P¨q§¡¦Ñ4PÐÐ Qô ÔLÑ6KÓLÓLÐLùò !Rs   œAr’   zsshsig.ssh_public_key.PublicKeyc           	      ó®  • SSK n/ nU HU  n UR                   SUR                   3nUR                  R                  R                  U5      nUR                  U5        MW     U$ ! [        [        4 a,  n[        SUR                   SUR                   S35      UeSnAf[         a,  n[        SUR                   SUR                   S35      UeSnAff = f)zÅConvert AllowedSigner objects to PublicKey objects.

Args:
  signers: List of AllowedSigner objects

Returns:
  List of PublicKey objects

Raises:
  UntrustedSignature: if any key cannot be parsed
r   Nr4   z3Failed to parse SSH key from allowed_signers file: z (principal: Ú)zUnsupported SSH key algorithm: )Ússhsig.ssh_public_keyÚkey_typeÚ
base64_keyÚssh_public_keyÚ	PublicKeyÚfrom_openssh_strr)   r  rL  r   Ú
principalsrf   )rI   r’   rA  r·   r  Úopenssh_strrœ   rº   s           r.   Ú_signers_to_keysÚ&SSHSigSignatureVendor._signers_to_keys¼  sô   € ó 	%à68ˆÛˆFðØ!'§¡Ð 1°°6×3DÑ3DÐ2EÐF�Ø×+Ñ+×5Ñ5×FÑFÀ{ÓS�Ø—‘˜CÖ ñ	 ð ˆøô Ô 2Ð3ó Ü(ØIØ—‘Ð' }°V×5FÑ5FÐ4GÀqðJóð ðûô 'ó Ü(Ø5°f·o±oÐ5Fð G#Ø#)×#4Ñ#4Ð"5°Qð8óð ðûðús$   �AA$Á$CÁ4'BÂCÂ('CÃCÚtimestamp_strc                 óð  • SSK nUR                  S5      n [        U5      =S:X  a    UR                   R                  US5      nOU=S:X  a    UR                   R                  US5      nO1S:X  a  UR                   R                  US	5      nO [	        S
U 35      e[        UR                  UR                  R                  S9R                  5       5      $ ! [         a  n[	        SU SU 35      UeSnAff = f)a  Parse SSH timestamp format to Unix timestamp.

Supports Git's SSH timestamp formats:
- YYYYMMDD[Z]
- YYYYMMDDHHMM[SS][Z]

Args:
  timestamp_str: Timestamp string to parse

Returns:
  Unix timestamp (seconds since epoch)

Raises:
  UntrustedSignature: if timestamp format is invalid
r   NÚZé   z%Y%m%dé   z
%Y%m%d%H%Mé   z%Y%m%d%H%M%SzInvalid SSH timestamp format: )ÚtzinfozFailed to parse SSH timestamp ú: )ÚdatetimeÚrstripr'   Ústrptimer   Úintr   ÚtimezoneÚutcÚ	timestampr  )rI   ri  rq  ÚtsÚdtrº   s         r.   Ú_parse_ssh_timestampÚ*SSHSigSignatureVendor._parse_ssh_timestampÞ  sí   € ó  	ð ×!Ñ! #Ó&ˆð	Ü�b“'ÞØ!×*Ñ*×3Ñ3°B¸ÓA‘BÞØ!×*Ñ*×3Ñ3°B¸ÓE‘BÜØ!×*Ñ*×3Ñ3°B¸ÓG‘BØÜ,Ø8¸¸ÐHóð ô
 �r—z‘z¨×):Ñ):×)>Ñ)>�zÐ?×IÑIÓKÓLÐLøÜó 	Ü$Ø0°°¸rÀ!ÀÐEóàðûð	ús   —B<C Ã
C5ÃC0Ã0C5r  Úcurrent_timec                 óf  • UR                   c  gSUR                   ;   aA  UR                   S   nU R                  U5      nX$:  a  [        SU SUR                   S35      eSUR                   ;   aB  UR                   S   nU R                  U5      nX&:¼  a  [        SU SUR                   S35      egg)zôCheck if a key is within its valid lifetime.

Args:
  signer: AllowedSigner object with optional lifetime constraints
  current_time: Current Unix timestamp to check against

Raises:
  UntrustedSignature: if key is not yet valid or has expired
Nzvalid-afterz$SSH key not yet valid (valid-after: z, principal: r^  zvalid-beforez#SSH key has expired (valid-before: )Úoptionsrz  r   re  )rI   r  r|  Úvalid_after_strÚvalid_afterÚvalid_before_strÚvalid_befores          r.   Ú_check_key_lifetimeÚ)SSHSigSignatureVendor._check_key_lifetime  sÞ   € ð �>‰>Ñ!Øð ˜FŸN™NÓ*Ø$Ÿn™n¨]Ñ;ˆOØ×3Ñ3°OÓDˆKØÓ)Ü(Ø:¸?Ð:Kð L"Ø"(×"3Ñ"3Ð!4°Að7óð ð ˜VŸ^™^Ó+Ø%Ÿ~™~¨nÑ=ÐØ×4Ñ4Ð5EÓFˆLØÓ+Ü(Ø9Ð:JÐ9Kð L"Ø"(×"3Ñ"3Ð!4°Að7óð ð ,ð ,r0   c                 ó”  • SSK nSSKn/ n [        UR                  U5      5       n[	        US5       Hk  u  pgUR                  5       nU(       a  UR                  S5      (       a  M4   UR                  R                  R                  U5      nUR                  U5        Mm     SSS5        U$ ! [        [        4 a  n	[        SU SU SU	 35      U	eSn	A	f[         a  n	[        SU SU SU	 35      U	eSn	A	ff = f! , (       d  f       U$ = f! [         a  n	[        S	U 35      U	eSn	A	f[         a  n	[        S
U 35      U	eSn	A	ff = f)aL  Load revoked SSH public keys from a revocation file.

The revocation file format is the same as authorized_keys:
each line contains a public key in OpenSSH format.

Args:
  path: Path to the revocation file

Returns:
  List of revoked PublicKey objects

Raises:
  UntrustedSignature: if file cannot be read or contains invalid keys
r   Nr"   Ú#zFailed to parse revoked key at Ú:rp  z4Unsupported SSH key algorithm in revocation file at zRevocation file not found: z&Revocation file has invalid encoding: )rE  r_  rG  rH  Ú	enumeraterX  r&   rb  rc  rd  r)   r  rL  r   rf   rK  )
rI   rC  rE  rA  Úrevoked_keysrM  Úline_numr,   rœ   rº   s
             r.   Ú_load_revoked_keysÚ(SSHSigSignatureVendor._load_revoked_keys*  sh  € ó 	ã$à>@ˆð	Ü�g—l‘l 4Ó(Ô)¨QÜ&/°°1¦o‘N�HØŸ:™:›<�DÞ 4§?¡?°3×#7Ñ#7Ù ð!Ø$×3Ñ3×=Ñ=×NÑNÈtÓT˜Ø$×+Ñ+¨CÖ0ñ '6÷ *ð2 Ðøô! 'Ô(:Ð;ó !Ü0Ø=¸d¸VÀ1ÀXÀJÈbÐQRÐPSÐTóà ð!ûô /ó !Ü0ð"Ø"&  q¨¨
°"°Q°Cð9óð  !ð!ûð!ú÷ *Ô)ð2 Ðûô !ó 	RÜ$Ð'BÀ4À&Ð%IÓJÐPQÐQûÜ!ó 	Ü$Ø8¸¸Ð?óàðûð	úsq   ŒD ¦AC;Á(6B,ÂC;Â"D Â,C8Â<CÃC8ÃC3Ã3C8Ã8C;Ã;
D
ÄD Ä
D Ä
EÄD&Ä&EÄ3EÅErœ   r‰  c                 ó6   • U H  nX:X  d  M
  [        S5      e   g)z¯Check if a key has been revoked.

Args:
  key: PublicKey to check
  revoked_keys: List of revoked PublicKey objects

Raises:
  UntrustedSignature: if the key has been revoked
zSSH key has been revokedN)r   )rI   rœ   r‰  Úrevoked_keys       r.   Ú_check_not_revokedÚ(SSHSigSignatureVendor._check_not_revoked[  s    € ó (ˆKØÕ!Ü(Ð)CÓDÐDò (r0   rd   rs   c           	      ó  • SSK nU R                  (       d  [        S5      eU R                  U R                  5      nU R                  (       aw  U Vs/ s H;  nU R                  UR                  [        U R                  5      5      (       d  M9  UPM=     nnU(       d'  [        SSR                  U R                  5       35      eOUnSSK	n[        UR                  5       5      nU H  n	U R                  X˜5        M     / n
U R                  (       a  U R                  U R                  5      n
U R                  U5      nU
(       a  U H  nU R                  XÊ5        M     U(       d  [        S5      e[!        U["        5      (       a  UR%                  S5      OUn UR&                  R)                  UUUSS	9  gs  snf ! UR&                  R*                   a  n[-        S
U 35      UeSnAf[.         a  n[-        SU 35      UeSnAff = f)ai  Verify an SSH signature using the sshsig package.

Args:
  data: The data that was signed
  signature: The SSH signature to verify (armored format)

Raises:
  UntrustedSignature: if no allowed signers are configured or if
                     signature is not from a trusted principal
  BadSignature: if signature verification fails

Note:
  For SSH signatures, keyids are interpreted as principals (identities)
  like "user@example.com", consistent with Git's SSH signature model.
  When keyids are provided, only signatures from keys associated with
  those principals (or wildcard "*" principals) will be trusted.
r   NúOSSH signature verification requires gpg.ssh.allowedSignersFile to be configuredzNo keys found for principals: z, zNo valid allowed signers foundr   Úgit)Úmsg_inÚarmored_signaturerI  Ú	namespaceú#SSH signature verification failed: z1SSH signature uses unsupported encoding feature: )Ússhsig.sshsigr2  r   rN  rn   r[  re  rX   ÚjoinÚtimert  rƒ  r3  r‹  rg  r�  rš   rk   r$   rA  ru   ÚInvalidSignaturer	   rf   )rI   rd   rs   rA  Úall_signersÚsÚfiltered_signersrš  r|  r  r‰  Úallowed_keysrœ   Úsig_strrº   s                  r.   ru   ÚSSHSigSignatureVendor.verifym  sö  € ó$ 	à×(×(Ü$ð#óð ð ×5Ñ5°d×6OÑ6OÓPˆð �;�;ñ %ó â$�AØ×*Ñ*¨1¯<©<¼¸d¿k¹kÓ9J×K÷ Ù$ð ð  ö $Ü(Ø4°T·Y±Y¸t¿{¹{Ó5KÐ4LÐMóð ð $ð
  +Ðó 	ä˜4Ÿ9™9›;Ó'ˆÛ&ˆFØ×$Ñ$ VÖ:ñ 'ð ACˆØ××Ø×2Ñ2°4×3GÑ3GÓHˆLð ×,Ñ,Ð-=Ó>ˆö Û#�Ø×'Ñ'¨Ö:ñ $ö Ü$Ð%EÓFÐFô *4°I¼u×)EÑ)EˆI×Ñ˜WÔ%È9ð 	ð	Ø�M‰M× Ñ ØØ")Ø ,Øð	 !ò ùòU øð` �}‰}×-Ñ-ó 	QÜÐ!DÀQÀCÐHÓIÈqÐPûÜ"ó 	ÜØCÀAÀ3ÐGóàðûð	ús0   Á8F5ÂF5ÆF: Æ:HÇG#Ç#HÇ0G?Ç?H)r2  r4  r3  )NNNNrW   )r<   r=   r>   r?   r@   rM   r   rH   ri   r…   rj   ra   rX   rN  r[  rg  rt  rz  rƒ  r‹  r�  rk   ru   rA   r;   r0   r.   r   r   #  sª  † ñð, ,0Ø&*Ø*.Ø'+ñ7à! D™jð7ð ˜t™ð7ð ! 4™Zð	7ð
 ˜‘ Ñ$ð7ð 
õ7ð0 àLPñ+
Ø$ð+
Ø5=¸c±]ÀTÑ5Ið+
à	 ô+
ó ð+
ðZ ð>˜$ó >ó ð>ðØðà	Ð4Ñ	5ôð8MØ!$ðMØ:>¸s¹)ðMà	ôMð. ØÐBÑCð à	Ð/Ñ	0ô ðD'°#ð '¸#ô 'ðR!Ø<ð!ØLOð!à	ô!ðF/ sð /¨tÐ4UÑ/Vô /ðbEà.ðEð Ð<Ñ=ðEð 
ô	Eð$T˜5ð T¨Uð T°t÷ Tr0   r   c                   óæ   • \ rS rSrSr     SS\S\S-  S\S-  S\S-  S\\   S-  S	S4S
 jjr\ SSSS\\   S-  S	S 4S jj5       r	\S	\
4S j5       rSS\S\S-  S	\4S jjrS\S\S	S4S jrSrg)r   iÄ  ah  Signature vendor that uses ssh-keygen command-line tool for SSH signatures.

Supports git config options:
- gpg.ssh.allowedSignersFile: File containing allowed SSH public keys
- gpg.ssh.revocationFile: File containing revoked SSH public keys
- gpg.ssh.program: Path to ssh-keygen command
- gpg.ssh.defaultKeyCommand: Command to get default SSH key for signing
NÚssh_commandr2  r3  r4  rn   r   c                 ó^   • [         R                  X5        Xl        X l        X0l        X@l        g)aŸ  Initialize the SSH CLI vendor.

Args:
  ssh_command: Path to ssh-keygen command (default: "ssh-keygen")
  allowed_signers_file: Path to allowed signers file
  revocation_file: Path to revocation file
  default_key_command: Command to get default SSH key for signing
  keyids: Optional iterable of trusted SSH key fingerprints for verification.
         If provided, only signatures from these keys will be trusted.
N)r   rH   r£  r2  r3  r4  )rI   r£  r2  r3  r4  rn   s         r.   rH   ÚSSHCliSignatureVendor.__init__Î  s*   € ô$ 	×"Ñ" 4Ô0Ø&ÔØ$8Ô!Ø.ÔØ#6Õ r0   r|   r}   c                 óö  • SnSnSnSnUb¥   UR                  SS5      nUR                  S5      n UR                  SS5      nU(       a  UR                  S5      n UR                  SS5      n	U	(       a  U	R                  S5      n UR                  SS5      n
U
(       a  U
R                  S5      nU " UUUUUS	9$ ! [         a     N—f = f! [         a     N|f = f! [         a     Naf = f! [         a     NFf = f)
zýCreate an SSH CLI vendor from git configuration.

Args:
  config: Git configuration to read settings from
  keyids: Optional iterable of trusted SSH key fingerprints for verification

Returns:
  SSHCliSignatureVendor instance configured from the config
ú
ssh-keygenNr8  rÂ   r   r9  r:  r;  )r£  r2  r3  r4  rn   rÃ   )r`   r|   rn   r£  r2  r3  r4  Ússh_programr<  r=  r>  s              r.   r…   Ú!SSHCliSignatureVendor.from_configæ  s1  € ð #ˆØ#ÐØˆØ"ÐàÑðØ$Ÿj™jÐ)9¸:ÓF�Ø)×0Ñ0°Ó9�ðØ%Ÿz™zÐ*:Ð<QÓR�ÞØ+7×+>Ñ+>¸wÓ+GÐ(ðØ#ŸZ™ZÐ(8Ð:KÓL�
ÞØ&0×&7Ñ&7¸Ó&@�OðØ$Ÿj™jÐ)9Ð;OÓP�ÞØ*5×*<Ñ*<¸WÓ*EÐ'ñ Ø#Ø!5Ø+Ø 3Øñ
ð 	
øô1 ó Ùðûô ó Ùðûô ó Ùðûô ó ÙðúsF   �#B; ±*C Á*C Â*C+ Â;
CÃCÃ
CÃCÃ
C(Ã'C(Ã+
C8Ã7C8c                 ó0   • SSK nUR                  S5      SL$ )zqCheck if the ssh-keygen command is available.

Returns:
  True if ssh-keygen command is in PATH, False otherwise
r   Nr§  rÈ   rË   s     r.   ra   ÚSSHCliSignatureVendor.available  s   € ó 	à�|‰|˜LÓ)°Ð5Ð5r0   rd   r2   c           	      ó¬  • SSK nSSKnSSKnUcf  U R                  (       aJ  UR	                  U R                  SSSSS9nUR
                  R                  5       nU(       d  [        S5      eO[        S5      eUR                  5        nUR                  R                  US5      nUS-   n	[        US	5       n
U
R                  U5        SSS5        U R                  S
SSUSSU/nUR	                  USSS9  [        U	S5       nUR                  5       nSSS5        WsSSS5        $ ! , (       d  f       Nc= f! , (       d  f       N*= f! , (       d  f       g= f)ap  Sign data with an SSH key using ssh-keygen.

Args:
  data: The data to sign
  keyid: Path to SSH private key. If not specified, will try to get
        default key from gpg.ssh.defaultKeyCommand

Returns:
  The signature as bytes

Raises:
  subprocess.CalledProcessError: if ssh-keygen command fails
  ValueError: if keyid is not provided and no default key available
r   NT)ÚshellrÓ   rÔ   Útextz,gpg.ssh.defaultKeyCommand returned empty keyziSSH signing requires a key to be specified via keyid parameter or gpg.ssh.defaultKeyCommand configurationúdata.gitrÞ   rÝ   ú-Yrg   ú-fú-nr“  rä   Úrb)ÚosrÕ   rñ   r4  r×   rØ   rX  r  ÚTemporaryDirectoryrC  r™  rG  ró   r£  Úread)rI   rd   r2   r´  rÕ   rñ   rµ   ÚtmpdirÚdata_filenameÚsig_filenamerú   rÚ   rù   rs   s                 r.   rg   ÚSSHCliSignatureVendor.sign'  sP  € ó 	ÛÛð ‰=Ø×'×'à#Ÿ™Ø×,Ñ,ØØ#'ØØð (ð �ð Ÿ™×+Ñ+Ó-�ÞÜ$Ð%SÓTÐTð ô !ðAóð ð ×(Ñ(Ô*¨fØŸG™GŸL™L¨°Ó<ˆMØ(¨6Ñ1ˆLô �m TÔ*¨iØ—‘ Ô%÷ +ð
 × Ñ ØØØØØØØð	ˆDð �N‰N˜4°¸DˆNÑAô �l DÔ)¨XØ$ŸM™M›O�	÷ *ð ÷5 +Ñ*÷
 +Õ*ú÷$ *Õ)ú÷/ +Õ*ús<   Â.EÂ4D#Ã9EÃ?D4Ä	EÄ#
D1	Ä-EÄ4
E	Ä>EÅ
Ers   c                 óª  • SSK nSSKnSSKnU R                  b  [	        S5      eU R
                  c  [	        S5      eUR                  5        nUR                  R                  US5      nUR                  R                  US5      n[        US5       n	U	R                  U5        SSS5        [        US5       n
U
R                  U5        SSS5        U R                  SS	S
U R
                  SSSSSU/nU R                  (       a  UR                  SU R                  /5         [        US5       n	UR                  UU	SSS9  SSS5        SSS5        g! , (       d  f       N´= f! , (       d  f       NŸ= f! , (       d  f       N9= f! UR                   a,  n[!        SUR"                  R%                  SSS9 35      UeSnAff = f! , (       d  f       g= f)zîVerify an SSH signature using ssh-keygen.

Args:
  data: The data that was signed
  signature: The signature to verify

Raises:
  BadSignature: if signature verification fails
  UntrustedSignature: if allowedSignersFile is not configured
r   NzjSSHCliSignatureVendor does not yet support keyids filtering. This will be implemented in a future version.r’  r¯  zdata.git.sigrÝ   r°  ru   r±  z-Ir“  r²  z-sz-rr³  T)ÚstdinrÓ   rÔ   r—  r   r   r   )r´  rÕ   rñ   rn   r   r2  rµ  rC  r™  rG  ró   r£  r3  rÖ   r×   rö   r	   r÷   r$   )rI   rd   rs   r´  rÕ   rñ   r·  r¸  r¹  rú   rù   rÚ   rº   s                r.   ru   ÚSSHCliSignatureVendor.verifyl  s¿  € ó 	ÛÛð �;‰;Ñ"Ü$ð@óð ð
 ×$Ñ$Ñ,Ü$ð#óð ð ×(Ñ(Ô*¨fØŸG™GŸL™L¨°Ó<ˆMØŸ7™7Ÿ<™<¨°Ó?ˆLô �m TÔ*¨iØ—‘ Ô%÷ +ô �l DÔ)¨XØ—‘˜yÔ)÷ *ð × Ñ ØØØØ×)Ñ)ØØØØØØðˆDð ×#×#Ø—‘˜T 4×#7Ñ#7Ð8Ô9ðÜ˜-¨Ô.°)Ø—N‘NØØ'Ø'+Ø"ð	 #ñ ÷ /÷A +Ð*÷
 +Õ*ú÷ *Õ)ú÷0 /Õ.ûð ×0Ñ0ó Ü"Ø9¸!¿(¹(¿/¹/È'ÐZc¸/Ð:dÐ9eÐfóàðûðú÷O +Õ*ús€   ÁAGÂEÂ$GÂ8E#Ã
AGÄ"FÄ.E4ÅFÅ
E 	ÅGÅ#
E1	Å-GÅ4
F	Å>FÆGÆFÆGÆ'F<Æ<GÇGÇ
G)r2  r4  r3  r£  )r§  NNNNrW   rL   r¼   r;   r0   r.   r   r   Ä  s  † ñð (Ø+/Ø&*Ø*.Ø'+ñ7àð7ð " D™jð7ð ˜t™ð	7ð
 ! 4™Zð7ð ˜‘ Ñ$ð7ð 
õ7ð0 àLPñ3
Ø$ð3
Ø5=¸c±]ÀTÑ5Ið3
à	 ô3
ó ð3
ðj ð6˜$ó 6ó ð6ñC˜ð C s¨T¡zð C¸Uõ CðJG˜5ð G¨Uð G°t÷ Gr0   r   Úformatr|   r}   c                 óÆ  • U c;  Ub2   UR                  SS5      nU(       a  UR                  S5      O[        n O[        n U R	                  5       nU[        :X  ac  [
        R                  5       (       a  [
        R                  US9$ [        R                  5       (       a  [        R                  US9$ [        S5      eU[        :X  a7  [        R                  5       (       a  [        R                  US9$ [        S5      eU[        :X  a7  [        R                  5       (       a  [        R                  US9$ [        S5      e[        SU  35      e! [         a
    [        n  GN f = f)	aÆ  Get a signature signer for the specified format.

Args:
  format: Signature format. If None, reads from config's gpg.format setting.
          Supported values:
          - "openpgp": Use OpenPGP/GPG signatures (default)
          - "x509": Use X.509 signatures
          - "ssh": Use SSH signatures
  config: Optional Git configuration

Returns:
  Signature signer instance for the requested format

Raises:
  ValueError: if the format is not supported
r   s   formatr   )r|   ú=No GPG vendor available (neither gpg package nor gpg command)ú0gpgsm command not available for X.509 signaturesz3ssh-keygen command not available for SSH signaturesúUnsupported signature format: )r�   r$   r   rƒ   r‚   r   ra   r…   r
   r  r   r   r   r   )r¾  r|   Úformat_bytesÚformat_lowers       r.   r   r   ¶  sM  € ð( �~ØÑð2Ø%Ÿz™z¨)°YÓ?�ö $ð !×'Ñ'¨Ô0ä1ñ ô .ˆFà—<‘<“>€LàÔ/Ó/ä×'Ñ'×)Ñ)Ü%×1Ñ1¸Ð1Ð@Ð@Ü"×,Ñ,×.Ñ.Ü(×4Ñ4¸FÐ4ÐCÐCäØOóð ð 
Ô.Ó	.Ü×(Ñ(×*Ñ*Ü&×2Ñ2¸&Ð2ÐAÐAäÐOÓPÐPØ	Ô-Ó	-ä ×*Ñ*×,Ñ,Ü(×4Ñ4¸FÐ4ÐCÐCäÐRÓSÐSäÐ9¸&¸ÐBÓCÐCøô; ó 2Ü1“ð2ús   ˆ0E ÅE ÅE rs   c                 óÀ   • U R                  S5      (       a  [        $ U R                  S5      (       a  [        $ U R                  S5      (       a  [        $ [	        S5      e)a,  Detect the signature format from the signature data.

Git signatures are always in ASCII-armored format.

Args:
  signature: The signature bytes

Returns:
  Signature format constant (SIGNATURE_FORMAT_OPENPGP, SIGNATURE_FORMAT_SSH, etc.)

Raises:
  ValueError: if signature format cannot be detected
s   -----BEGIN SSH SIGNATURE-----s   -----BEGIN PGP SIGNATURE-----)s   -----BEGIN SIGNED MESSAGE-----s   -----BEGIN PKCS7-----z!Unable to detect signature format)r&   r   r   r   r  r¦   s    r.   r   r   ó  sb   € ð ×ÑÐ<×=Ñ=Ü#Ð#ð ×ÑÐ<×=Ñ=Ü'Ð'ð ×ÑØE÷ñ ô %Ð$ä
Ð8Ó
9Ð9r0   rn   c                 óŠ  • [        U 5      nUR                  5       nU[        :X  ac  [        R	                  5       (       a  [        R                  XS9$ [        R	                  5       (       a  [        R                  XS9$ [        S5      eU[        :X  a7  [        R	                  5       (       a  [        R                  XS9$ [        S5      eU[        :X  ac  [        R	                  5       (       a  [        R                  XS9$ [        R	                  5       (       a  [        R                  XS9$ [        S5      e[        SU 35      e)a!  Get the appropriate signature vendor for a given signature.

This function detects the signature format and returns the appropriate
vendor to verify it.

Args:
  signature: The signature bytes to detect format from
  config: Optional Git configuration
  keyids: Optional iterable of trusted key IDs for verification.
         If provided, only signatures from these keys will be trusted.

Returns:
  Signature vendor instance appropriate for the signature format

Raises:
  ValueError: if signature format cannot be detected or is not supported
)r|   rn   rÀ  rÁ  zGNo SSH vendor available (neither sshsig package nor ssh-keygen command)rÂ  )r   r‚   r   r   ra   r…   r
   r  r   r   r   r   r   )rs   r|   rn   r¾  rÄ  s        r.   r   r     s(  € ô, % YÓ/€FØ—<‘<“>€Lð Ô/Ó/ä×'Ñ'×)Ñ)Ü%×1Ñ1¸Ð1ÐOÐOÜ"×,Ñ,×.Ñ.Ü(×4Ñ4¸FÐ4ÐRÐRäØOóð ð 
Ô.Ó	.Ü×(Ñ(×*Ñ*Ü&×2Ñ2¸&Ð2ÐPÐPäÐOÓPÐPØ	Ô-Ó	-ä ×*Ñ*×,Ñ,Ü(×4Ñ4¸FÐ4ÐRÐRÜ"×,Ñ,×.Ñ.Ü(×4Ñ4¸FÐ4ÐRÐRäØYóð ô Ð9¸&¸ÐBÓCÐCr0   c                  ó˜  • 0 n / n[         R                  5       (       a  UR                  [         5        [        R                  5       (       a  UR                  [        5        [        R                  5       (       a  UR                  [        5        U(       a  X[
        '   / n[        R                  5       (       a  UR                  [        5        U(       a  X [        '   / n[        R                  5       (       a  UR                  [        5        [        R                  5       (       a  UR                  [        5        U(       a  X0[        '   U $ )a‚  Get all available signature vendors on this system.

Returns a dictionary mapping signature format names to lists of available
vendor classes for each format. Only vendors whose dependencies are available
are included.

Returns:
  Dictionary mapping format names (e.g. "openpgp", "ssh", "x509") to lists
  of available vendor classes. If no vendors are available for a format,
  that format will not be present in the dictionary.

Example:
  >>> vendors = get_available_vendors()
  >>> if "openpgp" in vendors:
  ...     print(f"GPG vendors: {vendors['openpgp']}")
  >>> if "ssh" in vendors:
  ...     print(f"SSH vendors: {vendors['ssh']}")
)r   ra   r)   r
   r   r   r   r   r   r   r   )ra   Úopenpgp_vendorsÚx509_vendorsÚssh_vendorss       r.   r   r   I  s  € ð* SU€Ið NP€OÜ×#Ñ#×%Ñ%Ø×ÑÔ1Ô2Ü×&Ñ&×(Ñ(Ø×ÑÔ4Ô5Ü×)Ñ)×+Ñ+Ø×ÑÔ7Ô8ÞØ.=Ô*Ñ+ð KM€LÜ×$Ñ$×&Ñ&Ø×ÑÔ/Ô0ÞØ+7Ô'Ñ(ð JL€KÜ×&Ñ&×(Ñ(Ø×ÑÔ0Ô1Ü×&Ñ&×(Ñ(Ø×ÑÔ0Ô1ÞØ*5Ô&Ñ'àÐr0   rW   ))r@   Úcollections.abcr   Útypingr   rF  rA  r_  r  r  Údulwich.configr   Ú__all__rk   rX   rM   r/   rj   r8   Ú	Exceptionr   r	   r   r   r   r   r   r   r   r
   r   r   r   r   r   r   r   ÚdictÚtyper   r   r;   r0   r.   Ú<module>rÒ     s  ðñ, ?å $Ý  æðÛ%Û$ðÛõ &ò€ð. uð °°c±ô ð4	F ð 	F¨Cð 	F°Dô 	Fô> ô >ôÐ-ô ô$/Ð3ô /ð6 %Ð ØÐ ØÐ ÷-ñ -÷4 /ñ  /ôFVQ˜Ð*;ô VQôrV˜OÐ->ô Vôry˜Ð0Aô yôxX˜/Ð+<ô Xôv^Ð-ô ^ôBo˜OÐ->ô oðf :>ñ:DØ�$‰Jð:DØ'6ð:Dàõ:Dðz: uð :°ô :ðB #Ø#'ñ4DØð4Dàð4Dð �S‰M˜DÑ ð4Dð õ	4Dðn2˜tØˆˆd�?Ñ# dÐ+<Ñ&=Ñ=Ñ	>Ð>ñ ô 2ñl  Ó!�
øðA3 ó Úðûð
 ó Úðús"   —D  D% ÄD"Ä!D"Ä%D/Ä.D/