From dae5288456c3471d97a42a3bfe523df3c6f2174f Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Sat, 26 Jun 2021 16:30:54 +0200 Subject: [PATCH] Add KeyRingInfo.getVersion() --- .../main/java/org/pgpainless/key/info/KeyRingInfo.java | 9 +++++++++ .../java/org/pgpainless/key/info/KeyRingInfoTest.java | 2 ++ 2 files changed, 11 insertions(+) diff --git a/pgpainless-core/src/main/java/org/pgpainless/key/info/KeyRingInfo.java b/pgpainless-core/src/main/java/org/pgpainless/key/info/KeyRingInfo.java index 3dc75c6f..ab822393 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/key/info/KeyRingInfo.java +++ b/pgpainless-core/src/main/java/org/pgpainless/key/info/KeyRingInfo.java @@ -727,6 +727,15 @@ public class KeyRingInfo { return false; } + /** + * Return the version number of the public keys format. + * + * @return version + */ + public int getVersion() { + return keys.getPublicKey().getVersion(); + } + /** * Return a list of all subkeys which can be used for encryption of the given purpose. * This list does not include expired or revoked keys. diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/info/KeyRingInfoTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/info/KeyRingInfoTest.java index ec3d0b73..2e5d3bd4 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/info/KeyRingInfoTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/info/KeyRingInfoTest.java @@ -75,6 +75,8 @@ public class KeyRingInfoTest { assertEquals(Collections.singletonList(""), pInfo.getUserIds()); assertEquals(Collections.singletonList("emil@email.user"), sInfo.getEmailAddresses()); assertEquals(Collections.singletonList("emil@email.user"), pInfo.getEmailAddresses()); + assertEquals(4, sInfo.getVersion()); + assertEquals(4, pInfo.getVersion()); assertTrue(sInfo.isSecretKey()); assertFalse(pInfo.isSecretKey());