From 444ec6d5939295205d6f30b04684f30acf3b7862 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Wed, 1 Jun 2022 13:40:07 +0200 Subject: [PATCH] Add documentation to enforceBounds() --- .../signature/subpackets/SignatureSubpackets.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pgpainless-core/src/main/java/org/pgpainless/signature/subpackets/SignatureSubpackets.java b/pgpainless-core/src/main/java/org/pgpainless/signature/subpackets/SignatureSubpackets.java index df0269a3..a2eb1f7d 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/signature/subpackets/SignatureSubpackets.java +++ b/pgpainless-core/src/main/java/org/pgpainless/signature/subpackets/SignatureSubpackets.java @@ -287,6 +287,13 @@ public class SignatureSubpackets return setKeyExpirationTime(new KeyExpirationTime(isCritical, secondsFromCreationToExpiration)); } + /** + * Enforce that
secondsFromCreationToExpiration
is within bounds of an unsigned 32bit number. + * Values less than 0 are illegal, as well as values greater 0xffffffff. + * + * @param secondsFromCreationToExpiration number to check + * @throws IllegalArgumentException in case of an under- or overflow + */ private void enforceBounds(long secondsFromCreationToExpiration) { if (secondsFromCreationToExpiration < 0) { throw new IllegalArgumentException("Seconds from creation to expiration cannot be less than 0.");