From ceba7f290e6d56f7ee435a92e19de2919459fc0e Mon Sep 17 00:00:00 2001
From: zzz <zzz@i2pmail.org>
Date: Fri, 7 Feb 2025 10:54:14 -0500
Subject: [PATCH] Data: Ensure RouterIdent padding is compressed when read in

Did not affect most Destination creation code paths because they
are generally created via Destination.create(), not via readBytes(InputStream)

Add new more efficient method to indicate if padding was compressed
---
 core/java/src/net/i2p/data/KeysAndCert.java | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/core/java/src/net/i2p/data/KeysAndCert.java b/core/java/src/net/i2p/data/KeysAndCert.java
index 0b8a6c05f6..85e0f90aa8 100644
--- a/core/java/src/net/i2p/data/KeysAndCert.java
+++ b/core/java/src/net/i2p/data/KeysAndCert.java
@@ -147,6 +147,14 @@ public class KeysAndCert extends DataStructureImpl {
         _padding = padding;
         compressPadding();
     }
+
+    /**
+     * Is there compressible padding?
+     * @since 0.9.66
+     */
+    public boolean isCompressible() {
+        return _paddingBlocks > 1;
+    }
     
     /**
      * @throws IllegalStateException if data already set
@@ -165,6 +173,7 @@ public class KeysAndCert extends DataStructureImpl {
             byte[] pad1 = pk.getPadding(kcert);
             byte[] pad2 = spk.getPadding(kcert);
             _padding = combinePadding(pad1, pad2);
+            compressPadding();
             _certificate = kcert;
         } else {
             _publicKey = pk;
-- 
GitLab