RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  j...@rpm5.org
  Module: libtpm                           Date:   19-Sep-2013 19:13:18
  Branch: HEAD                             Handle: 2013091917131800

  Modified files:
    libtpm/libtpm/utils     cmk_setrestrictions.c createkey.c
                            createkeydelegation.c createownerdelegation.c
                            delegatemanage.c enableaudit.c flushspecific.c
                            getauditdigest.c getauditdigestsigned.c
                            getcapability.c

  Log:
    - tpm: refactoring.

  Summary:
    Revision    Changes     Path
    1.15        +2  -8      libtpm/libtpm/utils/cmk_setrestrictions.c
    1.23        +10 -14     libtpm/libtpm/utils/createkey.c
    1.17        +4  -7      libtpm/libtpm/utils/createkeydelegation.c
    1.19        +4  -7      libtpm/libtpm/utils/createownerdelegation.c
    1.14        +13 -16     libtpm/libtpm/utils/delegatemanage.c
    1.13        +6  -8      libtpm/libtpm/utils/enableaudit.c
    1.10        +5  -14     libtpm/libtpm/utils/flushspecific.c
    1.10        +4  -6      libtpm/libtpm/utils/getauditdigest.c
    1.14        +3  -5      libtpm/libtpm/utils/getauditdigestsigned.c
    1.17        +20 -34     libtpm/libtpm/utils/getcapability.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: libtpm/libtpm/utils/cmk_setrestrictions.c
  ============================================================================
  $ cvs diff -u -r1.14 -r1.15 cmk_setrestrictions.c
  --- libtpm/libtpm/utils/cmk_setrestrictions.c 16 Sep 2013 23:24:29 -0000      
1.14
  +++ libtpm/libtpm/utils/cmk_setrestrictions.c 19 Sep 2013 17:13:18 -0000      
1.15
  @@ -14,14 +14,10 @@
   
   #include "debug.h"
   
  -static uint32_t restrictions;
  -
  -static char * bm_str;
  -
   static struct poptOption optionsTable[] = {
     { "pwdo", '\0', POPT_ARG_STRING | POPT_ARGFLAG_ONEDASH, &__tpm.ownerpass, 
0,
        N_("Specify TPM owner <password>"),             N_(" <password>") },
  -  { "bm", '\0', POPT_ARG_STRING | POPT_ARGFLAG_ONEDASH, &bm_str, 0,
  +  { "bm", '\0', POPT_ARG_STRING | POPT_ARGFLAG_ONEDASH,      &__tpm.bm_str, 
0,
        N_("Specify the PSR <mask> in hex"),    N_(" <mask>") },
   
     { NULL, (char) -1, POPT_ARG_INCLUDE_TABLE, NULL, 0,
  @@ -50,15 +46,13 @@
       rpmtpm tpm = rpmtpmNew(argc, argv, optionsTable, 0);
       int ec = -1;     /* assume failure */
   
  -if (bm_str) sscanf(bm_str, "%x", &restrictions);
  -
       if (tpm->pwdo == NULL) {
        printf("Missing argument -pwdo.\n");
        goto exit;
       }
   
       ec = rpmtpmErr(tpm, "CMK_SetRestrictions", 0,
  -             TPM_CMK_SetRestrictions(restrictions, tpm->pwdo));
  +             TPM_CMK_SetRestrictions(tpm->restrictions, tpm->pwdo));
       if (ec)
        goto exit;
   
  @@ .
  patch -p0 <<'@@ .'
  Index: libtpm/libtpm/utils/createkey.c
  ============================================================================
  $ cvs diff -u -r1.22 -r1.23 createkey.c
  --- libtpm/libtpm/utils/createkey.c   19 Sep 2013 15:50:52 -0000      1.22
  +++ libtpm/libtpm/utils/createkey.c   19 Sep 2013 17:13:18 -0000      1.23
  @@ -24,14 +24,10 @@
       PCR_INFO_LONG
   };
   
  -static unsigned use_struct = NONE;
  -
  -static char *es_str;
  -
   static struct poptOption optionsTable[] = {
    { "v1", '\0', POPT_ARG_VAL|POPT_ARGFLAG_ONEDASH,    &__tpm.oldversion, TRUE,
        N_("Use TPM_KEY instead of TPM_KEY12"),         NULL },
  - { "es", '\0', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH, &es_str,        0,
  + { "es", '\0', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH, &__tpm.es_str,  0,
        N_("Use PKCSv15 encryption"),                   N_(" pkcsv15") },
    { "kt", '\0', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH,    &__tpm.kt_str,       
 0,
           N_("Specify new key <type>"),                   N_(" b|d|e|i|l|m|s") 
},
  @@ -47,9 +43,9 @@
    { "exp", '\0', POPT_ARG_INT | POPT_ARGFLAG_ONEDASH, &__tpm.exponent, 0,
        N_("Specify the public <exponent>"),            N_(" <exponent>") },
   
  - { "vlong", '\0', POPT_ARG_VAL|POPT_ARGFLAG_ONEDASH, &use_struct, 
PCR_INFO_LONG,
  + { "vlong", '\0', POPT_ARG_VAL|POPT_ARGFLAG_ONEDASH, &__tpm.use_struct, 
PCR_INFO_LONG,
        N_("Use PCR_INFO_LONG"),                        NULL },
  - { "vinfo", '\0', POPT_ARG_VAL|POPT_ARGFLAG_ONEDASH, &use_struct, PCR_INFO,
  + { "vinfo", '\0', POPT_ARG_VAL|POPT_ARGFLAG_ONEDASH, &__tpm.use_struct, 
PCR_INFO,
        N_("Use PCR_INFO"),                             NULL },
   
    { "ok", '\0', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH, &__tpm.ofn,     0,
  @@ -125,8 +121,8 @@
       memset(&pcrInfo, 0x0, sizeof(pcrInfo));
       memset(&pcrComp, 0x0, sizeof(pcrComp));
   
  -    if (es_str) {
  -     if (!strcmp(es_str, "pkcsv15"))
  +    if (tpm->es_str) {
  +     if (!strcmp(tpm->es_str, "pkcsv15"))
            tpm->pkcsv15 = TRUE;
        else {
            printf("Bad parameter for -es\n");
  @@ -231,7 +227,7 @@
                                              pcrComp.pcrValue.size);
            /* force usage of pcrInfoLong */
            if (ix >= 16)
  -             use_struct = PCR_INFO_LONG;
  +             tpm->use_struct = PCR_INFO_LONG;
   
            memcpy((char *) pcrComp.pcrValue.buffer +
                   (index_ctr - 1) * TPM_HASH_SIZE, future_hash,
  @@ -245,8 +241,8 @@
        */
       if (index_ctr != 0) {
        pcrInfoLong.creationPCRSelection.sizeOfSelect = pcrs / 8;
  -     if ((tpm->oldversion && use_struct != PCR_INFO_LONG)
  -      || use_struct == PCR_INFO)
  +     if ((tpm->oldversion && tpm->use_struct != PCR_INFO_LONG)
  +      || tpm->use_struct == PCR_INFO)
        {
            pcrComp.select.sizeOfSelect = 2;
            TPM_HashPCRComposite(&pcrComp, pcrInfoLong.digestAtRelease);
  @@ -267,7 +263,7 @@
                ec = -1;
                goto exit;
            }
  -         use_struct = PCR_INFO;
  +         tpm->use_struct = PCR_INFO;
            if (rpmIsVerbose())
                printf("Using TPM_PCR_INFO structure.\n");
        } else {
  @@ -279,7 +275,7 @@
                ec = -1;
                goto exit;
            }
  -         use_struct = PCR_INFO_LONG;
  +         tpm->use_struct = PCR_INFO_LONG;
            if (rpmIsVerbose())
                printf("Using TPM_PCR_INFO_LONG structure.\n");
        }
  @@ .
  patch -p0 <<'@@ .'
  Index: libtpm/libtpm/utils/createkeydelegation.c
  ============================================================================
  $ cvs diff -u -r1.16 -r1.17 createkeydelegation.c
  --- libtpm/libtpm/utils/createkeydelegation.c 18 Sep 2013 23:00:00 -0000      
1.16
  +++ libtpm/libtpm/utils/createkeydelegation.c 19 Sep 2013 17:13:18 -0000      
1.17
  @@ -23,15 +23,12 @@
   
   #include "debug.h"
   
  -static char *label;
  -static TPM_FAMILY_ID familyID;
  -
   static struct poptOption optionsTable[] = {
    { "hk", '\0', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH, &__tpm.hk_str,  0,
        N_("Specify key <handle>"),                     N_(" <handle>") },
  - { "la", '\0', POPT_ARG_STRING | POPT_ARGFLAG_ONEDASH, &label, 0,
  + { "la", '\0', POPT_ARG_STRING | POPT_ARGFLAG_ONEDASH, &__tpm.label, 0,
        N_("Specify public parameter <label>"),         N_(" <label>") },
  - { "id", '\0', POPT_ARG_INT | POPT_ARGFLAG_ONEDASH, &familyID, 0,
  + { "id", '\0', POPT_ARG_INT | POPT_ARGFLAG_ONEDASH, &__tpm.familyID, 0,
        N_("Specify family <id>"),                      N_(" <id>") },
    { "per1", '\0', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH,       
&__tpm.per1_str, 0,
        N_("Specify permissions1 <perms>"),             N_(" <perms>") },
  @@ -139,7 +136,7 @@
       }
   
       tdp.tag = TPM_TAG_DELEGATE_PUBLIC;
  -    tdp.rowLabel = label[0];
  +    tdp.rowLabel = (tpm->label ? tpm->label[0] : 0); /* XXX W2DO? */
       tdp.pcrInfo.pcrSelection.sizeOfSelect = pcrs / 8;
       memset(&tdp.pcrInfo.pcrSelection.pcrSelect,
           0x0, sizeof(tdp.pcrInfo.pcrSelection.pcrSelect));
  @@ -148,7 +145,7 @@
       tdp.permissions.delegateType = TPM_DEL_KEY_BITS;
       tdp.permissions.per1 = tpm->per1;
       tdp.permissions.per2 = tpm->per2;
  -    tdp.familyID = familyID;
  +    tdp.familyID = tpm->familyID;
       tdp.verificationCount = verificationCount;
   
       ec = rpmtpmErr(tpm, "Delegate_CreateKeyDelegation", 0,
  @@ .
  patch -p0 <<'@@ .'
  Index: libtpm/libtpm/utils/createownerdelegation.c
  ============================================================================
  $ cvs diff -u -r1.18 -r1.19 createownerdelegation.c
  --- libtpm/libtpm/utils/createownerdelegation.c       18 Sep 2013 23:00:00 
-0000      1.18
  +++ libtpm/libtpm/utils/createownerdelegation.c       19 Sep 2013 17:13:18 
-0000      1.19
  @@ -23,15 +23,12 @@
   
   #include "debug.h"
   
  -static unsigned inc = FALSE;
  -static TPM_FAMILY_ID familyID;
  -
   static struct poptOption optionsTable[] = {
  - { "inc", '\0', POPT_ARG_VAL | POPT_ARGFLAG_ONEDASH, &inc, TRUE,
  + { "inc", '\0', POPT_ARG_VAL | POPT_ARGFLAG_ONEDASH, &__tpm.inc, TRUE,
        N_("Specify family <id>"),                      N_(" <id>") },
    { "la", '\0', POPT_ARG_STRING | POPT_ARGFLAG_ONEDASH, &__tpm.label, 0,
        N_("Specify public parameter <label>"),         N_(" <label>") },
  - { "id", '\0', POPT_ARG_INT | POPT_ARGFLAG_ONEDASH, &familyID, 0,
  + { "id", '\0', POPT_ARG_INT | POPT_ARGFLAG_ONEDASH, &__tpm.familyID, 0,
        N_("Specify family <id>"),                      N_(" <id>") },
    { "per1", '\0', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH,       
&__tpm.per1_str, 0,
        N_("Specify permissions1 <perms>"),             N_(" <perms>") },
  @@ -155,11 +152,11 @@
       tdp.permissions.delegateType = TPM_DEL_OWNER_BITS;
       tdp.permissions.per1 = tpm->per1;
       tdp.permissions.per2 = tpm->per2;
  -    tdp.familyID = familyID;
  +    tdp.familyID = tpm->familyID;
       tdp.verificationCount = verificationCount;
   
       ec = rpmtpmErr(tpm, "Delegate_CreateOwnerDelegation", 0,
  -                     TPM_Delegate_CreateOwnerDelegation(inc,
  +                     TPM_Delegate_CreateOwnerDelegation(tpm->inc,
                                             &tdp,
                                             tpm->pwdd,
                                             tpm->pwdo,
  @@ .
  patch -p0 <<'@@ .'
  Index: libtpm/libtpm/utils/delegatemanage.c
  ============================================================================
  $ cvs diff -u -r1.13 -r1.14 delegatemanage.c
  --- libtpm/libtpm/utils/delegatemanage.c      16 Sep 2013 23:24:29 -0000      
1.13
  +++ libtpm/libtpm/utils/delegatemanage.c      19 Sep 2013 17:13:18 -0000      
1.14
  @@ -14,22 +14,19 @@
   
   #include "debug.h"
   
  -static TPM_FAMILY_ID familyID = 0x0; /* = UINT32 */
  -static int mode = -1;
  -
   static struct poptOption optionsTable[] = {
     { "pwdo", '\0', POPT_ARG_STRING | POPT_ARGFLAG_ONEDASH, &__tpm.ownerpass, 
0,
        N_("Specify TPM owner <password>"),             N_(" <password>") },
  -  { "id", '\0', POPT_ARG_INT | POPT_ARGFLAG_ONEDASH, &familyID, 0,
  +  { "id", '\0', POPT_ARG_INT | POPT_ARGFLAG_ONEDASH, &__tpm.familyID, 0,
        N_("Specify family <id>"),                              N_(" <id>") },
   
  -  { "create", '\0', POPT_ARG_VAL | POPT_ARGFLAG_ONEDASH, &mode, 
TPM_FAMILY_CREATE,
  +  { "create", '\0', POPT_ARG_VAL | POPT_ARGFLAG_ONEDASH, &__tpm.mode, 
TPM_FAMILY_CREATE,
        N_("Create a family id"),                               NULL },
  -  { "invalidate", '\0', POPT_ARG_VAL | POPT_ARGFLAG_ONEDASH, &mode, 
TPM_FAMILY_INVALIDATE,
  +  { "invalidate", '\0', POPT_ARG_VAL | POPT_ARGFLAG_ONEDASH, &__tpm.mode, 
TPM_FAMILY_INVALIDATE,
        N_("Invalidate a family id"),                   NULL },
  -  { "enable", '\0', POPT_ARG_VAL | POPT_ARGFLAG_ONEDASH, &mode, 
TPM_FAMILY_ENABLE,
  +  { "enable", '\0', POPT_ARG_VAL | POPT_ARGFLAG_ONEDASH, &__tpm.mode, 
TPM_FAMILY_ENABLE,
        N_("Enable/disable {0|1}"),                     NULL },
  -  { "admin", '\0', POPT_ARG_VAL | POPT_ARGFLAG_ONEDASH, &mode, 
TPM_FAMILY_ADMIN,
  +  { "admin", '\0', POPT_ARG_VAL | POPT_ARGFLAG_ONEDASH, &__tpm.mode, 
TPM_FAMILY_ADMIN,
        N_("Admnin {0|1}"),                             NULL },
   
     { NULL, (char) -1, POPT_ARG_INCLUDE_TABLE, NULL, 0,
  @@ -75,12 +72,12 @@
       uint32_t nb = sizeof(b);
       int x;
   
  -    if (mode == -1) {
  +    if (tpm->mode <= 0) {
        printf("Missing op code.\n");
        goto exit;
       }
   
  -    switch (mode) {
  +    switch (tpm->mode) {
       case TPM_FAMILY_CREATE:
        if (ac != 1) {
            printf("Incorrect parameters.\n");
  @@ -96,8 +93,8 @@
                TPM_WriteTPMFamilyLabel(&buffer, tfl));
        len = ec;
        ec = rpmtpmErr(tpm, "Delegate_Manage", 0,
  -                     TPM_Delegate_Manage(familyID,
  -                               mode,
  +                     TPM_Delegate_Manage(tpm->familyID,
  +                               tpm->mode,
                                  buffer.buffer, len,
                                  tpm->pwdo, b, &nb));
        if (ec)
  @@ -110,8 +107,8 @@
   
       case TPM_FAMILY_INVALIDATE:
        ec = rpmtpmErr(tpm, "Delegate_Manage", 0,
  -                     TPM_Delegate_Manage(familyID,
  -                               mode,
  +                     TPM_Delegate_Manage(tpm->familyID,
  +                               tpm->mode,
                                  NULL, 0,
                                  tpm->pwdo, b, &nb));
        if (ec)
  @@ -127,8 +124,8 @@
        x = atoi(av[0]);
        bool = (x ? 1 : 0);
        ec = rpmtpmErr(tpm, "Delegate_Manage", 0,
  -                     TPM_Delegate_Manage(familyID,
  -                               mode,
  +                     TPM_Delegate_Manage(tpm->familyID,
  +                               tpm->mode,
                                  &bool, sizeof(TPM_BOOL),
                                  tpm->pwdo, b, &nb));
        if (ec)
  @@ .
  patch -p0 <<'@@ .'
  Index: libtpm/libtpm/utils/enableaudit.c
  ============================================================================
  $ cvs diff -u -r1.12 -r1.13 enableaudit.c
  --- libtpm/libtpm/utils/enableaudit.c 16 Sep 2013 23:24:30 -0000      1.12
  +++ libtpm/libtpm/utils/enableaudit.c 19 Sep 2013 17:13:18 -0000      1.13
  @@ -14,16 +14,14 @@
   
   #include "debug.h"
   
  -static unsigned ordinal = -1;
  -static unsigned auditState = TRUE;
  -
   static struct poptOption optionsTable[] = {
  - { "ordinal", 'o', POPT_ARG_INT|POPT_ARGFLAG_ONEDASH,        &ordinal,       
0,
  -     N_("Sepcify the <ordinal> to audit"),   N_(" <ordinal>") },
  + { "ordinal", 'o', POPT_ARG_INT|POPT_ARGFLAG_ONEDASH,        &__tpm.ordinal, 
0,
  +     N_("Specify the <ordinal> to audit"),   N_(" <ordinal>") },
        /* XXX legacy -p */
    { "pwdo", 'p', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH,        
&__tpm.ownerpass, 0,
        N_("Specify TPM owner <password>"),     N_(" <password>") },
  - { "noaudit", 'd', POPT_ARG_VAL|POPT_ARGFLAG_ONEDASH,        &auditState,    
FALSE,
  +     /* XXX popt boolean as --[no]audit */
  + { "noaudit", 'd', POPT_ARG_VAL|POPT_ARGFLAG_ONEDASH,        &__tpm.audit,   
FALSE,
        N_("Disable the audit"),        NULL },
   
     { NULL, (char)-1, POPT_ARG_INCLUDE_TABLE, NULL, 0,
  @@ -49,13 +47,13 @@
       rpmtpm tpm = rpmtpmNew(argc, argv, optionsTable, 0);
       int ec = -1;     /* assume failure */
   
  -    if ((int) ordinal == -1 || tpm->pwdo == NULL) {
  +    if (tpm->ordinal == -1 || tpm->pwdo == NULL) {
        printf("Missing mandatory parameter.\n");
        goto exit;
       }
   
       ec = rpmtpmErr(tpm, "SetOrdinalAuditStatus", 0,
  -             TPM_SetOrdinalAuditStatus(ordinal, auditState, tpm->pwdo));
  +             TPM_SetOrdinalAuditStatus(tpm->ordinal, tpm->audit, tpm->pwdo));
       if (ec)
        goto exit;
   
  @@ .
  patch -p0 <<'@@ .'
  Index: libtpm/libtpm/utils/flushspecific.c
  ============================================================================
  $ cvs diff -u -r1.9 -r1.10 flushspecific.c
  --- libtpm/libtpm/utils/flushspecific.c       16 Sep 2013 20:04:31 -0000      
1.9
  +++ libtpm/libtpm/utils/flushspecific.c       19 Sep 2013 17:13:18 -0000      
1.10
  @@ -14,15 +14,10 @@
   
   #include "debug.h"
   
  -static uint32_t handle = -1;
  -static uint32_t restype = -1;
  -
  -static char * ha_str;
  -
   static struct poptOption optionsTable[] = {
  -  { "ha", '\0', POPT_ARG_STRING | POPT_ARGFLAG_ONEDASH, &ha_str, 0,
  +  { "ha", '\0', POPT_ARG_STRING | POPT_ARGFLAG_ONEDASH, &__tpm.ha_str, 0,
        N_("Specify resource <handle> in hex"), N_(" <handle>") },
  -  { "rt", '\0', POPT_ARG_INT | POPT_ARGFLAG_ONEDASH, &restype, 0,
  +  { "rt", '\0', POPT_ARG_INT | POPT_ARGFLAG_ONEDASH, &__tpm.restype, 0,
        N_("Specify resource <restype>"), N_(" <restype>") },
   
     { NULL, (char) -1, POPT_ARG_INCLUDE_TABLE, NULL, 0,
  @@ -51,24 +46,20 @@
       rpmtpm tpm = rpmtpmNew(argc, argv, optionsTable, 0);
       int ec = -1;     /* assume failure */
   
  -if (ha_str) sscanf(ha_str, "%x", &handle);
  -
  -    if ((int) handle == -1 || (int) restype == -1) {
  +    if (tpm->handle == 0 || tpm->restype == 0) {
        printf("Missing command line parameter.\n");
        goto exit;
       }
   
       ec = rpmtpmErr(tpm, "FlushSpecific", 0,
  -             TPM_FlushSpecific(handle, restype));
  +             TPM_FlushSpecific(tpm->handle, tpm->restype));
       if (ec)
        goto exit;
   
       printf("Successfuly flushed item of type %X with handle %08x.\n",
  -            restype, handle);
  +            tpm->restype, tpm->handle);
   
   exit:
  -    if (ha_str)
  -     free(ha_str);
       tpm = rpmtpmFree(tpm);
       return ec;
   }
  @@ .
  patch -p0 <<'@@ .'
  Index: libtpm/libtpm/utils/getauditdigest.c
  ============================================================================
  $ cvs diff -u -r1.9 -r1.10 getauditdigest.c
  --- libtpm/libtpm/utils/getauditdigest.c      16 Sep 2013 20:04:31 -0000      
1.9
  +++ libtpm/libtpm/utils/getauditdigest.c      19 Sep 2013 17:13:18 -0000      
1.10
  @@ -14,10 +14,8 @@
   
   #include "debug.h"
   
  -static uint32_t startOrdinal = -1;
  -
   static struct poptOption optionsTable[] = {
  - { "start", 's', POPT_ARG_INT|POPT_ARGFLAG_ONEDASH,  &startOrdinal,  0,
  + { "start", 's', POPT_ARG_INT|POPT_ARGFLAG_ONEDASH,  &__tpm.ordinal, 0,
        N_("Specify start <ordinal> for an audit"),     N_(" <ordinal>") },
   
     { NULL, (char)-1, POPT_ARG_INCLUDE_TABLE, NULL, 0,
  @@ -49,16 +47,16 @@
       uint32_t *ord = NULL;
       unsigned char digest[TPM_DIGEST_SIZE];
   
  -    if ((int) startOrdinal == -1) {
  +    if (tpm->ordinal == 0) {
        printf("Missing command line parameter.\n");
        goto exit;
       }
   
  -    lowest = startOrdinal;
  +    lowest = tpm->ordinal;
   
       while (more == TRUE) {
        unsigned char calcdigest[TPM_DIGEST_SIZE];
  -     int j = startOrdinal;
  +     int j = tpm->ordinal;
        ec = rpmtpmErr(tpm, "GetAuditDigest", 0,
                        TPM_GetAuditDigest(lowest,
                                 &counter, digest, &more, &ord, &ordSize));
  @@ .
  patch -p0 <<'@@ .'
  Index: libtpm/libtpm/utils/getauditdigestsigned.c
  ============================================================================
  $ cvs diff -u -r1.13 -r1.14 getauditdigestsigned.c
  --- libtpm/libtpm/utils/getauditdigestsigned.c        19 Sep 2013 15:50:52 
-0000      1.13
  +++ libtpm/libtpm/utils/getauditdigestsigned.c        19 Sep 2013 17:13:18 
-0000      1.14
  @@ -16,8 +16,6 @@
   
   #include "debug.h"
   
  -static uint32_t startOrdinal = -1;
  -
   static struct poptOption optionsTable[] = {
        /* XXX -hk? */
     { NULL, 'h', POPT_ARG_STRING | POPT_ARGFLAG_ONEDASH, &__tpm.hk_str, 0,
  @@ -25,7 +23,7 @@
        /* XXX -pwdk? */
     { NULL, 'p', POPT_ARG_STRING | POPT_ARGFLAG_ONEDASH, &__tpm.keypass, 0,
        N_("Specify key <password>"), N_(" <password>") },
  -  { NULL, 's', POPT_ARG_INT | POPT_ARGFLAG_ONEDASH, &startOrdinal, 0,
  +  { NULL, 's', POPT_ARG_INT | POPT_ARGFLAG_ONEDASH, &__tpm.ordinal, 0,
        N_("Specify start <ordinal>"), N_(" <ordinal>") },
   
     { NULL, (char) -1, POPT_ARG_INCLUDE_TABLE, NULL, 0,
  @@ -65,12 +63,12 @@
       TSS_gennonce(antiReplay);
   
        /* XXX keyhandle == -1? */
  -    if ((int) startOrdinal == -1 || tpm->keyhandle == 0) {
  +    if (tpm->ordinal == 0 || tpm->keyhandle == 0) {
        printf("Missing command line parameter.\n");
        goto exit;
       }
   
  -    lowest = startOrdinal;
  +    lowest = tpm->ordinal;
   
       ec = rpmtpmErr(tpm, "GetAuditDigestSigned", 0,
                TPM_GetAuditDigestSigned(tpm->keyhandle,
  @@ .
  patch -p0 <<'@@ .'
  Index: libtpm/libtpm/utils/getcapability.c
  ============================================================================
  $ cvs diff -u -r1.16 -r1.17 getcapability.c
  --- libtpm/libtpm/utils/getcapability.c       19 Sep 2013 15:50:52 -0000      
1.16
  +++ libtpm/libtpm/utils/getcapability.c       19 Sep 2013 17:13:18 -0000      
1.17
  @@ -64,12 +64,6 @@
       {-1, -1, -1}
   };
   
  -static uint32_t cap;
  -static uint32_t scap = -1;
  -#if 0
  -static uint32_t sscap = -1;
  -#endif
  -
   static void showPermanentFlags(TPM_PERMANENT_FLAGS * pf, uint32_t size)
   {
       printf("Permanent flags:\n");
  @@ -160,16 +154,12 @@
       return handled;
   }
   
  -static char *cap_str;
  -static char *scap_str;
  -static char *scapd_str;
  -
   static struct poptOption optionsTable[] = {
  - { "cap", '\0', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH,        &cap_str,       
0,
  + { "cap", '\0', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH,        &__tpm.cap_str, 
0,
        N_("Specify <capability> in hex"),              N_(" <capability>") },
  - { "scap", '\0', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH,       &scap_str,      
0,
  + { "scap", '\0', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH,       
&__tpm.scap_str,        0,
        N_("Specify <sub-capability> in hex"),  N_(" <sub-capability>") },
  - { "scapd", '\0', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH,      &scapd_str,     
0,
  + { "scapd", '\0', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH,      
&__tpm.scapd_str,       0,
        N_("Specify <sub-capability> in decimal"),      N_(" <sub-capability>") 
},
   
    { "hk", '\0', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH, &__tpm.hk_str,  0,
  @@ -217,12 +207,8 @@
       RSA *rsa = NULL;
       unsigned char *buffer = NULL;
   
  -if (cap_str) sscanf(cap_str, "%x", &cap);
  -if (scap_str) sscanf(scap_str, "%x", &scap);
  -if (scapd_str) sscanf(scapd_str, "%d", &scap);
  -
       for (index = 0; (int) matrx[index].cap != -1; index++) {
  -     if (cap == matrx[index].cap)
  +     if (tpm->cap == matrx[index].cap)
            break;
       }
       if ((int) matrx[index].cap == -1) {
  @@ -233,17 +219,17 @@
   
       subcap.used = 0;
       if (matrx[index].subcap_size > 0) {
  -     if ((int) scap == -1) {
  +     if (tpm->scap == 0) {
            printf("Need subcap parameter for this capability!\n");
            ec = -1;
            goto exit;
        }
  -     if (prepare_subcap(tpm, cap, &subcap, scap) == 0) {
  +     if (prepare_subcap(tpm, tpm->cap, &subcap, tpm->scap) == 0) {
            if (matrx[index].subcap_size == 2) {
  -             STORE16(subcap.buffer, 0, scap);
  +             STORE16(subcap.buffer, 0, tpm->scap);
                subcap.used = 2;
            } else if (matrx[index].subcap_size >= 4) {
  -             STORE32(subcap.buffer, 0, scap);
  +             STORE32(subcap.buffer, 0, tpm->scap);
                subcap.used = 4;
            }
        }
  @@ -252,7 +238,7 @@
       if (tpm->keyhandle == 0) {
   
        ec = rpmtpmErr(tpm, "GetCapability", 0,
  -             TPM_GetCapability(cap, &subcap, &resp));
  +             TPM_GetCapability(tpm->cap, &subcap, &resp));
        if (ec)
            goto exit;
   
  @@ -275,7 +261,7 @@
                TPM_GetCapabilitySigned(tpm->keyhandle,
                                      tpm->pwdk,
                                      antiReplay,
  -                                   cap,
  +                                   tpm->cap,
                                      &subcap,
                                      &resp, signature, &signaturelen));
   
  @@ -310,11 +296,11 @@
        goto exit;
       }
   
  -    if ((int) scap == -1)
  -     printf("Result for capability 0x%x is : ", cap);
  +    if (tpm->scap == 0)
  +     printf("Result for capability 0x%x is : ", tpm->cap);
       else
        printf("Result for capability 0x%x, subcapability 0x%x is : ",
  -                cap, scap);
  +                tpm->cap, tpm->scap);
   
       switch (matrx[index].result_size) {
       case TYPE_BOOL:
  @@ -328,18 +314,18 @@
        printf("\n");
        for (i = 0; i + 3 < (int) resp.used; i += 4) {
            rsp = LOAD32(resp.buffer, i);
  -         if (cap == TPM_CAP_NV_LIST)
  +         if (tpm->cap == TPM_CAP_NV_LIST)
                printf("%d. Index : %d = 0x%08x.\n", (i+4) / 4, rsp, rsp);
  -         else if (cap == TPM_CAP_KEY_HANDLE)
  +         else if (tpm->cap == TPM_CAP_KEY_HANDLE)
                printf("%d. keyhandle : %d.\n", (i+4) / 4, rsp);
            else
                printf("%d. item : %d.\n", (i+4) / 4, rsp);
        }
        break;  /* TYPE_UINT32_ARRAY */
       case TYPE_STRUCTURE:
  -     switch (cap) {
  +     switch (tpm->cap) {
        case TPM_CAP_FLAG:
  -         if (scap == TPM_CAP_FLAG_PERMANENT) {
  +         if (tpm->scap == TPM_CAP_FLAG_PERMANENT) {
                TPM_PERMANENT_FLAGS pf;
                STACK_TPM_BUFFER(tb)
                TSS_SetTPMBuffer(&tb, resp.buffer, resp.used);
  @@ -353,7 +339,7 @@
                }
                printf("\n");
                showPermanentFlags(&pf, resp.used);
  -         } else if (scap == TPM_CAP_FLAG_VOLATILE) {
  +         } else if (tpm->scap == TPM_CAP_FLAG_VOLATILE) {
                TPM_STCLEAR_FLAGS sf;
                STACK_TPM_BUFFER(tb);
                TSS_SetTPMBuffer(&tb, resp.buffer, resp.used);
  @@ -540,13 +526,13 @@
        }
        break;  /* TYPE_STRUCTURE */
       case TYPE_VARIOUS:
  -     if (cap == TPM_CAP_MFR && scap == TPM_CAP_PROCESS_ID) {
  +     if (tpm->cap == TPM_CAP_MFR && tpm->scap == TPM_CAP_PROCESS_ID) {
            rsp = LOAD32(resp.buffer, 0);
            printf("%d\n\n", rsp);
            ec = 0;
            goto exit;
        }
  -     switch (scap) {
  +     switch (tpm->scap) {
   
        /* Show booleans */
        case TPM_CAP_PROP_OWNER:
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to