Skip to content

Commit 5527999

Browse files
committed
Add an accessor for signature version
Signed-off-by: Daniel Alley <dalley@redhat.com>
1 parent 2970012 commit 5527999

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

NEXT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ New:
66
- Added `Sig.issuer_fingerprint`, `Sig.issuer_key_id`, `Sig.signers_user_id`, and `Sig.expiration` [#60]
77
- Added docstrings to the `Sig` API [#60]
88
- Added `PacketPile` and `Packet` for low-level reading of individual packet fields [#61]
9-
- Added `Sig.signature_type`, `Sig.hash_algorithm`, `Sig.key_algorithm`, and `Sig.key_validity_period` [#61]
9+
- Added `Sig.signature_type`, `Sig.hash_algorithm`, `Sig.key_algorithm`, `Sig.key_validity_period`, and `Sig.version` [#61]
1010
- Added `SignatureType`, `PublicKeyAlgorithm`, `HashAlgorithm`, `DataFormat`, `Tag` and `KeyFlags` as returned types [#61]
1111
- Added Sequoia's `armor::Writer` for applying Ascii Armor to data, via the `armor()` function and `ArmorKind` type [#61]
1212

src/packet.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,17 @@ impl PyPacket {
210210

211211
// -- Signature packet accessors --
212212

213+
/// The version of a signature packet (e.g. 4 or 6).
214+
///
215+
/// Returns `None` for non-Signature packets.
216+
#[getter]
217+
pub fn signature_version(&self) -> Option<u8> {
218+
match &self.packet {
219+
Packet::Signature(sig) => Some(sig.version()),
220+
_ => None,
221+
}
222+
}
223+
213224
/// The signature type (e.g. `SignatureType.SubkeyBinding`).
214225
///
215226
/// Returns `None` for non-Signature packets.

src/signature.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ impl Sig {
125125
self.sig.signature_expiration_time().map(Into::into)
126126
}
127127

128+
/// The version of this signature packet (e.g. 4 or 6).
129+
#[getter]
130+
pub fn version(&self) -> u8 {
131+
self.sig.version()
132+
}
133+
128134
/// The signature type (e.g. `SignatureType.SubkeyBinding`).
129135
#[getter]
130136
pub fn signature_type(&self) -> PyResult<SignatureType> {

0 commit comments

Comments
 (0)