@@ -150,35 +150,32 @@ public static byte[] generateHSSSignature(int L, LMSContext context)
150150 //
151151
152152 /**
153- * The context a message is absorbed into before verifying an encoded LMS signature against a
154- * public key. Consumed by {@link #verifySignature(LMSPublicKeyParameters, LMSContext)}.
155- *
156- * @throws IllegalStateException if the signature does not decode.
153+ * @deprecated use {@link LMSPublicKeyParameters#generateLMSContext(byte[])} instead.
157154 */
155+ @ Deprecated
158156 public static LMSContext generateVerifyContext (LMSPublicKeyParameters publicKey , byte [] signature )
159157 {
160- try
161- {
162- return generateVerifyContext (publicKey , LMSSignature .getInstance (signature ));
163- }
164- catch (IOException e )
165- {
166- throw Exceptions .illegalStateException ("cannot parse signature" , e );
167- }
158+ return publicKey .generateLMSContext (signature );
168159 }
169160
170161 /**
162+ * The context a message is absorbed into before verifying a decoded LMS signature against a
163+ * public key: the LM-OTS verification context of the leaf the signature names. Public only
164+ * because {@link LMSPublicKeyParameters#generateLMSContext(byte[])} lives in another package;
165+ * callers holding an encoded signature use that.
166+ * <p>
171167 * The typecode and leaf-number checks RFC 8554 sec. 5.4.2 requires before a signature is
172- * processed: step 2g refuses a signature whose LMS typecode is not the one from the public key,
173- * and step 2i refuses a leaf number q outside the tree. Without the first, the path computation
174- * below took its height and tree digest from the parameter set the signature named rather than
175- * the key's, so a signature claiming h25 drove a 25-level computation against an h5 key; without
176- * the second, an out-of-range q flowed into the node arithmetic and was left to be caught by the
177- * candidate-root comparison. Neither was a forgery under a secure hash - the domain separation
178- * and the final comparison saw to that - but both are work the specification says to refuse up
179- * front.
168+ * processed happen here: step 2g refuses a signature whose LMS typecode is not the one from the
169+ * public key, and step 2i refuses a leaf number q outside the tree. Without the first, the path
170+ * computation took its height and tree digest from the parameter set the signature named rather
171+ * than the key's, so a signature claiming h25 drove a 25-level computation against an h5 key;
172+ * without the second, an out-of-range q flowed into the node arithmetic and was left to be caught
173+ * by the candidate-root comparison. Neither was a forgery under a secure hash - the domain
174+ * separation and the final comparison saw to that - but both are work the specification says to
175+ * refuse up front.
176+ * </p>
180177 */
181- static LMSContext generateVerifyContext (LMSPublicKeyParameters publicKey , LMSSignature signature )
178+ public static LMSContext generateVerifyContext (LMSPublicKeyParameters publicKey , LMSSignature signature )
182179 {
183180 LMSigParameters sigParameters = publicKey .getSigParameters ();
184181 if (signature .getParameter ().getType () != sigParameters .getType ())
@@ -207,8 +204,8 @@ static LMSContext generateVerifyContext(LMSPublicKeyParameters publicKey, LMSSig
207204 }
208205
209206 /**
210- * Verify the LMS signature a context from {@link #generateVerifyContext} carries over the
211- * message absorbed into it (RFC 8554 sec. 5.4.2, Algorithm 6).
207+ * Verify the LMS signature a context from {@link LMSPublicKeyParameters#generateLMSContext(byte[])}
208+ * carries over the message absorbed into it (RFC 8554 sec. 5.4.2, Algorithm 6).
212209 */
213210 public static boolean verifySignature (LMSPublicKeyParameters publicKey , LMSContext context )
214211 {
0 commit comments