feature: Initial commit.

This commit is contained in:
greysoh 2024-10-19 14:49:24 -04:00
commit c6c407d205
Signed by: imterah
GPG key ID: 8FA7DD57BA6CEA37
12 changed files with 1402 additions and 0 deletions

41
tests/create_keyring.go Normal file
View file

@ -0,0 +1,41 @@
package bismuthd_test
import (
"github.com/ProtonMail/gopenpgp/v3/crypto"
"github.com/ProtonMail/gopenpgp/v3/profile"
)
// Creates an armored GPG keyring
// Argument order is public key, then private key
func CreateKeyring(name, email string) (string, string, error) {
pgp := crypto.PGPWithProfile(profile.RFC9580())
privateKey, err := pgp.KeyGeneration().
AddUserId(name, email).
New().
GenerateKey()
if err != nil {
return "", "", err
}
publicKey, err := privateKey.ToPublic()
if err != nil {
return "", "", err
}
privateKeyArmored, err := privateKey.Armor()
if err != nil {
return "", "", err
}
publicKeyArmored, err := publicKey.Armor()
if err != nil {
return "", "", err
}
return publicKeyArmored, privateKeyArmored, nil
}