Skip to content

Instantly share code, notes, and snippets.

@SomajitDey
Last active November 22, 2023 08:37
Show Gist options
  • Save SomajitDey/1c458b7191935b36f04eec08e62bf9c1 to your computer and use it in GitHub Desktop.
Save SomajitDey/1c458b7191935b36f04eec08e62bf9c1 to your computer and use it in GitHub Desktop.
Create ECC (elliptic curve crypto) keys using curve 25519 with/for GPG
#!/usr/bin/env -S gpg --batch --expert --gen-key
# Brief: Generate ECC PGP keys for signing (primary key) & encryption (subkey)
# Run as: chmod +x gpg_ecc-25519_keygen; ./gpg_ecc-25519_keygen
# Ref: https://www.gnupg.org/documentation/manuals/gnupg/Unattended-GPG-key-generation.html
%echo "Generating ECC keys (sign & encr) with no-expiry"
%no-protection
Key-Type: EDDSA
Key-Curve: ed25519
Subkey-Type: ECDH
Subkey-Curve: cv25519
Name-Real: dummy
Expire-Date: 0
# Now, let's do a commit here, so that we can later print "done" :-)
%commit
%echo Done
@adamjrat
Copy link

adamjrat commented Apr 4, 2023

I have a feeling the result is not for "signing" usage.
If you do not add the following line the result is encr only, but anyway it fails with specified Subkey-Usage not allowed for algo 18
Subkey-Usage: sign encrypt

@kuan51
Copy link

kuan51 commented Sep 25, 2023

@adamjrat I think thats because cv25519 is for encryption and ECDH while the primary key is used for signing. It should work with Subkey-Usage: encrypt and key-usage: sign.

Alternatively, you dont need to specify the key usages. The documentation says:

If no ‘Key-Usage’ is specified and the ‘Key-Type’ is not ‘default’, all allowed usages for that particular algorithm are used

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment