en = v.elements();
} else {
throw new IllegalArgumentException("DEREncodable must be one of: DERSequence, DERSet, DERTaggedObject");
}
while (en != null && en.hasMoreElements()) {
DEREncodable obj = (DEREncodable) en.nextElement();
if (!(obj instanceof DERSequence) &&
!(obj instanceof DERSet) &&
!(obj instanceof DERTaggedObject)) {
String str = obj.toString();
String name = obj.getClass().getName();
name = name.substring(name.lastIndexOf('.') + 1);
if (tag != null) {
name = " [tag=" + tag + "] " + name;
}
for (int i = 0; i < depth; i++) {
name = " " + name;
}
if (obj instanceof DERInteger) {
DERInteger dInt = (DERInteger) obj;
if (pkcs8.derIntegers != null) {
pkcs8.derIntegers.add(dInt);
}
BigInteger big = dInt.getValue();
int intValue = big.intValue();
if (BIGGEST.compareTo(big) >= 0 && intValue > 0) {
if (pkcs8.iterationCount == 0) {
pkcs8.iterationCount = intValue;
} else if (pkcs8.keySize == 0) {
pkcs8.keySize = intValue;
}
}
str = dInt.getValue().toString();
} else if (obj instanceof DERObjectIdentifier) {
DERObjectIdentifier id = (DERObjectIdentifier) obj;
str = id.getId();
pkcs8.oids.add(str);
if (pkcs8.oid1 == null) {
pkcs8.oid1 = str;
} else if (pkcs8.oid2 == null) {
pkcs8.oid2 = str;
} else if (pkcs8.oid3 == null) {
pkcs8.oid3 = str;
}
} else {
pkcs8.derIntegers = null;
if (obj instanceof DEROctetString) {
DEROctetString oct = (DEROctetString) obj;
byte[] octets = oct.getOctets();
int len = Math.min(10, octets.length);
boolean probablyBinary = false;
for (int i = 0; i < len; i++) {
byte b = octets[i];
boolean isBinary = b > 128 || b < 0;
if (isBinary) {
probablyBinary = true;
break;
}
}
if (probablyBinary && octets.length > 64) {
if (pkcs8.bigPayload == null) {
pkcs8.bigPayload = octets;
}
str = "probably binary";
} else {
str = Hex.encode(octets);
if (octets.length <= 64) {
if (octets.length % 8 == 0) {
if (pkcs8.salt == null) {
pkcs8.salt = octets;
} else if (pkcs8.iv == null) {
pkcs8.iv = octets;
}
} else {
if (pkcs8.smallPayload == null) {
pkcs8.smallPayload = octets;
}
}
}
}
str += " (length=" + octets.length + ")";
} else if (obj instanceof DERPrintableString) {
DERPrintableString dps = (DERPrintableString) obj;
str = dps.getString();
}
}
if (DEBUG) {
System.out.println(name + ": [" + str + "]");
}
} else {
if (tag != null && DEBUG) {
String name = obj.getClass().getName();
name = name.substring(name.lastIndexOf('.') + 1);
name = " [tag=" + tag + "] " + name;
for (int i = 0; i < depth; i++) {
name = " " + name;
}