From d9ac1385950217893be6f0d6fdb3324b8647d16b Mon Sep 17 00:00:00 2001 From: Ingo Klöcker Date: Mon, 24 Oct 2022 12:21:41 +0200 Subject: cpp: Allow setting the curve to use when generating ECC keys lang/cpp/src/gpggencardkeyinteractor.h (class GpgGenCardKeyInteractor): Add enum Curve. Add member function setCurve. lang/cpp/src/gpggencardkeyinteractor.cpp (class GpgGenCardKeyInteractor::Private): Initialize simple members in-class. Add member curve. (GpgGenCardKeyInteractor::~GpgGenCardKeyInteractor): Use default d'tor. (GpgGenCardKeyInteractor::setCurve): New. (GpgGenCardKeyInteractor::action): Return curve defaulting to Curve25519. -- This enables users of this interactor to request the generation of ECC keys with a specific curve as smart card keys. It's up to the user to specify a curve that is actually supported by the smart card. GnuPG-bug-id: 4429 --- lang/cpp/src/gpggencardkeyinteractor.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'lang/cpp/src/gpggencardkeyinteractor.h') diff --git a/lang/cpp/src/gpggencardkeyinteractor.h b/lang/cpp/src/gpggencardkeyinteractor.h index 3d9c7136..09a73b6a 100644 --- a/lang/cpp/src/gpggencardkeyinteractor.h +++ b/lang/cpp/src/gpggencardkeyinteractor.h @@ -58,10 +58,27 @@ public: enum Algo { RSA = 1, - ECC = 2 + ECC = 2, }; void setAlgo(Algo algo); + // the enum values minus 1 have to match the indexes of the curves used by + // ask_curve() in gnupg's g10/keygen.c + enum Curve { + DefaultCurve = 0, // currently Curve25519 + Curve25519 = 1, + Curve448, + NISTP256, + NISTP384, + NISTP521, + BrainpoolP256, + BrainpoolP384, + BrainpoolP512, + Secp256k1, + LastCurve = Secp256k1, + }; + void setCurve(Curve curve); + std::string backupFileName() const; private: -- cgit