mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-17 18:02:05 +01:00
Bump sop-java to 6.1.0
This commit is contained in:
parent
23fd630670
commit
eb1ff27a90
7 changed files with 79 additions and 45 deletions
|
@ -13,6 +13,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import org.bouncycastle.openpgp.PGPException;
|
import org.bouncycastle.openpgp.PGPException;
|
||||||
|
@ -105,7 +106,15 @@ public class RoundTripSignVerifyCmdTest extends CLITest {
|
||||||
"-----END PGP SIGNATURE-----";
|
"-----END PGP SIGNATURE-----";
|
||||||
private static final String TEXT_SIG_VERIFICATION =
|
private static final String TEXT_SIG_VERIFICATION =
|
||||||
"2022-11-09T18:41:18Z 444C10AB011EF8424C83F0A9DA9F413986211DC6 9DA09423C9F94BA4CCA30951099B11BF296A373E mode:text\n";
|
"2022-11-09T18:41:18Z 444C10AB011EF8424C83F0A9DA9F413986211DC6 9DA09423C9F94BA4CCA30951099B11BF296A373E mode:text\n";
|
||||||
private static final Date TEXT_SIG_CREATION = UTCUtil.parseUTCDate("2022-11-09T18:41:18Z");
|
private static final Date TEXT_SIG_CREATION;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
TEXT_SIG_CREATION = UTCUtil.parseUTCDate("2022-11-09T18:41:18Z");
|
||||||
|
} catch (ParseException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createArmoredSignature() throws IOException {
|
public void createArmoredSignature() throws IOException {
|
||||||
|
|
|
@ -4,15 +4,15 @@
|
||||||
|
|
||||||
package org.pgpainless.sop;
|
package org.pgpainless.sop;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import sop.ByteArrayAndResult;
|
import sop.ByteArrayAndResult;
|
||||||
import sop.DecryptionResult;
|
import sop.DecryptionResult;
|
||||||
import sop.Ready;
|
import sop.Ready;
|
||||||
|
import sop.testsuite.assertions.VerificationListAssert;
|
||||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
|
|
||||||
public class CarolKeySignEncryptRoundtripTest {
|
public class CarolKeySignEncryptRoundtripTest {
|
||||||
|
|
||||||
|
@ -290,6 +290,8 @@ public class CarolKeySignEncryptRoundtripTest {
|
||||||
|
|
||||||
byte[] plaintext = decryption.getBytes();
|
byte[] plaintext = decryption.getBytes();
|
||||||
assertArrayEquals(msg, plaintext);
|
assertArrayEquals(msg, plaintext);
|
||||||
assertEquals(1, decryption.getResult().getVerifications().size());
|
VerificationListAssert.assertThatVerificationList(decryption.getResult().getVerifications())
|
||||||
|
.hasSingleItem()
|
||||||
|
.issuedBy("71FFDA004409E5DDB0C3E8F19BA789DC76D6849A", "71FFDA004409E5DDB0C3E8F19BA789DC76D6849A");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import sop.Verification;
|
||||||
import sop.enums.SignAs;
|
import sop.enums.SignAs;
|
||||||
import sop.enums.SignatureMode;
|
import sop.enums.SignatureMode;
|
||||||
import sop.exception.SOPGPException;
|
import sop.exception.SOPGPException;
|
||||||
|
import sop.testsuite.assertions.VerificationListAssert;
|
||||||
|
|
||||||
public class DetachedSignTest {
|
public class DetachedSignTest {
|
||||||
|
|
||||||
|
@ -63,8 +64,9 @@ public class DetachedSignTest {
|
||||||
.signatures(signature)
|
.signatures(signature)
|
||||||
.data(data);
|
.data(data);
|
||||||
|
|
||||||
assertEquals(1, verifications.size());
|
VerificationListAssert.assertThatVerificationList(verifications)
|
||||||
assertEquals(SignatureMode.binary, verifications.get(0).getSignatureMode());
|
.hasSingleItem()
|
||||||
|
.hasMode(SignatureMode.binary);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -84,7 +86,8 @@ public class DetachedSignTest {
|
||||||
.signatures(signature)
|
.signatures(signature)
|
||||||
.data(data);
|
.data(data);
|
||||||
|
|
||||||
assertEquals(1, verifications.size());
|
VerificationListAssert.assertThatVerificationList(verifications)
|
||||||
|
.hasSingleItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -103,8 +106,9 @@ public class DetachedSignTest {
|
||||||
.signatures(signature)
|
.signatures(signature)
|
||||||
.data(data);
|
.data(data);
|
||||||
|
|
||||||
assertEquals(1, verifications.size());
|
VerificationListAssert.assertThatVerificationList(verifications)
|
||||||
assertEquals(SignatureMode.text, verifications.get(0).getSignatureMode());
|
.hasSingleItem()
|
||||||
|
.hasMode(SignatureMode.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -21,7 +21,9 @@ import sop.ByteArrayAndResult;
|
||||||
import sop.DecryptionResult;
|
import sop.DecryptionResult;
|
||||||
import sop.SOP;
|
import sop.SOP;
|
||||||
import sop.SessionKey;
|
import sop.SessionKey;
|
||||||
|
import sop.enums.SignatureMode;
|
||||||
import sop.exception.SOPGPException;
|
import sop.exception.SOPGPException;
|
||||||
|
import sop.testsuite.assertions.VerificationListAssert;
|
||||||
|
|
||||||
public class EncryptDecryptRoundTripTest {
|
public class EncryptDecryptRoundTripTest {
|
||||||
|
|
||||||
|
@ -75,7 +77,8 @@ public class EncryptDecryptRoundTripTest {
|
||||||
assertArrayEquals(message, decrypted.toByteArray());
|
assertArrayEquals(message, decrypted.toByteArray());
|
||||||
|
|
||||||
DecryptionResult result = bytesAndResult.getResult();
|
DecryptionResult result = bytesAndResult.getResult();
|
||||||
assertEquals(1, result.getVerifications().size());
|
VerificationListAssert.assertThatVerificationList(result.getVerifications())
|
||||||
|
.hasSingleItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -106,7 +109,8 @@ public class EncryptDecryptRoundTripTest {
|
||||||
assertArrayEquals(message, decrypted);
|
assertArrayEquals(message, decrypted);
|
||||||
|
|
||||||
DecryptionResult result = bytesAndResult.getResult();
|
DecryptionResult result = bytesAndResult.getResult();
|
||||||
assertEquals(1, result.getVerifications().size());
|
VerificationListAssert.assertThatVerificationList(result.getVerifications())
|
||||||
|
.hasSingleItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -125,7 +129,8 @@ public class EncryptDecryptRoundTripTest {
|
||||||
assertArrayEquals(message, decrypted);
|
assertArrayEquals(message, decrypted);
|
||||||
|
|
||||||
DecryptionResult result = bytesAndResult.getResult();
|
DecryptionResult result = bytesAndResult.getResult();
|
||||||
assertEquals(0, result.getVerifications().size());
|
VerificationListAssert.assertThatVerificationList(result.getVerifications())
|
||||||
|
.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -144,7 +149,8 @@ public class EncryptDecryptRoundTripTest {
|
||||||
assertArrayEquals(message, decrypted);
|
assertArrayEquals(message, decrypted);
|
||||||
|
|
||||||
DecryptionResult result = bytesAndResult.getResult();
|
DecryptionResult result = bytesAndResult.getResult();
|
||||||
assertEquals(0, result.getVerifications().size());
|
VerificationListAssert.assertThatVerificationList(result.getVerifications())
|
||||||
|
.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -163,7 +169,8 @@ public class EncryptDecryptRoundTripTest {
|
||||||
assertArrayEquals(message, decrypted);
|
assertArrayEquals(message, decrypted);
|
||||||
|
|
||||||
DecryptionResult result = bytesAndResult.getResult();
|
DecryptionResult result = bytesAndResult.getResult();
|
||||||
assertEquals(0, result.getVerifications().size());
|
VerificationListAssert.assertThatVerificationList(result.getVerifications())
|
||||||
|
.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -180,7 +187,8 @@ public class EncryptDecryptRoundTripTest {
|
||||||
.toByteArrayAndResult()
|
.toByteArrayAndResult()
|
||||||
.getResult();
|
.getResult();
|
||||||
|
|
||||||
assertTrue(result.getVerifications().isEmpty());
|
VerificationListAssert.assertThatVerificationList(result.getVerifications())
|
||||||
|
.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -486,14 +494,19 @@ public class EncryptDecryptRoundTripTest {
|
||||||
sop.decrypt().withKey(key).verifyWithCert(cert).ciphertext(ciphertext).toByteArrayAndResult();
|
sop.decrypt().withKey(key).verifyWithCert(cert).ciphertext(ciphertext).toByteArrayAndResult();
|
||||||
assertEquals(sessionKey, bytesAndResult.getResult().getSessionKey().get().toString());
|
assertEquals(sessionKey, bytesAndResult.getResult().getSessionKey().get().toString());
|
||||||
assertArrayEquals(plaintext, bytesAndResult.getBytes());
|
assertArrayEquals(plaintext, bytesAndResult.getBytes());
|
||||||
assertEquals(1, bytesAndResult.getResult().getVerifications().size());
|
VerificationListAssert.assertThatVerificationList(bytesAndResult.getResult().getVerifications())
|
||||||
|
.hasSingleItem()
|
||||||
|
.issuedBy("9C26EFAB1C6500A228E8A9C2658EE420C824D191")
|
||||||
|
.hasMode(SignatureMode.binary);
|
||||||
// Decrypt with session key
|
// Decrypt with session key
|
||||||
bytesAndResult = sop.decrypt().withSessionKey(SessionKey.fromString(sessionKey))
|
bytesAndResult = sop.decrypt().withSessionKey(SessionKey.fromString(sessionKey))
|
||||||
.verifyWithCert(cert).ciphertext(ciphertext).toByteArrayAndResult();
|
.verifyWithCert(cert).ciphertext(ciphertext).toByteArrayAndResult();
|
||||||
assertEquals(sessionKey, bytesAndResult.getResult().getSessionKey().get().toString());
|
assertEquals(sessionKey, bytesAndResult.getResult().getSessionKey().get().toString());
|
||||||
assertArrayEquals(plaintext, bytesAndResult.getBytes());
|
assertArrayEquals(plaintext, bytesAndResult.getBytes());
|
||||||
assertEquals(1, bytesAndResult.getResult().getVerifications().size());
|
VerificationListAssert.assertThatVerificationList(bytesAndResult.getResult().getVerifications())
|
||||||
|
.hasSingleItem()
|
||||||
|
.issuedBy("9C26EFAB1C6500A228E8A9C2658EE420C824D191")
|
||||||
|
.hasMode(SignatureMode.binary);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
package org.pgpainless.sop;
|
package org.pgpainless.sop;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
@ -34,7 +32,9 @@ import sop.SOP;
|
||||||
import sop.Signatures;
|
import sop.Signatures;
|
||||||
import sop.Verification;
|
import sop.Verification;
|
||||||
import sop.enums.InlineSignAs;
|
import sop.enums.InlineSignAs;
|
||||||
|
import sop.enums.SignatureMode;
|
||||||
import sop.exception.SOPGPException;
|
import sop.exception.SOPGPException;
|
||||||
|
import sop.testsuite.assertions.VerificationListAssert;
|
||||||
|
|
||||||
public class InlineDetachTest {
|
public class InlineDetachTest {
|
||||||
|
|
||||||
|
@ -79,9 +79,11 @@ public class InlineDetachTest {
|
||||||
.signatures(signature)
|
.signatures(signature)
|
||||||
.data(message);
|
.data(message);
|
||||||
|
|
||||||
assertFalse(verificationList.isEmpty());
|
VerificationListAssert.assertThatVerificationList(verificationList)
|
||||||
assertEquals(1, verificationList.size());
|
.hasSingleItem()
|
||||||
assertEquals(new OpenPgpV4Fingerprint(secretKey).toString(), verificationList.get(0).getSigningCertFingerprint());
|
.issuedBy(new OpenPgpV4Fingerprint(secretKey).toString())
|
||||||
|
.hasMode(SignatureMode.text);
|
||||||
|
|
||||||
assertArrayEquals(data, message);
|
assertArrayEquals(data, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,8 +123,10 @@ public class InlineDetachTest {
|
||||||
.signatures(signature)
|
.signatures(signature)
|
||||||
.data(message);
|
.data(message);
|
||||||
|
|
||||||
assertFalse(verificationList.isEmpty());
|
VerificationListAssert.assertThatVerificationList(verificationList)
|
||||||
assertEquals(1, verificationList.size());
|
.hasSingleItem()
|
||||||
|
.hasMode(SignatureMode.binary);
|
||||||
|
|
||||||
assertArrayEquals(data, message);
|
assertArrayEquals(data, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,8 +195,10 @@ public class InlineDetachTest {
|
||||||
.signatures(signature)
|
.signatures(signature)
|
||||||
.data(message);
|
.data(message);
|
||||||
|
|
||||||
assertFalse(verificationList.isEmpty());
|
VerificationListAssert.assertThatVerificationList(verificationList)
|
||||||
assertEquals(1, verificationList.size());
|
.hasSingleItem()
|
||||||
|
.hasMode(SignatureMode.binary);
|
||||||
|
|
||||||
assertArrayEquals(data, message);
|
assertArrayEquals(data, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,19 +4,19 @@
|
||||||
|
|
||||||
package org.pgpainless.sop;
|
package org.pgpainless.sop;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import sop.ByteArrayAndResult;
|
import sop.ByteArrayAndResult;
|
||||||
import sop.SOP;
|
import sop.SOP;
|
||||||
import sop.Verification;
|
import sop.Verification;
|
||||||
import sop.enums.InlineSignAs;
|
import sop.enums.InlineSignAs;
|
||||||
import sop.enums.SignatureMode;
|
import sop.enums.SignatureMode;
|
||||||
|
import sop.testsuite.assertions.VerificationListAssert;
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
|
|
||||||
public class InlineSignVerifyRoundtripTest {
|
public class InlineSignVerifyRoundtripTest {
|
||||||
|
|
||||||
|
@ -48,9 +48,9 @@ public class InlineSignVerifyRoundtripTest {
|
||||||
byte[] verified = result.getBytes();
|
byte[] verified = result.getBytes();
|
||||||
|
|
||||||
List<Verification> verificationList = result.getResult();
|
List<Verification> verificationList = result.getResult();
|
||||||
assertEquals(1, verificationList.size());
|
VerificationListAssert.assertThatVerificationList(verificationList)
|
||||||
Verification verification = verificationList.get(0);
|
.hasSingleItem()
|
||||||
assertEquals(SignatureMode.text, verification.getSignatureMode());
|
.hasMode(SignatureMode.text);
|
||||||
|
|
||||||
assertArrayEquals(message, verified);
|
assertArrayEquals(message, verified);
|
||||||
}
|
}
|
||||||
|
@ -81,9 +81,9 @@ public class InlineSignVerifyRoundtripTest {
|
||||||
byte[] verified = result.getBytes();
|
byte[] verified = result.getBytes();
|
||||||
|
|
||||||
List<Verification> verificationList = result.getResult();
|
List<Verification> verificationList = result.getResult();
|
||||||
assertEquals(1, verificationList.size());
|
VerificationListAssert.assertThatVerificationList(verificationList)
|
||||||
Verification verification = verificationList.get(0);
|
.hasSingleItem()
|
||||||
assertEquals(SignatureMode.binary, verification.getSignatureMode());
|
.hasMode(SignatureMode.binary);
|
||||||
|
|
||||||
assertArrayEquals(message, verified);
|
assertArrayEquals(message, verified);
|
||||||
}
|
}
|
||||||
|
@ -115,9 +115,9 @@ public class InlineSignVerifyRoundtripTest {
|
||||||
byte[] verified = result.getBytes();
|
byte[] verified = result.getBytes();
|
||||||
|
|
||||||
List<Verification> verificationList = result.getResult();
|
List<Verification> verificationList = result.getResult();
|
||||||
assertEquals(1, verificationList.size());
|
VerificationListAssert.assertThatVerificationList(verificationList)
|
||||||
Verification verification = verificationList.get(0);
|
.hasSingleItem()
|
||||||
assertEquals(SignatureMode.text, verification.getSignatureMode());
|
.hasMode(SignatureMode.text);
|
||||||
|
|
||||||
assertArrayEquals(message, verified);
|
assertArrayEquals(message, verified);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,6 @@ allprojects {
|
||||||
logbackVersion = '1.2.11'
|
logbackVersion = '1.2.11'
|
||||||
mockitoVersion = '4.5.1'
|
mockitoVersion = '4.5.1'
|
||||||
slf4jVersion = '1.7.36'
|
slf4jVersion = '1.7.36'
|
||||||
sopJavaVersion = '6.0.0'
|
sopJavaVersion = '6.1.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue