Add implementation of update-key command

This commit is contained in:
Paul Schaub 2024-09-17 22:43:36 +02:00
parent 1dcf13244d
commit 4115a5041d
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
6 changed files with 163 additions and 12 deletions

View file

@ -4,18 +4,7 @@
package sop
import sop.operation.Armor
import sop.operation.ChangeKeyPassword
import sop.operation.Dearmor
import sop.operation.Decrypt
import sop.operation.DetachedSign
import sop.operation.Encrypt
import sop.operation.ExtractCert
import sop.operation.GenerateKey
import sop.operation.InlineDetach
import sop.operation.InlineSign
import sop.operation.ListProfiles
import sop.operation.RevokeKey
import sop.operation.*
/**
* Stateless OpenPGP Interface. This class provides a stateless interface to various OpenPGP related
@ -70,4 +59,9 @@ interface SOP : SOPV {
/** Update a key's password. */
fun changeKeyPassword(): ChangeKeyPassword
/**
* Keep a secret key up-to-date.
*/
fun updateKey(): UpdateKey
}

View file

@ -0,0 +1,43 @@
// SPDX-FileCopyrightText: 2024 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package sop.operation
import sop.Ready
import sop.exception.SOPGPException
import sop.util.UTF8Util
import java.io.IOException
import java.io.InputStream
interface UpdateKey {
/**
* Disable ASCII armor encoding of the output.
*
* @return builder instance
*/
fun noArmor(): UpdateKey
@Throws(SOPGPException.UnsupportedOption::class) fun signingOnly(): UpdateKey
@Throws(SOPGPException.UnsupportedOption::class) fun noNewMechanisms(): UpdateKey
@Throws(SOPGPException.PasswordNotHumanReadable::class, SOPGPException.UnsupportedOption::class)
fun withKeyPassword(password: String): UpdateKey = withKeyPassword(password.toByteArray(UTF8Util.UTF8))
@Throws(SOPGPException.PasswordNotHumanReadable::class, SOPGPException.UnsupportedOption::class)
fun withKeyPassword(password: ByteArray): UpdateKey
@Throws(SOPGPException.UnsupportedOption::class, SOPGPException.BadData::class, IOException::class)
fun mergeCerts(certs: InputStream): UpdateKey
@Throws(SOPGPException.UnsupportedOption::class, SOPGPException.BadData::class, IOException::class)
fun mergeCerts(certs: ByteArray): UpdateKey = mergeCerts(certs.inputStream())
@Throws(SOPGPException.BadData::class, IOException::class, SOPGPException.KeyIsProtected::class, SOPGPException.PrimaryKeyBad::class)
fun key(key: InputStream): Ready
@Throws(SOPGPException.BadData::class, IOException::class, SOPGPException.KeyIsProtected::class, SOPGPException.PrimaryKeyBad::class)
fun key(key: ByteArray): Ready = key(key.inputStream())
}