78 lines
2.8 KiB
Java
78 lines
2.8 KiB
Java
|
package org.bouncycastle.crypto.tls;
|
||
|
|
||
|
import java.io.ByteArrayInputStream;
|
||
|
import java.io.ByteArrayOutputStream;
|
||
|
import java.io.IOException;
|
||
|
import java.io.InputStream;
|
||
|
import java.io.OutputStream;
|
||
|
import java.util.Vector;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public class CertificateURL {
|
||
|
protected short type;
|
||
|
protected Vector urlAndHashList;
|
||
|
|
||
|
public Vector getURLAndHashList() {
|
||
|
return this.urlAndHashList;
|
||
|
}
|
||
|
|
||
|
public short getType() {
|
||
|
return this.type;
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
class ListBuffer16 extends ByteArrayOutputStream {
|
||
|
final CertificateURL this$0;
|
||
|
|
||
|
void encodeTo(OutputStream outputStream) throws IOException {
|
||
|
int i = ((ByteArrayOutputStream) this).count - 2;
|
||
|
TlsUtils.checkUint16(i);
|
||
|
TlsUtils.writeUint16(i, ((ByteArrayOutputStream) this).buf, 0);
|
||
|
outputStream.write(((ByteArrayOutputStream) this).buf, 0, ((ByteArrayOutputStream) this).count);
|
||
|
((ByteArrayOutputStream) this).buf = null;
|
||
|
}
|
||
|
|
||
|
ListBuffer16(CertificateURL certificateURL) throws IOException {
|
||
|
this.this$0 = certificateURL;
|
||
|
TlsUtils.writeUint16(0, this);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void encode(OutputStream outputStream) throws IOException {
|
||
|
TlsUtils.writeUint8(this.type, outputStream);
|
||
|
ListBuffer16 listBuffer16 = new ListBuffer16(this);
|
||
|
for (int i = 0; i < this.urlAndHashList.size(); i++) {
|
||
|
((URLAndHash) this.urlAndHashList.elementAt(i)).encode(listBuffer16);
|
||
|
}
|
||
|
listBuffer16.encodeTo(outputStream);
|
||
|
}
|
||
|
|
||
|
public static CertificateURL parse(TlsContext tlsContext, InputStream inputStream) throws IOException {
|
||
|
short readUint8 = TlsUtils.readUint8(inputStream);
|
||
|
if (!CertChainType.isValid(readUint8)) {
|
||
|
throw new TlsFatalAlert((short) 50);
|
||
|
}
|
||
|
int readUint16 = TlsUtils.readUint16(inputStream);
|
||
|
if (readUint16 <= 0) {
|
||
|
throw new TlsFatalAlert((short) 50);
|
||
|
}
|
||
|
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(TlsUtils.readFully(readUint16, inputStream));
|
||
|
Vector vector = new Vector();
|
||
|
while (byteArrayInputStream.available() > 0) {
|
||
|
vector.addElement(URLAndHash.parse(tlsContext, byteArrayInputStream));
|
||
|
}
|
||
|
return new CertificateURL(readUint8, vector);
|
||
|
}
|
||
|
|
||
|
public CertificateURL(short s, Vector vector) {
|
||
|
if (!CertChainType.isValid(s)) {
|
||
|
throw new IllegalArgumentException("'type' is not a valid CertChainType value");
|
||
|
}
|
||
|
if (vector == null || vector.isEmpty()) {
|
||
|
throw new IllegalArgumentException("'urlAndHashList' must have length > 0");
|
||
|
}
|
||
|
this.type = s;
|
||
|
this.urlAndHashList = vector;
|
||
|
}
|
||
|
}
|