RFR: 8246797: A convenient method to read OPTIONAL element [v2]
Weijun Wang
weijun at openjdk.java.net
Tue Aug 24 18:08:27 UTC 2021
On Tue, 24 Aug 2021 17:47:18 GMT, Valerie Peng <valeriep at openjdk.org> wrote:
>> Weijun Wang has updated the pull request incrementally with one additional commit since the last revision:
>>
>> best practice for reading DEFAULT, switch expression, etc
>
> src/java.base/share/classes/sun/security/util/DerInputStream.java line 352:
>
>> 350: * @throws IOException if an I/O error happens while peeking the byte
>> 351: */
>> 352: public boolean seeOptionalContextSpecific(int n) throws IOException {
>
> Given the two getOptionalXXXContextSpecific(int) method, do we really need this to be public? Same goes for the two checkNextTag(...) methods above.
It is useful for other OPTIONAL fields that does not have a context tag. For example, `keyLength` inside
PBKDF2-params ::= SEQUENCE {
salt CHOICE {
specified OCTET STRING,
otherSource AlgorithmIdentifier {{PBKDF2-SaltSources}}
},
iterationCount INTEGER (1..MAX),
keyLength INTEGER (1..MAX) OPTIONAL,
prf AlgorithmIdentifier {{PBKDF2-PRFs}} DEFAULT algid-hmacWithSHA1
}
```
Maybe I should create a `getOptional(byte)` method?
-------------
PR: https://git.openjdk.java.net/jdk/pull/5221
More information about the security-dev
mailing list