RPM Package Manager, CVS Repository
/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: jbj@rpm5.org
Module: rpm Date: 12-Aug-2010 14:44:44
Branch: HEAD Handle: 2010081212444400
Modified files:
rpm/rpmio librpmio.vers rpmtpm.c rpmtpm.h
Log:
- tpm: WIP.
Summary:
Revision Changes Path
2.188 +4 -0 rpm/rpmio/librpmio.vers
1.5 +37 -18 rpm/rpmio/rpmtpm.c
2.2 +14 -6 rpm/rpmio/rpmtpm.h
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/rpmio/librpmio.vers
============================================================================
$ cvs diff -u -r2.187 -r2.188 librpmio.vers
--- rpm/rpmio/librpmio.vers 24 Jul 2010 18:05:50 -0000 2.187
+++ rpm/rpmio/librpmio.vers 12 Aug 2010 12:44:44 -0000 2.188
@@ -600,6 +600,10 @@
rpmtclRun;
rpmtclRunFile;
_rpmtpm_debug;
+ __tpm;
+ _tpm;
+ rpmtpmDump;
+ rpmtpmErr;
rpmtpmNew;
rpmUndefineMacro;
rpmuuidMake;
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/rpmtpm.c
============================================================================
$ cvs diff -u -r1.4 -r1.5 rpmtpm.c
--- rpm/rpmio/rpmtpm.c 9 Aug 2010 11:45:06 -0000 1.4
+++ rpm/rpmio/rpmtpm.c 12 Aug 2010 12:44:44 -0000 1.5
@@ -28,23 +28,42 @@
/*@unchecked@*/
int _rpmtpm_debug = -1;
+struct rpmtpm_s __tpm = {
+};
+rpmtpm _tpm = &__tpm;
+
+int rpmtpmErr(rpmtpm tpm, const char * msg, uint32_t mask, uint32_t rc)
+{
+ uint32_t err = rc & (mask ? mask : 0xffffffff);
+ tpm = tpm;
#if defined(WITH_TPM)
-static
-int rpmtpmErr(rpmtpm tpm, const char * msg, uint32_t rc)
- /*@*/
-{
- /* XXX Don't spew on expected failures ... */
- if (rc || _rpmtpm_debug)
- fprintf (stderr, "*** TPM_%s rc %u: %s\n", msg, rc,
- (rc ? TPM_GetErrMsg(rc) : "Success"));
+ if (err || _rpmtpm_debug)
+ fprintf (stderr, "*** TPM_%s rc %u: %s\n", msg, rc,
+ (err ? TPM_GetErrMsg(rc) : "Success"));
+#endif /* WITH_TPM */
return rc;
}
+void rpmtpmDump(rpmtpm tpm, const char * msg, unsigned char * b, size_t nb)
+{
+ FILE * fp = stdout;
+ size_t i;
+ tpm = tpm;
+ if (msg)
+ fprintf(fp, "%s: ", msg);
+ if (b)
+ for (i = 0; i < nb; i++)
+ fprintf(fp, "%02X", b[i]);
+ fprintf(fp, "\n");
+}
+
/*==============================================================*/
static int rpmtpmGetPhysicalCMDEnable(rpmtpm tpm)
{
- int xx;
+ int xx = -1;
+
+#if defined(WITH_TPM)
STACK_TPM_BUFFER( subcap );
STACK_TPM_BUFFER( resp );
STACK_TPM_BUFFER( tb );
@@ -53,19 +72,20 @@
STORE32(subcap.buffer, 0, TPM_CAP_FLAG_PERMANENT);
subcap.used = 4;
- xx = rpmtpmErr(tpm, "GetCapability",
+ xx = rpmtpmErr(tpm, "GetCapability", 0,
TPM_GetCapability(TPM_CAP_FLAG, &subcap, &resp));
if (xx)
goto exit;
TSS_SetTPMBuffer(&tb, resp.buffer, resp.used);
- xx = rpmtpmErr(tpm, "ReadPermanentFlags",
+ xx = rpmtpmErr(tpm, "ReadPermanentFlags", 0,
TPM_ReadPermanentFlags(&tb, 0, &permanentFlags, resp.used));
if (xx)
goto exit;
tpm->enabled = permanentFlags.physicalPresenceCMDEnable;
+#endif /* WITH_TPM */
exit:
return xx;
@@ -73,7 +93,6 @@
/*==============================================================*/
-#endif
/*@-mustmod@*/ /* XXX splint on crack */
static void rpmtpmFini(void * _tpm)
/*@globals fileSystem @*/
@@ -117,31 +136,31 @@
TPM_setlog(0); /* turn off verbose output */
- xx = rpmtpmErr(tpm, "Startup",
+ xx = rpmtpmErr(tpm, "Startup", 0,
TPM_Startup(startupparm));
/* Enable TPM (if not already done). */
xx = rpmtpmGetPhysicalCMDEnable(tpm);
if (!xx && !tpm->enabled) {
/* TSC_PhysicalPresence to turn on physicalPresenceCMDEnable */
- xx = rpmtpmErr(tpm, "PhysicalPresence(0x20)",
+ xx = rpmtpmErr(tpm, "PhysicalPresence(0x20)", 0,
TSC_PhysicalPresence(0x20));
/* TSC_PhysicalPresence to turn on physicalPresence */
if (!xx)
- xx = rpmtpmErr(tpm, "PhysicalPresence(0x08)",
+ xx = rpmtpmErr(tpm, "PhysicalPresence(0x08)", 0,
TSC_PhysicalPresence(0x08));
/* TPM_Process_PhysicalEnable to clear disabled */
if (!xx)
- xx = rpmtpmErr(tpm, "PhysicalEnable()",
+ xx = rpmtpmErr(tpm, "PhysicalEnable()", 0,
TPM_PhysicalEnable());
/* TPM_Process_PhysicalSetDeactivated to clear deactivated */
if (!xx)
- xx = rpmtpmErr(tpm, "PhysicalSetDeactivated(FALSE)",
+ xx = rpmtpmErr(tpm, "PhysicalSetDeactivated(FALSE)", 0,
TPM_PhysicalSetDeactivated(FALSE));
if (!xx)
tpm->enabled = 1;
}
-#endif
+#endif /* WITH_TPM */
return rpmtpmLink(tpm);
}
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/rpmtpm.h
============================================================================
$ cvs diff -u -r2.1 -r2.2 rpmtpm.h
--- rpm/rpmio/rpmtpm.h 24 Jul 2010 18:05:50 -0000 2.1
+++ rpm/rpmio/rpmtpm.h 12 Aug 2010 12:44:44 -0000 2.2
@@ -5,9 +5,12 @@
* \file rpmio/rpmtpm.h
*/
+#include <stdlib.h> /* XXX libtpm bootstrapping */
+#include <stdint.h> /* XXX libtpm bootstrapping */
#include <rpmiotypes.h>
-#include <rpmpgp.h>
-#include <rpmsw.h>
+#include <rpmlog.h>
+#include <rpmcb.h>
+#include <argv.h>
/** \ingroup rpmio
*/
@@ -19,7 +22,6 @@
typedef /*@refcounted@*/ struct rpmtpm_s * rpmtpm;
#if defined(_RPMTPM_INTERNAL)
-
/** \ingroup rpmio
*/
struct rpmtpm_s {
@@ -41,10 +43,11 @@
int nrefs; /*!< (unused) keep splint happy */
#endif
};
-#endif /* _RPMTPM_INTERNAL */
-/*@unchecked@*/
-extern pgpImplVecs_t rpmtpmImplVecs;
+extern struct rpmtpm_s __tpm;
+extern rpmtpm _tpm;
+
+#endif /* _RPMTPM_INTERNAL */
#ifdef __cplusplus
extern "C" {
@@ -95,6 +98,11 @@
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
+int rpmtpmErr(rpmtpm tpm, const char * msg, uint32_t mask, uint32_t rc)
+ /*@*/;
+void rpmtpmDump(rpmtpm tpm, const char * msg, unsigned char * b, size_t nb)
+ /*@*/;
+
#ifdef __cplusplus
}
#endif
@@ .
Received on Thu Aug 12 14:44:44 2010