mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-10-31 17:45:58 +01:00
Remove empty newlines
This commit is contained in:
parent
6926cedf61
commit
c031ea9285
4 changed files with 0 additions and 18 deletions
|
@ -88,7 +88,6 @@ public class ManagePolicy {
|
||||||
// Per default, non-revocation signatures using SHA-1 are rejected
|
// Per default, non-revocation signatures using SHA-1 are rejected
|
||||||
assertFalse(sigHashAlgoPolicy.isAcceptable(HashAlgorithm.SHA1));
|
assertFalse(sigHashAlgoPolicy.isAcceptable(HashAlgorithm.SHA1));
|
||||||
|
|
||||||
|
|
||||||
// Create a new custom policy which contains SHA-1
|
// Create a new custom policy which contains SHA-1
|
||||||
Policy.HashAlgorithmPolicy customPolicy = new Policy.HashAlgorithmPolicy(
|
Policy.HashAlgorithmPolicy customPolicy = new Policy.HashAlgorithmPolicy(
|
||||||
// The default hash algorithm will be used when hash algorithm negotiation fails when creating a sig
|
// The default hash algorithm will be used when hash algorithm negotiation fails when creating a sig
|
||||||
|
@ -98,7 +97,6 @@ public class ManagePolicy {
|
||||||
// Set the hash algo policy as policy for non-revocation signatures
|
// Set the hash algo policy as policy for non-revocation signatures
|
||||||
policy.setSignatureHashAlgorithmPolicy(customPolicy);
|
policy.setSignatureHashAlgorithmPolicy(customPolicy);
|
||||||
|
|
||||||
|
|
||||||
sigHashAlgoPolicy = policy.getSignatureHashAlgorithmPolicy();
|
sigHashAlgoPolicy = policy.getSignatureHashAlgorithmPolicy();
|
||||||
assertTrue(sigHashAlgoPolicy.isAcceptable(HashAlgorithm.SHA512));
|
assertTrue(sigHashAlgoPolicy.isAcceptable(HashAlgorithm.SHA512));
|
||||||
// SHA-1 is now acceptable as well
|
// SHA-1 is now acceptable as well
|
||||||
|
@ -122,7 +120,6 @@ public class ManagePolicy {
|
||||||
assertFalse(pkAlgorithmPolicy.isAcceptable(PublicKeyAlgorithm.RSA_GENERAL, 1024));
|
assertFalse(pkAlgorithmPolicy.isAcceptable(PublicKeyAlgorithm.RSA_GENERAL, 1024));
|
||||||
assertTrue(pkAlgorithmPolicy.isAcceptable(PublicKeyAlgorithm.ECDSA, 256));
|
assertTrue(pkAlgorithmPolicy.isAcceptable(PublicKeyAlgorithm.ECDSA, 256));
|
||||||
|
|
||||||
|
|
||||||
Policy.PublicKeyAlgorithmPolicy customPolicy = new Policy.PublicKeyAlgorithmPolicy(
|
Policy.PublicKeyAlgorithmPolicy customPolicy = new Policy.PublicKeyAlgorithmPolicy(
|
||||||
new HashMap<PublicKeyAlgorithm, Integer>(){{
|
new HashMap<PublicKeyAlgorithm, Integer>(){{
|
||||||
// Put minimum bit strengths for acceptable algorithms.
|
// Put minimum bit strengths for acceptable algorithms.
|
||||||
|
@ -133,7 +130,6 @@ public class ManagePolicy {
|
||||||
);
|
);
|
||||||
policy.setPublicKeyAlgorithmPolicy(customPolicy);
|
policy.setPublicKeyAlgorithmPolicy(customPolicy);
|
||||||
|
|
||||||
|
|
||||||
pkAlgorithmPolicy = policy.getPublicKeyAlgorithmPolicy();
|
pkAlgorithmPolicy = policy.getPublicKeyAlgorithmPolicy();
|
||||||
assertTrue(pkAlgorithmPolicy.isAcceptable(PublicKeyAlgorithm.RSA_GENERAL, 4096));
|
assertTrue(pkAlgorithmPolicy.isAcceptable(PublicKeyAlgorithm.RSA_GENERAL, 4096));
|
||||||
// RSA 2048 is no longer acceptable
|
// RSA 2048 is no longer acceptable
|
||||||
|
@ -156,10 +152,8 @@ public class ManagePolicy {
|
||||||
NotationRegistry notationRegistry = policy.getNotationRegistry();
|
NotationRegistry notationRegistry = policy.getNotationRegistry();
|
||||||
assertFalse(notationRegistry.isKnownNotation("unknown@pgpainless.org"));
|
assertFalse(notationRegistry.isKnownNotation("unknown@pgpainless.org"));
|
||||||
|
|
||||||
|
|
||||||
notationRegistry.addKnownNotation("unknown@pgpainless.org");
|
notationRegistry.addKnownNotation("unknown@pgpainless.org");
|
||||||
|
|
||||||
|
|
||||||
assertTrue(notationRegistry.isKnownNotation("unknown@pgpainless.org"));
|
assertTrue(notationRegistry.isKnownNotation("unknown@pgpainless.org"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,6 @@ public class ModifyKeys {
|
||||||
// the certificate consists of only the public keys
|
// the certificate consists of only the public keys
|
||||||
PGPPublicKeyRing certificate = PGPainless.extractCertificate(secretKey);
|
PGPPublicKeyRing certificate = PGPainless.extractCertificate(secretKey);
|
||||||
|
|
||||||
|
|
||||||
KeyRingInfo info = PGPainless.inspectKeyRing(certificate);
|
KeyRingInfo info = PGPainless.inspectKeyRing(certificate);
|
||||||
assertFalse(info.isSecretKey());
|
assertFalse(info.isSecretKey());
|
||||||
}
|
}
|
||||||
|
@ -79,11 +78,9 @@ public class ModifyKeys {
|
||||||
public void toAsciiArmoredString() throws IOException {
|
public void toAsciiArmoredString() throws IOException {
|
||||||
PGPPublicKeyRing certificate = PGPainless.extractCertificate(secretKey);
|
PGPPublicKeyRing certificate = PGPainless.extractCertificate(secretKey);
|
||||||
|
|
||||||
|
|
||||||
String asciiArmoredSecretKey = PGPainless.asciiArmor(secretKey);
|
String asciiArmoredSecretKey = PGPainless.asciiArmor(secretKey);
|
||||||
String asciiArmoredCertificate = PGPainless.asciiArmor(certificate);
|
String asciiArmoredCertificate = PGPainless.asciiArmor(certificate);
|
||||||
|
|
||||||
|
|
||||||
assertTrue(asciiArmoredSecretKey.startsWith("-----BEGIN PGP PRIVATE KEY BLOCK-----"));
|
assertTrue(asciiArmoredSecretKey.startsWith("-----BEGIN PGP PRIVATE KEY BLOCK-----"));
|
||||||
assertTrue(asciiArmoredCertificate.startsWith("-----BEGIN PGP PUBLIC KEY BLOCK-----"));
|
assertTrue(asciiArmoredCertificate.startsWith("-----BEGIN PGP PUBLIC KEY BLOCK-----"));
|
||||||
}
|
}
|
||||||
|
@ -99,7 +96,6 @@ public class ModifyKeys {
|
||||||
.toNewPassphrase(Passphrase.fromPassword("n3wP4ssW0rD"))
|
.toNewPassphrase(Passphrase.fromPassword("n3wP4ssW0rD"))
|
||||||
.done();
|
.done();
|
||||||
|
|
||||||
|
|
||||||
// Old passphrase no longer works
|
// Old passphrase no longer works
|
||||||
assertThrows(WrongPassphraseException.class, () ->
|
assertThrows(WrongPassphraseException.class, () ->
|
||||||
UnlockSecretKey.unlockSecretKey(secretKey.getSecretKey(), Passphrase.fromPassword(originalPassphrase)));
|
UnlockSecretKey.unlockSecretKey(secretKey.getSecretKey(), Passphrase.fromPassword(originalPassphrase)));
|
||||||
|
@ -120,7 +116,6 @@ public class ModifyKeys {
|
||||||
.toNewPassphrase(Passphrase.fromPassword("cryptP4ssphr4s3"))
|
.toNewPassphrase(Passphrase.fromPassword("cryptP4ssphr4s3"))
|
||||||
.done();
|
.done();
|
||||||
|
|
||||||
|
|
||||||
// encryption key can now only be unlocked using the new passphrase
|
// encryption key can now only be unlocked using the new passphrase
|
||||||
assertThrows(WrongPassphraseException.class, () ->
|
assertThrows(WrongPassphraseException.class, () ->
|
||||||
UnlockSecretKey.unlockSecretKey(
|
UnlockSecretKey.unlockSecretKey(
|
||||||
|
@ -143,7 +138,6 @@ public class ModifyKeys {
|
||||||
.addUserId("additional@user.id", protector)
|
.addUserId("additional@user.id", protector)
|
||||||
.done();
|
.done();
|
||||||
|
|
||||||
|
|
||||||
KeyRingInfo info = PGPainless.inspectKeyRing(secretKey);
|
KeyRingInfo info = PGPainless.inspectKeyRing(secretKey);
|
||||||
assertTrue(info.isUserIdValid("additional@user.id"));
|
assertTrue(info.isUserIdValid("additional@user.id"));
|
||||||
assertFalse(info.isUserIdValid("another@user.id"));
|
assertFalse(info.isUserIdValid("another@user.id"));
|
||||||
|
@ -176,7 +170,6 @@ public class ModifyKeys {
|
||||||
protector)
|
protector)
|
||||||
.done();
|
.done();
|
||||||
|
|
||||||
|
|
||||||
KeyRingInfo info = PGPainless.inspectKeyRing(secretKey);
|
KeyRingInfo info = PGPainless.inspectKeyRing(secretKey);
|
||||||
assertEquals(4, info.getSecretKeys().size());
|
assertEquals(4, info.getSecretKeys().size());
|
||||||
assertEquals(4, info.getPublicKeys().size());
|
assertEquals(4, info.getPublicKeys().size());
|
||||||
|
@ -199,7 +192,6 @@ public class ModifyKeys {
|
||||||
.setExpirationDate(expirationDate, protector)
|
.setExpirationDate(expirationDate, protector)
|
||||||
.done();
|
.done();
|
||||||
|
|
||||||
|
|
||||||
KeyRingInfo info = PGPainless.inspectKeyRing(secretKey);
|
KeyRingInfo info = PGPainless.inspectKeyRing(secretKey);
|
||||||
assertEquals(DateUtil.formatUTCDate(expirationDate),
|
assertEquals(DateUtil.formatUTCDate(expirationDate),
|
||||||
DateUtil.formatUTCDate(info.getPrimaryKeyExpirationDate()));
|
DateUtil.formatUTCDate(info.getPrimaryKeyExpirationDate()));
|
||||||
|
|
|
@ -44,7 +44,6 @@ public class ReadKeys {
|
||||||
PGPPublicKeyRing publicKey = PGPainless.readKeyRing()
|
PGPPublicKeyRing publicKey = PGPainless.readKeyRing()
|
||||||
.publicKeyRing(certificate);
|
.publicKeyRing(certificate);
|
||||||
|
|
||||||
|
|
||||||
KeyRingInfo keyInfo = new KeyRingInfo(publicKey);
|
KeyRingInfo keyInfo = new KeyRingInfo(publicKey);
|
||||||
OpenPgpFingerprint fingerprint = new OpenPgpV4Fingerprint("EB85 BB5F A33A 75E1 5E94 4E63 F231 550C 4F47 E38E");
|
OpenPgpFingerprint fingerprint = new OpenPgpV4Fingerprint("EB85 BB5F A33A 75E1 5E94 4E63 F231 550C 4F47 E38E");
|
||||||
assertEquals(fingerprint, keyInfo.getFingerprint());
|
assertEquals(fingerprint, keyInfo.getFingerprint());
|
||||||
|
@ -77,7 +76,6 @@ public class ReadKeys {
|
||||||
PGPSecretKeyRing secretKey = PGPainless.readKeyRing()
|
PGPSecretKeyRing secretKey = PGPainless.readKeyRing()
|
||||||
.secretKeyRing(key);
|
.secretKeyRing(key);
|
||||||
|
|
||||||
|
|
||||||
KeyRingInfo keyInfo = new KeyRingInfo(secretKey);
|
KeyRingInfo keyInfo = new KeyRingInfo(secretKey);
|
||||||
OpenPgpFingerprint fingerprint = new OpenPgpV4Fingerprint("EB85 BB5F A33A 75E1 5E94 4E63 F231 550C 4F47 E38E");
|
OpenPgpFingerprint fingerprint = new OpenPgpV4Fingerprint("EB85 BB5F A33A 75E1 5E94 4E63 F231 550C 4F47 E38E");
|
||||||
assertEquals(fingerprint, keyInfo.getFingerprint());
|
assertEquals(fingerprint, keyInfo.getFingerprint());
|
||||||
|
|
|
@ -40,7 +40,6 @@ public class UnlockSecretKeys {
|
||||||
// This protector will only unlock unprotected keys
|
// This protector will only unlock unprotected keys
|
||||||
SecretKeyRingProtector protector = SecretKeyRingProtector.unprotectedKeys();
|
SecretKeyRingProtector protector = SecretKeyRingProtector.unprotectedKeys();
|
||||||
|
|
||||||
|
|
||||||
assertProtectorUnlocksAllSecretKeys(unprotectedKey, protector);
|
assertProtectorUnlocksAllSecretKeys(unprotectedKey, protector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +104,6 @@ public class UnlockSecretKeys {
|
||||||
protector.addPassphrase(new OpenPgpV4Fingerprint("DD8E1195E4B1720E7FB10EF7F60402708E75D941"),
|
protector.addPassphrase(new OpenPgpV4Fingerprint("DD8E1195E4B1720E7FB10EF7F60402708E75D941"),
|
||||||
Passphrase.fromPassword("s3c0ndsubk3y"));
|
Passphrase.fromPassword("s3c0ndsubk3y"));
|
||||||
|
|
||||||
|
|
||||||
assertProtectorUnlocksAllSecretKeys(secretKey, protector);
|
assertProtectorUnlocksAllSecretKeys(secretKey, protector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue