1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-25 04:17:59 +01:00

More tests

This commit is contained in:
Paul Schaub 2024-02-21 14:33:18 +01:00
parent 95bd9532bd
commit 4afc30c462
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -414,4 +414,29 @@ class OpenPgpKeyGeneratorTest {
.setPrimaryKey(KeyType.EDDSA(EdDSACurve._Ed25519))
.addSubkey(KeyType.XDH(XDHSpec._X25519)) { addBindingSignature(bindingTime = t0) }
}
@Test
fun `opinionated add subkey with weak binding signature hash algorithm fails`() {
val policy = Policy()
assertThrows<IllegalArgumentException> {
OpenPgpKeyGenerator.buildV4Key(policy)
.setPrimaryKey(KeyType.EDDSA(EdDSACurve._Ed25519))
.addSubkey(KeyType.XDH(XDHSpec._X25519)) {
addBindingSignature(hashAlgorithm = HashAlgorithm.SHA1)
}
}
}
@Test
fun `unopinionated add subkey with weak binding signature hash algorithm is okay`() {
val policy = Policy()
OpenPgpKeyGenerator.buildV4Key(policy)
.setPrimaryKey(KeyType.EDDSA(EdDSACurve._Ed25519))
.unopinionated()
.addSubkey(KeyType.XDH(XDHSpec._X25519)) {
addBindingSignature(hashAlgorithm = HashAlgorithm.SHA1)
}
}
}