00001
00009
00010
00011
00012 #include "PKIFdll.h"
00013 #include "components.h"
00014 #include "PKIFErrors.h"
00015 #include "ToolkitUtils.h"
00016 #include "PKIFLog.h"
00017 #include "PKIFCertificatePath.h"
00018 #include "EventLog.h"
00019
00020 #include "OID.h"
00021 #include "AlgorithmIdentifier.h"
00022 #include "PolicyInformation.h"
00023
00024 #ifdef _WIN32
00025 #include "Log.h"
00026 #endif
00027
00028 #include <fstream>
00029 #include <iostream>
00030 #include <sstream>
00031 #include <bitset>
00032 #include <iomanip>
00033 #include <cstring>
00034
00035
00036 #ifndef _DISABLE_ALL_LOGGING
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #endif
00047 void configureLogging();
00048 void InitGlobalOIDs();
00049 static bool LOGGING_CONFIGURED = false;
00050
00051 using namespace std;
00059 void GetObjectDesc(
00061 DWORD subcomponentID,
00063 char* numbuf)
00064 {
00065 switch(subcomponentID)
00066 {
00067
00068 case TOOLKIT_EXTENSION_MEDIATOR:
00069 strcpy(numbuf, "CPKIFX509ExtensionMediator");
00070 break;
00071 case TOOLKIT_X509_ASN:
00072 strcpy(numbuf, "X.509 DER encoder/decoder");
00073 break;
00074
00075
00076 case TOOLKIT_SR_MEDIATOR:
00077 strcpy(numbuf, "CPKIFCacheMediator");
00078 break;
00079 case TOOLKIT_SR_CAPICERTUPDATE:
00080 strcpy(numbuf, "CPKIFCAPICertUpdate");
00081 break;
00082 case TOOLKIT_SR_CAPICRLUPDATE:
00083 strcpy(numbuf, "CPKIFCAPICRLUpdate");
00084 break;
00085 case TOOLKIT_SR_CAPIREPOSITORY:
00086 strcpy(numbuf, "CPKIFCAPIRepository");
00087 break;
00088 case TOOLKIT_SR_CAPITRUSTROOTCRLSTORE:
00089 strcpy(numbuf, "CPKIFCAPITrustRootCRLRepository");
00090 break;
00091 case TOOLKIT_SR_CAPITRUSTSTORE:
00092 strcpy(numbuf, "CPKIFCAPITrustStore");
00093 break;
00094 case TOOLKIT_SR_CAPIUSERREPOSITORY:
00095 strcpy(numbuf, "CPKIFCAPIUserRepository");
00096 break;
00097 case TOOLKIT_SR_LDAPREPOSITORY:
00098 strcpy(numbuf, "CPKIFLDAPRepository");
00099 break;
00100 case TOOLKIT_SR_SIMPLECERTCACHE:
00101 strcpy(numbuf, "SimpleCertCache");
00102 break;
00103 case TOOLKIT_SR_SIMPLECRLCACHE:
00104 strcpy(numbuf, "SimpleCRLCache");
00105 break;
00106 case TOOLKIT_SR_SIMPLEROOTSTORE:
00107 strcpy(numbuf, "SimpleRootStore");
00108 break;
00109 case TOOLKIT_SR_MISC:
00110 strcpy(numbuf, "Miscellaneous cache component");
00111 break;
00112
00113
00114 case TOOLKIT_CRYPTO_MEDIATOR:
00115 strcpy(numbuf, "CPKIFCryptoMediator");
00116 break;
00117 case TOOLKIT_CRYPTO_CAPICRED:
00118 strcpy(numbuf, "CPKIFCAPICredential");
00119 break;
00120 case TOOLKIT_CRYPTO_CAPI:
00121 strcpy(numbuf, "CPKIFCAPI");
00122 break;
00123 case TOOLKIT_CRYPTO_CAPIRAW:
00124 strcpy(numbuf, "CPKIFCAPIRaw");
00125 break;
00126 case TOOLKIT_CRYPTO_KEYMATERIAL:
00127 strcpy(numbuf, "CPKIFKeyMaterial");
00128 break;
00129 case TOOLKIT_CRYPTO_MISC:
00130 strcpy(numbuf, "Miscellaneous crypto component");
00131 break;
00132
00133
00134 case TOOLKIT_MESSAGE_SIGNED_DATA:
00135 strcpy(numbuf, "CPKIFSignedData");
00136 break;
00137 case TOOLKIT_MESSAGE_ATTR_MEDIATOR:
00138 strcpy(numbuf, "CPKIFCMSAttributeMediator");
00139 break;
00140 case TOOLKIT_MESSAGE_ASN:
00141 strcpy(numbuf, "CMS DER encoder/decode");
00142 break;
00143 case TOOLKIT_MESSAGE_PARALLEL_HASH:
00144 strcpy(numbuf, "CPKIFParallelHash");
00145 break;
00146 case TOOLKIT_MESSAGE_ENVELOPED_DATA:
00147 strcpy(numbuf, "CPKIFEnvelopedData");
00148 break;
00149 case TOOLKIT_MESSAGE_CONTENT_INFO:
00150 strcpy(numbuf, "CPKIFContentInfo");
00151 break;
00152
00153
00154 case TOOLKIT_PATH_MEDIATOR:
00155 strcpy(numbuf, "CPKIFPathProcessingMediator");
00156 break;
00157 case TOOLKIT_PATH_REV_STATUS_MEDIATOR:
00158 strcpy(numbuf, "CPKIFRevocationStatusMediator");
00159 break;
00160 case TOOLKIT_PATH_CRL_CHECKER:
00161 strcpy(numbuf, "CPKIFX509CRLChecker");
00162 break;
00163 case TOOLKIT_PATH_BASIC_CHECKS:
00164 strcpy(numbuf, "CPKIFPathBasicChecks");
00165 break;
00166 case TOOLKIT_PATH_BUILDER:
00167 strcpy(numbuf, "CPKIFPathBuilder");
00168 break;
00169 case TOOLKIT_PATH_VALIDATOR:
00170 strcpy(numbuf, "CPKIFPathValidator");
00171 break;
00172 case TOOLKIT_PATH_MISC:
00173 strcpy(numbuf, "Miscellaneous path components");
00174 break;
00175 case TOOLKIT_OCSP_CHECKER:
00176 strcpy(numbuf, "CPKIFOCSPChecker");
00177 break;
00178
00179
00180 case TOOLKIT_PKIF_DLL:
00181 strcpy(numbuf, "PKIF DLL");
00182 break;
00183
00184
00185 case TOOLKIT_OCSP_ASN:
00186 strcpy(numbuf, "OCSP DER encoder/decode");
00187 break;
00188
00189
00190 case TOOLKIT_TAP_ASN:
00191 strcpy(numbuf, "TAP DER encoder/decode");
00192 break;
00193
00194
00195 case TOOLKIT_TSP_ASN:
00196 strcpy(numbuf, "TSP DER encoder/decode");
00197 break;
00198 case TOOLKIT_TSP_TIMESTAMP_VERIFIER:
00199 strcpy(numbuf, "CPKIFTimestampVerifier");
00200 break;
00201
00202
00203 case TOOLKIT_APP + 1 :
00204 strcpy(numbuf, "CFindCertsDialog");
00205 break;
00206 case TOOLKIT_APP + 2 :
00207 strcpy(numbuf, "CSelectCertDialog");
00208 break;
00209
00210 default:
00211 strcpy(numbuf, "Unknown component");
00212 }
00213 }
00214
00215 #if defined (WIN32) || defined (_WIN32)
00216
00223 bool GetLogConfigFile(
00225 char* ppszFilename,
00227 unsigned long* pnLen)
00228 {
00229 HKEY key = NULL;
00230 #ifdef _DISABLE_ALL_LOGGING
00231 return false;
00232 #endif
00233 long rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Orion Security Solutions\\PKIF", 0, KEY_READ, &key);
00234 if(0 != rv)
00235 return false;
00236
00237 DWORD type = 0;
00238 rv = RegQueryValueEx(key, "LogConfigFile", 0, &type, (BYTE*)ppszFilename, pnLen);
00239 if(0 == rv)
00240 {
00241 RegCloseKey(key);
00242
00243 if(REG_SZ != type)
00244 return false;
00245 else
00246 return true;
00247 }
00248 else
00249 {
00250 RegCloseKey(key);
00251 return false;
00252 }
00253 }
00254
00255 #endif // WIN32
00256
00264 bool InitPKIF(void)
00265 {
00266 InitGlobalOIDs();
00267 #if defined(_DISABLE_LOGGING_MACROS)
00268 return true;
00269 #else
00270 return InitLogging();
00271 #endif
00272 }
00273
00274
00275 #if defined(_WIN32) || defined(WIN32)
00276 std::ofstream* g_pathLogFile = NULL;
00277 #endif
00278
00285 long filesize(
00287 FILE *stream)
00288 {
00289 long curpos, length;
00290
00291 curpos = ftell(stream);
00292 fseek(stream, 0L, SEEK_END);
00293 length = ftell(stream);
00294 fseek(stream, curpos, SEEK_SET);
00295 return length;
00296 }
00304 void GetLoggingIndicator(DWORD* value)
00305 {
00306 #if defined(_WIN32) || defined(WIN32)
00307 *value = 0;
00308
00309 HKEY key = NULL;
00310 if(0 != RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Cygnacom\\PKIF\\", 0, KEY_ALL_ACCESS, &key))
00311 return;
00312
00313 *value = 0;
00314
00315 DWORD type = 0, size = 4;
00316
00317
00318 if(RegQueryValueEx(key, "LogTypes", NULL, &type, (BYTE*)value, &size))
00319 {
00320 if(REG_DWORD != type)
00321 {
00322 RegCloseKey(key);
00323 *value = 0;
00324 }
00325 else
00326 {
00327 RegCloseKey(key);
00328 }
00329 }
00330 else
00331 {
00332 RegCloseKey(key);
00333 }
00334 #endif
00335 }
00343 bool GetLogFile(
00345 char* ppszFilename, unsigned long* pnLen)
00346 {
00347 #if defined(_WIN32) || defined(WIN32)
00348 HKEY key = NULL;
00349 long rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Cygnacom\\PKIF\\", 0, KEY_READ, &key);
00350 if(0 != rv)
00351 return false;
00352
00353 DWORD type = 0;
00354 rv = RegQueryValueEx(key, "LogFile", 0, &type, (BYTE*)ppszFilename, pnLen);
00355 if(0 == rv)
00356 {
00357 RegCloseKey(key);
00358
00359 if(REG_SZ != type)
00360 return false;
00361 else
00362 return true;
00363 }
00364 else
00365 {
00366 RegCloseKey(key);
00367 return false;
00368 }
00369 #else
00370 return false;
00371 #endif
00372 }
00373
00381 bool GetPathLogFile(
00383 char* ppszFilename, unsigned long* pnLen)
00384 {
00385 #if defined(_WIN32) || defined(WIN32)
00386 HKEY key = NULL;
00387 long rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Cygnacom\\PKIF\\", 0, KEY_READ, &key);
00388 if(0 != rv)
00389 return false;
00390
00391 DWORD type = 0;
00392 rv = RegQueryValueEx(key, "PathLogFile", 0, &type, (BYTE*)ppszFilename, pnLen);
00393 if(0 == rv)
00394 {
00395 RegCloseKey(key);
00396
00397 if(REG_SZ != type)
00398 return false;
00399 else
00400 return true;
00401 }
00402 else
00403 {
00404 RegCloseKey(key);
00405 return false;
00406 }
00407 #else
00408 return false;
00409 #endif
00410 }
00411
00412
00413 #if !defined(_DISABLE_LOGGING_MACROS) && defined(_WIN32)
00414 DWORD g_loggingIndicator = 0;
00415 DWORD g_logInfo = 0x0000FFFF;
00416 CLog g_log("PKIF");
00417 #endif
00418
00434 bool InitLogging()
00435 {
00436
00437 #if !defined(_WIN32) || defined(_DISABLE_LOGGING_MACROS)
00438 return false;
00439
00440 #else
00441
00442 TerminateLogging();
00443
00444 char logFile[MAX_PATH]; logFile[0] = 0x00;
00445 unsigned long len = MAX_PATH;
00446
00447
00448 GetLogFile((char*)&logFile, &len);
00449 GetLoggingIndicator(&g_loggingIndicator);
00450
00451
00452 if(strlen(logFile) > 0)
00453 {
00454 bool writeHeaders = false;
00455
00456
00457 std::ostringstream oss;
00458 char numbuf[25];
00459 oss << logFile << itoa(GetCurrentProcessId(), numbuf, 10) << ".txt";
00460 string logFileWithPID = oss.str();
00461 FILE* fLogFile = fopen(logFileWithPID.c_str(), "r");
00462 if(fLogFile)
00463 {
00464
00465 bool b = filesize(fLogFile) > 10000000;
00466 fclose(fLogFile); fLogFile = NULL;
00467 if(b)
00468 {
00469 remove(logFile);
00470 writeHeaders = true;
00471 }
00472 }
00473 else
00474 writeHeaders = true;
00475
00476 if(writeHeaders)
00477 {
00478 fLogFile = fopen(logFile, "w+");
00479 if(fLogFile)
00480 {
00481 char headers[] = "Current Time|Source|Type|PID|TID|Object|Subcomponent ID|Component Category|Subcomponent Description|Error Code|Error Code Description|Error Message\n";
00482 fwrite(headers, strlen(headers), 1, fLogFile);
00483 fflush(fLogFile);
00484 fclose(fLogFile);
00485 }
00486 }
00487
00488
00489 try
00490 {
00491 enum nsCLog::eSeverity es;
00492 switch(g_loggingIndicator)
00493 {
00494 case 1:
00495 es = nsCLog::info;
00496 break;
00497 case 2:
00498 es = nsCLog::warning;
00499 break;
00500 case 3:
00501 es = nsCLog::error;
00502 break;
00503 default:
00504 es = nsCLog::debug;
00505 break;
00506 }
00507 CFileLogAppender * pFileLogAppender = new CFileLogAppender(es, logFileWithPID.c_str());
00508 g_log.addAppender(pFileLogAppender);
00509 }
00510 catch(...)
00511 {
00512 AuditString(EVENTLOG_ERROR_TYPE, PKIF_UTILS, PKIF_UNEXPECTED_EXCEPTION, "Failed to initiate file logger", TOOLKIT_PKIF_DLL);
00513 }
00514 }
00515
00516 char pathLogFile[MAX_PATH];
00517 unsigned long pathLen = MAX_PATH;
00518 pathLogFile[0] = 0x00;
00519 GetPathLogFile((char*)&pathLogFile, &pathLen);
00520 if(strlen(pathLogFile) > 0)
00521 {
00522 g_pathLogFile = new std::ofstream(pathLogFile, std::ios::out|std::ios::app);
00523 }
00524
00525 return true;
00526 #endif
00527 }
00528
00536 void CAC_API LogString(
00538 const char* errorMessage,
00540 DWORD subcomponentID,
00542 DWORD errorCode,
00544 const void* objectPointer,
00546 nsCLog::eSeverity threshold,
00548 const char* fileName,
00550 int lineNumber)
00551 {
00552
00553 #if !defined(_WIN32) || defined(_DISABLE_LOGGING_MACROS)
00554 return;
00555 #else
00556 char numbuf[MAX_ERROR_CODE_STRING_SIZE];
00557
00558 std::ostringstream oss;
00559
00560
00561 #ifdef _WIN32
00562 oss << GetCurrentProcessId() << "|";
00563
00564 oss << GetCurrentThreadId() << "|";
00565 #else
00566 oss << getppid() << "|";
00567 oss << getpid() << "|";
00568 #endif
00569
00570 if(0 != objectPointer)
00571 {
00572 sprintf(numbuf, "%p", objectPointer);
00573 oss << numbuf << "|";
00574 }
00575 else
00576 oss << "0x00000000" << "|";
00577
00578
00579 oss << subcomponentID << "|";
00580
00581
00582 oss << subcomponentID/TOOLKIT_SUBCOMPONENT_MULTIPLIER << "|";
00583
00584
00585 GetObjectDesc(subcomponentID, numbuf);
00586 oss << numbuf << "|";
00587
00588
00589 oss << errorCode << "|";
00590
00591
00592 GetErrorCodeString(errorCode, numbuf);
00593 oss << numbuf << "|";
00594
00595
00596 if(NULL != errorMessage)
00597 oss << errorMessage << "|";
00598 else
00599 oss << " " << "|";
00600
00601 std::string tmp = oss.str();
00602
00603 g_log.writeLog(threshold, tmp);
00604 #endif
00605 }
00606
00607
00615 bool TerminateLogging()
00616 {
00617 return true;
00618 }
00619
00627 bool InitAudit()
00628 {
00629
00630 #if !defined(_WIN32) || defined(_DISABLE_LOGGING_MACROS)
00631 return false;
00632 #else
00633
00634 #if defined (_WIN32) || defined (WIN32)
00635 return CEventLog::AddEventSource();
00636 #else
00637
00638 return true;
00639 #endif
00640 #endif
00641 }
00642
00643 #if !defined _NO_AUDITFACILITY
00644
00645
00646
00647
00648
00649
00650
00658 void AuditString (
00660 int eventType,
00662 int eventCat,
00664 int eventID,
00666 const char* str,
00668 DWORD subcomponentID,
00670 DWORD errorCode,
00672 void *objectPointer)
00673 {
00674
00675 #if !defined(_WIN32) || defined(_DISABLE_LOGGING_MACROS)
00676 return;
00677 #else
00678
00679
00680
00681
00682
00683
00684
00685 #if defined (_WIN32) || defined (WIN32)
00686 HMODULE hCaller = NULL;
00687 char szBuffer[MAX_PATH];
00688 std::ostringstream o;
00689 if(0 != GetModuleFileName(hCaller,szBuffer,sizeof(szBuffer)))
00690 o << "Calling application (" << szBuffer << ") - " << str;
00691 else
00692 o << str;
00693
00694 CEventLog::Write(eventType, eventCat, eventID, o.str().c_str());
00695 #else
00696 logger = log4cxx::Logger::getLogger("AUDIT");
00697 LOG4CXX_INFO(logger, str);
00698 #endif
00699 #endif
00700 }
00701
00702 #endif // _NO_AUDITFACILITY
00703
00711 bool TerminateAudit()
00712 {
00713 return true;
00714 }
00722 void CAC_API AuditPathEvent(
00724 PathOp op,
00726 bool succeeded,
00728 CPKIFCertificatePath& path)
00729 {
00730
00731 #if !defined(_WIN32) || defined(_DISABLE_LOGGING_MACROS)
00732 return;
00733 #else
00734 std::string auditStr = "An attempt to ";
00735
00736 if(PO_VALIDATE == op)
00737 auditStr.append("validate a path ");
00738 else
00739 auditStr.append("build a path ");
00740
00741 DWORD dwType = PKIF_PATH_OPERATION_FAILED;
00742
00743 #if defined (WIN32) || defined (_WIN32)
00744 DWORD dwCat = EVENTLOG_INFORMATION_TYPE;
00745 #else
00746 DWORD dwCat = 0;
00747 #endif
00748 if(succeeded)
00749 {
00750 dwType = PKIF_PATH_OPERATION_SUCCEEDED;
00751 auditStr.append("succeeded. ");
00752 }
00753 else
00754 {
00755 dwType = PKIF_PATH_OPERATION_FAILED;
00756 auditStr.append("failed. ");
00757 #if defined (WIN32) || defined (_WIN32)
00758 dwCat = EVENTLOG_ERROR_TYPE;
00759 #endif
00760 }
00761
00762
00763 if(!succeeded)
00764 {
00765 auditStr.append("Target certificate information: ");
00766 CPKIFCertificatePtr targetCert;
00767 path.GetTarget(targetCert);
00768 auditStr.append(*GetCertInfo(targetCert));
00769
00770 AuditString(dwCat, CAT_PKIF_PATH, dwType, auditStr.c_str(), TOOLKIT_PATH_MEDIATOR, 0, 0);
00771 }
00772 #endif
00773 }
00774
00775
00776
00777
00778
00779 CAC_API CPKIFOIDPtr g_md2WithRSAEncryption;
00780 CAC_API CPKIFOIDPtr g_md5WithRSAEncryption;
00781 CAC_API CPKIFOIDPtr g_sha1WithRSAEncryption;
00782 CAC_API CPKIFOIDPtr g_sha224WithRSAEncryption;
00783 CAC_API CPKIFOIDPtr g_sha256WithRSAEncryption;
00784 CAC_API CPKIFOIDPtr g_sha384WithRSAEncryption;
00785 CAC_API CPKIFOIDPtr g_sha512WithRSAEncryption;
00786 CAC_API CPKIFOIDPtr g_dsaWithSHA1;
00787 CAC_API CPKIFOIDPtr g_dsaWithSHA1Alternative;
00788 CAC_API CPKIFOIDPtr g_dsa;
00789 CAC_API CPKIFOIDPtr g_rsa;
00790 CAC_API CPKIFOIDPtr g_ecc;
00791 CAC_API CPKIFOIDPtr g_ecdsa_sha1;
00792 CAC_API CPKIFOIDPtr g_ecdsa_rec;
00793 CAC_API CPKIFOIDPtr g_ecdsa_params;
00794 CAC_API CPKIFOIDPtr g_ecdsa_sha224;
00795 CAC_API CPKIFOIDPtr g_ecdsa_sha256;
00796 CAC_API CPKIFOIDPtr g_ecdsa_sha384;
00797 CAC_API CPKIFOIDPtr g_ecdsa_sha512;
00798
00799
00800 CAC_API CPKIFOIDPtr g_ecdh_std_sha1kdf;
00801 CAC_API CPKIFOIDPtr g_ecdh_cofactor_sha1kdf;
00802 CAC_API CPKIFOIDPtr g_ecmqv_sha1kdf;
00803 CAC_API CPKIFOIDPtr g_ecdh_std_sha256kdf;
00804 CAC_API CPKIFOIDPtr g_ecdh_std_sha384kdf;
00805
00806 CAC_API CPKIFOIDPtr g_sha1;
00807 CAC_API CPKIFOIDPtr g_sha224;
00808 CAC_API CPKIFOIDPtr g_sha256;
00809 CAC_API CPKIFOIDPtr g_sha384;
00810 CAC_API CPKIFOIDPtr g_sha512;
00811 CAC_API CPKIFOIDPtr g_md5;
00812
00813 CAC_API CPKIFOIDPtr g_desCBC;
00814 CAC_API CPKIFOIDPtr g_tdesCBC;
00815 CAC_API CPKIFOIDPtr g_tdesECB;
00816 CAC_API CPKIFOIDPtr g_desECB;
00817
00818 CAC_API CPKIFOIDPtr g_aes128ECB;
00819 CAC_API CPKIFOIDPtr g_aes128CBC;
00820 CAC_API CPKIFOIDPtr g_aes192ECB;
00821 CAC_API CPKIFOIDPtr g_aes192CBC;
00822 CAC_API CPKIFOIDPtr g_aes256ECB;
00823 CAC_API CPKIFOIDPtr g_aes256CBC;
00824
00825 CAC_API CPKIFOIDPtr g_aes128Wrap;
00826 CAC_API CPKIFOIDPtr g_aes192Wrap;
00827 CAC_API CPKIFOIDPtr g_aes256Wrap;
00828
00829
00830 CAC_API CPKIFOIDPtr g_contentInfo;
00831 CAC_API CPKIFOIDPtr g_data;
00832 CAC_API CPKIFOIDPtr g_signedData;
00833 CAC_API CPKIFOIDPtr g_envelopedData;
00834 CAC_API CPKIFOIDPtr g_encryptedData;
00835
00836 CAC_API CPKIFOIDPtr g_contentCollection;
00837 CAC_API CPKIFOIDPtr g_contentWithAttributes;
00838 CAC_API CPKIFOIDPtr g_compressedData;
00839 CAC_API CPKIFOIDPtr g_authenticatedData;
00840 CAC_API CPKIFOIDPtr g_digestedData;
00841 CAC_API CPKIFOIDPtr g_authEnvelopedData;
00842
00843
00844 CAC_API CPKIFOIDPtr g_contentTypeAttribute;
00845 CAC_API CPKIFOIDPtr g_messageDigestAttribute;
00846 CAC_API CPKIFOIDPtr g_signingTimeAttribute;
00847 CAC_API CPKIFOIDPtr g_countersignatureAttribute;
00848 CAC_API CPKIFOIDPtr g_timestampAttribute;
00849 CAC_API CPKIFOIDPtr g_archiveTokenAttribute;
00850 CAC_API CPKIFOIDPtr g_binarySigningTimeAttribute;
00851 CAC_API CPKIFOIDPtr g_signingCertificateAttribute;
00852
00853
00854 CAC_API CPKIFOIDPtr g_timestampingEKU;
00855 CAC_API CPKIFOIDPtr g_ocspSigningEKU;
00856 CAC_API CPKIFOIDPtr g_anyEKU;
00857
00858 CAC_API CPKIFOIDPtr g_anyPolicyOID;
00859 CAC_API CPKIFOIDPtr g_aiaCAIssuer;
00860 CAC_API CPKIFOIDPtr g_aiaCARepository;
00861
00862
00863 CAC_API CPKIFOIDPtr g_secp224r1;
00864 CAC_API CPKIFOIDPtr g_secp256r1;
00865 CAC_API CPKIFOIDPtr g_secp384r1;
00866 CAC_API CPKIFOIDPtr g_secp521r1;
00867
00868
00869
00870
00871 CAC_API CPKIFAlgorithmIdentifierPtr g_md5AI;
00872 CAC_API CPKIFAlgorithmIdentifierPtr g_sha1AI;
00873 CAC_API CPKIFAlgorithmIdentifierPtr g_sha256AI;
00874 CAC_API CPKIFAlgorithmIdentifierPtr g_sha384AI;
00875 CAC_API CPKIFAlgorithmIdentifierPtr g_sha512AI;
00876 CAC_API CPKIFPolicyInformationPtr g_anyPolicy;
00877
00878
00879 CAC_API unsigned char g_nullParams[] = {0x05,0x00};
00880
00888 void InitGlobalOIDs()
00889 {
00890
00891
00892
00893
00894 CPKIFOIDPtr md2WithRSAEncryption(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.1.2"))));
00895 g_md2WithRSAEncryption =md2WithRSAEncryption;
00896 CPKIFOIDPtr md5WithRSAEncryption(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.1.4"))));
00897 g_md5WithRSAEncryption =md5WithRSAEncryption;
00898 CPKIFOIDPtr sha1WithRSAEncryption(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.1.5"))));
00899 g_sha1WithRSAEncryption =sha1WithRSAEncryption;
00900 CPKIFOIDPtr sha224WithRSAEncryption(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.1.14"))));
00901 g_sha224WithRSAEncryption =sha224WithRSAEncryption;
00902 CPKIFOIDPtr sha256WithRSAEncryption(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.1.11"))));
00903 g_sha256WithRSAEncryption =sha256WithRSAEncryption;
00904 CPKIFOIDPtr sha384WithRSAEncryption(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.1.12"))));
00905 g_sha384WithRSAEncryption =sha384WithRSAEncryption;
00906 CPKIFOIDPtr sha512WithRSAEncryption(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.1.13"))));
00907 g_sha512WithRSAEncryption =sha512WithRSAEncryption;
00908 CPKIFOIDPtr dsaWithSHA1(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.10040.4.3"))));
00909 g_dsaWithSHA1 =dsaWithSHA1;
00910 CPKIFOIDPtr dsaWithSHA1Alternative(new CPKIFOID(CPKIFStringPtr(new std::string("1.3.14.3.2.27"))));
00911 g_dsaWithSHA1Alternative =dsaWithSHA1Alternative;
00912 CPKIFOIDPtr rsa(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.1.1"))));
00913 g_rsa =rsa;
00914 CPKIFOIDPtr dsa(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.10040.4.1"))));
00915 g_dsa =dsa;
00916 CPKIFOIDPtr ecc(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.10045.2.1"))));
00917 g_ecc =ecc;
00918
00919
00920
00921 CPKIFOIDPtr ecdsa_rec(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.10045.4.2"))));
00922 g_ecdsa_rec = ecdsa_rec;
00923 CPKIFOIDPtr ecdsa_params(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.10045.4.3"))));
00924 g_ecdsa_params = ecdsa_params;
00925
00926
00927 CPKIFOIDPtr ecdsa_sha1(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.10045.4.1"))));
00928 g_ecdsa_sha1 = ecdsa_sha1;
00929 CPKIFOIDPtr ecdsa_sha224(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.10045.4.3.1"))));
00930 g_ecdsa_sha224 = ecdsa_sha224;
00931 CPKIFOIDPtr ecdsa_sha256(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.10045.4.3.2"))));
00932 g_ecdsa_sha256 = ecdsa_sha256;
00933 CPKIFOIDPtr ecdsa_sha384(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.10045.4.3.3"))));
00934 g_ecdsa_sha384 = ecdsa_sha384;
00935 CPKIFOIDPtr ecdsa_sha512(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.10045.4.3.4"))));
00936 g_ecdsa_sha512 = ecdsa_sha512;
00937
00938
00939 CPKIFOIDPtr ecdh_std_sha1kdf(new CPKIFOID(CPKIFStringPtr(new std::string("1.3.133.16.840.63.0.2"))));
00940 g_ecdh_std_sha1kdf = ecdh_std_sha1kdf;
00941 CPKIFOIDPtr ecdh_cofactor_sha1kdf(new CPKIFOID(CPKIFStringPtr(new std::string("1.3.133.16.840.63.0.3"))));
00942 g_ecdh_cofactor_sha1kdf = ecdh_cofactor_sha1kdf;
00943 CPKIFOIDPtr ecmqv_sha1kdf(new CPKIFOID(CPKIFStringPtr(new std::string("1.3.133.16.840.63.0.16"))));
00944 g_ecmqv_sha1kdf = ecmqv_sha1kdf;
00945
00946
00947 CPKIFOIDPtr ecdh_std_sha256kdf(new CPKIFOID(CPKIFStringPtr(new std::string("1.3.132.1.11.1"))));
00948 g_ecdh_std_sha256kdf = ecdh_std_sha256kdf;
00949 CPKIFOIDPtr ecdh_std_sha384kdf(new CPKIFOID(CPKIFStringPtr(new std::string("1.3.132.1.11.1"))));
00950 g_ecdh_std_sha384kdf = ecdh_std_sha384kdf;
00951
00952
00953
00954
00955 CPKIFOIDPtr sha1(new CPKIFOID(CPKIFStringPtr(new std::string("1.3.14.3.2.26"))));
00956 g_sha1 =sha1;
00957 CPKIFOIDPtr sha256(new CPKIFOID(CPKIFStringPtr(new std::string("2.16.840.1.101.3.4.2.1"))));
00958 g_sha256 =sha256;
00959 CPKIFOIDPtr sha384(new CPKIFOID(CPKIFStringPtr(new std::string("2.16.840.1.101.3.4.2.2"))));
00960 g_sha384 =sha384;
00961 CPKIFOIDPtr sha512(new CPKIFOID(CPKIFStringPtr(new std::string("2.16.840.1.101.3.4.2.3"))));
00962 g_sha512 =sha512;
00963 CPKIFOIDPtr sha224(new CPKIFOID(CPKIFStringPtr(new std::string("2.16.840.1.101.3.4.2.4"))));
00964 g_sha224 =sha224;
00965 CPKIFOIDPtr md5(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.2.5"))));
00966 g_md5 =md5;
00967
00968 CPKIFOIDPtr desCBC(new CPKIFOID(CPKIFStringPtr(new std::string("1.3.14.3.2.7"))));
00969 g_desCBC =desCBC;
00970 CPKIFOIDPtr tdesCBC(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.3.7"))));
00971 g_tdesCBC =tdesCBC;
00972 CPKIFOIDPtr tdesECB(new CPKIFOID(CPKIFStringPtr(new std::string("1.3.14.3.2.17"))));
00973 g_tdesECB = tdesECB;
00974 CPKIFOIDPtr desECB(new CPKIFOID(CPKIFStringPtr(new std::string("1.3.14.3.2.6"))));
00975 g_desECB =desECB;
00976
00977 CPKIFOIDPtr aes128ECB(new CPKIFOID(CPKIFStringPtr(new std::string("2.16.840.1.101.3.4.1.1"))));
00978 g_aes128ECB = aes128ECB;
00979 CPKIFOIDPtr aes128CBC(new CPKIFOID(CPKIFStringPtr(new std::string("2.16.840.1.101.3.4.1.2"))));
00980 g_aes128CBC = aes128CBC;
00981 CPKIFOIDPtr aes192ECB(new CPKIFOID(CPKIFStringPtr(new std::string("2.16.840.1.101.3.4.1.21"))));
00982 g_aes192ECB = aes192ECB;
00983 CPKIFOIDPtr aes192CBC(new CPKIFOID(CPKIFStringPtr(new std::string("2.16.840.1.101.3.4.1.22"))));
00984 g_aes192CBC = aes192CBC;
00985 CPKIFOIDPtr aes256ECB(new CPKIFOID(CPKIFStringPtr(new std::string("2.16.840.1.101.3.4.1.41"))));
00986 g_aes256ECB = aes256ECB;
00987 CPKIFOIDPtr aes256CBC(new CPKIFOID(CPKIFStringPtr(new std::string("2.16.840.1.101.3.4.1.42"))));
00988 g_aes256CBC = aes256CBC;
00989
00990 CPKIFOIDPtr aes128Wrap(new CPKIFOID(CPKIFStringPtr(new std::string("2.16.840.1.101.3.4.1.5"))));
00991 g_aes128Wrap = aes128Wrap;
00992 CPKIFOIDPtr aes192Wrap(new CPKIFOID(CPKIFStringPtr(new std::string("2.16.840.1.101.3.4.1.25"))));
00993 g_aes192Wrap = aes192Wrap;
00994 CPKIFOIDPtr aes256Wrap(new CPKIFOID(CPKIFStringPtr(new std::string("2.16.840.1.101.3.4.1.45"))));
00995 g_aes256Wrap = aes256Wrap;
00996
00997
00998 CPKIFOIDPtr contentInfo(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.9.16.1.6"))));
00999 g_contentInfo =contentInfo;
01000 CPKIFOIDPtr data(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.7.1"))));
01001 g_data =data;
01002 CPKIFOIDPtr signedData(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.7.2"))));
01003 g_signedData =signedData;
01004 CPKIFOIDPtr envelopedData(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.7.3"))));
01005 g_envelopedData =envelopedData;
01006 CPKIFOIDPtr encryptedData(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.7.6"))));
01007 g_encryptedData =encryptedData;
01008
01009 CPKIFOIDPtr contentCollection(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.9.16.1.19"))));
01010 g_contentCollection =contentCollection;
01011 CPKIFOIDPtr contentWithAttributes(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.9.16.1.20"))));
01012 g_contentWithAttributes =contentWithAttributes;
01013 CPKIFOIDPtr compressedData(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.9.16.1.9"))));
01014 g_compressedData =compressedData;
01015 CPKIFOIDPtr authenticatedData(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.9.16.1.2"))));
01016 g_authenticatedData =authenticatedData;
01017 CPKIFOIDPtr digestedData(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.7.5"))));
01018 g_digestedData =digestedData;
01019 CPKIFOIDPtr authEnvelopedData(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.9.16.1.23"))));
01020 g_authEnvelopedData =authEnvelopedData;
01021
01022
01023 CPKIFOIDPtr contentTypeAttribute(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.9.3"))));
01024 g_contentTypeAttribute =contentTypeAttribute;
01025 CPKIFOIDPtr messageDigestAttribute(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.9.4"))));
01026 g_messageDigestAttribute =messageDigestAttribute;
01027 CPKIFOIDPtr signingTimeAttribute(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.9.5"))));
01028 g_signingTimeAttribute =signingTimeAttribute;
01029 CPKIFOIDPtr countersignatureAttribute(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.9.6"))));
01030 g_countersignatureAttribute =countersignatureAttribute;
01031 CPKIFOIDPtr timestampAttribute(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.9.16.2.14"))));
01032 g_timestampAttribute =timestampAttribute;
01033 CPKIFOIDPtr archiveTokenAttribute(new CPKIFOID(CPKIFStringPtr(new std::string("1.3.6.1.5.5.7.22.2.3"))));
01034 g_archiveTokenAttribute =archiveTokenAttribute;
01035 CPKIFOIDPtr binarySigningTime(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.9.16.2.46"))));
01036 g_binarySigningTimeAttribute =binarySigningTime;
01037 CPKIFOIDPtr signingCertificateAttribute(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.113549.1.9.16.2.12"))));
01038 g_signingCertificateAttribute =signingCertificateAttribute;
01039
01040
01041 CPKIFOIDPtr timestampingEKU(new CPKIFOID(CPKIFStringPtr(new std::string("1.3.6.1.5.5.7.3.8"))));
01042 g_timestampingEKU =timestampingEKU;
01043 CPKIFOIDPtr ocspSigningEKU(new CPKIFOID(CPKIFStringPtr(new std::string("1.3.6.1.5.5.7.3.9"))));
01044 g_ocspSigningEKU =ocspSigningEKU;
01045 CPKIFOIDPtr anyEKU(new CPKIFOID(CPKIFStringPtr(new std::string("2.5.29.37.0"))));
01046 g_anyEKU =anyEKU;
01047
01048 CPKIFOIDPtr anyPolicyOID(new CPKIFOID(CPKIFStringPtr(new std::string("2.5.29.32.0"))));
01049 g_anyPolicyOID =anyPolicyOID;
01050
01051 CPKIFOIDPtr aiaCAIssuer(new CPKIFOID(CPKIFStringPtr(new std::string("1.3.6.1.5.5.7.48.2"))));
01052 g_aiaCAIssuer =aiaCAIssuer;
01053
01054 CPKIFOIDPtr aiaCARepository(new CPKIFOID(CPKIFStringPtr(new std::string("1.3.6.1.5.5.7.48.5"))));
01055 g_aiaCARepository =aiaCARepository;
01056
01057
01058
01059
01060 CPKIFAlgorithmIdentifierPtr md5AI(new CPKIFAlgorithmIdentifier(g_md5));
01061 g_md5AI =md5AI;
01062 CPKIFAlgorithmIdentifierPtr sha1AI(new CPKIFAlgorithmIdentifier(g_sha1));
01063 g_sha1AI =sha1AI;
01064 CPKIFAlgorithmIdentifierPtr sha256AI(new CPKIFAlgorithmIdentifier(g_sha256));
01065 g_sha256AI =sha256AI;
01066 CPKIFAlgorithmIdentifierPtr sha384AI(new CPKIFAlgorithmIdentifier(g_sha384));
01067 g_sha384AI =sha384AI;
01068 CPKIFAlgorithmIdentifierPtr sha512AI(new CPKIFAlgorithmIdentifier(g_sha512));
01069 g_sha512AI = sha512AI;
01070
01071
01072
01073
01074
01075 CPKIFOIDPtr secp224r1(new CPKIFOID(CPKIFStringPtr(new std::string("1.3.132.0.33"))));
01076 g_secp224r1 =secp224r1;
01077 CPKIFOIDPtr secp256r1(new CPKIFOID(CPKIFStringPtr(new std::string("1.2.840.10045.3.1.7"))));
01078 g_secp256r1 =secp256r1;
01079 CPKIFOIDPtr secp384r1(new CPKIFOID(CPKIFStringPtr(new std::string("1.3.132.0.34"))));
01080 g_secp384r1 =secp384r1;
01081 CPKIFOIDPtr secp521r1(new CPKIFOID(CPKIFStringPtr(new std::string("1.3.132.0.35"))));
01082 g_secp521r1 =secp521r1;
01083
01084
01085 CPKIFPolicyInformationPtr anyPolicy(new CPKIFPolicyInformation(g_anyPolicyOID));
01086 g_anyPolicy = anyPolicy;
01087 }
01088