Skip to content

Commit

Permalink
Move DigestAlgorithms and OID to kernel, merge SecurityIDs into OID
Browse files Browse the repository at this point in the history
DEVSIX-8565

Autoported commit.
Original commit hash: [84ae14f7d]
Manual files:
kernel/src/main/java/com/itextpdf/kernel/crypto/CryptoUtil.java
sign/src/main/java/com/itextpdf/signatures/BouncyCastleDigest.java
sign/src/main/java/com/itextpdf/signatures/ProviderDigest.java
sign/src/main/java/com/itextpdf/signatures/RSASSAPSSMechanismParams.java
sign/src/main/java/com/itextpdf/signatures/SignUtils.java
sign/src/main/java/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtension.java
sign/src/test/java/com/itextpdf/signatures/CertificateSupportedCriticalExtensionsTest.java
sign/src/test/java/com/itextpdf/signatures/DigestAlgorithmsManualTest.java
sign/src/test/java/com/itextpdf/signatures/ProviderDigestUnitTest.java
sign/src/test/java/com/itextpdf/signatures/sign/IsoSignatureExtensionsRoundtripTest.java
sign/src/test/java/com/itextpdf/signatures/sign/LtvSigTest.java
sign/src/test/java/com/itextpdf/signatures/sign/PadesSignatureLevelTest.java
sign/src/test/java/com/itextpdf/signatures/sign/PadesTwoPhaseSigningLevelsTest.java
sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesSignerLevelsTest.java
sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesSignerTest.java
sign/src/test/java/com/itextpdf/signatures/sign/TwoPhaseSigningTest.java
sign/src/test/java/com/itextpdf/signatures/testutils/builder/TestTimestampTokenBuilder.java
  • Loading branch information
introfog committed Sep 24, 2024
1 parent 7eb1313 commit e96df9e
Show file tree
Hide file tree
Showing 73 changed files with 346 additions and 337 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ You should have received a copy of the GNU Affero General Public License
using iText.Forms.Fields.Properties;
using iText.Forms.Form.Element;
using iText.IO.Util;
using iText.Kernel.Crypto;
using iText.Kernel.Font;
using iText.Kernel.Geom;
using iText.Kernel.Pdf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ You should have received a copy of the GNU Affero General Public License
using System;
using System.Collections;
using System.Collections.Generic;
using iText.Kernel.Crypto;
using iText.Test;
using NUnit.Framework;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ You should have received a copy of the GNU Affero General Public License
using System.IO;
using iText.Bouncycastleconnector;
using iText.Commons.Bouncycastle;
using iText.Kernel.Crypto;
using iText.Kernel.Logs;
using iText.Signatures.Logs;
using iText.Test;
using iText.Test.Attributes;
Expand Down Expand Up @@ -63,7 +65,7 @@ public virtual void DigestSHA256SUNTest()
NUnit.Framework.Assert.AreEqual(expected, hash);
}

[LogMessage(SignLogMessageConstant.ALGORITHM_NOT_FROM_SPEC, Ignore = true)]
[LogMessage(KernelLogMessageConstant.ALGORITHM_NOT_FROM_SPEC, Ignore = true)]
[NUnit.Framework.Test]
public virtual void NotAllowedNameGetAllowedDigestTest() {
String name = "SM3";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ You should have received a copy of the GNU Affero General Public License
using System;
using iText.Bouncycastleconnector;
using iText.Commons.Bouncycastle;
using iText.Signatures.Logs;
using iText.Kernel.Crypto;
using iText.Kernel.Logs;
using iText.Test;
using iText.Test.Attributes;

Expand Down Expand Up @@ -66,7 +67,7 @@ public virtual void NullNameGetAllowedDigestTest() {
NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => DigestAlgorithms.GetAllowedDigest(null));
}

[LogMessage(SignLogMessageConstant.ALGORITHM_NOT_FROM_SPEC, Ignore = true)]
[LogMessage(KernelLogMessageConstant.ALGORITHM_NOT_FROM_SPEC, Ignore = true)]
[NUnit.Framework.Test]
public virtual void NotAllowedOidGetDigestTest() {
String name = "SM3";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ You should have received a copy of the GNU Affero General Public License
using iText.Commons.Bouncycastle.Crypto;
using iText.Commons.Utils;
using iText.IO.Source;
using iText.Kernel.Crypto;
using iText.Kernel.Pdf;
using iText.Signatures.Testutils;
using iText.Signatures.Testutils.Builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ You should have received a copy of the GNU Affero General Public License
using iText.Commons.Bouncycastle.Asn1.Tsp;
using iText.Commons.Bouncycastle.Cert;
using iText.Commons.Utils;
using iText.Kernel.Crypto;
using iText.Kernel.Exceptions;
using iText.Kernel.Pdf;
using iText.Signatures.Exceptions;
Expand Down Expand Up @@ -72,7 +73,7 @@ public virtual void SimpleCreationWithPrivateKeyTest() {
NUnit.Framework.Assert.AreEqual(expectedOid, pkcs7.GetDigestAlgorithmOid());
NUnit.Framework.Assert.AreEqual(chain[0], pkcs7.GetSigningCertificate());
NUnit.Framework.Assert.AreEqual(chain, pkcs7.GetCertificates());
NUnit.Framework.Assert.AreEqual(SecurityIDs.ID_RSA_WITH_SHA256, pkcs7.GetSignatureMechanismOid());
NUnit.Framework.Assert.AreEqual(OID.RSA_WITH_SHA256, pkcs7.GetSignatureMechanismOid());
}

[NUnit.Framework.Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ You should have received a copy of the GNU Affero General Public License
using iText.Forms.Fields;
using iText.Forms.Form.Element;
using iText.IO.Source;
using iText.Kernel.Crypto;
using iText.Kernel.Exceptions;
using iText.Kernel.Geom;
using iText.Kernel.Logs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ You should have received a copy of the GNU Affero General Public License
using iText.Bouncycastleconnector;
using iText.Commons.Bouncycastle;
using iText.IO.Source;
using iText.Kernel.Crypto;
using iText.Kernel.Pdf;
using iText.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ You should have received a copy of the GNU Affero General Public License
using iText.Commons.Utils;
using iText.IO.Source;
using iText.Kernel.Actions.Events;
using iText.Kernel.Crypto;
using iText.Kernel.Pdf;
using iText.Signatures.Cms;
using iText.Signatures.Testutils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ You should have received a copy of the GNU Affero General Public License
using iText.Commons.Bouncycastle.Asn1.Esf;
using iText.Commons.Bouncycastle.Asn1.X509;
using iText.Commons.Utils;
using iText.Kernel.Crypto;
using iText.Test;

namespace iText.Signatures {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ You should have received a copy of the GNU Affero General Public License
using iText.Commons.Bouncycastle.Cert;
using iText.Commons.Bouncycastle.Crypto;
using iText.Commons.Utils;
using iText.Kernel.Crypto;
using iText.Kernel.Exceptions;
using iText.Kernel.Pdf;
using iText.Signatures;
Expand Down Expand Up @@ -84,8 +85,8 @@ public virtual void TestSerialize() {
si.SetMessageDigest(new byte[256]);
si.SetOcspResponses(fakeOcspREsponses);
si.SetCrlResponses(JavaCollectionsUtil.SingletonList(testCrlResponse));
si.SetDigestAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_SHA512));
si.SetSigningCertificateAndAddToSignedAttributes(signCert, SecurityIDs.ID_SHA512);
si.SetDigestAlgorithm(new AlgorithmIdentifier(OID.SHA_512));
si.SetSigningCertificateAndAddToSignedAttributes(signCert, OID.SHA_512);
si.SetSignatureAlgorithm(new AlgorithmIdentifier(SignatureMechanisms.GetSignatureMechanismOid("RSA", DigestAlgorithms
.SHA512)));
si.SetSignature(new byte[256]);
Expand All @@ -105,8 +106,8 @@ public virtual void TestSerializationWithRevocationData() {
SignerInfo si = new SignerInfo();
si.SetSigningCertificate(signCert);
si.SetMessageDigest(new byte[256]);
si.SetDigestAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_SHA512));
si.SetSigningCertificateAndAddToSignedAttributes(signCert, SecurityIDs.ID_SHA512);
si.SetDigestAlgorithm(new AlgorithmIdentifier(OID.SHA_512));
si.SetSigningCertificateAndAddToSignedAttributes(signCert, OID.SHA_512);
si.SetSignatureAlgorithm(new AlgorithmIdentifier(SignatureMechanisms.GetSignatureMechanismOid("RSA", DigestAlgorithms
.SHA512)));
si.SetSignature(new byte[256]);
Expand All @@ -127,10 +128,10 @@ public virtual void TestGetSizeEstimation() {
si.SetMessageDigest(new byte[256]);
si.SetOcspResponses(fakeOcspREsponses);
si.SetCrlResponses(JavaCollectionsUtil.SingletonList(testCrlResponse));
si.SetDigestAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_SHA512));
si.SetDigestAlgorithm(new AlgorithmIdentifier(OID.SHA_512));
si.SetSignatureAlgorithm(new AlgorithmIdentifier(SignatureMechanisms.GetSignatureMechanismOid("RSA", DigestAlgorithms
.SHA512)));
si.SetSigningCertificateAndAddToSignedAttributes(signCert, SecurityIDs.ID_SHA512);
si.SetSigningCertificateAndAddToSignedAttributes(signCert, OID.SHA_512);
si.SetSignature(new byte[256]);
sut.SetSignerInfo(si);
long size = sut.GetSizeEstimation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ You should have received a copy of the GNU Affero General Public License
using iText.Commons.Bouncycastle;
using iText.Commons.Bouncycastle.Asn1;
using iText.Commons.Utils;
using iText.Signatures;
using iText.Kernel.Crypto;
using iText.Test;

namespace iText.Signatures.Cms {
Expand All @@ -40,10 +40,10 @@ public class EncapsulatedContentInfoTest : ExtendedITextTest {
[NUnit.Framework.Test]
public virtual void TestDeserializationWithoutContent() {
IAsn1EncodableVector v = FACTORY.CreateASN1EncodableVector();
v.Add(FACTORY.CreateASN1ObjectIdentifier(SecurityIDs.ID_PKCS7_DATA));
v.Add(FACTORY.CreateASN1ObjectIdentifier(OID.PKCS7_DATA));
IAsn1Sequence testData = FACTORY.CreateDERSequence(v);
EncapsulatedContentInfo sut = new EncapsulatedContentInfo(testData);
NUnit.Framework.Assert.AreEqual(SecurityIDs.ID_PKCS7_DATA, sut.GetContentType());
NUnit.Framework.Assert.AreEqual(OID.PKCS7_DATA, sut.GetContentType());
NUnit.Framework.Assert.IsNull(sut.GetContent());
}

Expand All @@ -57,16 +57,16 @@ public virtual void TestDeserializationWithContent() {

[NUnit.Framework.Test]
public virtual void TestCreation() {
EncapsulatedContentInfo sut = new EncapsulatedContentInfo(SecurityIDs.ID_PKCS7_DATA);
NUnit.Framework.Assert.AreEqual(SecurityIDs.ID_PKCS7_DATA, sut.GetContentType());
EncapsulatedContentInfo sut = new EncapsulatedContentInfo(OID.PKCS7_DATA);
NUnit.Framework.Assert.AreEqual(OID.PKCS7_DATA, sut.GetContentType());
NUnit.Framework.Assert.IsNull(sut.GetContent());
}

[NUnit.Framework.Test]
public virtual void TestCreationWithContent() {
EncapsulatedContentInfo sut = new EncapsulatedContentInfo(SecurityIDs.ID_PKCS7_DATA, FACTORY.CreateDEROctetString
(new byte[20]));
NUnit.Framework.Assert.AreEqual(SecurityIDs.ID_PKCS7_DATA, sut.GetContentType());
EncapsulatedContentInfo sut = new EncapsulatedContentInfo(OID.PKCS7_DATA, FACTORY.CreateDEROctetString(new
byte[20]));
NUnit.Framework.Assert.AreEqual(OID.PKCS7_DATA, sut.GetContentType());
NUnit.Framework.Assert.IsNotNull(sut.GetContent());
}
}
Expand Down
Loading

0 comments on commit e96df9e

Please sign in to comment.