mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8246797: A convenient method to read OPTIONAL element
Reviewed-by: jnimeh, valeriep
This commit is contained in:
parent
6cf5079d8e
commit
fc0f8542c3
6 changed files with 276 additions and 96 deletions
|
@ -255,6 +255,16 @@ public class PKCS7 {
|
|||
}
|
||||
}
|
||||
|
||||
// SignedData ::= SEQUENCE {
|
||||
// version Version,
|
||||
// digestAlgorithms DigestAlgorithmIdentifiers,
|
||||
// contentInfo ContentInfo,
|
||||
// certificates
|
||||
// [0] IMPLICIT ExtendedCertificatesAndCertificates
|
||||
// OPTIONAL,
|
||||
// crls
|
||||
// [1] IMPLICIT CertificateRevocationLists OPTIONAL,
|
||||
// signerInfos SignerInfos }
|
||||
private void parseSignedData(DerValue val)
|
||||
throws ParsingException, IOException {
|
||||
|
||||
|
@ -294,9 +304,9 @@ public class PKCS7 {
|
|||
* check if certificates (implicit tag) are provided
|
||||
* (certificates are OPTIONAL)
|
||||
*/
|
||||
if ((byte)(dis.peekByte()) == (byte)0xA0) {
|
||||
DerValue[] certVals = dis.getSet(2, true);
|
||||
|
||||
var certDer = dis.getOptionalImplicitContextSpecific(0, DerValue.tag_SetOf);
|
||||
if (certDer.isPresent()) {
|
||||
DerValue[] certVals = certDer.get().subs(DerValue.tag_SetOf, 2);
|
||||
len = certVals.length;
|
||||
certificates = new X509Certificate[len];
|
||||
int count = 0;
|
||||
|
@ -339,9 +349,9 @@ public class PKCS7 {
|
|||
}
|
||||
|
||||
// check if crls (implicit tag) are provided (crls are OPTIONAL)
|
||||
if ((byte)(dis.peekByte()) == (byte)0xA1) {
|
||||
DerValue[] crlVals = dis.getSet(1, true);
|
||||
|
||||
var crlsDer = dis.getOptionalImplicitContextSpecific(1, DerValue.tag_SetOf);
|
||||
if (crlsDer.isPresent()) {
|
||||
DerValue[] crlVals = crlsDer.get().subs(DerValue.tag_SetOf, 1);
|
||||
len = crlVals.length;
|
||||
crls = new X509CRL[len];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue