mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-10 02:39:45 +02:00
Move signature verification operations to sopv interface subset
This commit is contained in:
parent
7b04275625
commit
34a05e96a1
10 changed files with 224 additions and 25 deletions
|
@ -9,16 +9,13 @@ import sop.operation.ChangeKeyPassword
|
|||
import sop.operation.Dearmor
|
||||
import sop.operation.Decrypt
|
||||
import sop.operation.DetachedSign
|
||||
import sop.operation.DetachedVerify
|
||||
import sop.operation.Encrypt
|
||||
import sop.operation.ExtractCert
|
||||
import sop.operation.GenerateKey
|
||||
import sop.operation.InlineDetach
|
||||
import sop.operation.InlineSign
|
||||
import sop.operation.InlineVerify
|
||||
import sop.operation.ListProfiles
|
||||
import sop.operation.RevokeKey
|
||||
import sop.operation.Version
|
||||
|
||||
/**
|
||||
* Stateless OpenPGP Interface. This class provides a stateless interface to various OpenPGP related
|
||||
|
@ -26,10 +23,7 @@ import sop.operation.Version
|
|||
* intended for reuse. If you for example need to generate multiple keys, make a dedicated call to
|
||||
* [generateKey] once per key generation.
|
||||
*/
|
||||
interface SOP {
|
||||
|
||||
/** Get information about the implementations name and version. */
|
||||
fun version(): Version
|
||||
interface SOP : SOPV {
|
||||
|
||||
/** Generate a secret key. */
|
||||
fun generateKey(): GenerateKey
|
||||
|
@ -53,24 +47,6 @@ interface SOP {
|
|||
*/
|
||||
fun inlineSign(): InlineSign
|
||||
|
||||
/**
|
||||
* Verify detached signatures. If you need to verify an inline-signed message, use
|
||||
* [inlineVerify] instead.
|
||||
*/
|
||||
fun verify(): DetachedVerify = detachedVerify()
|
||||
|
||||
/**
|
||||
* Verify detached signatures. If you need to verify an inline-signed message, use
|
||||
* [inlineVerify] instead.
|
||||
*/
|
||||
fun detachedVerify(): DetachedVerify
|
||||
|
||||
/**
|
||||
* Verify signatures of an inline-signed message. If you need to verify detached signatures over
|
||||
* a message, use [detachedVerify] instead.
|
||||
*/
|
||||
fun inlineVerify(): InlineVerify
|
||||
|
||||
/** Detach signatures from an inline signed message. */
|
||||
fun inlineDetach(): InlineDetach
|
||||
|
||||
|
|
34
sop-java/src/main/kotlin/sop/SOPV.kt
Normal file
34
sop-java/src/main/kotlin/sop/SOPV.kt
Normal file
|
@ -0,0 +1,34 @@
|
|||
// SPDX-FileCopyrightText: 2024 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop
|
||||
|
||||
import sop.operation.DetachedVerify
|
||||
import sop.operation.InlineVerify
|
||||
import sop.operation.Version
|
||||
|
||||
/** Subset of [SOP] implementing only OpenPGP signature verification. */
|
||||
interface SOPV {
|
||||
|
||||
/** Get information about the implementations name and version. */
|
||||
fun version(): Version
|
||||
|
||||
/**
|
||||
* Verify detached signatures. If you need to verify an inline-signed message, use
|
||||
* [inlineVerify] instead.
|
||||
*/
|
||||
fun verify(): DetachedVerify = detachedVerify()
|
||||
|
||||
/**
|
||||
* Verify detached signatures. If you need to verify an inline-signed message, use
|
||||
* [inlineVerify] instead.
|
||||
*/
|
||||
fun detachedVerify(): DetachedVerify
|
||||
|
||||
/**
|
||||
* Verify signatures of an inline-signed message. If you need to verify detached signatures over
|
||||
* a message, use [detachedVerify] instead.
|
||||
*/
|
||||
fun inlineVerify(): InlineVerify
|
||||
}
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
package sop.operation
|
||||
|
||||
import kotlin.jvm.Throws
|
||||
import sop.exception.SOPGPException
|
||||
|
||||
interface Version {
|
||||
|
||||
/**
|
||||
|
@ -97,4 +100,11 @@ interface Version {
|
|||
* @return remarks or null
|
||||
*/
|
||||
fun getSopSpecImplementationRemarks(): String?
|
||||
|
||||
/**
|
||||
* Return the single-line SEMVER version of the sopv interface subset it provides complete
|
||||
* coverage of. If the implementation does not provide complete coverage for any sopv interface,
|
||||
* this method throws an [SOPGPException.UnsupportedOption] instead.
|
||||
*/
|
||||
@Throws(SOPGPException.UnsupportedOption::class) fun getSopVVersion(): String
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.junit.jupiter.params.provider.Arguments;
|
|||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.opentest4j.TestAbortedException;
|
||||
import sop.SOP;
|
||||
import sop.exception.SOPGPException;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
@ -72,4 +73,17 @@ public class VersionTest extends AbstractSOPTest {
|
|||
int sopRevision = sop.version().getSopSpecRevisionNumber();
|
||||
assertTrue(sop.version().getSopSpecRevisionName().endsWith("" + sopRevision));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideInstances")
|
||||
public void sopVVersionTest(SOP sop) {
|
||||
try {
|
||||
sop.version().getSopVVersion();
|
||||
} catch (SOPGPException.UnsupportedOption e) {
|
||||
throw new TestAbortedException(
|
||||
"Implementation does (gracefully) not provide coverage for any sopv interface version.");
|
||||
} catch (RuntimeException e) {
|
||||
throw new TestAbortedException("Implementation does not provide coverage for any sopv interface version.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue