1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-12-10 14:21:09 +01:00

Add documentation

This commit is contained in:
Paul Schaub 2025-05-13 13:53:55 +02:00
parent f3b5664d95
commit 8c7e9e1b54
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
10 changed files with 144 additions and 43 deletions

View file

@ -4,18 +4,12 @@
package org.pgpainless.bouncycastle.extensions
import java.io.ByteArrayOutputStream
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.Assertions.assertNull
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.pgpainless.PGPainless
import org.pgpainless.encryption_signing.ProducerOptions
import org.pgpainless.encryption_signing.SigningOptions
import org.pgpainless.key.TestKeys
import org.pgpainless.key.protection.SecretKeyRingProtector
class PGPSecretKeyRingExtensionsTest {
@ -46,23 +40,4 @@ class PGPSecretKeyRingExtensionsTest {
}
assertThrows<NoSuchElementException> { key.requireSecretKey(TestKeys.ROMEO_FINGERPRINT) }
}
@Test
fun testGetSecretKeyForSignature() {
val key = TestKeys.getEmilKey()
val signer =
PGPainless.getInstance()
.generateMessage()
.onOutputStream(ByteArrayOutputStream())
.withOptions(
ProducerOptions.sign(
SigningOptions.get()
.addDetachedSignature(SecretKeyRingProtector.unprotectedKeys(), key)))
signer.write("Hello, World!\n".toByteArray())
signer.close()
val sig = signer.result.detachedSignatures.first().value.first()
assertNotNull(key.getSecretKeyFor(sig))
assertNull(TestKeys.getRomeoSecretKeyRing().getSecretKeyFor(sig))
}
}