mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
agent: Minor cleanup of the TPM patches.
* configure.ac (AC_CHECK_HEADERS): Add tss2/tss.h. * agent/divert-tpm2.c: Print an error if that file is not available. * agent/Makefile.am (gpg_agent_SOURCES): Add tpm.h * agent/command.c (do_one_keyinfo): Replace xstrdup by xtrystrdup. * agent/protect.c (agent_get_shadow_info_type): Check error of xtrystrdup. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
72ece35fb7
commit
fb0470a9f5
@ -52,7 +52,7 @@ gpg_agent_SOURCES = \
|
|||||||
trustlist.c \
|
trustlist.c \
|
||||||
divert-scd.c \
|
divert-scd.c \
|
||||||
divert-tpm2.c \
|
divert-tpm2.c \
|
||||||
tpm2.c \
|
tpm2.c tpm2.h \
|
||||||
cvt-openpgp.c cvt-openpgp.h \
|
cvt-openpgp.c cvt-openpgp.h \
|
||||||
call-scd.c \
|
call-scd.c \
|
||||||
learncard.c
|
learncard.c
|
||||||
|
@ -1104,7 +1104,8 @@ do_one_keyinfo (ctrl_t ctrl, const unsigned char *grip, assuan_context_t ctx,
|
|||||||
char hexgrip[40+1];
|
char hexgrip[40+1];
|
||||||
char *fpr = NULL;
|
char *fpr = NULL;
|
||||||
int keytype;
|
int keytype;
|
||||||
unsigned char *shadow_info = NULL, *shadow_info_type = NULL;
|
unsigned char *shadow_info = NULL;
|
||||||
|
unsigned char *shadow_info_type = NULL;
|
||||||
char *serialno = NULL;
|
char *serialno = NULL;
|
||||||
char *idstr = NULL;
|
char *idstr = NULL;
|
||||||
const char *keytypestr;
|
const char *keytypestr;
|
||||||
@ -1194,7 +1195,12 @@ do_one_keyinfo (ctrl_t ctrl, const unsigned char *grip, assuan_context_t ctx,
|
|||||||
}
|
}
|
||||||
else if (strcmp (shadow_info_type, "tpm2-v1") == 0)
|
else if (strcmp (shadow_info_type, "tpm2-v1") == 0)
|
||||||
{
|
{
|
||||||
serialno = xstrdup("TPM-Protected");
|
serialno = xtrystrdup("TPM-Protected");
|
||||||
|
if (!serialno)
|
||||||
|
{
|
||||||
|
err = gpg_error_from_syserror ();
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
idstr = NULL;
|
idstr = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -8,6 +8,12 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
/* FIXME: Until we have a proper checking in configure we give a hint
|
||||||
|
* on what to do */
|
||||||
|
#ifndef HAVE_TSS2_TSS_H
|
||||||
|
# error Please install the libtss2 dev package first
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "agent.h"
|
#include "agent.h"
|
||||||
#include "../common/i18n.h"
|
#include "../common/i18n.h"
|
||||||
#include "../common/sexp-parse.h"
|
#include "../common/sexp-parse.h"
|
||||||
|
@ -1559,11 +1559,12 @@ agent_shadow_key_type (const unsigned char *pubkey,
|
|||||||
|
|
||||||
/* Calculate required length by taking in account: the "shadowed-"
|
/* Calculate required length by taking in account: the "shadowed-"
|
||||||
prefix, the "shadowed", shadow type as well as some parenthesis */
|
prefix, the "shadowed", shadow type as well as some parenthesis */
|
||||||
|
/* FIXME: We should use membuf functions here. */
|
||||||
n = 12 + pubkey_len + 1 + 3+8 + 2+5 + shadow_info_len + 1;
|
n = 12 + pubkey_len + 1 + 3+8 + 2+5 + shadow_info_len + 1;
|
||||||
*result = xtrymalloc (n);
|
*result = xtrymalloc (n);
|
||||||
p = (char*)*result;
|
p = (char*)*result;
|
||||||
if (!p)
|
if (!p)
|
||||||
return out_of_core ();
|
return out_of_core ();
|
||||||
p = stpcpy (p, "(20:shadowed-private-key");
|
p = stpcpy (p, "(20:shadowed-private-key");
|
||||||
/* (10:public-key ...)*/
|
/* (10:public-key ...)*/
|
||||||
memcpy (p, pubkey+14, point - (pubkey+14));
|
memcpy (p, pubkey+14, point - (pubkey+14));
|
||||||
@ -1643,12 +1644,15 @@ agent_get_shadow_info_type (const unsigned char *shadowkey,
|
|||||||
n = snext (&s);
|
n = snext (&s);
|
||||||
if (!n)
|
if (!n)
|
||||||
return gpg_error (GPG_ERR_INV_SEXP);
|
return gpg_error (GPG_ERR_INV_SEXP);
|
||||||
if (shadow_type) {
|
if (shadow_type)
|
||||||
char *buf = xtrymalloc(n+1);
|
{
|
||||||
memcpy(buf, s, n);
|
char *buf = xtrymalloc(n+1);
|
||||||
buf[n] = '\0';
|
if (!buf)
|
||||||
*shadow_type = buf;
|
return gpg_error_from_syserror ();
|
||||||
}
|
memcpy (buf, s, n);
|
||||||
|
buf[n] = '\0';
|
||||||
|
*shadow_type = buf;
|
||||||
|
}
|
||||||
|
|
||||||
if (smatch (&s, n, "t1-v1") || smatch(&s, n, "tpm2-v1"))
|
if (smatch (&s, n, "t1-v1") || smatch(&s, n, "tpm2-v1"))
|
||||||
{
|
{
|
||||||
|
@ -1301,7 +1301,7 @@ AC_HEADER_STDC
|
|||||||
AC_CHECK_HEADERS([string.h unistd.h langinfo.h termio.h locale.h getopt.h \
|
AC_CHECK_HEADERS([string.h unistd.h langinfo.h termio.h locale.h getopt.h \
|
||||||
pty.h utmp.h pwd.h inttypes.h signal.h sys/select.h \
|
pty.h utmp.h pwd.h inttypes.h signal.h sys/select.h \
|
||||||
stdint.h signal.h util.h libutil.h termios.h \
|
stdint.h signal.h util.h libutil.h termios.h \
|
||||||
ucred.h sys/ucred.h sys/sysmacros.h sys/mkdev.h])
|
ucred.h sys/ucred.h sys/sysmacros.h sys/mkdev.h tss2/tss.h])
|
||||||
|
|
||||||
AC_HEADER_TIME
|
AC_HEADER_TIME
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user