From 9b5754879a95cbc45febf0eaba172bbd09d52152 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Mon, 19 Feb 2024 14:56:25 +0100 Subject: [PATCH] Add more documentation --- .../key/generation/OpenPgpKeyGenerator.kt | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pgpainless-core/src/main/kotlin/org/pgpainless/key/generation/OpenPgpKeyGenerator.kt b/pgpainless-core/src/main/kotlin/org/pgpainless/key/generation/OpenPgpKeyGenerator.kt index d8be5344..3e088703 100644 --- a/pgpainless-core/src/main/kotlin/org/pgpainless/key/generation/OpenPgpKeyGenerator.kt +++ b/pgpainless-core/src/main/kotlin/org/pgpainless/key/generation/OpenPgpKeyGenerator.kt @@ -34,6 +34,19 @@ import org.pgpainless.signature.builder.SubkeyBindingSignatureBuilder import org.pgpainless.signature.subpackets.SelfSignatureSubpackets import org.pgpainless.util.Passphrase +/** + * API for generating OpenPGP keys. The API allows to generate keys of different OpenPGP protocol + * versions (currently only v4). The API is divided into an opinionated and unopinionated + * implementation. + * + * The opinionated implementation will sanitize algorithms and key sizes and will furthermore make + * sure that required signatures (e.g. direct-key or binding signatures) are placed on the key, + * while the unopinionated API allows for the use of weak algorithms and does not add any signatures + * by itself. + * + * You can switch from the opinionated API to the unopinionated API by calling `unopinionated()` on + * the builder. + */ class OpenPgpKeyGenerator internal constructor() { companion object { @@ -125,7 +138,13 @@ internal constructor(val policy: Policy, val creationTime: Date, val preferences ): PGPKeyPair /** - * Define the primary key for the OpenPGP key. + * Define the primary key for the OpenPGP key. Example: + * ``` + * setPrimaryKey(KeyType.EDDSA(EdDSACurve._Ed25519)) { + * addUserId("Alice ") + * addUserId("Bob ") + * } + * ``` * * @param type primary key type * @param keyFlags list of key flags that denote the primary keys capabilities