Author: jmagne
Update of /cvs/dirsec/esc/src/lib/coolkey
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv2362
Modified Files:
SlotUtils.cpp
Log Message:
Add time stamps to log messages and formatting.
Index: SlotUtils.cpp
===================================================================
RCS file: /cvs/dirsec/esc/src/lib/coolkey/SlotUtils.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SlotUtils.cpp 27 Sep 2006 17:47:46 -0000 1.2
+++ SlotUtils.cpp 24 Feb 2007 02:21:15 -0000 1.3
@@ -32,6 +32,7 @@
#include "prprf.h"
#include "prlock.h"
#include <assert.h>
+#include <time.h>
#include "SlotUtils.h"
#include <list>
@@ -52,48 +53,48 @@
class AutoCoolKeyListLock
{
public:
- AutoCoolKeyListLock() { LockCoolKeyList(); }
- ~AutoCoolKeyListLock() { UnlockCoolKeyList(); }
+ AutoCoolKeyListLock() { LockCoolKeyList(); }
+ ~AutoCoolKeyListLock() { UnlockCoolKeyList(); }
};
void
InitCoolKeyList()
{
-
- gCoolKeyListLock = PR_NewLock();
+ gCoolKeyListLock = PR_NewLock();
}
void
DestroyCoolKeyList()
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("DestroyCoolKeyList:\n"));
- ClearCoolKeyList();
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
DestroyCoolKeyList:\n",GetTStamp(tBuff,56)));
+ ClearCoolKeyList();
- if (gCoolKeyListLock)
- {
- PR_DestroyLock(gCoolKeyListLock);
- gCoolKeyListLock = NULL;
- }
+ if (gCoolKeyListLock)
+ {
+ PR_DestroyLock(gCoolKeyListLock);
+ gCoolKeyListLock = NULL;
+ }
}
void
LockCoolKeyList()
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("LockCoolKeyList:\n gCoolKeyListLock
%p",gCoolKeyListLock));
-
- if(!gCoolKeyListLock)
- {
- gCoolKeyListLock = PR_NewLock();
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s LockCoolKeyList:\n gCoolKeyListLock
%p",GetTStamp(tBuff,56),gCoolKeyListLock));
- }
+ if(!gCoolKeyListLock)
+ {
+ gCoolKeyListLock = PR_NewLock();
+ }
- if (gCoolKeyListLock) {
+ if (gCoolKeyListLock) {
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("LockCoolKeyList:\n gCoolKeyListLock %p
about to lock gCoolKeyListLock",gCoolKeyListLock));
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s LockCoolKeyList:\n gCoolKeyListLock %p
about to lock gCoolKeyListLock",GetTStamp(tBuff,56),gCoolKeyListLock));
PR_Lock(gCoolKeyListLock);
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("LockCoolKeyList:\n gCoolKeyListLock %p
obtained gCoolKeyListLock",gCoolKeyListLock));
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s LockCoolKeyList:\n gCoolKeyListLock %p
obtained gCoolKeyListLock",GetTStamp(tBuff,56),gCoolKeyListLock));
#ifdef DEBUG
assert(gCoolKeyListLockCount == 0);
@@ -105,385 +106,409 @@
void
UnlockCoolKeyList()
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("UnLockCoolKeyList:\n"));
- if (gCoolKeyListLock) {
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
UnLockCoolKeyList:\n",GetTStamp(tBuff,56)));
+ if (gCoolKeyListLock) {
#ifdef DEBUG
- --gCoolKeyListLockCount;
- assert(gCoolKeyListLockCount == 0);
+ --gCoolKeyListLockCount;
+ assert(gCoolKeyListLockCount == 0);
#endif // DEBUG
- PR_Unlock(gCoolKeyListLock);
- }
+ PR_Unlock(gCoolKeyListLock);
+ }
}
CoolKeyInfo *
GetCoolKeyInfoByReaderName(const char *aReaderName)
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetCoolKeyInfoByReaderName:\n"));
- AutoCoolKeyListLock autoLock;
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
GetCoolKeyInfoByReaderName:\n",GetTStamp(tBuff,56)));
+ AutoCoolKeyListLock autoLock;
- std::list<CoolKeyInfo*>::iterator it;
+ std::list<CoolKeyInfo*>::iterator it;
- for (it = gCoolKeyList.begin(); it != gCoolKeyList.end(); ++it)
- {
- if (!PL_strcasecmp((*it)->mReaderName, aReaderName))
- return *it;
- }
+ for (it = gCoolKeyList.begin(); it != gCoolKeyList.end(); ++it)
+ {
+ if (!PL_strcasecmp((*it)->mReaderName, aReaderName))
+ return *it;
+ }
- return NULL;
+ return NULL;
}
CoolKeyInfo *
GetCoolKeyInfoBySlotName(const char *aSlotName)
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetCoolKeyInfoBySlotName:\n"));
- AutoCoolKeyListLock autoLock;
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
GetCoolKeyInfoBySlotName:\n",GetTStamp(tBuff,56)));
+ AutoCoolKeyListLock autoLock;
- std::list<CoolKeyInfo*>::iterator it;
+ std::list<CoolKeyInfo*>::iterator it;
- for (it = gCoolKeyList.begin(); it != gCoolKeyList.end(); ++it)
- {
- const char* slotName = PK11_GetSlotName((*it)->mSlot);
-
- if (!PL_strcasecmp(slotName, aSlotName))
- {
- return (*it);
- }
- }
+ for (it = gCoolKeyList.begin(); it != gCoolKeyList.end(); ++it)
+ {
+ const char* slotName = PK11_GetSlotName((*it)->mSlot);
- return NULL;
+ if (!PL_strcasecmp(slotName, aSlotName))
+ {
+ return (*it);
+ }
+ }
+
+ return NULL;
}
CoolKeyInfo *
GetCoolKeyInfoBySlot(PK11SlotInfo *aSlot)
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetCoolKeyInfoBySlot:\n"));
- AutoCoolKeyListLock autoLock;
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
GetCoolKeyInfoBySlot:\n",GetTStamp(tBuff,56)));
+ AutoCoolKeyListLock autoLock;
- std::list<CoolKeyInfo*>::iterator it;
+ std::list<CoolKeyInfo*>::iterator it;
- for (it = gCoolKeyList.begin(); it != gCoolKeyList.end(); ++it)
- {
- if ((*it)->mSlot == aSlot)
- {
- return (*it);
- }
- }
+ for (it = gCoolKeyList.begin(); it != gCoolKeyList.end(); ++it)
+ {
+ if ((*it)->mSlot == aSlot)
+ {
+ return (*it);
+ }
+ }
- return NULL;
+ return NULL;
}
CoolKeyInfo *
GetCoolKeyInfoByKeyIDInternal(const CoolKey *aKey)
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetCoolKeyInfoByKeyIDInternal:\n"));
- std::list<CoolKeyInfo*>::iterator it;
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
GetCoolKeyInfoByKeyIDInternal:\n",GetTStamp(tBuff,56)));
+ std::list<CoolKeyInfo*>::iterator it;
+
+ if(!aKey)
+ return NULL;
- for (it = gCoolKeyList.begin(); it != gCoolKeyList.end(); ++it)
- {
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetCoolKeyInfoByKeyIDInternal id
%s:\n",(*it)->mCUID));
+ for (it = gCoolKeyList.begin(); it != gCoolKeyList.end(); ++it)
+ {
+
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s GetCoolKeyInfoByKeyIDInternal id
%s:\n",GetTStamp(tBuff,56),(*it)->mCUID));
// XXX_KEY_TYPE_CASUALTY: We need to check the keyType here too!
- if (!PL_strcasecmp((*it)->mCUID, aKey->mKeyID))
- return *it;
- }
+ if (!PL_strcasecmp((*it)->mCUID, aKey->mKeyID))
+ return *it;
+ }
- return NULL;
+ return NULL;
}
CoolKeyInfo *
GetCoolKeyInfoByKeyID(const CoolKey *aKey)
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetCoolKeyInfoByKeyID:\n"));
- AutoCoolKeyListLock autoLock;
- return GetCoolKeyInfoByKeyIDInternal(aKey);
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
GetCoolKeyInfoByKeyID:\n",GetTStamp(tBuff,56)));
+ AutoCoolKeyListLock autoLock;
+ return GetCoolKeyInfoByKeyIDInternal(aKey);
}
-
CoolKeyInfo *
GetCoolKeyInfoByTokenName(const char *aTokenName)
{
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
GetCoolKeyInfoByTokenName:\n",GetTStamp(tBuff,56)));
+ AutoCoolKeyListLock autoLock;
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetCoolKeyInfoByTokenName:\n"));
- AutoCoolKeyListLock autoLock;
+ std::list<CoolKeyInfo*>::iterator it;
- std::list<CoolKeyInfo*>::iterator it;
+ for (it = gCoolKeyList.begin(); it != gCoolKeyList.end(); ++it)
+ {
+ char* tokenName = PK11_GetTokenName((*it)->mSlot);
- for (it = gCoolKeyList.begin(); it != gCoolKeyList.end(); ++it)
- {
- char* tokenName = PK11_GetTokenName((*it)->mSlot);
-
- if (!PL_strcasecmp(tokenName, aTokenName))
- {
- return (*it);
- }
- }
+ if (!PL_strcasecmp(tokenName, aTokenName))
+ {
+ return (*it);
+ }
+ }
- return NULL;
+ return NULL;
}
const char *
GetReaderNameForKeyID(const CoolKey *aKey)
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetReaderNameForKeyID:\n"));
- AutoCoolKeyListLock autoLock;
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
GetReaderNameForKeyID:\n",GetTStamp(tBuff,56)));
+ AutoCoolKeyListLock autoLock;
- const CoolKeyInfo *info = GetCoolKeyInfoByKeyIDInternal(aKey);
+ const CoolKeyInfo *info = GetCoolKeyInfoByKeyIDInternal(aKey);
- if (!info)
- return 0;
+ if (!info)
+ return 0;
- return info->mReaderName;
+ return info->mReaderName;
}
const char *
GetSlotNameForKeyID(const CoolKey *aKey)
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetSlotNameForKeyID:\n"));
- const CoolKeyInfo *info = GetCoolKeyInfoByKeyIDInternal(aKey);
- if (!info)
- return NULL;
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
GetSlotNameForKeyID:\n",GetTStamp(tBuff,56)));
+ const CoolKeyInfo *info = GetCoolKeyInfoByKeyIDInternal(aKey);
+ if (!info)
+ return NULL;
- return PK11_GetSlotName(info->mSlot);
+ return PK11_GetSlotName(info->mSlot);
}
const char *
GetATRForKeyID(const CoolKey *aKey)
{
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
GetSlotNameForKeyID:\n",GetTStamp(tBuff,56)));
+ AutoCoolKeyListLock autoLock;
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetSlotNameForKeyID:\n"));
- AutoCoolKeyListLock autoLock;
-
- const CoolKeyInfo *info = GetCoolKeyInfoByKeyIDInternal(aKey);
+ const CoolKeyInfo *info = GetCoolKeyInfoByKeyIDInternal(aKey);
- if (!info)
- return 0;
+ if (!info)
+ return 0;
- return info->mATR;
+ return info->mATR;
}
const char *
GetCUIDForKeyID(const CoolKey *aKey)
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetCUIDForKeyID:\n"));
- AutoCoolKeyListLock autoLock;
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
GetCUIDForKeyID:\n",GetTStamp(tBuff,56)));
+ AutoCoolKeyListLock autoLock;
- const CoolKeyInfo *info = GetCoolKeyInfoByKeyIDInternal(aKey);
+ const CoolKeyInfo *info = GetCoolKeyInfoByKeyIDInternal(aKey);
- if (!info)
- return 0;
+ if (!info)
+ return 0;
- return info->mCUID;
+ return info->mCUID;
}
const char *
GetMSNForKeyIDInternal(const CoolKey *aKey)
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetMSNForKeyIDInternal:\n"));
- const CoolKeyInfo *info = GetCoolKeyInfoByKeyIDInternal(aKey);
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
GetMSNForKeyIDInternal:\n",GetTStamp(tBuff,56)));
+ const CoolKeyInfo *info = GetCoolKeyInfoByKeyIDInternal(aKey);
- if (!info)
- return 0;
+ if (!info)
+ return 0;
- return info->mMSN;
+ return info->mMSN;
}
const char *
GetMSNForKeyID(const CoolKey *aKey)
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetMSNForKeyID:\n"));
- AutoCoolKeyListLock autoLock;
- return GetMSNForKeyIDInternal(aKey);
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
GetMSNForKeyID:\n",GetTStamp(tBuff,56)));
+ AutoCoolKeyListLock autoLock;
+ return GetMSNForKeyIDInternal(aKey);
}
unsigned int
GetInfoFlagsForKeyID(const CoolKey *aKey)
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetInfoFlagsForKeyID:\n"));
- AutoCoolKeyListLock autoLock;
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
GetInfoFlagsForKeyID:\n",GetTStamp(tBuff,56)));
+ AutoCoolKeyListLock autoLock;
- const CoolKeyInfo *info = GetCoolKeyInfoByKeyIDInternal(aKey);
+ const CoolKeyInfo *info = GetCoolKeyInfoByKeyIDInternal(aKey);
- if (!info)
- return 0;
+ if (!info)
+ return 0;
- return info->mInfoFlags;
+ return info->mInfoFlags;
}
int
RefreshInfoFlagsForKeyID(const CoolKey *aKey)
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("RefreshInfoFlagsForKeyID:\n"));
- AutoCoolKeyListLock autoLock;
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
RefreshInfoFlagsForKeyID:\n",GetTStamp(tBuff,56)));
+ AutoCoolKeyListLock autoLock;
- CoolKeyInfo *info = GetCoolKeyInfoByKeyIDInternal(aKey);
+ CoolKeyInfo *info = GetCoolKeyInfoByKeyIDInternal(aKey);
- int alreadyCoolKey = 0;
- if( IS_REALLY_A_COOLKEY(info->mInfoFlags))
- alreadyCoolKey = 1;
+ if(!info)
+ return -1;
+ int alreadyCoolKey = 0;
+ if( IS_REALLY_A_COOLKEY(info->mInfoFlags))
+ alreadyCoolKey = 1;
- if (!info)
- return -1;
+ if (!info)
+ return -1;
- if (!HAS_ATR(info->mInfoFlags))
- return -1;
+ if (!HAS_ATR(info->mInfoFlags))
+ return -1;
- info->mInfoFlags = CKHGetInfoFlags(info->mSlot);
+ info->mInfoFlags = CKHGetInfoFlags(info->mSlot);
- if(alreadyCoolKey)
- {
- info->mInfoFlags |= COOLKEY_INFO_IS_REALLY_A_COOLKEY_MASK;
- }
+ if(alreadyCoolKey)
+ {
+ info->mInfoFlags |= COOLKEY_INFO_IS_REALLY_A_COOLKEY_MASK;
+ }
- return 0;
+ return 0;
}
int
InsertCoolKeyInfoIntoCoolKeyList(CoolKeyInfo *aInfo)
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG,
("InsertCoolKeyInfoIntoCoolKeyList:\n"));
- AutoCoolKeyListLock autoLock;
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
InsertCoolKeyInfoIntoCoolKeyList:\n",GetTStamp(tBuff,56)));
+ AutoCoolKeyListLock autoLock;
- if (!aInfo)
- return -1;
+ if (!aInfo)
+ return -1;
- gCoolKeyList.push_back(aInfo);
+ gCoolKeyList.push_back(aInfo);
- return 0;
+ return 0;
}
int
RemoveCoolKeyInfoFromCoolKeyList(CoolKeyInfo *aInfo)
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG,
("RemoveCoolKeyInfoFromCoolKeyList:\n"));
- AutoCoolKeyListLock autoLock;
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
RemoveCoolKeyInfoFromCoolKeyList:\n",GetTStamp(tBuff,56)));
+ AutoCoolKeyListLock autoLock;
+
+ if (!aInfo)
+ return -1;
- if (!aInfo)
- return -1;
+ std::list<CoolKeyInfo*>::iterator it;
- std::list<CoolKeyInfo*>::iterator it;
- for (it = gCoolKeyList.begin(); it != gCoolKeyList.end(); ++it)
- {
- if (*it == aInfo)
+ for (it = gCoolKeyList.begin(); it != gCoolKeyList.end(); ++it)
{
- gCoolKeyList.erase(it);
- break;
+ if (*it == aInfo)
+ {
+ gCoolKeyList.erase(it);
+ break;
+ }
}
- }
- return 0;
+ return 0;
}
int
ClearCoolKeyList()
{
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
ClearCoolKeyList:entering\n",GetTStamp(tBuff,56)));
+ AutoCoolKeyListLock autoLock;
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("ClearCoolKeyList:entering\n"));
- AutoCoolKeyListLock autoLock;
-
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("ClearCoolKeyList:\n"));
- std::list<CoolKeyInfo*>::iterator it;
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
ClearCoolKeyList:\n",GetTStamp(tBuff,56)));
+ std::list<CoolKeyInfo*>::iterator it;
- for (it = gCoolKeyList.begin(); it != gCoolKeyList.end(); ++it)
- {
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("ClearCoolKeyList: clearing %p
\n",*it));
- CoolKeyInfo *info = *it;
- delete info;
- }
+ for (it = gCoolKeyList.begin(); it != gCoolKeyList.end(); ++it)
+ {
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s ClearCoolKeyList: clearing %p
\n",GetTStamp(tBuff,56),*it));
+ CoolKeyInfo *info = *it;
+ delete info;
+ }
- gCoolKeyList.clear();
+ gCoolKeyList.clear();
- return 0;
+ return 0;
}
PK11SlotInfo *GetSlotForKeyID(const CoolKey *aKey)
{
- AutoCoolKeyListLock autoLock;
-
+ AutoCoolKeyListLock autoLock;
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetSlotForKeyID:\n"));
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
GetSlotForKeyID:\n",GetTStamp(tBuff,56)));
- if (!aKey)
- {
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetSlotForKeyID: null CoolKey.\n"));
- return NULL;
- }
+ if (!aKey)
+ {
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s GetSlotForKeyID: null
CoolKey.\n",GetTStamp(tBuff,56)));
+ return NULL;
+ }
- CoolKeyInfo *info = GetCoolKeyInfoByKeyIDInternal(aKey);
- if (!info)
- return NULL;
+ CoolKeyInfo *info = GetCoolKeyInfoByKeyIDInternal(aKey);
+ if (!info)
+ return NULL;
- return PK11_ReferenceSlot(info->mSlot);
+ return PK11_ReferenceSlot(info->mSlot);
}
enum {
- eGetPublicKey,
- eGetPrivateKey
+ eGetPublicKey,
+ eGetPrivateKey
};
void* GetAuthKey(int keyType, PK11SlotInfo* slot)
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetAuthKey:\n"));
- CERTCertListNode *node;
- CERTCertList *certs = PK11_ListCertsInSlot(slot);
- if (!certs)
- return NULL;
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
GetAuthKey:\n",GetTStamp(tBuff,56)));
+ CERTCertListNode *node;
+ CERTCertList *certs = PK11_ListCertsInSlot(slot);
+ if (!certs)
+ return NULL;
- for (node = CERT_LIST_HEAD(certs); !CERT_LIST_END(node,certs); node =
CERT_LIST_NEXT(node))
- {
- SECItem policyItem;
- policyItem.data = 0;
-
- SECStatus s = CERT_FindCertExtension(node->cert,
SEC_OID_X509_CERTIFICATE_POLICIES, &policyItem);
-
- if (s != SECSuccess || !policyItem.data)
- continue;
-
- CERTCertificatePolicies *policies =
CERT_DecodeCertificatePoliciesExtension(&policyItem);
-
- if (!policies)
+ for (node = CERT_LIST_HEAD(certs); !CERT_LIST_END(node,certs); node =
CERT_LIST_NEXT(node))
{
- PORT_Free(policyItem.data);
- continue;
- }
+ SECItem policyItem;
+ policyItem.data = 0;
- CERTPolicyInfo **policyInfos = policies->policyInfos;
+ SECStatus s = CERT_FindCertExtension(node->cert,
SEC_OID_X509_CERTIFICATE_POLICIES, &policyItem);
- while (*policyInfos)
- {
- char *policyID = CERT_GetOidString(&(*policyInfos)->policyID);
- if (!PL_strcasecmp(policyID, SAOL_OID_BRONZE))
- {
- PR_smprintf_free(policyID);
- PORT_Free(policyItem.data);
-
- if (keyType == eGetPrivateKey)
- return PK11_FindPrivateKeyFromCert(slot, node->cert, NULL);
+ if (s != SECSuccess || !policyItem.data)
+ continue;
+
+ CERTCertificatePolicies *policies =
CERT_DecodeCertificatePoliciesExtension(&policyItem);
+
+ if (!policies)
+ {
+ PORT_Free(policyItem.data);
+ continue;
+ }
+
+ CERTPolicyInfo **policyInfos = policies->policyInfos;
+
+ while (*policyInfos)
+ {
+ char *policyID = CERT_GetOidString(&(*policyInfos)->policyID);
+ if (!PL_strcasecmp(policyID, SAOL_OID_BRONZE))
+ {
+ PR_smprintf_free(policyID);
+ PORT_Free(policyItem.data);
+
+ if (keyType == eGetPrivateKey)
+ return PK11_FindPrivateKeyFromCert(slot, node->cert, NULL);
+
+ if (keyType == eGetPublicKey)
+ return SECITEM_DupItem(&node->cert->derPublicKey);
+ }
+ policyInfos++;
+ PR_smprintf_free(policyID);
+ }
- if (keyType == eGetPublicKey)
- return SECITEM_DupItem(&node->cert->derPublicKey);
- }
- policyInfos++;
- PR_smprintf_free(policyID);
+ PORT_Free(policyItem.data);
+ CERT_DestroyCertificatePoliciesExtension(policies);
}
- PORT_Free(policyItem.data);
- CERT_DestroyCertificatePoliciesExtension(policies);
- }
-
- CERT_DestroyCertList(certs);
- return NULL;
+ CERT_DestroyCertList(certs);
+ return NULL;
}
SECKEYPrivateKey* GetAuthenticationPrivateKey(PK11SlotInfo* slot)
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetAuthenticationPrivateKey:\n"));
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
GetAuthenticationPrivateKey:\n",GetTStamp(tBuff,56)));
return (SECKEYPrivateKey*) GetAuthKey(eGetPrivateKey, slot);
}
SECItem* GetAuthenticationPublicKey(PK11SlotInfo* slot)
{
- PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("GetAuthenticationPrivateKey:\n"));
+ char tBuff[56];
+ PR_LOG( coolKeyLogSU, PR_LOG_DEBUG, ("%s
GetAuthenticationPrivateKey:\n",GetTStamp(tBuff,56)));
return (SECItem*) GetAuthKey(eGetPublicKey, slot);
}
@@ -491,47 +516,47 @@
#ifdef DUMP_CHALLENGE_RESPONSE
void DumpAuthenticationPublicKey(PK11SlotInfo* slot, FILE *f)
{
- CERTCertListNode *node;
- CERTCertList *certs = PK11_ListCertsInSlot(slot);
- if (!certs)
- return;
+ CERTCertListNode *node;
+ CERTCertList *certs = PK11_ListCertsInSlot(slot);
+ if (!certs)
+ return;
- for (node = CERT_LIST_HEAD(certs); !CERT_LIST_END(node,certs); node =
CERT_LIST_NEXT(node))
- {
- SECItem policyItem;
- policyItem.data = 0;
-
- SECStatus s = CERT_FindCertExtension(node->cert,
SEC_OID_X509_CERTIFICATE_POLICIES, &policyItem);
-
- if (s != SECSuccess || !policyItem.data)
- continue;
-
- CERTCertificatePolicies *policies =
CERT_DecodeCertificatePoliciesExtension(&policyItem);
-
- if (!policies)
+ for (node = CERT_LIST_HEAD(certs); !CERT_LIST_END(node,certs); node =
CERT_LIST_NEXT(node))
{
- PORT_Free(policyItem.data);
- continue;
- }
+ SECItem policyItem;
+ policyItem.data = 0;
- CERTPolicyInfo **policyInfos = policies->policyInfos;
+ SECStatus s = CERT_FindCertExtension(node->cert,
SEC_OID_X509_CERTIFICATE_POLICIES, &policyItem);
- while (*policyInfos)
- {
- char *policyID = CERT_GetOidString(&(*policyInfos)->policyID);
- if (!PL_strcasecmp(policyID, SAOL_OID_BRONZE))
- {
- PR_smprintf_free(policyID);
- PORT_Free(policyItem.data);
- fwrite(node->cert->derCert.data, node->cert->derCert.len, 1, f);
- return;
- }
- policyInfos++;
- PR_smprintf_free(policyID);
- }
+ if (s != SECSuccess || !policyItem.data)
+ continue;
+
+ CERTCertificatePolicies *policies =
CERT_DecodeCertificatePoliciesExtension(&policyItem);
+
+ if (!policies)
+ {
+ PORT_Free(policyItem.data);
+ continue;
+ }
+
+ CERTPolicyInfo **policyInfos = policies->policyInfos;
+
+ while (*policyInfos)
+ {
+ char *policyID = CERT_GetOidString(&(*policyInfos)->policyID);
+ if (!PL_strcasecmp(policyID, SAOL_OID_BRONZE))
+ {
+ PR_smprintf_free(policyID);
+ PORT_Free(policyItem.data);
+ fwrite(node->cert->derCert.data, node->cert->derCert.len, 1,
f);
+ return;
+ }
+ policyInfos++;
+ PR_smprintf_free(policyID);
+ }
- PORT_Free(policyItem.data);
- CERT_DestroyCertificatePoliciesExtension(policies);
+ PORT_Free(policyItem.data);
+ CERT_DestroyCertificatePoliciesExtension(policies);
}
CERT_DestroyCertList(certs);