@@ -87,6 +87,26 @@ impl Sig {
8787 . map ( |issuer| format ! ( "{issuer:x}" ) )
8888 }
8989
90+ /// The short key ID of the key that made this signature, as a lowercase hex string.
91+ ///
92+ /// Returns ``None`` if the signature does not carry an issuer key ID subpacket.
93+ /// Prefer ``issuer_fingerprint`` over this where possible, as key IDs are not collision-resistant.
94+ #[ getter]
95+ pub fn issuer_key_id ( & self ) -> Option < String > {
96+ self . sig . issuers ( ) . next ( ) . map ( |id| format ! ( "{id:x}" ) )
97+ }
98+
99+ /// The User ID of the signer, as declared in the signature's Signer's User ID subpacket.
100+ ///
101+ /// Returns ``None`` if the signature does not carry a Signer's User ID subpacket.
102+ /// Note that this value is self-reported by the signer and is not verified against any cert.
103+ #[ getter]
104+ pub fn signers_user_id ( & self ) -> Option < String > {
105+ self . sig
106+ . signers_user_id ( )
107+ . map ( |uid| String :: from_utf8_lossy ( uid) . into_owned ( ) )
108+ }
109+
90110 /// The time at which this signature was created.
91111 ///
92112 /// Returns ``None`` if the signature does not carry a creation time subpacket.
@@ -95,6 +115,17 @@ impl Sig {
95115 self . sig . signature_creation_time ( ) . map ( Into :: into)
96116 }
97117
118+ /// The time at which this signature expires, or ``None`` if it does not expire.
119+ ///
120+ /// Computed as the signature creation time plus the signature validity period.
121+ /// Returns ``None`` if either subpacket is absent.
122+ #[ getter]
123+ pub fn expiration ( & self ) -> Option < chrono:: DateTime < chrono:: Utc > > {
124+ let created = self . sig . signature_creation_time ( ) ?;
125+ let validity = self . sig . signature_validity_period ( ) ?;
126+ Some ( created. checked_add ( validity) ?. into ( ) )
127+ }
128+
98129 /// Return the ASCII-armored representation of the signature.
99130 pub fn __str__ ( & self ) -> PyResult < String > {
100131 let bytes = crate :: serialize ( self . sig . clone ( ) . into ( ) , armor:: Kind :: Signature ) ?;
0 commit comments