mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
agent: Add new shadow key type and functions to call tpm2daemon
* agent/call-tpm2d.c: New. * divert-tpm2.c: New. * agent/Makefile.am: Add new files. * agent/agent.h (DAEMON_TPM2D): New. Add stub fucntions. * agent/call-daemon.c (GNUPG_MODULE_NAME_TPM2DAEMON): New. * agent/command.c (do_one_keyinfo): Handle tpmv2. * agent/gpg-agent.c (oTpm2daemonProgram): New. (opts): New option --tpm2daemon-program. (parse_rereadable_options): Handle option. * agent/pkdecrypt.c (agent_pkdecrypt): Divert to tpm2d. (agent_pksign_do): Ditto. --- A new shadow key type: "tpm2-v1" is introduced signalling that the shadowed key is handled by the tpm2daemon. A function to identify this type is introduced and diversions to the tpm2daemon functions are conditioned on this function for pkign and pkdecrypt where the same diversions to scd are currently done. The (info) field of the shadowed key stores the actual TPM key. The TPM key is encrypted so only the physical TPM it was created on can read it (so no special protection is required for the info filed), but if the (info) field becomes corrupt or damaged, the key will be lost (unlike the token case, where the key is actually moved inside the token). Note, this commit adds handling for existing TPM format shadow keys, but there is still no way to create them. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> Additional changes: * Add ChangeLog entries. * Some minor indentation fixes. * agent/Makefile.am (gpg_agent_SOURCES): Change to make distcheck work. * agent/agent.h [!HAVE_LIBTSS]: Do not return -EINVAL but an gpg_error_t. Mark args as unused. * agent/protect.c (agent_is_tpm2_key): Free BUF. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
62a7854816
commit
1f995b9ba4
11 changed files with 519 additions and 22 deletions
|
@ -59,6 +59,7 @@
|
|||
enum daemon_type
|
||||
{
|
||||
DAEMON_SCD,
|
||||
DAEMON_TPM2D,
|
||||
DAEMON_MAX_TYPE
|
||||
};
|
||||
|
||||
|
@ -459,6 +460,7 @@ gpg_error_t agent_public_key_from_file (ctrl_t ctrl,
|
|||
const unsigned char *grip,
|
||||
gcry_sexp_t *result);
|
||||
int agent_pk_get_algo (gcry_sexp_t s_key);
|
||||
int agent_is_tpm2_key(gcry_sexp_t s_key);
|
||||
int agent_key_available (const unsigned char *grip);
|
||||
gpg_error_t agent_key_info_from_file (ctrl_t ctrl, const unsigned char *grip,
|
||||
int *r_keytype,
|
||||
|
@ -577,6 +579,52 @@ gpg_error_t agent_marktrusted (ctrl_t ctrl, const char *name,
|
|||
const char *fpr, int flag);
|
||||
void agent_reload_trustlist (void);
|
||||
|
||||
/*-- divert-tpm2.c --*/
|
||||
#ifdef HAVE_LIBTSS
|
||||
int divert_tpm2_pksign (ctrl_t ctrl, const char *desc_text,
|
||||
const unsigned char *digest, size_t digestlen, int algo,
|
||||
const unsigned char *shadow_info, unsigned char **r_sig,
|
||||
size_t *r_siglen);
|
||||
int divert_tpm2_pkdecrypt (ctrl_t ctrl, const char *desc_text,
|
||||
const unsigned char *cipher,
|
||||
const unsigned char *shadow_info,
|
||||
char **r_buf, size_t *r_len, int *r_padding);
|
||||
int divert_tpm2_writekey (ctrl_t ctrl, const unsigned char *grip,
|
||||
gcry_sexp_t s_skey);
|
||||
#else /*!HAVE_LIBTSS*/
|
||||
static inline int
|
||||
divert_tpm2_pksign (ctrl_t ctrl, const char *desc_text,
|
||||
const unsigned char *digest,
|
||||
size_t digestlen, int algo,
|
||||
const unsigned char *shadow_info,
|
||||
unsigned char **r_sig,
|
||||
size_t *r_siglen)
|
||||
{
|
||||
(void)ctrl; (void)desc_text; (void)digest; (void)digestlen;
|
||||
(void)algo; (void)shadow_info; (void)r_sig; (void)r_siglen;
|
||||
return gpg_error (GPG_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
static inline int
|
||||
divert_tpm2_pkdecrypt (ctrl_t ctrl, const char *desc_text,
|
||||
const unsigned char *cipher,
|
||||
const unsigned char *shadow_info,
|
||||
char **r_buf, size_t *r_len,
|
||||
int *r_padding)
|
||||
{
|
||||
(void)ctrl; (void)desc_text; (void)cipher; (void)shadow_info;
|
||||
(void)r_buf; (void)r_len; (void)r_padding;
|
||||
return gpg_error (GPG_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
static inline int
|
||||
divert_tpm2_writekey (ctrl_t ctrl, const unsigned char *grip,
|
||||
gcry_sexp_t s_skey)
|
||||
{
|
||||
(void)ctrl; (void)grip; (void)s_key;
|
||||
return gpg_error (GPG_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
#endif /*!HAVE_LIBTSS*/
|
||||
|
||||
|
||||
|
||||
/*-- divert-scd.c --*/
|
||||
int divert_pksign (ctrl_t ctrl, const char *desc_text,
|
||||
|
@ -606,6 +654,16 @@ void agent_daemon_check_aliveness (void);
|
|||
void agent_reset_daemon (ctrl_t ctrl);
|
||||
void agent_kill_daemon (enum daemon_type type);
|
||||
|
||||
/*-- call-tpm2d.c --*/
|
||||
int agent_tpm2d_writekey (ctrl_t ctrl, unsigned char **shadow_info,
|
||||
gcry_sexp_t s_skey);
|
||||
int agent_tpm2d_pksign (ctrl_t ctrl, const unsigned char *digest,
|
||||
size_t digestlen, const unsigned char *shadow_info,
|
||||
unsigned char **r_sig, size_t *r_siglen);
|
||||
int agent_tpm2d_pkdecrypt (ctrl_t ctrl, const unsigned char *cipher,
|
||||
size_t cipherlen, const unsigned char *shadow_info,
|
||||
char **r_buf, size_t *r_len);
|
||||
|
||||
/*-- call-scd.c --*/
|
||||
int agent_card_learn (ctrl_t ctrl,
|
||||
void (*kpinfo_cb)(void*, const char *),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue