mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-12-22 12:57:57 +01:00
Add test for signing with protected key without password
This commit is contained in:
parent
0d9db2bdd3
commit
c95ca8fedc
2 changed files with 28 additions and 1 deletions
|
@ -96,7 +96,11 @@ public class DetachedSignExternal implements DetachedSign {
|
|||
}
|
||||
|
||||
data.close();
|
||||
processOut.close();
|
||||
try {
|
||||
processOut.close();
|
||||
} catch (IOException e) {
|
||||
// Ignore Stream closed
|
||||
}
|
||||
|
||||
while ((r = processIn.read(buf)) > 0) {
|
||||
outputStream.write(buf, 0 , r);
|
||||
|
|
|
@ -166,4 +166,27 @@ public class ExternalDetachedSignVerifyRoundTripTest extends AbstractExternalSOP
|
|||
.signatures(signature)
|
||||
.data(message));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void signVerifyWithFreshEncryptedKeyWithoutPassphraseFails() throws IOException {
|
||||
ignoreIf("sqop", Is.leq, "0.27.2"); // does not return exit code 67 for encrypted keys without passphrase
|
||||
|
||||
byte[] keyPassword = "sw0rdf1sh".getBytes(StandardCharsets.UTF_8);
|
||||
byte[] key = getSop().generateKey()
|
||||
.userId("Alice <alice@openpgp.org>")
|
||||
.withKeyPassword(keyPassword)
|
||||
.generate()
|
||||
.getBytes();
|
||||
|
||||
byte[] message = "Hello, World!\n".getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
assertThrows(SOPGPException.KeyIsProtected.class, () ->
|
||||
getSop().detachedSign()
|
||||
.key(key)
|
||||
.data(message)
|
||||
.toByteArrayAndResult()
|
||||
.getBytes());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue