8296072: CertAttrSet::encode and DerEncoder::derEncode should write into DerOutputStream

Reviewed-by: xuelei, mullan
This commit is contained in:
Weijun Wang 2022-11-01 12:49:11 +00:00
parent 37107fc157
commit 0d0bd7bd40
50 changed files with 209 additions and 314 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,7 +25,6 @@
package sun.security.x509;
import java.io.IOException;
import java.io.OutputStream;
import java.security.cert.*;
import java.util.Date;
import java.util.Enumeration;
@ -144,10 +143,11 @@ public class CertificateValidity implements CertAttrSet<String> {
/**
* Encode the CertificateValidity period in DER form to the stream.
*
* @param out the OutputStream to marshal the contents to.
* @param out the DerOutputStream to marshal the contents to.
* @exception IOException on errors.
*/
public void encode(OutputStream out) throws IOException {
@Override
public void encode(DerOutputStream out) throws IOException {
// in cases where default constructor is used check for
// null values
@ -167,10 +167,7 @@ public class CertificateValidity implements CertAttrSet<String> {
} else {
pair.putGeneralizedTime(notAfter);
}
DerOutputStream seq = new DerOutputStream();
seq.write(DerValue.tag_Sequence, pair);
out.write(seq.toByteArray());
out.write(DerValue.tag_Sequence, pair);
}
/**