RFR: 8246797: A convenient method to read OPTIONAL element [v2]

Valerie Peng valeriep at openjdk.java.net
Tue Aug 24 19:09:29 UTC 2021


On Tue, 24 Aug 2021 14:24:00 GMT, Weijun Wang <weijun at openjdk.org> wrote:

>> This code change adds new methods to `DerInputStream` to easily and safely read optional fields in a ASN.1 DER-encoded value. It also adds several wrapping methods to `DerValue` to avoid unnecessary memory copying when calling by an internal method.
>> 
>> The new methods are applied to `OAEPParameters` to show out how they work. A new regression test is added to show that not only the new methods are simper but they are safer and more correct.
>
> Weijun Wang has updated the pull request incrementally with one additional commit since the last revision:
> 
>   best practice for reading DEFAULT, switch expression, etc

test/jdk/com/sun/crypto/provider/AlgorithmParameters/OAEPOrder.java line 34:

> 32:  * @test
> 33:  * @bug 8246797
> 34:  * @summary Ensures OAEPParameters read correct encoding

nit: add "and reject encoding with invalid ordering"

test/jdk/com/sun/crypto/provider/AlgorithmParameters/OAEPOrder.java line 39:

> 37: public class OAEPOrder {
> 38:     public static void main(String[] args) throws Exception {
> 39:         // Do not use default fields

The comment states do not use default fields, but supplies SHA-1 and MGF1SHA1 below?

-------------

PR: https://git.openjdk.java.net/jdk/pull/5221



More information about the security-dev mailing list