Eneboo - Documentación para desarrolladores
|
00001 #ifndef __DIGIDOC_OBJ_H__ 00002 #define __DIGIDOC_OBJ_H__ 00003 //================================================== 00004 // FILE: DigiDocGen.h 00005 // PROJECT: Digi Doc 00006 // DESCRIPTION: DigiDoc helper routines for accessing dogidoc data 00007 // AUTHOR: Veiko Sinivee, S|E|B IT Partner Estonia 00008 //================================================== 00009 // Copyright (C) AS Sertifitseerimiskeskus 00010 // This library is free software; you can redistribute it and/or 00011 // modify it under the terms of the GNU Lesser General Public 00012 // License as published by the Free Software Foundation; either 00013 // version 2.1 of the License, or (at your option) any later version. 00014 // This library is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 // Lesser General Public License for more details. 00018 // GNU Lesser General Public Licence is available at 00019 // http://www.gnu.org/copyleft/lesser.html 00020 //==========< HISTORY >============================= 00021 // 26.04.2006 Veiko Sinivee 00022 // Creation 00023 //================================================== 00024 00025 #include <libdigidoc/DigiDocDefs.h> 00026 //#include <libdigidoc/DigiDocLib.h> 00027 #include <libdigidoc/DigiDocMem.h> 00028 #include <openssl/x509.h> 00029 #include <openssl/ocsp.h> 00030 #ifdef WITH_TS 00031 #include <libdigidoc/ts/DigiDocTS.h> 00032 #endif 00033 00034 //==========< DigiDoc object structure >======================== 00035 00036 #ifdef __cplusplus 00037 extern "C" { 00038 #endif 00039 00040 00041 // contains the signed attributes of each document file entry 00042 typedef struct DocInfo_st { 00043 char* szDocId; // document id 00044 char* szDigestType; // digest method used 00045 byte* szDigest; // digest value 00046 int nDigestLen; // digest value length 00047 byte* szMimeDigest; // digest value 00048 int nMimeDigestLen; // digest value length 00049 } DocInfo; 00050 00051 typedef struct SignatureProductionPlace_st { 00052 char* szCity; 00053 char* szStateOrProvince; 00054 char* szPostalCode; 00055 char* szCountryName; 00056 } SignatureProductionPlace; 00057 00058 typedef struct SignerRole_st { 00059 int nClaimedRoles; 00060 char** pClaimedRoles; 00061 int nCertifiedRoles; 00062 char** pCertifiedRoles; 00063 } SignerRole; 00064 00065 typedef struct DigestValue_st { 00066 char* szDigestMethod; 00067 DigiDocMemBuf mbufDigestValue; 00068 } DigestValue; 00069 /* 00070 typedef struct ReferenceInfo_st { 00071 char* szId; 00072 char* szUri; 00073 char* szType; 00074 DigestValue digestValue; 00075 } ReferenceInfo; 00076 */ 00077 typedef struct SignatureValue_st { 00078 char* szId; 00079 char* szType; 00080 DigiDocMemBuf mbufSignatureValue; 00081 } SignatureValue; 00082 00083 #define CERTID_TYPE_UNKNOWN 0 00084 #define CERTID_TYPE_SIGNERS_CERTID 1 00085 #define CERTID_TYPE_RESPONDERS_CERTID 2 00086 #define CERTID_TYPE_TSA_CERTID 3 00087 00088 00089 typedef struct CertID_st { 00090 int nType; // internal CertID type: 00091 char* szId; 00092 char* szIssuerSerial; 00093 char* szIssuerName; 00094 DigestValue* pDigestValue; 00095 } CertID; 00096 00097 typedef struct CertIDList_st { 00098 int nCertIDs; 00099 CertID** pCertIDs; 00100 } CertIDList; 00101 00102 #define CERTID_VALUE_UNKNOWN 0 00103 #define CERTID_VALUE_SIGNERS_CERT 1 00104 #define CERTID_VALUE_RESPONDERS_CERT 2 00105 #define CERTID_VALUE_TSA_CERT 3 00106 00107 typedef struct CertValue_st { 00108 int nType; 00109 char* szId; 00110 X509* pCert; 00111 } CertValue; 00112 00113 typedef struct CertValueList_st { 00114 int nCertValues; 00115 CertValue** pCertValues; 00116 } CertValueList; 00117 00118 // data file entry for each data file 00119 typedef struct DataFile_st { 00120 char* szId; // data file id 00121 char* szFileName; // signed doc file name 00122 char* szMimeType; // date file mime type 00123 char* szContentType; // DETATCHED, EMBEDDED or EMBEDDED_BASE64 00124 long nSize; // file size (unencoded) 00125 char* szDigestType; // digest type 00126 DigiDocMemBuf mbufDigest; // real DataFile digest value 00127 DigiDocMemBuf mbufWrongDigest; // bad digest calculated in some versions 00128 DigiDocMemBuf mbufDetachedDigest; // detached file digest 00129 int nAttributes; // number of other attributes 00130 char* szCharset; // datafile initial codepage 00131 char** pAttNames; // other attribute names 00132 char** pAttValues; // other attribute values 00133 DigiDocMemBuf mbufContent; 00134 } DataFile; 00135 00136 typedef struct NotaryInfo_sk { 00137 char* szId; // Notary id 00138 char* szNotType; // notary info type (OCSP-1.0) 00139 char* timeProduced; // producedAt 00140 int nRespIdType; // RESP_ID_NAME, RESP_ID_KEY 00141 DigiDocMemBuf mbufRespId; // responder id value 00142 char* szDigestType; // digest method used 00143 // notaries personal signature 00144 char* szSigType; // signature type used 00145 DigiDocMemBuf mbufOcspDigest; // OCSP response digest (as in XML 00146 DigiDocMemBuf mbufOcspResponse; // OCSP response (in memory held in DER) 00147 } NotaryInfo; 00148 00149 // signature info for each user signature 00150 typedef struct SignatureInfo_st { 00151 char* szId; // signature id 00152 int nDocs; // number of separate documents signed 00153 DocInfo** pDocs; // info for each signed document 00154 char* szTimeStamp; // signature timestamp in format "YYYY-MM-DDTHH:MM:SSZ" 00155 DigestValue *pSigPropDigest; 00156 DigestValue *pSigPropRealDigest; 00157 DigestValue *pSigInfoRealDigest; 00158 SignatureValue *pSigValue; // RSA+SHA1 signature value 00159 X509* pX509Cert; // X509Cert certificate (used internally for data during loading) 00160 SignatureProductionPlace sigProdPlace; 00161 SignerRole signerRole; 00162 DigiDocMemBuf mbufOrigContent; 00163 NotaryInfo* pNotary; 00164 #ifdef WITH_TS 00165 TimestampInfoList *pTimestamps; 00166 #endif 00167 CertIDList *pCertIDs; 00168 CertValueList *pCertValues; 00169 } SignatureInfo; 00170 00171 00172 00173 typedef struct SignedDoc_st { 00174 char* szFormat; // data format name 00175 char* szFormatVer; // data format version 00176 int nDataFiles; 00177 DataFile** pDataFiles; 00178 int nSignatures; 00179 SignatureInfo** pSignatures; 00180 } SignedDoc; 00181 00182 //============================================================ 00183 // Sets a string element of a struct to a new value 00184 // dest - element pointer 00185 // value - new value 00186 // valLen - value length (use -1 for null terminated strings) 00187 //============================================================ 00188 EXP_OPTION int setString(char** dest, const char* value, int valLen); 00189 00190 // creates a new <SignedDoc> structure 00191 EXP_OPTION int SignedDoc_new(SignedDoc **newSignedDoc, const char* format, const char* version); 00192 // cleanup signed doc data 00193 EXP_OPTION void SignedDoc_free(SignedDoc* pSigDoc); 00194 00195 //======================< DataFile functions >============================= 00196 00197 // returns the number of data files 00198 EXP_OPTION int getCountOfDataFiles(const SignedDoc* pSigDoc); 00199 // returns the n-th DataFile object 00200 EXP_OPTION DataFile* getDataFile(const SignedDoc* pSigDoc, int nIdx); 00201 // returns the last DataFile object 00202 EXP_OPTION DataFile* ddocGetLastDataFile(const SignedDoc* pSigDoc); 00203 // Retrieve and convert DataFile Filename atribute and convert 00204 EXP_OPTION int ddocGetDataFileFilename(SignedDoc* pSigDoc, const char* szDocId, void** ppBuf, int* pLen); 00205 // returns the DataFile object with the given id 00206 EXP_OPTION DataFile* getDataFileWithId(const SignedDoc* pSigDoc, const char* id); 00207 // add a <DataFile> block to <SignedDoc> 00208 // use NULL for any parameter you don't have the value 00209 // use NULL for id if you want to auto-calculate it (recommended!!!) 00210 EXP_OPTION int DataFile_new(DataFile **newDataFile, SignedDoc* pSigDoc, const char* id, 00211 const char* filename, const char* contentType, 00212 const char* mime, long size, 00213 const byte* digest, int digLen, 00214 const char* digType, const char* szCharset); 00215 // cleanup DataFile memory 00216 EXP_OPTION void DataFile_free(DataFile* pDataFile); 00217 00218 // Removes this DataFile from signed doc and frees it's memory 00219 EXP_OPTION int DataFile_delete(SignedDoc* pSigDoc, const char* id); 00220 00221 //-------------------------------------------------- 00222 // Accessor for Digest atribute of DataFile object. 00223 // pDataFile - address of object [REQUIRED] 00224 // returns value of atribute or NULL. 00225 //-------------------------------------------------- 00226 EXP_OPTION DigiDocMemBuf* ddocDataFile_GetDigestValue(DataFile* pDataFile); 00227 00228 //-------------------------------------------------- 00229 // Mutatoror for Digest atribute of DataFile object. 00230 // pDataFile - address of object [REQUIRED] 00231 // value - new value for atribute [REQUIRED] 00232 // len - length of value in bytes [REQUIRED] 00233 // returns error code or ERR_OK 00234 //-------------------------------------------------- 00235 EXP_OPTION int ddocDataFile_SetDigestValue(DataFile* pDataFile, 00236 const char* value, long len); 00237 00238 //-------------------------------------------------- 00239 // Accessor for DetachedDigest atribute of DataFile object. 00240 // pDataFile - address of object [REQUIRED] 00241 // returns value of atribute or NULL. 00242 //-------------------------------------------------- 00243 EXP_OPTION DigiDocMemBuf* ddocDataFile_GetDetachedDigestValue(DataFile* pDataFile); 00244 00245 //-------------------------------------------------- 00246 // Mutatoror for DetachedDigest atribute of DataFile object. 00247 // pDataFile - address of object [REQUIRED] 00248 // value - new value for atribute [REQUIRED] 00249 // len - length of value in bytes [REQUIRED] 00250 // returns error code or ERR_OK 00251 //-------------------------------------------------- 00252 EXP_OPTION int ddocDataFile_SetDetachedDigestValue(DataFile* pDataFile, 00253 const char* value, long len); 00254 00255 00256 00257 // Returns number of DataFile attributes 00258 EXP_OPTION int getCountOfDataFileAttributes(const DataFile* pDataFile); 00259 // Adds an attribute to data file 00260 EXP_OPTION int addDataFileAttribute(DataFile* pDataFile, const char* name, 00261 const char* value); 00262 // Gets an attribute of a data file 00263 EXP_OPTION int getDataFileAttribute(DataFile* pDataFile, int idx, char** name, char** value); 00264 00265 // get datafile cahed data 00266 int ddocGetDataFileCachedData(SignedDoc* pSigDoc, const char* szDocId, void** ppBuf, long* pLen); 00267 00268 // apppends DataFile content to cache 00269 void ddocAppendDataFileData(DataFile* pDf, int maxLen, void* data, int len); 00270 00271 // calculates file size and digest and store in the 00272 // given DataFile object 00273 EXP_OPTION int calculateDataFileSizeAndDigest(SignedDoc* pSigDoc, const char* id, 00274 const char* filename, int digType); 00275 00276 //======================< DigestValue functions >============================= 00277 00278 //-------------------------------------------------- 00279 // "Constructor" of DigestValue object 00280 // ppDigestValue - address of buffer for newly allocated object [REQUIRED] 00281 // szDigestMethod - digest method [OPTIONAL] 00282 // szDigVal/lDigLen - digest value and length [OPTIONAL] 00283 // returns error code or ERR_OK 00284 //-------------------------------------------------- 00285 EXP_OPTION int ddocDigestValue_new(DigestValue** ppDigestValue, 00286 const char* szDigestMethod, 00287 void* szDigVal, long lDigLen); 00288 00289 //-------------------------------------------------- 00290 // "Destructor" of DigestValue object 00291 // pDigestValue - address of object to be deleted [REQUIRED] 00292 // returns error code or ERR_OK 00293 //-------------------------------------------------- 00294 EXP_OPTION int ddocDigestValue_free(DigestValue* pDigestValue); 00295 00296 //-------------------------------------------------- 00297 // Accessor for DigestMethod atribute of DigestValue object. 00298 // pDigestValue - address of object [REQUIRED] 00299 // returns value of atribute or NULL. 00300 //-------------------------------------------------- 00301 EXP_OPTION const char* ddocDigestValue_GetDigestMethod(DigestValue* pDigestValue); 00302 00303 //-------------------------------------------------- 00304 // Mutatoror for DigestMethod atribute of DigestValue object. 00305 // pDigestValue - address of object [REQUIRED] 00306 // value - new value for atribute [REQUIRED] 00307 // returns error code or ERR_OK 00308 //-------------------------------------------------- 00309 EXP_OPTION int ddocDigestValue_SetDigestMethod(DigestValue* pDigestValue, const char* value); 00310 00311 //-------------------------------------------------- 00312 // Accessor for DigestValue atribute of DigestValue object. 00313 // pDigestValue - address of object [REQUIRED] 00314 // returns value of atribute or NULL. 00315 //-------------------------------------------------- 00316 EXP_OPTION DigiDocMemBuf* ddocDigestValue_GetDigestValue(DigestValue* pDigestValue); 00317 00318 //-------------------------------------------------- 00319 // Mutatoror for DigestValue atribute of DigestValue object. 00320 // pDigestValue - address of object [REQUIRED] 00321 // value - new value for atribute [REQUIRED] 00322 // len - length of value in bytes [REQUIRED] 00323 // returns error code or ERR_OK 00324 //-------------------------------------------------- 00325 EXP_OPTION int ddocDigestValue_SetDigestValue(DigestValue* pDigestValue, 00326 const char* value, long len); 00327 00328 //-------------------------------------------------- 00329 // Compares two DigestValue structure on equality 00330 // pDigest1 - address of first digest [REQUIRED] 00331 // pDigest2 - address of second digest [REQUIRED] 00332 // returns error code or ERR_OK 00333 //-------------------------------------------------- 00334 int ddocCompareDigestValues(DigestValue* pDigest1, DigestValue* pDigest2); 00335 00336 //-------------------------------------------------- 00337 // Generates XML for <DigestValue> element 00338 // pSigDoc - signed doc object [REQUIRED] 00339 // pDigestValue - DigestValue object [REQUIRED] 00340 // pBuf - memory buffer for storing xml [REQUIRED] 00341 // returns error code or ERR_OK 00342 //-------------------------------------------------- 00343 int ddocDigestValue_toXML(const SignedDoc* pSigDoc, const DigestValue* pDigestValue, DigiDocMemBuf* pBuf); 00344 00345 //======================< SignatureValue functions >============================= 00346 00347 //============================================================ 00348 // Returns the next free signature id 00349 // pSigDoc - signed doc pointer 00350 //============================================================ 00351 EXP_OPTION int getNextSignatureId(const SignedDoc* pSigDoc); 00352 00353 //-------------------------------------------------- 00354 // "Constructor" of SignatureValue object 00355 // ppSignatureValue - address of buffer for newly allocated object [REQUIRED] 00356 // szId - Id atribute value [OPTIONAL] 00357 // szType - signature type [OPTIONAL] 00358 // szDigVal/lDigLen - digest value and length [OPTIONAL] 00359 // returns error code or ERR_OK 00360 //-------------------------------------------------- 00361 EXP_OPTION int ddocSignatureValue_new(SignatureValue** ppSignatureValue, 00362 const char* szId, const char* szType, 00363 void* szSigVal, long lSigLen); 00364 00365 //-------------------------------------------------- 00366 // "Destructor" of SignatureValue object 00367 // pSignatureValue - address of object to be deleted [REQUIRED] 00368 // returns error code or ERR_OK 00369 //-------------------------------------------------- 00370 EXP_OPTION int ddocSignatureValue_free(SignatureValue* pSignatureValue); 00371 00372 //-------------------------------------------------- 00373 // Accessor for Id atribute of SignatureValue object. 00374 // pSignatureValue - address of object [REQUIRED] 00375 // returns value of atribute or NULL. 00376 //-------------------------------------------------- 00377 EXP_OPTION const char* ddocSignatureValue_GetId(const SignatureValue* pSignatureValue); 00378 00379 //-------------------------------------------------- 00380 // Mutatoror for Id atribute of SignatureValue object. 00381 // pSignatureValue - address of object [REQUIRED] 00382 // value - new value for atribute [REQUIRED] 00383 // returns error code or ERR_OK 00384 //-------------------------------------------------- 00385 EXP_OPTION int ddocSignatureValue_SetId(SignatureValue* pSignatureValue, const char* value); 00386 00387 //-------------------------------------------------- 00388 // Accessor for Type atribute of SignatureValue object. 00389 // pSignatureValue - address of object [REQUIRED] 00390 // returns value of atribute or NULL. 00391 //-------------------------------------------------- 00392 EXP_OPTION const char* ddocSignatureValue_GetType(const SignatureValue* pSignatureValue); 00393 00394 //-------------------------------------------------- 00395 // Mutatoror for Type atribute of SignatureValue object. 00396 // pSignatureValue - address of object [REQUIRED] 00397 // value - new value for atribute [REQUIRED] 00398 // returns error code or ERR_OK 00399 //-------------------------------------------------- 00400 EXP_OPTION int ddocSignatureValue_SetType(SignatureValue* pSignatureValue, const char* value); 00401 00402 //-------------------------------------------------- 00403 // Accessor for SignatureValue atribute of SignatureValue object. 00404 // pSignatureValue - address of object [REQUIRED] 00405 // returns value of atribute or NULL. 00406 //-------------------------------------------------- 00407 EXP_OPTION DigiDocMemBuf* ddocSignatureValue_GetSignatureValue(const SignatureValue* pSignatureValue); 00408 00409 //-------------------------------------------------- 00410 // Mutatoror for SignatureValue atribute of SignatureValue object. 00411 // pSignatureValue - address of object [REQUIRED] 00412 // value - new value for atribute [REQUIRED] 00413 // len - length of value in bytes [REQUIRED] 00414 // returns error code or ERR_OK 00415 //-------------------------------------------------- 00416 EXP_OPTION int ddocSignatureValue_SetSignatureValue(SignatureValue* pSignatureValue, 00417 const char* value, long len); 00418 00419 //-------------------------------------------------- 00420 // Generates XML for <IncludeInfo> element 00421 // pSignatureValue - SignatureValue object [REQUIRED] 00422 // pBuf - memory buffer for storing xml [REQUIRED] 00423 // returns error code or ERR_OK 00424 //-------------------------------------------------- 00425 int ddocSignatureValue_toXML(const SignatureValue* pSignatureValue, DigiDocMemBuf* pBuf); 00426 00427 //======================< CertID >==================================== 00428 00429 //-------------------------------------------------- 00430 // "Constructor" of CertID object 00431 // ppCertID - address of buffer for newly allocated object [REQUIRED] 00432 // szId - Id atribute value [OPTIONAL] 00433 // nType - certid internal type (signers or responders cert) [REQUIRED] 00434 // szIssuerSerial - issuer serial number [OPTIONAL] 00435 // szIssuerName - issuer DN [OPTIONAL] 00436 // szDigVal/lDigLen - digest value and length [OPTIONAL] 00437 // returns error code or ERR_OK 00438 //-------------------------------------------------- 00439 EXP_OPTION int ddocCertID_new(CertID** ppCertID, 00440 int nType, const char* szId, 00441 const char* szIssuerSerial, const char* szIssuerName, 00442 void* szDigVal, long lDigLen); 00443 00444 //-------------------------------------------------- 00445 // "Destructor" of CertID object 00446 // pCertID - address of object to be deleted [REQUIRED] 00447 // returns error code or ERR_OK 00448 //-------------------------------------------------- 00449 EXP_OPTION int ddocCertID_free(CertID* pCertID); 00450 00451 //-------------------------------------------------- 00452 // Accessor for Id atribute of CertID object. 00453 // pCertID - address of object [REQUIRED] 00454 // returns value of atribute or NULL. 00455 //-------------------------------------------------- 00456 EXP_OPTION const char* ddocCertID_GetId(const CertID* pCertID); 00457 00458 //-------------------------------------------------- 00459 // Mutatoror for Id atribute of CertID object. 00460 // pCertID - address of object [REQUIRED] 00461 // value - new value for atribute [REQUIRED] 00462 // returns error code or ERR_OK 00463 //-------------------------------------------------- 00464 EXP_OPTION int ddocCertID_SetId(CertID* pCertID, const char* value); 00465 00466 //-------------------------------------------------- 00467 // Accessor for IssuerSerial atribute of CertID object. 00468 // pCertID - address of object [REQUIRED] 00469 // returns value of atribute or NULL. 00470 //-------------------------------------------------- 00471 EXP_OPTION const char* ddocCertID_GetIssuerSerial(const CertID* pCertID); 00472 00473 //-------------------------------------------------- 00474 // Mutatoror for IssuerSerial atribute of CertID object. 00475 // pCertID - address of object [REQUIRED] 00476 // value - new value for atribute [REQUIRED] 00477 // returns error code or ERR_OK 00478 //-------------------------------------------------- 00479 EXP_OPTION int ddocCertID_SetIssuerSerial(CertID* pCertID, const char* value); 00480 00481 //-------------------------------------------------- 00482 // Accessor for IssuerName atribute of CertID object. 00483 // pCertID - address of object [REQUIRED] 00484 // returns value of atribute or NULL. 00485 //-------------------------------------------------- 00486 EXP_OPTION const char* ddocCertID_GetIssuerName(const CertID* pCertID); 00487 00488 //-------------------------------------------------- 00489 // Mutatoror for IssuerName atribute of CertID object. 00490 // pCertID - address of object [REQUIRED] 00491 // value - new value for atribute [REQUIRED] 00492 // returns error code or ERR_OK 00493 //-------------------------------------------------- 00494 EXP_OPTION int ddocCertID_SetIssuerName(CertID* pCertID, const char* value); 00495 00496 //-------------------------------------------------- 00497 // Accessor for DigestValue atribute of CertID object. 00498 // pCertID - address of object [REQUIRED] 00499 // returns value of atribute or NULL. 00500 //-------------------------------------------------- 00501 EXP_OPTION DigiDocMemBuf* ddocCertID_GetDigestValue(const CertID* pCertID); 00502 00503 00504 //-------------------------------------------------- 00505 // Mutatoror for DigestValue atribute of CertID object. 00506 // pCertID - address of object [REQUIRED] 00507 // value - new value for atribute [REQUIRED] 00508 // len - length of value in bytes [REQUIRED] 00509 // returns error code or ERR_OK 00510 //-------------------------------------------------- 00511 EXP_OPTION int ddocCertID_SetDigestValue(CertID* pCertID, 00512 const char* value, long len); 00513 00514 //-------------------------------------------------- 00515 // Generates XML for <Cert> element 00516 // pCertID - CertID object [REQUIRED] 00517 // pBuf - memory buffer for storing xml [REQUIRED] 00518 // returns error code or ERR_OK 00519 //-------------------------------------------------- 00520 int ddocCertID_toXML(const SignedDoc* pSigDoc, const CertID* pCertID, DigiDocMemBuf* pBuf); 00521 00522 //-------------------------------------------------- 00523 // Generates XML for <CompleteCertificateRefs> element 00524 // pSigDoc - SignedDoc object [REQUIRED] 00525 // pBuf - memory buffer for storing xml [REQUIRED] 00526 // returns error code or ERR_OK 00527 //-------------------------------------------------- 00528 int ddocCompleteCertificateRefs_toXML(const SignedDoc* pSigDoc, const SignatureInfo* pSigInfo, DigiDocMemBuf* pBuf); 00529 00530 //-------------------------------------------------- 00531 // Generates XML for <CompleteRevocationRefs> element 00532 // pSigDoc - SignedDoc object [REQUIRED] 00533 // pBuf - memory buffer for storing xml [REQUIRED] 00534 // returns error code or ERR_OK 00535 //-------------------------------------------------- 00536 int ddocCompleteRevocationRefs_toXML(const SignedDoc* pSigDoc, const SignatureInfo* pSigInfo, DigiDocMemBuf* pBuf); 00537 00538 00539 //==========< CertIDList >==================== 00540 00541 //-------------------------------------------------- 00542 // "Constructor" of CertIDList object 00543 // ppCertIDList - address of buffer for newly allocated object [REQUIRED] 00544 // returns error code or ERR_OK 00545 //-------------------------------------------------- 00546 EXP_OPTION int ddocCertIDList_new(CertIDList** ppCertIDList); 00547 00548 //-------------------------------------------------- 00549 // "Destructor" of CertIDList object 00550 // pCertIDList - address of object to be deleted [REQUIRED] 00551 // returns error code or ERR_OK 00552 //-------------------------------------------------- 00553 EXP_OPTION int ddocCertIDList_free(CertIDList* pCertIDList); 00554 00555 //-------------------------------------------------- 00556 // Accessor for count of CertIDs subelement of CertIDList object. 00557 // pCertIDList - pointer to CertIDList object [REQUIRED] 00558 // returns error code or ERR_OK 00559 //-------------------------------------------------- 00560 int ddocCertIDList_addCertID(CertIDList* pCertIDList, CertID* pCertID); 00561 00562 //-------------------------------------------------- 00563 // Accessor for count of CertIDs subelement of CertIDList object. 00564 // pCertIDList - pointer to CertIDList object [REQUIRED] 00565 // returns count or -1 for error. Then use error API to check errors 00566 //-------------------------------------------------- 00567 EXP_OPTION int ddocCertIDList_GetCertIDsCount(CertIDList* pCertIDList); 00568 00569 //-------------------------------------------------- 00570 // Accessor for CertIDs subelement of CertIDList object. 00571 // pCertIDList - pointer to CertIDList object [REQUIRED] 00572 // nIdx - index of CertID object [REQUIRED] 00573 // returns CertID pointer or NULL for error 00574 //-------------------------------------------------- 00575 EXP_OPTION CertID* ddocCertIDList_GetCertID(CertIDList* pCertIDList, int nIdx); 00576 00577 //-------------------------------------------------- 00578 // Accessor for last CertIDs subelement of CertIDList object. 00579 // pCertIDList - pointer to CertIDList object [REQUIRED] 00580 // returns CertID pointer or NULL for error 00581 //-------------------------------------------------- 00582 EXP_OPTION CertID* ddocCertIDList_GetLastCertID(CertIDList* pCertIDList); 00583 00584 //-------------------------------------------------- 00585 // Deletes CertID subelement of CertIDList object. 00586 // pCertIDList - pointer to CertIDList object [REQUIRED] 00587 // nIdx - index of CertID object to be removed [REQUIRED] 00588 // returns error code or ERR_OK 00589 //-------------------------------------------------- 00590 EXP_OPTION int ddocCertIDList_DeleteCertID(CertIDList* pCertIDList, int nIdx); 00591 00592 //-------------------------------------------------- 00593 // Finds a CertID object with required type 00594 // pCertIDList - pointer to CertIDList object [REQUIRED] 00595 // nType - type of CertID object [REQUIRED] 00596 // returns CertID pointer or NULL for error 00597 //-------------------------------------------------- 00598 EXP_OPTION CertID* ddocCertIDList_GetCertIDOfType(CertIDList* pCertIDList, int nType); 00599 00600 //-------------------------------------------------- 00601 // Finds a CertID object with required serial nr 00602 // pCertIDList - pointer to CertIDList object [REQUIRED] 00603 // szSerial - issuer serial 00604 // returns CertID pointer or NULL for error 00605 //-------------------------------------------------- 00606 EXP_OPTION CertID* ddocCertIDList_GetCertIDOfSerial(CertIDList* pCertIDList, const char* szSerial); 00607 00608 //-------------------------------------------------- 00609 // Finds a CertID object with required type or creates a new one 00610 // pCertIDList - pointer to CertIDList object [REQUIRED] 00611 // nType - type of CertID object [REQUIRED] 00612 // returns CertID pointer or NULL for error 00613 //-------------------------------------------------- 00614 EXP_OPTION CertID* ddocCertIDList_GetOrCreateCertIDOfType(CertIDList* pCertIDList, int nType); 00615 00616 //======================< CertValue >==================================== 00617 00618 //-------------------------------------------------- 00619 // "Constructor" of CertValue object 00620 // ppCertValue - address of buffer for newly allocated object [REQUIRED] 00621 // szId - Id atribute value [OPTIONAL] 00622 // nType - certid internal type (signers or responders cert) [REQUIRED] 00623 // pCert - certificate itself [OPTIONAL]. Must fill in later. Do not X509_free() param! 00624 // returns error code or ERR_OK 00625 //-------------------------------------------------- 00626 EXP_OPTION int ddocCertValue_new(CertValue** ppCertValue, 00627 int nType, const char* szId, 00628 X509* pCert); 00629 00630 //-------------------------------------------------- 00631 // "Destructor" of CertValue object 00632 // pCertValue - address of object to be deleted [REQUIRED] 00633 // returns error code or ERR_OK 00634 //-------------------------------------------------- 00635 EXP_OPTION int ddocCertValue_free(CertValue* pCertValue); 00636 00637 //-------------------------------------------------- 00638 // Accessor for Id atribute of CertValue object. 00639 // pCertValue - address of object [REQUIRED] 00640 // returns value of atribute or NULL. 00641 //-------------------------------------------------- 00642 EXP_OPTION const char* ddocCertValue_GetId(CertValue* pCertValue); 00643 00644 //-------------------------------------------------- 00645 // Mutatoror for Id atribute of CertValue object. 00646 // pCertValue - address of object [REQUIRED] 00647 // value - new value for atribute [REQUIRED] 00648 // returns error code or ERR_OK 00649 //-------------------------------------------------- 00650 EXP_OPTION int ddocCertValue_SetId(CertValue* pCertValue, const char* value); 00651 00652 //-------------------------------------------------- 00653 // Accessor for Cert atribute of CertValue object. 00654 // pCertValue - address of object [REQUIRED] 00655 // returns value of atribute or NULL. 00656 //-------------------------------------------------- 00657 EXP_OPTION X509* ddocCertValue_GetCert(CertValue* pCertValue); 00658 00659 //-------------------------------------------------- 00660 // Mutatoror for Cert atribute of CertValue object. 00661 // pCertValue - address of object [REQUIRED] 00662 // pCert - new value for atribute [REQUIRED] 00663 // returns error code or ERR_OK 00664 //-------------------------------------------------- 00665 EXP_OPTION int ddocCertValue_SetCert(CertValue* pCertValue, X509* pCert); 00666 00667 //-------------------------------------------------- 00668 // Generates XML for <EncapsulatedX509Certificate> element 00669 // pCertID - CertID object [REQUIRED] 00670 // pBuf - memory buffer for storing xml [REQUIRED] 00671 // returns error code or ERR_OK 00672 //-------------------------------------------------- 00673 int ddocCertValue_toXML(const CertValue* pCertValue, DigiDocMemBuf* pBuf); 00674 00675 //==========< CertValueList >==================== 00676 00677 //-------------------------------------------------- 00678 // "Constructor" of CertValueList object 00679 // ppCertValueList - address of buffer for newly allocated object [REQUIRED] 00680 // returns error code or ERR_OK 00681 //-------------------------------------------------- 00682 EXP_OPTION int ddocCertValueList_new(CertValueList** ppCertValueList); 00683 00684 //-------------------------------------------------- 00685 // "Destructor" of CertValueList object 00686 // pCertValueList - address of object to be deleted [REQUIRED] 00687 // returns error code or ERR_OK 00688 //-------------------------------------------------- 00689 EXP_OPTION int ddocCertValueList_free(CertValueList* pCertValueList); 00690 00691 //-------------------------------------------------- 00692 // Adds a CertValue element to CertValueList object. 00693 // pCertValueList - pointer to CertValueList object [REQUIRED] 00694 // pCertValue - new object [REQUIRED] 00695 // returns error code or ERR_OK 00696 //-------------------------------------------------- 00697 EXP_OPTION int ddocCertValueList_addCertValue(CertValueList* pCertValueList, CertValue* pCertValue); 00698 00699 //-------------------------------------------------- 00700 // Accessor for count of CertValues subelement of CertValueList object. 00701 // pCertValueList - pointer to CertValueList object [REQUIRED] 00702 // returns count or -1 for error. Then use error API to check errors 00703 //-------------------------------------------------- 00704 EXP_OPTION int ddocCertValueList_GetCertValuesCount(CertValueList* pCertValueList); 00705 00706 //-------------------------------------------------- 00707 // Accessor for CertValues subelement of CertValueList object. 00708 // pCertValueList - pointer to CertValueList object [REQUIRED] 00709 // nIdx - index of CertValue object [REQUIRED] 00710 // returns CertValue pointer or NULL for error 00711 //-------------------------------------------------- 00712 EXP_OPTION CertValue* ddocCertValueList_GetCertValue(CertValueList* pCertValueList, int nIdx); 00713 00714 //-------------------------------------------------- 00715 // Deletes CertValue subelement of CertValueList object. 00716 // pCertValueList - pointer to CertValueList object [REQUIRED] 00717 // nIdx - index of CertValue object to be removed [REQUIRED] 00718 // returns error code or ERR_OK 00719 //-------------------------------------------------- 00720 EXP_OPTION int ddocCertValueList_DeleteCertValue(CertValueList* pCertValueList, int nIdx); 00721 00722 //-------------------------------------------------- 00723 // Finds a CertValue object with required type 00724 // pCertValueList - pointer to CertValueList object [REQUIRED] 00725 // nType - type of CertValue object [REQUIRED] 00726 // returns CertValue pointer or NULL for error 00727 //-------------------------------------------------- 00728 EXP_OPTION CertValue* ddocCertValueList_GetCertValueOfType(CertValueList* pCertValueList, int nType); 00729 00730 //-------------------------------------------------- 00731 // Finds a CertValue object with required type or creates a new one 00732 // pCertValueList - pointer to CertValueList object [REQUIRED] 00733 // nType - type of CertValue object [REQUIRED] 00734 // returns CertValue pointer or NULL for error 00735 //-------------------------------------------------- 00736 EXP_OPTION CertValue* ddocCertValueList_GetOrCreateCertValueOfType(CertValueList* pCertValueList, int nType); 00737 00738 //======================< SignatureInfo functions >============================= 00739 00740 // returns the number of signatures 00741 EXP_OPTION int getCountOfSignatures(const SignedDoc* pSigDoc); 00742 // Returns the desired SignatureInfo object 00743 EXP_OPTION SignatureInfo* getSignature(const SignedDoc* pSigDoc, int nIdx); 00744 00745 //============================================================ 00746 // Returns signatures signed properties digest 00747 // pSigInfo - signature info object 00748 // return digest value as DigiDocMemBuf pointer or NULL 00749 //============================================================ 00750 EXP_OPTION DigiDocMemBuf* ddocSigInfo_GetSigPropDigest(SignatureInfo* pSigInfo); 00751 00752 //============================================================ 00753 // Sets signatures signed properties digest 00754 // pSigInfo - signature info object 00755 // value - new binary digest value 00756 // len - length of the value 00757 //============================================================ 00758 EXP_OPTION int ddocSigInfo_SetSigPropDigest(SignatureInfo* pSigInfo, const char* value, long len); 00759 00760 //============================================================ 00761 // Returns signatures signed properties digest as read from file 00762 // pSigInfo - signature info object 00763 // return digest value as DigiDocMemBuf pointer or NULL 00764 //============================================================ 00765 EXP_OPTION DigiDocMemBuf* ddocSigInfo_GetSigPropRealDigest(SignatureInfo* pSigInfo); 00766 00767 //============================================================ 00768 // Sets signatures signed properties real digest as read from file 00769 // pSigInfo - signature info object 00770 // value - new binary digest value 00771 // len - length of the value 00772 //============================================================ 00773 EXP_OPTION int ddocSigInfo_SetSigPropRealDigest(SignatureInfo* pSigInfo, const char* value, long len); 00774 00775 //============================================================ 00776 // Returns signatures signed info digest as read from file 00777 // pSigInfo - signature info object 00778 // return digest value as DigiDocMemBuf pointer or NULL 00779 //============================================================ 00780 EXP_OPTION DigiDocMemBuf* ddocSigInfo_GetSigInfoRealDigest(SignatureInfo* pSigInfo); 00781 00782 //============================================================ 00783 // Sets signatures signed info real digest as read from file 00784 // pSigInfo - signature info object 00785 // value - new binary digest value 00786 // len - length of the value 00787 //============================================================ 00788 EXP_OPTION int ddocSigInfo_SetSigInfoRealDigest(SignatureInfo* pSigInfo, const char* value, long len); 00789 00790 //============================================================ 00791 // Returns signatures signature-value 00792 // pSigInfo - signature info object 00793 // return signature-value as SignatureValue pointer or NULL 00794 //============================================================ 00795 EXP_OPTION SignatureValue* ddocSigInfo_GetSignatureValue(SignatureInfo* pSigInfo); 00796 00797 //============================================================ 00798 // Returns signatures signature-value 00799 // pSigInfo - signature info object 00800 // return signature-value as DigiDocMemBuf pointer or NULL 00801 //============================================================ 00802 EXP_OPTION DigiDocMemBuf* ddocSigInfo_GetSignatureValue_Value(SignatureInfo* pSigInfo); 00803 00804 //============================================================ 00805 // Sets signatures signature-value 00806 // pSigInfo - signature info object 00807 // value - new binary signature value 00808 // len - length of the value 00809 //============================================================ 00810 EXP_OPTION int ddocSigInfo_SetSignatureValue(SignatureInfo* pSigInfo, const char* value, long len); 00811 00812 //============================================================ 00813 // Returns signaers certs - issuer-serial 00814 // pSigInfo - signature info object 00815 // return required atribute value 00816 //============================================================ 00817 EXP_OPTION const char* ddocSigInfo_GetSignersCert_IssuerSerial(const SignatureInfo* pSigInfo); 00818 00819 //============================================================ 00820 // Sets signers certs issuer serial 00821 // pSigInfo - signature info object 00822 // value - new value 00823 //============================================================ 00824 EXP_OPTION int ddocSigInfo_SetSignersCert_IssuerSerial(SignatureInfo* pSigInfo, const char* value); 00825 00826 //============================================================ 00827 // Returns signaers certs - issuer-name 00828 // pSigInfo - signature info object 00829 // return required atribute value 00830 //============================================================ 00831 EXP_OPTION const char* ddocSigInfo_GetSignersCert_IssuerName(const SignatureInfo* pSigInfo); 00832 00833 //============================================================ 00834 // Sets signers certs issuer name 00835 // pSigInfo - signature info object 00836 // value - new value 00837 //============================================================ 00838 EXP_OPTION int ddocSigInfo_SetSignersCert_IssuerName(SignatureInfo* pSigInfo, const char* value); 00839 00840 //============================================================ 00841 // Returns signers certs digest as DigiDocMemBuf object 00842 // pSigInfo - signature info object 00843 // return signers certs digest as DigiDocMemBuf pointer or NULL 00844 //============================================================ 00845 EXP_OPTION DigiDocMemBuf* ddocSigInfo_GetSignersCert_DigestValue(const SignatureInfo* pSigInfo); 00846 00847 //============================================================ 00848 // Sets signers certs digest 00849 // pSigInfo - signature info object 00850 // value - new binary signature value 00851 // len - length of the value 00852 //============================================================ 00853 EXP_OPTION int ddocSigInfo_SetSignersCert_DigestValue(SignatureInfo* pSigInfo, const char* value, long len); 00854 00855 //-------------------------------------------------- 00856 // Finds a CertID object with required type 00857 // pSigInfo - signature info object [REQUIRED] 00858 // nType - type of CertID object [REQUIRED] 00859 // returns CertID pointer or NULL for error 00860 //-------------------------------------------------- 00861 EXP_OPTION CertID* ddocSigInfo_GetCertIDOfType(const SignatureInfo* pSigInfo, int nType); 00862 00863 //-------------------------------------------------- 00864 // Finds a CertID object with required type or creates a new one 00865 // pSigInfo - signature info object [REQUIRED] 00866 // nType - type of CertID object [REQUIRED] 00867 // returns CertID pointer or NULL for error 00868 //-------------------------------------------------- 00869 EXP_OPTION CertID* ddocSigInfo_GetOrCreateCertIDOfType(SignatureInfo* pSigInfo, int nType); 00870 00871 00872 //-------------------------------------------------- 00873 // Finds a CertValue object with required type 00874 // pSigInfo - signature info object [REQUIRED] 00875 // nType - type of CertValue object [REQUIRED] 00876 // returns CertValue pointer or NULL for error 00877 //-------------------------------------------------- 00878 EXP_OPTION CertValue* ddocSigInfo_GetCertValueOfType(const SignatureInfo* pSigInfo, int nType); 00879 00880 //-------------------------------------------------- 00881 // Finds last CertValue 00882 // pSigInfo - signature info object [REQUIRED] 00883 // returns CertValue pointer or NULL for error 00884 //-------------------------------------------------- 00885 EXP_OPTION CertValue* ddocSigInfo_GetLastCertValue(const SignatureInfo* pSigInfo); 00886 00887 //-------------------------------------------------- 00888 // Finds a CertValue object with required type or creates a new one 00889 // pSigInfo - signature info object [REQUIRED] 00890 // nType - type of CertValue object [REQUIRED] 00891 // returns CertValue pointer or NULL for error 00892 //-------------------------------------------------- 00893 EXP_OPTION CertValue* ddocSigInfo_GetOrCreateCertValueOfType(SignatureInfo* pSigInfo, int nType); 00894 00895 //-------------------------------------------------- 00896 // Finds the signers certificate 00897 // pSigInfo - signature info object [REQUIRED] 00898 // returns certificate or NULL 00899 //-------------------------------------------------- 00900 EXP_OPTION X509* ddocSigInfo_GetSignersCert(const SignatureInfo* pSigInfo); 00901 00902 //-------------------------------------------------- 00903 // Sets the signers certificate 00904 // pSigInfo - signature info object [REQUIRED] 00905 // pCert - certificate [REQUIRED] 00906 // returns error code or ERR_OK 00907 //-------------------------------------------------- 00908 EXP_OPTION int ddocSigInfo_SetSignersCert(SignatureInfo* pSigInfo, X509* pCert); 00909 00910 //-------------------------------------------------- 00911 // Finds the OCSP responders certificate 00912 // pSigInfo - signature info object [REQUIRED] 00913 // returns certificate or NULL 00914 //-------------------------------------------------- 00915 EXP_OPTION X509* ddocSigInfo_GetOCSPRespondersCert(const SignatureInfo* pSigInfo); 00916 00917 //-------------------------------------------------- 00918 // Sets the OCSP Responders certificate 00919 // pSigInfo - signature info object [REQUIRED] 00920 // pCert - certificate [REQUIRED] 00921 // returns error code or ERR_OK 00922 //-------------------------------------------------- 00923 EXP_OPTION int ddocSigInfo_SetOCSPRespondersCert(SignatureInfo* pSigInfo, X509* pCert); 00924 00925 //============================================================ 00926 // Adds a certificate and it's certid to this signature 00927 // pSigInfo - signature info object [REQUIRED] 00928 // pCert - vertificate [REQUIRED] 00929 // nCertIdType - type of cert [REQUIRED] 00930 // return error code or ERR_OK 00931 //============================================================ 00932 EXP_OPTION int ddocSigInfo_addCert(SignatureInfo* pSigInfo, X509* pCert, int nCertIdType); 00933 00934 00935 #ifdef WITH_TS 00936 00937 //-------------------------------------------------- 00938 // Finds the TSA certificate 00939 // pSigInfo - signature info object [REQUIRED] 00940 // returns certificate or NULL 00941 //-------------------------------------------------- 00942 EXP_OPTION X509* ddocSigInfo_GetTSACert(const SignatureInfo* pSigInfo); 00943 00944 //-------------------------------------------------- 00945 // Sets the TSA certificate 00946 // pSigInfo - signature info object [REQUIRED] 00947 // pTsInfo - timestamp object [REQUIRED] 00948 // pCert - certificate [REQUIRED] 00949 // returns error code or ERR_OK 00950 //-------------------------------------------------- 00951 EXP_OPTION int ddocSigInfo_SetTSACert(SignatureInfo* pSigInfo, X509* pCert); 00952 00953 //-------------------------------------------------- 00954 // Finds a TimestampInfo object with required type 00955 // pSigInfo - signature info object [REQUIRED] 00956 // nType - type of TimestampInfo object [REQUIRED] 00957 // returns TimestampInfo pointer or NULL for error 00958 //-------------------------------------------------- 00959 EXP_OPTION TimestampInfo* ddocSigInfo_GetTypestampOfType(const SignatureInfo* pSigInfo, const char* szType); 00960 00961 //-------------------------------------------------- 00962 // Finds a TimestampInfo object with required type 00963 // pSigInfo - signature info object [REQUIRED] 00964 // nType - type of TimestampInfo object [REQUIRED] 00965 // returns TimestampInfo pointer or NULL for error 00966 //-------------------------------------------------- 00967 EXP_OPTION TimestampInfo* ddocSigInfo_GetOrCreateTypestampOfType(SignatureInfo* pSigInfo, const char* szType); 00968 00969 //-------------------------------------------------- 00970 // Finds last TimestampInfo object 00971 // pSigInfo - signature info object [REQUIRED] 00972 // returns TimestampInfo pointer or NULL for error 00973 //-------------------------------------------------- 00974 EXP_OPTION TimestampInfo* ddocSigInfo_GetLastTypestamp(const SignatureInfo* pSigInfo); 00975 00976 //-------------------------------------------------- 00977 // Calculates digest of timestampable xml block 00978 // pSigDoc - signed doc pointer [REQUIRED] 00979 // pSigInfo - signature pointer [REQUIRED] 00980 // nTsType - timestamp type [REQUIRED] 00981 // pMBufDigest - buffer for digest [REQUIRED] 00982 // returns error code or ERR_OK 00983 //-------------------------------------------------- 00984 int ddocCalculateTimestampSourceDigest(const SignedDoc* pSigDoc, 00985 const SignatureInfo* pSigInfo, 00986 int nTsType, DigiDocMemBuf* pMBufDigest); 00987 00988 //-------------------------------------------------- 00989 // Adds a <SignatureTimeStamp> to signature 00990 // retrieves the TS_RESP object 00991 // pSigInfo - signature pointer [REQUIRED] 00992 // ppCert - TSA certificate, returnes TSA cert [OPTIONAL] 00993 // policy - policy OID [OPTIONAL] 00994 // url - TSA url [REQUIRED] 00995 // proxyHost - http proxy host [OPTIONAL] 00996 // proxyPort - http proxy port [OPTIONAL] 00997 // returns error code or ERR_OK 00998 //-------------------------------------------------- 00999 int ddocGetSignatureTimeStamp(SignatureInfo* pSigInfo, X509** ppCert, 01000 const char* policy, const char* url, 01001 const char* proxyHost, const char* proxyPort); 01002 01003 01004 //-------------------------------------------------- 01005 // Generates <SignatureTimeStamp> element XML 01006 // pSigInfo - signature pointer [REQUIRED] 01007 // pMBuf - buffer for XML [REQUIRED] 01008 // returns error code or ERR_OK 01009 //-------------------------------------------------- 01010 int ddocSigInfo_SignatureTimeStamp_toXML(const SignatureInfo* pSigInfo, DigiDocMemBuf* pMBuf); 01011 01012 //-------------------------------------------------- 01013 // Adds a <SigAndRefsTimeStamp> to signature 01014 // retrieves the TS_RESP object 01015 // pSigInfo - signature pointer [REQUIRED] 01016 // ppCert - TSA certificate [OPTIONAL] 01017 // policy - policy OID [OPTIONAL] 01018 // url - TSA url [REQUIRED] 01019 // proxyHost - http proxy host [OPTIONAL] 01020 // proxyPort - http proxy port [OPTIONAL] 01021 // returns error code or ERR_OK 01022 //-------------------------------------------------- 01023 int ddocGetSigAndRefsTimeStamp(const SignedDoc* pSigDoc, 01024 const SignatureInfo* pSigInfo, X509** ppCert, 01025 const char* policy, const char* url, 01026 const char* proxyHost, const char* proxyPort); 01027 01028 //-------------------------------------------------- 01029 // Generates <SignatureTimeStamp> element XML 01030 // pSigInfo - signature pointer [REQUIRED] 01031 // pMBuf - buffer for XML [REQUIRED] 01032 // returns error code or ERR_OK 01033 //-------------------------------------------------- 01034 int ddocSigInfo_SigAndRefsTimeStamp_toXML(const SignatureInfo* pSigInfo, DigiDocMemBuf* pMBuf); 01035 01036 #endif 01037 01038 // Returns the last SignatureInfo object 01039 EXP_OPTION SignatureInfo* ddocGetLastSignature(const SignedDoc* pSigDoc); 01040 // Returns the SignatureInfo object with the given id 01041 EXP_OPTION SignatureInfo* getSignatureWithId(const SignedDoc* pSigDoc, const char* id); 01042 // Returns the SignatureInfo for the given NotaryInfo 01043 EXP_OPTION SignatureInfo* ddocGetSignatureForNotary(const SignedDoc* pSigDoc, const NotaryInfo* pNotInfo); 01044 01045 // Adds a new SignedInfo element to a SignedDoc element and initializes it 01046 EXP_OPTION int SignatureInfo_new(SignatureInfo **newSignatureInfo, SignedDoc* pSigDoc, const char* id); 01047 01048 // Sets the signature production place info (use NULL for unknown attributes) 01049 EXP_OPTION int setSignatureProductionPlace(SignatureInfo* pSigInfo, 01050 const char* city, const char* state, 01051 const char* zip, const char* country); 01052 // Adds a signer role 01053 EXP_OPTION int addSignerRole(SignatureInfo* pSigInfo, int nCertified, 01054 const char* role, int rLen, int encode); 01055 // Returns the number of signer roles 01056 EXP_OPTION int getCountOfSignerRoles(SignatureInfo* pSigInfo, int nCertified); 01057 // Returns the desired signer role 01058 EXP_OPTION const char* getSignerRole(SignatureInfo* pSigInfo, int nCertified, int nIdx); 01059 01060 // Removes this SignatureInfo from signed doc and frees it's memory 01061 EXP_OPTION int SignatureInfo_delete(SignedDoc* pSigDoc, const char* id); 01062 01063 // cleanup SignatureInfo memory 01064 EXP_OPTION void SignatureInfo_free(SignatureInfo* pSigInfo); 01065 01066 //======================< DocInfo functions >============================= 01067 01068 // Adds a new DocInfo element to a SignatureInfo element and initializes it 01069 EXP_OPTION int addDocInfo(DocInfo **newDocInfo, SignatureInfo* pSigInfo, const char* docId, 01070 const char* digType, const byte* digest, 01071 int digLen, const byte* mimeDig, int mimeDigLen); 01072 // cleanup DocInfo memory 01073 EXP_OPTION void DocInfo_free(DocInfo* pDocInfo); 01074 // Returns number of DocInfos 01075 EXP_OPTION int getCountOfDocInfos(const SignatureInfo* pSigInfo); 01076 // Returns the desired DocInfo 01077 EXP_OPTION DocInfo* getDocInfo(const SignatureInfo* pSigInfo, int idx); 01078 // Returns the last DocInfo 01079 EXP_OPTION DocInfo* ddocGetLastDocInfo(const SignatureInfo* pSigInfo); 01080 01081 01082 // Returns the DocInfo object with the given id 01083 EXP_OPTION DocInfo* getDocInfoWithId(const SignatureInfo* pSigInfo, const char* id); 01084 // Sets the DocInfo objects document digest and digest type 01085 EXP_OPTION void setDocInfoDigest(DocInfo* pDocInfo, const byte* digest, 01086 int digLen, const char* digType); 01087 // Sets the DocInfo objects mime digest and mime type 01088 EXP_OPTION void setDocInfoMimeDigest(DocInfo* pDocInfo, const byte* mimeDig, int mimeDigLen); 01089 01090 // Adds all DocInfo elements in this file to a SignatureInfo element 01091 EXP_OPTION int addAllDocInfos(SignedDoc* pSigDoc, SignatureInfo* pSigInfo); 01092 01093 //======================< NotaryInfo functions >============================= 01094 01095 // returns the number of notarys 01096 EXP_OPTION int getCountOfNotaryInfos(const SignedDoc* pSigDoc); 01097 // Returns the desired NotaryInfo object 01098 EXP_OPTION NotaryInfo* getNotaryInfo(const SignedDoc* pSigDoc, int nIdx); 01099 // Returns the last NotaryInfo object 01100 EXP_OPTION NotaryInfo* ddocGetLastNotaryInfo(const SignedDoc* pSigDoc); 01101 // Returns the NotaryInfo object with the given id 01102 EXP_OPTION NotaryInfo* getNotaryWithId(const SignedDoc* pSigDoc, const char* id); 01103 // Returns the NotaryInfo object that corresponds to the given signature 01104 EXP_OPTION NotaryInfo* getNotaryWithSigId(const SignedDoc* pSigDoc, const char* sigId); 01105 // Returns the NotaryInfo object that corresponds to the given signature 01106 // ore creates a new one 01107 EXP_OPTION NotaryInfo* getOrCreateNotaryWithSigId(SignedDoc* pSigDoc, const char* sigId); 01108 01109 // Adds a new NotaryInfo element to a SignedDoc element and initializes it partly 01110 EXP_OPTION int NotaryInfo_new(NotaryInfo** newNotaryInfo, SignedDoc* pSigDoc, SignatureInfo* pSigInfo); 01111 // the same as above, but reads response and cert from file 01112 EXP_OPTION int NotaryInfo_new_file(NotaryInfo** newNotaryInfo, SignedDoc* pSigDoc, const SignatureInfo* pSigInfo, 01113 const char* ocspRespFile, const char* notaryCertFile); 01114 // cleanup NotaryInfo memory 01115 EXP_OPTION void NotaryInfo_free(NotaryInfo* pNotary); 01116 01117 //============================================================ 01118 // Returns OCSP responders id as in XML document 01119 // pNotary - Notary info 01120 // return DigiDocMemBuf buffer pointer or NULL for error 01121 //============================================================ 01122 EXP_OPTION const DigiDocMemBuf* ddocNotInfo_GetResponderId(const NotaryInfo* pNotary); 01123 01124 //============================================================ 01125 // Returns OCSP responders id value as string 01126 // pNotary - Notary info 01127 // return responder id value or NULL 01128 //============================================================ 01129 EXP_OPTION const char* ddocNotInfo_GetResponderId_Value(const NotaryInfo* pNotary); 01130 01131 //============================================================ 01132 // Sets OCSP responders id as in XML document 01133 // pNotary - Notary info 01134 // data - new responder id value 01135 // len - length of value 01136 // return DigiDocMemBuf buffer pointer or NULL for error 01137 //============================================================ 01138 int ddocNotInfo_SetResponderId(NotaryInfo* pNotary, const char* data, long len); 01139 01140 //============================================================ 01141 // Returns OCSP response as memory buffer 01142 // pNotary - Notary info 01143 // return DigiDocMemBuf buffer pointer or NULL for error 01144 //============================================================ 01145 const DigiDocMemBuf* ddocNotInfo_GetOCSPResponse(const NotaryInfo* pNotary); 01146 01147 //============================================================ 01148 // Retrieves OCSP responses responder id type and value 01149 // pResp - OCSP response 01150 // pType - buffer for type 01151 // pMbufRespId - responder id 01152 // returns error code or ERR_OK 01153 //============================================================ 01154 int ddocGetOcspRespIdTypeAndValue(OCSP_RESPONSE* pResp, 01155 int *pType, DigiDocMemBuf* pMbufRespId); 01156 01157 //============================================================ 01158 // Sets OCSP respondese value as in XML document. Must pass in 01159 // binary DER data! 01160 // pNotary - Notary info 01161 // data - new responder id value 01162 // len - length of value 01163 // return DigiDocMemBuf buffer pointer or NULL for error 01164 //============================================================ 01165 int ddocNotInfo_SetOCSPResponse(NotaryInfo* pNotary, const char* data, long len); 01166 01167 //============================================================ 01168 // Returns OCSP response value 01169 // pNotary - Notary info 01170 // return OCSP_RESPONSE pointer or NULL for error. Caller must 01171 // use OCSP_RESPONSE_free() to release it. 01172 //============================================================ 01173 OCSP_RESPONSE* ddocNotInfo_GetOCSPResponse_Value(const NotaryInfo* pNotary); 01174 01175 //============================================================ 01176 // Sets OCSP respondese value. Must pass in real OCSP_RESPONSE 01177 // pNotary - Notary info 01178 // data - new responder id value 01179 // len - length of value 01180 // return DigiDocMemBuf buffer pointer or NULL for error 01181 //============================================================ 01182 int ddocNotInfo_SetOCSPResponse_Value(NotaryInfo* pNotary, OCSP_RESPONSE* pResp); 01183 01184 //============================================================ 01185 // Returns OCSP responders id type as string 01186 // pNotary - Notary info 01187 // return responder id type or NULL. DO NOT free() it! 01188 //============================================================ 01189 EXP_OPTION const char* ddocNotInfo_GetResponderId_Type(const NotaryInfo* pNotary); 01190 01191 //============================================================ 01192 // Returns OCSP responses thisUpdate atribute as string 01193 // pNotary - Notary info 01194 // pMBuf - buffer for thisUpdate value 01195 // return error code OR ERR_OK. 01196 //============================================================ 01197 EXP_OPTION int ddocNotInfo_GetThisUpdate(const NotaryInfo* pNotary, DigiDocMemBuf* pMBuf); 01198 01199 //============================================================ 01200 // Returns OCSP responses producedAt atribute as time_t 01201 // pNotary - Notary info 01202 // pTime - address of time_t variable 01203 // return error code OR ERR_OK. 01204 //============================================================ 01205 int ddocNotInfo_GetProducedAt_timet(const NotaryInfo* pNotary, time_t* pTime); 01206 01207 //============================================================ 01208 // Returns OCSP responses thisUpdate atribute as time_t 01209 // pNotary - Notary info 01210 // pTime - address of time_t variable 01211 // return error code OR ERR_OK. 01212 //============================================================ 01213 int ddocNotInfo_GetThisUpdate_timet(const NotaryInfo* pNotary, time_t* pTime); 01214 01215 //============================================================ 01216 // Returns OCSP responses nextUpdate atribute as string 01217 // pNotary - Notary info 01218 // pMBuf - buffer for thisUpdate value 01219 // return error code OR ERR_OK. 01220 //============================================================ 01221 EXP_OPTION int ddocNotInfo_GetNextUpdate(const NotaryInfo* pNotary, DigiDocMemBuf* pMBuf); 01222 01223 //============================================================ 01224 // Returns OCSP responses IssuerNameHash atribute 01225 // pNotary - Notary info 01226 // pMBuf - buffer for IssuerNameHash value 01227 // return error code OR ERR_OK. 01228 //============================================================ 01229 int ddocNotInfo_GetIssuerNameHash(const NotaryInfo* pNotary, DigiDocMemBuf* pMBuf); 01230 01231 //============================================================ 01232 // Returns OCSP responses IssuerKeyHash atribute 01233 // pNotary - Notary info 01234 // pMBuf - buffer for IssuerKeyHash value 01235 // return error code OR ERR_OK. 01236 //============================================================ 01237 int ddocNotInfo_GetIssuerKeyHash(const NotaryInfo* pNotary, DigiDocMemBuf* pMBuf); 01238 01239 //============================================================ 01240 // Returns OCSP responses real digest from response data 01241 // pNotary - Notary info 01242 // pMBuf - buffer for digest value 01243 // return error code OR ERR_OK. 01244 //============================================================ 01245 int ddocNotInfo_GetOcspRealDigest(const NotaryInfo* pNotary, DigiDocMemBuf* pMBuf); 01246 01247 //============================================================ 01248 // Returns OCSP response digest as in XML document 01249 // pNotary - Notary info 01250 // return DigiDocMemBuf buffer pointer or NULL for error 01251 //============================================================ 01252 EXP_OPTION const DigiDocMemBuf* ddocNotInfo_GetOcspDigest(const NotaryInfo* pNotary); 01253 01254 //============================================================ 01255 // Sets OCSP response digest id as in XML document 01256 // pNotary - Notary info 01257 // data - new digest value 01258 // len - length of value 01259 // return DigiDocMemBuf buffer pointer or NULL for error 01260 //============================================================ 01261 int ddocNotInfo_SetOcspDigest(NotaryInfo* pNotary, const char* data, long len); 01262 01263 //============================================================ 01264 // Returns OCSP responses signature value 01265 // pNotary - Notary info 01266 // pMBuf - buffer for signature value 01267 // return error code OR ERR_OK. 01268 //============================================================ 01269 int ddocNotInfo_GetOcspSignatureValue(const NotaryInfo* pNotary, DigiDocMemBuf* pMBuf); 01270 01271 01272 // Removes this NotaryInfo from signed doc and frees it's memory 01273 EXP_OPTION int NotaryInfo_delete(SignatureInfo* pSigInfo); 01274 01275 // Calculates and stores a signature for this SignatureInfo object 01276 EXP_OPTION int calculateSigInfoSignature(const SignedDoc* pSigDoc, SignatureInfo* pSigInfo, int nSigType, 01277 const char* keyfile, const char* passwd, const char* certfile); 01278 01279 //============================================================ 01280 // Adds a certificate to Notary and initializes Notary 01281 // pNotary - Notary info 01282 // cert - responders certificate 01283 // return error code 01284 //============================================================ 01285 int addNotaryInfoCert(SignedDoc *pSigDoc, NotaryInfo *pNotary, X509 *cert); 01286 01287 //============================================================ 01288 // Removes Notary cert value and id after unsucessful verification attempt 01289 // pSigInfo - signature info [REQUIRED] 01290 // return error code 01291 //============================================================ 01292 int removeNotaryInfoCert(SignatureInfo* pSigInfo); 01293 01294 // Calculates <SignedProperties> digest 01295 EXP_OPTION int calculateSignedPropertiesDigest(SignedDoc* pSigDoc, SignatureInfo* pSigInfo); 01296 // Calculates <SignedInfo> digest 01297 EXP_OPTION int calculateSignedInfoDigest(SignedDoc* pSigDoc, SignatureInfo* pSigInfo, byte* digBuf, int* digLen); 01298 01299 01300 #ifdef __cplusplus 01301 } 01302 #endif 01303 01304 01305 #endif // __DIGIDOC_OBJ_H__ 01306 01307