mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-25 04:17:59 +01:00
Add tests for keys with malformed sig subpackets
This commit is contained in:
parent
b164900a59
commit
0d3fb446a8
1 changed files with 47 additions and 7 deletions
|
@ -4,7 +4,9 @@
|
|||
|
||||
package org.pgpainless.key.generation
|
||||
|
||||
import org.bouncycastle.bcpg.sig.Exportable
|
||||
import org.bouncycastle.bcpg.sig.PrimaryUserID
|
||||
import org.bouncycastle.bcpg.sig.Revocable
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.pgpainless.PGPainless
|
||||
import org.pgpainless.key.generation.type.KeyType
|
||||
|
@ -17,17 +19,55 @@ class MalformedKeyGenerationTest {
|
|||
@Test
|
||||
fun malformedPrimaryUserIdSubpacket() {
|
||||
val userId = "Alice <alice@pgpainless.org>"
|
||||
val key = GenerateOpenPgpKey(Policy.getInstance())
|
||||
.buildV4Key(KeyType.EDDSA(EdDSACurve._Ed25519))
|
||||
.addUserId(userId,
|
||||
SelfSignatureSubpackets.applyHashed {
|
||||
setPrimaryUserId(PrimaryUserID(false, false, byteArrayOf(0x02)))
|
||||
})
|
||||
.build()
|
||||
val key =
|
||||
GenerateOpenPgpKey(Policy.getInstance())
|
||||
.buildV4Key(KeyType.EDDSA(EdDSACurve._Ed25519))
|
||||
.addUserId(
|
||||
userId,
|
||||
SelfSignatureSubpackets.applyHashed {
|
||||
setPrimaryUserId(PrimaryUserID(false, false, byteArrayOf(0x02)))
|
||||
})
|
||||
.build()
|
||||
|
||||
println(PGPainless.asciiArmor(key))
|
||||
|
||||
PGPainless.readKeyRing().secretKeyRing(key.encoded)!!
|
||||
// TODO: Check interpretation of faulty PrimaryUserID packet
|
||||
}
|
||||
|
||||
@Test
|
||||
fun malformedExportableSubpacket() {
|
||||
val key =
|
||||
GenerateOpenPgpKey(Policy.getInstance())
|
||||
.buildV4Key(KeyType.EDDSA(EdDSACurve._Ed25519))
|
||||
.addUserId(
|
||||
"Alice <alice@pgpainless.org>",
|
||||
SelfSignatureSubpackets.applyHashed {
|
||||
setExportable(Exportable(false, false, byteArrayOf(0x03)))
|
||||
})
|
||||
.build()
|
||||
|
||||
println(PGPainless.asciiArmor(key))
|
||||
|
||||
PGPainless.readKeyRing().secretKeyRing(key.encoded)!!
|
||||
// TODO: Check interpretation of faulty packet
|
||||
}
|
||||
|
||||
@Test
|
||||
fun malformedRevocableSubpacket() {
|
||||
val key =
|
||||
GenerateOpenPgpKey(Policy.getInstance())
|
||||
.buildV4Key(KeyType.EDDSA(EdDSACurve._Ed25519))
|
||||
.addUserId(
|
||||
"Alice <alice@pgpainless.org>",
|
||||
SelfSignatureSubpackets.applyHashed {
|
||||
setRevocable(Revocable(false, false, byteArrayOf(0x04)))
|
||||
})
|
||||
.build()
|
||||
|
||||
println(PGPainless.asciiArmor(key))
|
||||
|
||||
PGPainless.readKeyRing().secretKeyRing(key.encoded)!!
|
||||
// TODO: Check interpretation of faulty packet
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue