Rename key generation typealiases
This commit is contained in:
parent
42516d53b8
commit
05cef99f40
|
@ -31,13 +31,13 @@ import org.pgpainless.util.Passphrase
|
|||
* Function block that is applied to the OpenPGP [PrimaryKeyBuilder]. Within this block, you add
|
||||
* User-IDs, User-Attributes and Direct-Key signatures on the primary key.
|
||||
*/
|
||||
typealias PrimaryKeyBlock = (PrimaryKeyBuilder.() -> Unit)
|
||||
typealias PrimaryKeyBuilderBlock = (PrimaryKeyBuilder.() -> Unit)
|
||||
|
||||
/**
|
||||
* Function block that is applied to an OpenPGP [SubkeyBuilder]. Here you typically add
|
||||
* subkey-binding signatures.
|
||||
*/
|
||||
typealias SubkeyBlock = (SubkeyBuilder.() -> Unit)
|
||||
typealias SubkeyBuilderBlock = (SubkeyBuilder.() -> Unit)
|
||||
|
||||
/**
|
||||
* API for generating OpenPGP keys. The API allows to generate keys of different OpenPGP protocol
|
||||
|
@ -140,7 +140,7 @@ internal constructor(val policy: Policy, val creationTime: Date, val preferences
|
|||
*/
|
||||
protected abstract fun invokeOnPrimaryKey(
|
||||
primaryKey: PGPKeyPair,
|
||||
block: PrimaryKeyBlock?
|
||||
block: PrimaryKeyBuilderBlock?
|
||||
): PGPKeyPair
|
||||
|
||||
/**
|
||||
|
@ -165,7 +165,7 @@ internal constructor(val policy: Policy, val creationTime: Date, val preferences
|
|||
type: KeyType,
|
||||
keyFlags: List<KeyFlag>? = listOf(KeyFlag.CERTIFY_OTHER),
|
||||
creationTime: Date = this.creationTime,
|
||||
block: PrimaryKeyBlock? = null
|
||||
block: PrimaryKeyBuilderBlock? = null
|
||||
): O {
|
||||
require(type.canCertify) {
|
||||
"Primary key cannot use algorithm ${type.algorithm} because it needs to be " +
|
||||
|
@ -174,14 +174,14 @@ internal constructor(val policy: Policy, val creationTime: Date, val preferences
|
|||
return doSetPrimaryKey(type, keyFlags, creationTime, block)
|
||||
}
|
||||
|
||||
fun setPrimaryKey(type: KeyType, block: PrimaryKeyBlock?): O =
|
||||
fun setPrimaryKey(type: KeyType, block: PrimaryKeyBuilderBlock?): O =
|
||||
setPrimaryKey(type, listOf(KeyFlag.CERTIFY_OTHER), this.creationTime, block)
|
||||
|
||||
protected abstract fun doSetPrimaryKey(
|
||||
type: KeyType,
|
||||
keyFlags: List<KeyFlag>?,
|
||||
creationTime: Date,
|
||||
block: PrimaryKeyBlock?
|
||||
block: PrimaryKeyBuilderBlock?
|
||||
): O
|
||||
|
||||
/**
|
||||
|
@ -456,7 +456,7 @@ internal constructor(
|
|||
type: KeyType,
|
||||
flags: List<KeyFlag>? = null,
|
||||
creationTime: Date = this.creationTime,
|
||||
block: SubkeyBlock? = null
|
||||
block: SubkeyBuilderBlock? = null
|
||||
): B =
|
||||
apply {
|
||||
sanitizeKeyFlags(type.algorithm, flags)
|
||||
|
@ -465,7 +465,7 @@ internal constructor(
|
|||
var subkey = generateSubkey(type, creationTime)
|
||||
|
||||
// Default function block will only set appropriate key flags
|
||||
val defaultBlock: SubkeyBlock = {
|
||||
val defaultBlock: SubkeyBuilderBlock = {
|
||||
addBindingSignature(
|
||||
SelfSignatureSubpackets.applyHashed { flags?.let { setKeyFlags(it) } },
|
||||
bindingTime = creationTime)
|
||||
|
@ -491,7 +491,7 @@ internal constructor(
|
|||
* @param block function block
|
||||
* @return modified subkey
|
||||
*/
|
||||
protected abstract fun invokeOnSubkey(subkey: PGPKeyPair, block: SubkeyBlock?): PGPKeyPair
|
||||
protected abstract fun invokeOnSubkey(subkey: PGPKeyPair, block: SubkeyBuilderBlock?): PGPKeyPair
|
||||
|
||||
/**
|
||||
* Generate an OpenPGP subkey.
|
||||
|
|
|
@ -120,7 +120,7 @@ internal constructor(primaryKey: PGPKeyPair, subkey: PGPKeyPair, builder: Define
|
|||
return OpenPgpKeyPairGenerator.V4().generateSubkey(type, creationTime)
|
||||
}
|
||||
|
||||
override fun invokeOnSubkey(subkey: PGPKeyPair, block: SubkeyBlock?): PGPKeyPair {
|
||||
override fun invokeOnSubkey(subkey: PGPKeyPair, block: SubkeyBuilderBlock?): PGPKeyPair {
|
||||
return with(SubkeyBuilderV4(primaryKey, subkey, this)) {
|
||||
if (block != null) {
|
||||
block()
|
||||
|
@ -224,7 +224,7 @@ internal constructor(policy: Policy, creationTime: Date, preferences: AlgorithmS
|
|||
type: KeyType,
|
||||
keyFlags: List<KeyFlag>?,
|
||||
creationTime: Date,
|
||||
block: PrimaryKeyBlock?
|
||||
block: PrimaryKeyBuilderBlock?
|
||||
): OpinionatedDefineSubkeysV4 {
|
||||
|
||||
// Check key strength
|
||||
|
@ -325,7 +325,7 @@ internal constructor(policy: Policy, creationTime: Date, preferences: AlgorithmS
|
|||
type: KeyType,
|
||||
keyFlags: List<KeyFlag>?,
|
||||
creationTime: Date,
|
||||
block: PrimaryKeyBlock?
|
||||
block: PrimaryKeyBuilderBlock?
|
||||
): UnopinionatedDefineSubkeysV4 {
|
||||
|
||||
// Add user-provided signatures
|
||||
|
@ -374,7 +374,7 @@ internal constructor(
|
|||
fun addSigningSubkey(
|
||||
type: KeyType,
|
||||
creationTime: Date = this.creationTime,
|
||||
block: SubkeyBlock? = null
|
||||
block: SubkeyBuilderBlock? = null
|
||||
): OpinionatedDefineSubkeysV4 {
|
||||
return addSubkey(type, listOf(KeyFlag.SIGN_DATA), creationTime, block)
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ internal constructor(
|
|||
* @param type signing key type
|
||||
* @param block function block to add binding signatures to the subkey
|
||||
*/
|
||||
fun addSigningSubkey(type: KeyType, block: SubkeyBlock?) =
|
||||
fun addSigningSubkey(type: KeyType, block: SubkeyBuilderBlock?) =
|
||||
addSigningSubkey(type, this.creationTime, block)
|
||||
|
||||
/**
|
||||
|
@ -403,7 +403,7 @@ internal constructor(
|
|||
fun addEncryptionSubkey(
|
||||
type: KeyType,
|
||||
creationTime: Date = this.creationTime,
|
||||
block: SubkeyBlock? = null,
|
||||
block: SubkeyBuilderBlock? = null,
|
||||
): OpinionatedDefineSubkeysV4 {
|
||||
return addSubkey(
|
||||
type, listOf(KeyFlag.ENCRYPT_COMMS, KeyFlag.ENCRYPT_STORAGE), creationTime, block)
|
||||
|
@ -417,7 +417,7 @@ internal constructor(
|
|||
* @param type encryption key type
|
||||
* @param block function block to add binding signatures to the subkey
|
||||
*/
|
||||
fun addEncryptionSubkey(type: KeyType, block: SubkeyBlock?) =
|
||||
fun addEncryptionSubkey(type: KeyType, block: SubkeyBuilderBlock?) =
|
||||
addEncryptionSubkey(type, this.creationTime, block)
|
||||
|
||||
override fun sanitizeHashAlgorithm(algorithm: HashAlgorithm) {
|
||||
|
@ -582,7 +582,7 @@ class PrimaryKeyBuilderV4 internal constructor(keyPair: PGPKeyPair, builder: Def
|
|||
|
||||
override fun invokeOnPrimaryKey(
|
||||
primaryKey: PGPKeyPair,
|
||||
block: PrimaryKeyBlock?
|
||||
block: PrimaryKeyBuilderBlock?
|
||||
): PGPKeyPair {
|
||||
return with(PrimaryKeyBuilderV4(primaryKey, this)) {
|
||||
if (block != null) {
|
||||
|
|
Loading…
Reference in New Issue