On 5/1/18 5:45 PM, Jamil Nimeh wrote:
134             throw new IllegalArgumentException(
 135                     "Unsupported parameter format: " + decodingMethod);

Although this seems like a reasonable exception to throw, AlgorithmParametersSpi.engineInit is not spec'ed to throw this, so I think you should throw an IOE instead.

 202             throw new IllegalArgumentException(
 203                     "Unsupported encoding format: " + encodingMethod);

Similar comment, AlgorithmParametersSpi.engineGetEncoded is not spec'ed to throw this, so I think you should throw an IOE instead.
JN: Fair enough.  I had figured IAE would be OK since it's an unchecked exception and seemed more appropriate to the situation. But IOE is fine too.  Will fix.

I checked all of the other JDK AlgorithmParametersSpi implementations, and they actually ignore the format parameter completely and always encode using ASN.1. But I don't think that is right. So, I think we should throw an Exception and maybe file a bug to add a clarification to the spec for engineGetEncoded.

One other issue. The spec for engineGetEncoded says that if the format is null, the primary encoding format for parameters is used, so the code for 199-200 should be:

199 if (encodingMethod == null || encodingMethod.equalsIgnoreCase(DEFAULT_FMT)) {
200             return engineGetEncoded();

--Sean

Reply via email to