Estonian ID Card C-library
Loading...
Searching...
No Matches
DigiDocObj.h
1#ifndef __DIGIDOC_OBJ_H__
2#define __DIGIDOC_OBJ_H__
3//==================================================
4// FILE: DigiDocGen.h
5// PROJECT: Digi Doc
6// DESCRIPTION: DigiDoc helper routines for accessing dogidoc data
7// AUTHOR: Veiko Sinivee, S|E|B IT Partner Estonia
8//==================================================
9// Copyright (C) AS Sertifitseerimiskeskus
10// This library is free software; you can redistribute it and/or
11// modify it under the terms of the GNU Lesser General Public
12// License as published by the Free Software Foundation; either
13// version 2.1 of the License, or (at your option) any later version.
14// This library is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17// Lesser General Public License for more details.
18// GNU Lesser General Public Licence is available at
19// http://www.gnu.org/copyleft/lesser.html
20//==========< HISTORY >=============================
21// 26.04.2006 Veiko Sinivee
22// Creation
23//==================================================
24
25#include "DigiDocDefs.h"
26#include "DigiDocMem.h"
27#include <openssl/x509.h>
28#include <openssl/ocsp.h>
29
30//==========< DigiDoc object structure >========================
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36
37// contains the signed attributes of each document file entry
38typedef struct DocInfo_st {
39 char* szDocId; // document id
40 char* szDigestType; // digest method used
41 byte* szDigest; // digest value
42 int nDigestLen; // digest value length
43 byte* szMimeDigest; // digest value
44 int nMimeDigestLen; // digest value length
45} DocInfo;
46
48 char* szCity;
49 char* szStateOrProvince;
50 char* szPostalCode;
51 char* szCountryName;
53
54typedef struct SignerRole_st {
55 int nClaimedRoles;
56 char** pClaimedRoles;
57 int nCertifiedRoles;
58 char** pCertifiedRoles;
60
61typedef struct DigestValue_st {
62 char* szDigestMethod;
63 DigiDocMemBuf mbufDigestValue;
65 /*
66typedef struct ReferenceInfo_st {
67 char* szId;
68 char* szUri;
69 char* szType;
70 DigestValue digestValue;
71} ReferenceInfo;
72 */
73typedef struct SignatureValue_st {
74 char* szId;
75 char* szType;
76 DigiDocMemBuf mbufSignatureValue;
78
79#define CERTID_TYPE_UNKNOWN 0
80#define CERTID_TYPE_SIGNERS_CERTID 1
81#define CERTID_TYPE_RESPONDERS_CERTID 2
82#define CERTID_TYPE_TSA_CERTID 3
83//AM 12.03.08
84#define CERTID_VALUE_CA_CERT 4
85
86
87typedef struct CertID_st {
88 int nType; // internal CertID type:
89 char* szId;
90 char* szIssuerSerial;
91 char* szIssuerName;
92 DigestValue* pDigestValue;
93 //AM 24.04.08
94 char* szDigestType; // digest method used
95} CertID;
96
97typedef struct CertIDList_st {
98 int nCertIDs;
99 CertID** pCertIDs;
100} CertIDList;
101
102#define CERTID_VALUE_UNKNOWN 0
103#define CERTID_VALUE_SIGNERS_CERT 1
104#define CERTID_VALUE_RESPONDERS_CERT 2
105#define CERTID_VALUE_TSA_CERT 3
106//AM 12.03.08
107#define CERTID_TYPE_CA_CERTID 4
108#define ERR_VER_1_0 300
109
110typedef struct CertValue_st {
111 int nType;
112 char* szId;
113 X509* pCert;
114} CertValue;
115
116typedef struct CertValueList_st {
117 int nCertValues;
118 CertValue** pCertValues;
120
121// data file entry for each data file
122typedef struct DataFile_st {
123 char* szId; // data file id
124 char* szFileName; // signed doc file name
125 char* szMimeType; // date file mime type
126 char* szContentType; // EMBEDDED or EMBEDDED_BASE64
127 long nSize; // file size (unencoded)
128 char* szDigestType; // digest type
129 DigiDocMemBuf mbufDigest; // real DataFile digest value
130 DigiDocMemBuf mbufWrongDigest; // bad digest calculated in some versions
131 DigiDocMemBuf mbufDetachedDigest; // detached file digest
132 int nAttributes; // number of other attributes
133 char* szCharset; // datafile initial codepage
134 char** pAttNames; // other attribute names
135 char** pAttValues; // other attribute values
136 DigiDocMemBuf mbufContent;
137} DataFile;
138
139typedef struct NotaryInfo_sk {
140 char* szId; // Notary id
141 char* szNotType; // notary info type (OCSP-1.0)
142 char* timeProduced; // producedAt
143 char* szProducedAt; // producedAt in xml
144 int nRespIdType; // RESP_ID_NAME, RESP_ID_KEY
145 DigiDocMemBuf mbufRespId; // responder id value
146 char* szDigestType; // digest method used
147 // notaries personal signature
148 char* szSigType; // signature type used
149 DigiDocMemBuf mbufOcspDigest; // OCSP response digest (as in XML
150 DigiDocMemBuf mbufOcspResponse; // OCSP response (in memory held in DER)
151} NotaryInfo;
152
153// signature info for each user signature
154typedef struct SignatureInfo_st {
155 char* szId; // signature id
156 int nDocs; // number of separate documents signed
157 DocInfo** pDocs; // info for each signed document
158 char* szTimeStamp; // signature timestamp in format "YYYY-MM-DDTHH:MM:SSZ"
159 DigestValue *pSigPropDigest;
160 DigestValue *pSigPropRealDigest;
161 DigestValue *pSigInfoRealDigest;
162 SignatureValue *pSigValue; // RSA+SHA1 signature value
163 X509* pX509Cert; // X509Cert certificate (used internally for data during loading)
164 SignatureProductionPlace sigProdPlace;
165 SignerRole signerRole;
166 DigiDocMemBuf mbufOrigContent;
167 NotaryInfo* pNotary;
168 CertIDList *pCertIDs;
169 CertValueList *pCertValues;
170 //AM 24.04.08
171 char* szDigestType; // digest method used
172 int nErr1; // possible parse error codes, need many?
174
175
176
177typedef struct SignedDoc_st {
178 char* szFormat; // data format name
179 char* szFormatVer; // data format version
180 int nDataFiles;
181 DataFile** pDataFiles;
182 int nSignatures;
183 SignatureInfo** pSignatures;
184 //AM 14.03.08
185 char* szFileName;
186 //AM 13.05.08
187 char* szProfile;
188} SignedDoc;
189
190//============================================================
191// Sets a string element of a struct to a new value
192// dest - element pointer
193// value - new value
194// valLen - value length (use -1 for null terminated strings)
195//============================================================
196EXP_OPTION int setString(char** dest, const char* value, int valLen);
197
198// creates a new <SignedDoc> structure
199EXP_OPTION int SignedDoc_new(SignedDoc **newSignedDoc, const char* format, const char* version);
200// cleanup signed doc data
201EXP_OPTION void SignedDoc_free(SignedDoc* pSigDoc);
202
203//======================< DataFile functions >=============================
204
205// returns the number of data files
206EXP_OPTION int getCountOfDataFiles(const SignedDoc* pSigDoc);
207// returns the n-th DataFile object
208EXP_OPTION DataFile* getDataFile(const SignedDoc* pSigDoc, int nIdx);
209// returns the last DataFile object
210EXP_OPTION DataFile* ddocGetLastDataFile(const SignedDoc* pSigDoc);
211// Retrieve and convert DataFile Filename atribute and convert
212EXP_OPTION int ddocGetDataFileFilename(SignedDoc* pSigDoc, const char* szDocId, void** ppBuf, int* pLen);
213// returns the DataFile object with the given id
214EXP_OPTION DataFile* getDataFileWithId(const SignedDoc* pSigDoc, const char* id);
215// add a <DataFile> block to <SignedDoc>
216// use NULL for any parameter you don't have the value
217// use NULL for id if you want to auto-calculate it (recommended!!!)
218EXP_OPTION int DataFile_new(DataFile **newDataFile, SignedDoc* pSigDoc, const char* id,
219 const char* filename, const char* contentType,
220 const char* mime, long size,
221 const byte* digest, int digLen,
222 const char* digType, const char* szCharset);
223// cleanup DataFile memory
224EXP_OPTION void DataFile_free(DataFile* pDataFile);
225
226// Removes this DataFile from signed doc and frees it's memory
227EXP_OPTION int DataFile_delete(SignedDoc* pSigDoc, const char* id);
228
229//--------------------------------------------------
230// Accessor for Digest atribute of DataFile object.
231// pDataFile - address of object [REQUIRED]
232// returns value of atribute or NULL.
233//--------------------------------------------------
234EXP_OPTION DigiDocMemBuf* ddocDataFile_GetDigestValue(DataFile* pDataFile);
235
236//--------------------------------------------------
237// Mutatoror for Digest atribute of DataFile object.
238// pDataFile - address of object [REQUIRED]
239// value - new value for atribute [REQUIRED]
240// len - length of value in bytes [REQUIRED]
241// returns error code or ERR_OK
242//--------------------------------------------------
243EXP_OPTION int ddocDataFile_SetDigestValue(DataFile* pDataFile,
244 const char* value, long len);
245
246//--------------------------------------------------
247// Accessor for DetachedDigest atribute of DataFile object.
248// pDataFile - address of object [REQUIRED]
249// returns value of atribute or NULL.
250//--------------------------------------------------
251EXP_OPTION DigiDocMemBuf* ddocDataFile_GetDetachedDigestValue(DataFile* pDataFile);
252
253//--------------------------------------------------
254// Mutatoror for DetachedDigest atribute of DataFile object.
255// pDataFile - address of object [REQUIRED]
256// value - new value for atribute [REQUIRED]
257// len - length of value in bytes [REQUIRED]
258// returns error code or ERR_OK
259//--------------------------------------------------
260EXP_OPTION int ddocDataFile_SetDetachedDigestValue(DataFile* pDataFile,
261 const char* value, long len);
262
263//--------------------------------------------------
264// Accessor for WrongDigest atribute of DataFile object.
265// pDataFile - address of object [REQUIRED]
266// returns value of atribute or NULL.
267//--------------------------------------------------
268EXP_OPTION DigiDocMemBuf* ddocDataFile_GetWrongDigestValue(DataFile* pDataFile);
269
270//--------------------------------------------------
271// Mutatoror for WrongDigest atribute of DataFile object.
272// pDataFile - address of object [REQUIRED]
273// value - new value for atribute [REQUIRED]
274// len - length of value in bytes [REQUIRED]
275// returns error code or ERR_OK
276//--------------------------------------------------
277EXP_OPTION int ddocDataFile_SetWrongDigestValue(DataFile* pDataFile,
278 const char* value, long len);
279
280// Returns number of DataFile attributes
281EXP_OPTION int getCountOfDataFileAttributes(const DataFile* pDataFile);
282// Adds an attribute to data file
283EXP_OPTION int addDataFileAttribute(DataFile* pDataFile, const char* name,
284 const char* value);
285// Gets an attribute of a data file
286EXP_OPTION int getDataFileAttribute(DataFile* pDataFile, int idx, char** name, char** value);
287
288// get datafile cahed data
289EXP_OPTION int ddocGetDataFileCachedData(SignedDoc* pSigDoc, const char* szDocId, void** ppBuf, long* pLen);
290
291// apppends DataFile content to cache
292EXP_OPTION void ddocAppendDataFileData(DataFile* pDf, int maxLen, void* data, int len, int isBase64);
293
294// calculates file size and digest and store in the
295// given DataFile object
296EXP_OPTION int calculateDataFileSizeAndDigest(SignedDoc* pSigDoc, const char* id,
297 const char* filename, int digType);
298
299//--------------------------------------------------
300// Creates new DataFile and assigns contet from memory
301// ppDataFile address of pointer to return new DataFile object
302// pSigDoc - SignedDoc object
303// id - new DataFile id. Use NULL for default
304// filename - filename
305// contentType - content type
306// mime - mime type
307// pData - address of DataFile content to be assigned
308// size - length of data in bytes
309//--------------------------------------------------
310EXP_OPTION int createDataFileInMemory(DataFile **ppDataFile, SignedDoc* pSigDoc, const char* id,
311 const char* filename, const char* contentType,
312 const char* mime, const char* pData, long size);
313
314//======================< DigestValue functions >=============================
315
316//--------------------------------------------------
317// "Constructor" of DigestValue object
318// ppDigestValue - address of buffer for newly allocated object [REQUIRED]
319// szDigestMethod - digest method [OPTIONAL]
320// szDigVal/lDigLen - digest value and length [OPTIONAL]
321// returns error code or ERR_OK
322//--------------------------------------------------
323EXP_OPTION int ddocDigestValue_new(DigestValue** ppDigestValue,
324 const char* szDigestMethod,
325 void* szDigVal, long lDigLen);
326
327//--------------------------------------------------
328// "Destructor" of DigestValue object
329// pDigestValue - address of object to be deleted [REQUIRED]
330// returns error code or ERR_OK
331//--------------------------------------------------
332EXP_OPTION int ddocDigestValue_free(DigestValue* pDigestValue);
333
334//--------------------------------------------------
335// Accessor for DigestMethod atribute of DigestValue object.
336// pDigestValue - address of object [REQUIRED]
337// returns value of atribute or NULL.
338//--------------------------------------------------
339EXP_OPTION const char* ddocDigestValue_GetDigestMethod(DigestValue* pDigestValue);
340
341//--------------------------------------------------
342// Mutatoror for DigestMethod atribute of DigestValue object.
343// pDigestValue - address of object [REQUIRED]
344// value - new value for atribute [REQUIRED]
345// returns error code or ERR_OK
346//--------------------------------------------------
347EXP_OPTION int ddocDigestValue_SetDigestMethod(DigestValue* pDigestValue, const char* value);
348
349//--------------------------------------------------
350// Accessor for DigestValue atribute of DigestValue object.
351// pDigestValue - address of object [REQUIRED]
352// returns value of atribute or NULL.
353//--------------------------------------------------
354EXP_OPTION DigiDocMemBuf* ddocDigestValue_GetDigestValue(DigestValue* pDigestValue);
355
356//--------------------------------------------------
357// Mutatoror for DigestValue atribute of DigestValue object.
358// pDigestValue - address of object [REQUIRED]
359// value - new value for atribute [REQUIRED]
360// len - length of value in bytes [REQUIRED]
361// returns error code or ERR_OK
362//--------------------------------------------------
363EXP_OPTION int ddocDigestValue_SetDigestValue(DigestValue* pDigestValue,
364 const char* value, long len);
365
366//--------------------------------------------------
367// Compares two DigestValue structure on equality
368// pDigest1 - address of first digest [REQUIRED]
369// pDigest2 - address of second digest [REQUIRED]
370// returns error code or ERR_OK
371//--------------------------------------------------
372int ddocCompareDigestValues(DigestValue* pDigest1, DigestValue* pDigest2);
373
374//--------------------------------------------------
375// Generates XML for <DigestValue> element
376// pDigestValue - DigestValue object [REQUIRED]
377// pBuf - memory buffer for storing xml [REQUIRED]
378// returns error code or ERR_OK
379//--------------------------------------------------
380int ddocDigestValue_toXML(const DigestValue* pDigestValue, DigiDocMemBuf* pBuf);
381
382//======================< SignatureValue functions >=============================
383
384//============================================================
385// Returns the next free signature id
386// pSigDoc - signed doc pointer
387//============================================================
388EXP_OPTION int getNextSignatureId(const SignedDoc* pSigDoc);
389
390//--------------------------------------------------
391// "Constructor" of SignatureValue object
392// ppSignatureValue - address of buffer for newly allocated object [REQUIRED]
393// szId - Id atribute value [OPTIONAL]
394// szType - signature type [OPTIONAL]
395// szDigVal/lDigLen - digest value and length [OPTIONAL]
396// returns error code or ERR_OK
397//--------------------------------------------------
398EXP_OPTION int ddocSignatureValue_new(SignatureValue** ppSignatureValue,
399 const char* szId, const char* szType,
400 void* szSigVal, long lSigLen);
401
402//--------------------------------------------------
403// "Destructor" of SignatureValue object
404// pSignatureValue - address of object to be deleted [REQUIRED]
405// returns error code or ERR_OK
406//--------------------------------------------------
407EXP_OPTION int ddocSignatureValue_free(SignatureValue* pSignatureValue);
408
409//--------------------------------------------------
410// Accessor for Id atribute of SignatureValue object.
411// pSignatureValue - address of object [REQUIRED]
412// returns value of atribute or NULL.
413//--------------------------------------------------
414EXP_OPTION const char* ddocSignatureValue_GetId(const SignatureValue* pSignatureValue);
415
416//--------------------------------------------------
417// Mutatoror for Id atribute of SignatureValue object.
418// pSignatureValue - address of object [REQUIRED]
419// value - new value for atribute [REQUIRED]
420// returns error code or ERR_OK
421//--------------------------------------------------
422EXP_OPTION int ddocSignatureValue_SetId(SignatureValue* pSignatureValue, const char* value);
423
424//--------------------------------------------------
425// Accessor for Type atribute of SignatureValue object.
426// pSignatureValue - address of object [REQUIRED]
427// returns value of atribute or NULL.
428//--------------------------------------------------
429EXP_OPTION const char* ddocSignatureValue_GetType(const SignatureValue* pSignatureValue);
430
431//--------------------------------------------------
432// Mutatoror for Type atribute of SignatureValue object.
433// pSignatureValue - address of object [REQUIRED]
434// value - new value for atribute [REQUIRED]
435// returns error code or ERR_OK
436//--------------------------------------------------
437EXP_OPTION int ddocSignatureValue_SetType(SignatureValue* pSignatureValue, const char* value);
438
439//--------------------------------------------------
440// Accessor for SignatureValue atribute of SignatureValue object.
441// pSignatureValue - address of object [REQUIRED]
442// returns value of atribute or NULL.
443//--------------------------------------------------
444EXP_OPTION DigiDocMemBuf* ddocSignatureValue_GetSignatureValue(const SignatureValue* pSignatureValue);
445
446//--------------------------------------------------
447// Mutatoror for SignatureValue atribute of SignatureValue object.
448// pSignatureValue - address of object [REQUIRED]
449// value - new value for atribute [REQUIRED]
450// len - length of value in bytes [REQUIRED]
451// returns error code or ERR_OK
452//--------------------------------------------------
453EXP_OPTION int ddocSignatureValue_SetSignatureValue(SignatureValue* pSignatureValue,
454 const char* value, long len);
455
456//--------------------------------------------------
457// Generates XML for <IncludeInfo> element
458// pSignatureValue - SignatureValue object [REQUIRED]
459// pBuf - memory buffer for storing xml [REQUIRED]
460// returns error code or ERR_OK
461//--------------------------------------------------
462int ddocSignatureValue_toXML(const SignatureValue* pSignatureValue, DigiDocMemBuf* pBuf);
463
464//======================< CertID >====================================
465
466//--------------------------------------------------
467// "Constructor" of CertID object
468// ppCertID - address of buffer for newly allocated object [REQUIRED]
469// szId - Id atribute value [OPTIONAL]
470// nType - certid internal type (signers or responders cert) [REQUIRED]
471// szIssuerSerial - issuer serial number [OPTIONAL]
472// szIssuerName - issuer DN [OPTIONAL]
473// szDigVal/lDigLen - digest value and length [OPTIONAL]
474// returns error code or ERR_OK
475//--------------------------------------------------
476EXP_OPTION int ddocCertID_new(CertID** ppCertID,
477 int nType, const char* szId,
478 const char* szIssuerSerial, const char* szIssuerName,
479 void* szDigVal, long lDigLen);
480
481//--------------------------------------------------
482// "Destructor" of CertID object
483// pCertID - address of object to be deleted [REQUIRED]
484// returns error code or ERR_OK
485//--------------------------------------------------
486EXP_OPTION int ddocCertID_free(CertID* pCertID);
487
488//--------------------------------------------------
489// Accessor for Id atribute of CertID object.
490// pCertID - address of object [REQUIRED]
491// returns value of atribute or NULL.
492//--------------------------------------------------
493EXP_OPTION const char* ddocCertID_GetId(const CertID* pCertID);
494
495//--------------------------------------------------
496// Mutatoror for Id atribute of CertID object.
497// pCertID - address of object [REQUIRED]
498// value - new value for atribute [REQUIRED]
499// returns error code or ERR_OK
500//--------------------------------------------------
501EXP_OPTION int ddocCertID_SetId(CertID* pCertID, const char* value);
502
503//--------------------------------------------------
504// Accessor for IssuerSerial atribute of CertID object.
505// pCertID - address of object [REQUIRED]
506// returns value of atribute or NULL.
507//--------------------------------------------------
508EXP_OPTION const char* ddocCertID_GetIssuerSerial(const CertID* pCertID);
509
510//--------------------------------------------------
511// Mutatoror for IssuerSerial atribute of CertID object.
512// pCertID - address of object [REQUIRED]
513// value - new value for atribute [REQUIRED]
514// returns error code or ERR_OK
515//--------------------------------------------------
516EXP_OPTION int ddocCertID_SetIssuerSerial(CertID* pCertID, const char* value);
517
518//--------------------------------------------------
519// Accessor for IssuerName atribute of CertID object.
520// pCertID - address of object [REQUIRED]
521// returns value of atribute or NULL.
522//--------------------------------------------------
523EXP_OPTION const char* ddocCertID_GetIssuerName(const CertID* pCertID);
524
525//--------------------------------------------------
526// Mutatoror for IssuerName atribute of CertID object.
527// pCertID - address of object [REQUIRED]
528// value - new value for atribute [REQUIRED]
529// returns error code or ERR_OK
530//--------------------------------------------------
531EXP_OPTION int ddocCertID_SetIssuerName(CertID* pCertID, const char* value);
532
533//--------------------------------------------------
534// Accessor for DigestValue atribute of CertID object.
535// pCertID - address of object [REQUIRED]
536// returns value of atribute or NULL.
537//--------------------------------------------------
538EXP_OPTION DigiDocMemBuf* ddocCertID_GetDigestValue(const CertID* pCertID);
539
540
541//--------------------------------------------------
542// Mutatoror for DigestValue atribute of CertID object.
543// pCertID - address of object [REQUIRED]
544// value - new value for atribute [REQUIRED]
545// len - length of value in bytes [REQUIRED]
546// returns error code or ERR_OK
547//--------------------------------------------------
548EXP_OPTION int ddocCertID_SetDigestValue(CertID* pCertID,
549 const char* value, long len);
550
551//--------------------------------------------------
552// Generates XML for <Cert> element
553// pCertID - CertID object [REQUIRED]
554// pBuf - memory buffer for storing xml [REQUIRED]
555// returns error code or ERR_OK
556//--------------------------------------------------
557int ddocCertID_toXML(const SignedDoc* pSigDoc, const CertID* pCertID, DigiDocMemBuf* pBuf);
558
559//--------------------------------------------------
560// Generates XML for <CompleteCertificateRefs> element
561// pSigDoc - SignedDoc object [REQUIRED]
562// pBuf - memory buffer for storing xml [REQUIRED]
563// returns error code or ERR_OK
564//--------------------------------------------------
565int ddocCompleteCertificateRefs_toXML(const SignedDoc* pSigDoc, const SignatureInfo* pSigInfo, DigiDocMemBuf* pBuf);
566int bdocCompleteCertificateRefs_toXML(const SignedDoc* pSigDoc, const SignatureInfo* pSigInfo, DigiDocMemBuf* pBuf);
567
568//--------------------------------------------------
569// Generates XML for <CompleteRevocationRefs> element
570// pSigDoc - SignedDoc object [REQUIRED]
571// pBuf - memory buffer for storing xml [REQUIRED]
572// returns error code or ERR_OK
573//--------------------------------------------------
574int ddocCompleteRevocationRefs_toXML(const SignedDoc* pSigDoc, const SignatureInfo* pSigInfo, DigiDocMemBuf* pBuf);
575
576
577//==========< CertIDList >====================
578
579//--------------------------------------------------
580// "Constructor" of CertIDList object
581// ppCertIDList - address of buffer for newly allocated object [REQUIRED]
582// returns error code or ERR_OK
583//--------------------------------------------------
584EXP_OPTION int ddocCertIDList_new(CertIDList** ppCertIDList);
585
586//--------------------------------------------------
587// "Destructor" of CertIDList object
588// pCertIDList - address of object to be deleted [REQUIRED]
589// returns error code or ERR_OK
590//--------------------------------------------------
591EXP_OPTION int ddocCertIDList_free(CertIDList* pCertIDList);
592
593//--------------------------------------------------
594// Accessor for count of CertIDs subelement of CertIDList object.
595// pCertIDList - pointer to CertIDList object [REQUIRED]
596// returns error code or ERR_OK
597//--------------------------------------------------
598int ddocCertIDList_addCertID(CertIDList* pCertIDList, CertID* pCertID);
599
600//--------------------------------------------------
601// Accessor for count of CertIDs subelement of CertIDList object.
602// pCertIDList - pointer to CertIDList object [REQUIRED]
603// returns count or -1 for error. Then use error API to check errors
604//--------------------------------------------------
605EXP_OPTION int ddocCertIDList_GetCertIDsCount(CertIDList* pCertIDList);
606
607//--------------------------------------------------
608// Accessor for CertIDs subelement of CertIDList object.
609// pCertIDList - pointer to CertIDList object [REQUIRED]
610// nIdx - index of CertID object [REQUIRED]
611// returns CertID pointer or NULL for error
612//--------------------------------------------------
613EXP_OPTION CertID* ddocCertIDList_GetCertID(CertIDList* pCertIDList, int nIdx);
614
615//--------------------------------------------------
616// Accessor for last CertIDs subelement of CertIDList object.
617// pCertIDList - pointer to CertIDList object [REQUIRED]
618// returns CertID pointer or NULL for error
619//--------------------------------------------------
620EXP_OPTION CertID* ddocCertIDList_GetLastCertID(CertIDList* pCertIDList);
621
622//--------------------------------------------------
623// Deletes CertID subelement of CertIDList object.
624// pCertIDList - pointer to CertIDList object [REQUIRED]
625// nIdx - index of CertID object to be removed [REQUIRED]
626// returns error code or ERR_OK
627//--------------------------------------------------
628EXP_OPTION int ddocCertIDList_DeleteCertID(CertIDList* pCertIDList, int nIdx);
629
630//--------------------------------------------------
631// Finds a CertID object with required type
632// pCertIDList - pointer to CertIDList object [REQUIRED]
633// nType - type of CertID object [REQUIRED]
634// returns CertID pointer or NULL for error
635//--------------------------------------------------
636EXP_OPTION CertID* ddocCertIDList_GetCertIDOfType(CertIDList* pCertIDList, int nType);
637
638//--------------------------------------------------
639// Finds a CertID object with required serial nr
640// pCertIDList - pointer to CertIDList object [REQUIRED]
641// szSerial - issuer serial
642// returns CertID pointer or NULL for error
643//--------------------------------------------------
644EXP_OPTION CertID* ddocCertIDList_GetCertIDOfSerial(CertIDList* pCertIDList, const char* szSerial);
645
646//--------------------------------------------------
647// Finds a CertID object with required type or creates a new one
648// pCertIDList - pointer to CertIDList object [REQUIRED]
649// nType - type of CertID object [REQUIRED]
650// returns CertID pointer or NULL for error
651//--------------------------------------------------
652EXP_OPTION CertID* ddocCertIDList_GetOrCreateCertIDOfType(CertIDList* pCertIDList, int nType);
653
654//======================< CertValue >====================================
655
656//--------------------------------------------------
657// "Constructor" of CertValue object
658// ppCertValue - address of buffer for newly allocated object [REQUIRED]
659// szId - Id atribute value [OPTIONAL]
660// nType - certid internal type (signers or responders cert) [REQUIRED]
661// pCert - certificate itself [OPTIONAL]. Must fill in later. Do not X509_free() param!
662// returns error code or ERR_OK
663//--------------------------------------------------
664EXP_OPTION int ddocCertValue_new(CertValue** ppCertValue,
665 int nType, const char* szId,
666 X509* pCert);
667
668//--------------------------------------------------
669// "Destructor" of CertValue object
670// pCertValue - address of object to be deleted [REQUIRED]
671// returns error code or ERR_OK
672//--------------------------------------------------
673EXP_OPTION int ddocCertValue_free(CertValue* pCertValue);
674
675//--------------------------------------------------
676// Accessor for Id atribute of CertValue object.
677// pCertValue - address of object [REQUIRED]
678// returns value of atribute or NULL.
679//--------------------------------------------------
680EXP_OPTION const char* ddocCertValue_GetId(CertValue* pCertValue);
681
682//--------------------------------------------------
683// Mutatoror for Id atribute of CertValue object.
684// pCertValue - address of object [REQUIRED]
685// value - new value for atribute [REQUIRED]
686// returns error code or ERR_OK
687//--------------------------------------------------
688EXP_OPTION int ddocCertValue_SetId(CertValue* pCertValue, const char* value);
689
690//--------------------------------------------------
691// Accessor for Cert atribute of CertValue object.
692// pCertValue - address of object [REQUIRED]
693// returns value of atribute or NULL.
694//--------------------------------------------------
695EXP_OPTION X509* ddocCertValue_GetCert(CertValue* pCertValue);
696
697//--------------------------------------------------
698// Mutatoror for Cert atribute of CertValue object.
699// pCertValue - address of object [REQUIRED]
700// pCert - new value for atribute [REQUIRED]
701// returns error code or ERR_OK
702//--------------------------------------------------
703EXP_OPTION int ddocCertValue_SetCert(CertValue* pCertValue, X509* pCert);
704
705//--------------------------------------------------
706// Generates XML for <EncapsulatedX509Certificate> element
707// pCertID - CertID object [REQUIRED]
708// pBuf - memory buffer for storing xml [REQUIRED]
709// returns error code or ERR_OK
710//--------------------------------------------------
711int ddocCertValue_toXML(const CertValue* pCertValue, DigiDocMemBuf* pBuf);
712
713//==========< CertValueList >====================
714
715//--------------------------------------------------
716// "Constructor" of CertValueList object
717// ppCertValueList - address of buffer for newly allocated object [REQUIRED]
718// returns error code or ERR_OK
719//--------------------------------------------------
720EXP_OPTION int ddocCertValueList_new(CertValueList** ppCertValueList);
721
722//--------------------------------------------------
723// "Destructor" of CertValueList object
724// pCertValueList - address of object to be deleted [REQUIRED]
725// returns error code or ERR_OK
726//--------------------------------------------------
727EXP_OPTION int ddocCertValueList_free(CertValueList* pCertValueList);
728
729//--------------------------------------------------
730// Adds a CertValue element to CertValueList object.
731// pCertValueList - pointer to CertValueList object [REQUIRED]
732// pCertValue - new object [REQUIRED]
733// returns error code or ERR_OK
734//--------------------------------------------------
735EXP_OPTION int ddocCertValueList_addCertValue(CertValueList* pCertValueList, CertValue* pCertValue);
736
737//--------------------------------------------------
738// Accessor for count of CertValues subelement of CertValueList object.
739// pCertValueList - pointer to CertValueList object [REQUIRED]
740// returns count or -1 for error. Then use error API to check errors
741//--------------------------------------------------
742EXP_OPTION int ddocCertValueList_GetCertValuesCount(CertValueList* pCertValueList);
743
744//--------------------------------------------------
745// Accessor for CertValues subelement of CertValueList object.
746// pCertValueList - pointer to CertValueList object [REQUIRED]
747// nIdx - index of CertValue object [REQUIRED]
748// returns CertValue pointer or NULL for error
749//--------------------------------------------------
750EXP_OPTION CertValue* ddocCertValueList_GetCertValue(CertValueList* pCertValueList, int nIdx);
751
752//--------------------------------------------------
753// Deletes CertValue subelement of CertValueList object.
754// pCertValueList - pointer to CertValueList object [REQUIRED]
755// nIdx - index of CertValue object to be removed [REQUIRED]
756// returns error code or ERR_OK
757//--------------------------------------------------
758EXP_OPTION int ddocCertValueList_DeleteCertValue(CertValueList* pCertValueList, int nIdx);
759
760//--------------------------------------------------
761// Finds a CertValue object with required type
762// pCertValueList - pointer to CertValueList object [REQUIRED]
763// nType - type of CertValue object [REQUIRED]
764// returns CertValue pointer or NULL for error
765//--------------------------------------------------
766EXP_OPTION CertValue* ddocCertValueList_GetCertValueOfType(CertValueList* pCertValueList, int nType);
767
768//--------------------------------------------------
769// Finds a CertValue object with required type or creates a new one
770// pCertValueList - pointer to CertValueList object [REQUIRED]
771// nType - type of CertValue object [REQUIRED]
772// returns CertValue pointer or NULL for error
773//--------------------------------------------------
774EXP_OPTION CertValue* ddocCertValueList_GetOrCreateCertValueOfType(CertValueList* pCertValueList, int nType);
775
776//======================< SignatureInfo functions >=============================
777
778// returns the number of signatures
779EXP_OPTION int getCountOfSignatures(const SignedDoc* pSigDoc);
780// Returns the desired SignatureInfo object
781EXP_OPTION SignatureInfo* getSignature(const SignedDoc* pSigDoc, int nIdx);
782
783//============================================================
784// Returns signatures signed properties digest
785// pSigInfo - signature info object
786// return digest value as DigiDocMemBuf pointer or NULL
787//============================================================
788EXP_OPTION DigiDocMemBuf* ddocSigInfo_GetSigPropDigest(SignatureInfo* pSigInfo);
789
790//============================================================
791// Sets signatures signed properties digest
792// pSigInfo - signature info object
793// value - new binary digest value
794// len - length of the value
795//============================================================
796EXP_OPTION int ddocSigInfo_SetSigPropDigest(SignatureInfo* pSigInfo, const char* value, long len);
797
798//============================================================
799// Returns signatures signed properties digest as read from file
800// pSigInfo - signature info object
801// return digest value as DigiDocMemBuf pointer or NULL
802//============================================================
803EXP_OPTION DigiDocMemBuf* ddocSigInfo_GetSigPropRealDigest(SignatureInfo* pSigInfo);
804
805//============================================================
806// Sets signatures signed properties real digest as read from file
807// pSigInfo - signature info object
808// value - new binary digest value
809// len - length of the value
810//============================================================
811EXP_OPTION int ddocSigInfo_SetSigPropRealDigest(SignatureInfo* pSigInfo, const char* value, long len);
812
813//============================================================
814// Returns signatures signed info digest as read from file
815// pSigInfo - signature info object
816// return digest value as DigiDocMemBuf pointer or NULL
817//============================================================
818EXP_OPTION DigiDocMemBuf* ddocSigInfo_GetSigInfoRealDigest(SignatureInfo* pSigInfo);
819
820//============================================================
821// Sets signatures signed info real digest as read from file
822// pSigInfo - signature info object
823// value - new binary digest value
824// len - length of the value
825//============================================================
826EXP_OPTION int ddocSigInfo_SetSigInfoRealDigest(SignatureInfo* pSigInfo, const char* value, long len);
827
828//============================================================
829// Returns signatures signature-value
830// pSigInfo - signature info object
831// return signature-value as SignatureValue pointer or NULL
832//============================================================
833EXP_OPTION SignatureValue* ddocSigInfo_GetSignatureValue(SignatureInfo* pSigInfo);
834
835//============================================================
836// Returns signatures signature-value
837// pSigInfo - signature info object
838// return signature-value as DigiDocMemBuf pointer or NULL
839//============================================================
840EXP_OPTION DigiDocMemBuf* ddocSigInfo_GetSignatureValue_Value(SignatureInfo* pSigInfo);
841
842//============================================================
843// Sets signatures signature-value
844// pSigInfo - signature info object
845// value - new binary signature value
846// len - length of the value
847//============================================================
848EXP_OPTION int ddocSigInfo_SetSignatureValue(SignatureInfo* pSigInfo, const char* value, long len);
849
850//============================================================
851// Returns signaers certs - issuer-serial
852// pSigInfo - signature info object
853// return required atribute value
854//============================================================
855EXP_OPTION const char* ddocSigInfo_GetSignersCert_IssuerSerial(const SignatureInfo* pSigInfo);
856
857//============================================================
858// Sets signers certs issuer serial
859// pSigInfo - signature info object
860// value - new value
861//============================================================
862EXP_OPTION int ddocSigInfo_SetSignersCert_IssuerSerial(SignatureInfo* pSigInfo, const char* value);
863
864//============================================================
865// Returns signaers certs - issuer-name
866// pSigInfo - signature info object
867// return required atribute value
868//============================================================
869EXP_OPTION const char* ddocSigInfo_GetSignersCert_IssuerName(const SignatureInfo* pSigInfo);
870
871//============================================================
872// Returns signaers certs - issuer-name
873// pSigInfo - signature info object
874// pMbuf - memory buffer to return hash
875// return required atribute value
876//============================================================
877EXP_OPTION const char* ddocSigInfo_GetSignersCert_IssuerNameAndHash(const SignatureInfo* pSigInfo, DigiDocMemBuf *pMbuf);
878
879//============================================================
880// Sets signers certs issuer name
881// pSigInfo - signature info object
882// value - new value
883//============================================================
884EXP_OPTION int ddocSigInfo_SetSignersCert_IssuerName(SignatureInfo* pSigInfo, const char* value);
885
886//============================================================
887// Returns signers certs digest as DigiDocMemBuf object
888// pSigInfo - signature info object
889// return signers certs digest as DigiDocMemBuf pointer or NULL
890//============================================================
891EXP_OPTION DigiDocMemBuf* ddocSigInfo_GetSignersCert_DigestValue(const SignatureInfo* pSigInfo);
892
893//============================================================
894// Sets signers certs digest
895// pSigInfo - signature info object
896// value - new binary signature value
897// len - length of the value
898//============================================================
899EXP_OPTION int ddocSigInfo_SetSignersCert_DigestValue(SignatureInfo* pSigInfo, const char* value, long len);
900
901//--------------------------------------------------
902// Finds a CertID object with required type
903// pSigInfo - signature info object [REQUIRED]
904// nType - type of CertID object [REQUIRED]
905// returns CertID pointer or NULL for error
906//--------------------------------------------------
907EXP_OPTION CertID* ddocSigInfo_GetCertIDOfType(const SignatureInfo* pSigInfo, int nType);
908
909//--------------------------------------------------
910// Finds a CertID object with required type or creates a new one
911// pSigInfo - signature info object [REQUIRED]
912// nType - type of CertID object [REQUIRED]
913// returns CertID pointer or NULL for error
914//--------------------------------------------------
915EXP_OPTION CertID* ddocSigInfo_GetOrCreateCertIDOfType(SignatureInfo* pSigInfo, int nType);
916
917//--------------------------------------------------
918// Finds last CertID object of this signature
919// pSigInfo - signature info object [REQUIRED]
920// returns CertID pointer or NULL for error
921//--------------------------------------------------
922EXP_OPTION CertID* ddocSigInfo_GetLastCertID(const SignatureInfo* pSigInfo);
923
924//--------------------------------------------------
925// Finds a CertValue object with required type
926// pSigInfo - signature info object [REQUIRED]
927// nType - type of CertValue object [REQUIRED]
928// returns CertValue pointer or NULL for error
929//--------------------------------------------------
930EXP_OPTION CertValue* ddocSigInfo_GetCertValueOfType(const SignatureInfo* pSigInfo, int nType);
931
932//--------------------------------------------------
933// Finds last CertValue
934// pSigInfo - signature info object [REQUIRED]
935// returns CertValue pointer or NULL for error
936//--------------------------------------------------
937EXP_OPTION CertValue* ddocSigInfo_GetLastCertValue(const SignatureInfo* pSigInfo);
938
939//--------------------------------------------------
940// Finds a CertValue object with required type or creates a new one
941// pSigInfo - signature info object [REQUIRED]
942// nType - type of CertValue object [REQUIRED]
943// returns CertValue pointer or NULL for error
944//--------------------------------------------------
945EXP_OPTION CertValue* ddocSigInfo_GetOrCreateCertValueOfType(SignatureInfo* pSigInfo, int nType);
946
947//--------------------------------------------------
948// Finds the signers certificate
949// pSigInfo - signature info object [REQUIRED]
950// returns certificate or NULL
951//--------------------------------------------------
952EXP_OPTION X509* ddocSigInfo_GetSignersCert(const SignatureInfo* pSigInfo);
953
954//--------------------------------------------------
955// Sets the signers certificate
956// pSigInfo - signature info object [REQUIRED]
957// pCert - certificate [REQUIRED]
958// returns error code or ERR_OK
959//--------------------------------------------------
960EXP_OPTION int ddocSigInfo_SetSignersCert(SignatureInfo* pSigInfo, X509* pCert);
961
962//--------------------------------------------------
963// Finds the OCSP responders certificate
964// pSigInfo - signature info object [REQUIRED]
965// returns certificate or NULL
966//--------------------------------------------------
967EXP_OPTION X509* ddocSigInfo_GetOCSPRespondersCert(const SignatureInfo* pSigInfo);
968
969//--------------------------------------------------
970// Sets the OCSP Responders certificate
971// pSigInfo - signature info object [REQUIRED]
972// pCert - certificate [REQUIRED]
973// returns error code or ERR_OK
974//--------------------------------------------------
975EXP_OPTION int ddocSigInfo_SetOCSPRespondersCert(SignatureInfo* pSigInfo, X509* pCert);
976
977//============================================================
978// Adds a certificate and it's certid to this signature
979// pSigInfo - signature info object [REQUIRED]
980// pCert - vertificate [REQUIRED]
981// nCertIdType - type of cert [REQUIRED]
982// return error code or ERR_OK
983//============================================================
984EXP_OPTION int ddocSigInfo_addCert(SignatureInfo* pSigInfo, X509* pCert, int nCertIdType);
985//AM
986EXP_OPTION int bdocSigInfo_addCert(SignatureInfo* pSigInfo, X509* pCert, int nCertIdType);
987
988
989
990// Returns the last SignatureInfo object
991EXP_OPTION SignatureInfo* ddocGetLastSignature(const SignedDoc* pSigDoc);
992// Returns the SignatureInfo object with the given id
993EXP_OPTION SignatureInfo* getSignatureWithId(const SignedDoc* pSigDoc, const char* id);
994// Returns the SignatureInfo for the given NotaryInfo
995EXP_OPTION SignatureInfo* ddocGetSignatureForNotary(const SignedDoc* pSigDoc, const NotaryInfo* pNotInfo);
996
997// Adds a new SignedInfo element to a SignedDoc element and initializes it
998EXP_OPTION int SignatureInfo_new(SignatureInfo **newSignatureInfo, SignedDoc* pSigDoc, const char* id);
999
1000// Sets the signature production place info (use NULL for unknown attributes)
1001EXP_OPTION int setSignatureProductionPlace(SignatureInfo* pSigInfo,
1002 const char* city, const char* state,
1003 const char* zip, const char* country);
1004// Adds a signer role
1005EXP_OPTION int addSignerRole(SignatureInfo* pSigInfo, int nCertified,
1006 const char* role, int rLen, int encode);
1007// Returns the number of signer roles
1008EXP_OPTION int getCountOfSignerRoles(SignatureInfo* pSigInfo, int nCertified);
1009// Returns the desired signer role
1010EXP_OPTION const char* getSignerRole(SignatureInfo* pSigInfo, int nCertified, int nIdx);
1011
1012// Removes this SignatureInfo from signed doc and frees it's memory
1013EXP_OPTION int SignatureInfo_delete(SignedDoc* pSigDoc, const char* id);
1014
1015// cleanup SignatureInfo memory
1016EXP_OPTION void SignatureInfo_free(SignatureInfo* pSigInfo);
1017
1018//======================< DocInfo functions >=============================
1019
1020// Adds a new DocInfo element to a SignatureInfo element and initializes it
1021EXP_OPTION int addDocInfo(DocInfo **newDocInfo, SignatureInfo* pSigInfo, const char* docId,
1022 const char* digType, const byte* digest,
1023 int digLen, const byte* mimeDig, int mimeDigLen);
1024// cleanup DocInfo memory
1025EXP_OPTION void DocInfo_free(DocInfo* pDocInfo);
1026// Returns number of DocInfos
1027EXP_OPTION int getCountOfDocInfos(const SignatureInfo* pSigInfo);
1028// Returns the desired DocInfo
1029EXP_OPTION DocInfo* getDocInfo(const SignatureInfo* pSigInfo, int idx);
1030// Returns the last DocInfo
1031EXP_OPTION DocInfo* ddocGetLastDocInfo(const SignatureInfo* pSigInfo);
1032
1033
1034// Returns the DocInfo object with the given id
1035EXP_OPTION DocInfo* getDocInfoWithId(const SignatureInfo* pSigInfo, const char* id);
1036// Sets the DocInfo objects document digest and digest type
1037EXP_OPTION void setDocInfoDigest(DocInfo* pDocInfo, const byte* digest,
1038 int digLen, const char* digType);
1039// Sets the DocInfo objects mime digest and mime type
1040EXP_OPTION void setDocInfoMimeDigest(DocInfo* pDocInfo, const byte* mimeDig, int mimeDigLen);
1041
1042// Adds all DocInfo elements in this file to a SignatureInfo element
1043EXP_OPTION int addAllDocInfos(SignedDoc* pSigDoc, SignatureInfo* pSigInfo);
1044
1045//======================< NotaryInfo functions >=============================
1046
1047// returns the number of notarys
1048EXP_OPTION int getCountOfNotaryInfos(const SignedDoc* pSigDoc);
1049// Returns the desired NotaryInfo object
1050EXP_OPTION NotaryInfo* getNotaryInfo(const SignedDoc* pSigDoc, int nIdx);
1051// Returns the last NotaryInfo object
1052EXP_OPTION NotaryInfo* ddocGetLastNotaryInfo(const SignedDoc* pSigDoc);
1053// Returns the NotaryInfo object with the given id
1054EXP_OPTION NotaryInfo* getNotaryWithId(const SignedDoc* pSigDoc, const char* id);
1055// Returns the NotaryInfo object that corresponds to the given signature
1056EXP_OPTION NotaryInfo* getNotaryWithSigId(const SignedDoc* pSigDoc, const char* sigId);
1057// Returns the NotaryInfo object that corresponds to the given signature
1058// ore creates a new one
1059EXP_OPTION NotaryInfo* getOrCreateNotaryWithSigId(SignedDoc* pSigDoc, const char* sigId);
1060
1061// Adds a new NotaryInfo element to a SignedDoc element and initializes it partly
1062EXP_OPTION int NotaryInfo_new(NotaryInfo** newNotaryInfo, SignedDoc* pSigDoc, SignatureInfo* pSigInfo);
1063// the same as above, but reads response and cert from file
1064EXP_OPTION int NotaryInfo_new_file(NotaryInfo** newNotaryInfo, SignedDoc* pSigDoc, const SignatureInfo* pSigInfo,
1065 const char* ocspRespFile, const char* notaryCertFile);
1066// cleanup NotaryInfo memory
1067EXP_OPTION void NotaryInfo_free(NotaryInfo* pNotary);
1068
1069//============================================================
1070// Returns OCSP responders id as in XML document
1071// pNotary - Notary info
1072// return DigiDocMemBuf buffer pointer or NULL for error
1073//============================================================
1074EXP_OPTION const DigiDocMemBuf* ddocNotInfo_GetResponderId(const NotaryInfo* pNotary);
1075
1076//============================================================
1077// Returns OCSP responders id value as string
1078// pNotary - Notary info
1079// return responder id value or NULL
1080//============================================================
1081EXP_OPTION const char* ddocNotInfo_GetResponderId_Value(const NotaryInfo* pNotary);
1082
1083//============================================================
1084// Sets OCSP responders id as in XML document
1085// pNotary - Notary info
1086// data - new responder id value
1087// len - length of value
1088// return DigiDocMemBuf buffer pointer or NULL for error
1089//============================================================
1090int ddocNotInfo_SetResponderId(NotaryInfo* pNotary, const char* data, long len);
1091
1092//============================================================
1093// Returns OCSP response as memory buffer
1094// pNotary - Notary info
1095// return DigiDocMemBuf buffer pointer or NULL for error
1096//============================================================
1097const DigiDocMemBuf* ddocNotInfo_GetOCSPResponse(const NotaryInfo* pNotary);
1098
1099//============================================================
1100// Retrieves OCSP responses responder id type and value
1101// pResp - OCSP response
1102// pType - buffer for type
1103// pMbufRespId - responder id
1104// returns error code or ERR_OK
1105//============================================================
1106int ddocGetOcspRespIdTypeAndValue(OCSP_RESPONSE* pResp,
1107 int *pType, DigiDocMemBuf* pMbufRespId);
1108
1109//============================================================
1110// Sets OCSP respondese value as in XML document. Must pass in
1111// binary DER data!
1112// pNotary - Notary info
1113// data - new responder id value
1114// len - length of value
1115// return DigiDocMemBuf buffer pointer or NULL for error
1116//============================================================
1117int ddocNotInfo_SetOCSPResponse(NotaryInfo* pNotary, const char* data, long len);
1118
1119//============================================================
1120// Returns OCSP response value
1121// pNotary - Notary info
1122// return OCSP_RESPONSE pointer or NULL for error. Caller must
1123// use OCSP_RESPONSE_free() to release it.
1124//============================================================
1125OCSP_RESPONSE* ddocNotInfo_GetOCSPResponse_Value(const NotaryInfo* pNotary);
1126
1127//============================================================
1128// Sets OCSP respondese value. Must pass in real OCSP_RESPONSE
1129// pNotary - Notary info
1130// data - new responder id value
1131// len - length of value
1132// return DigiDocMemBuf buffer pointer or NULL for error
1133//============================================================
1134int ddocNotInfo_SetOCSPResponse_Value(NotaryInfo* pNotary, OCSP_RESPONSE* pResp);
1135
1136//============================================================
1137// Returns OCSP responders id type as string
1138// pNotary - Notary info
1139// return responder id type or NULL. DO NOT free() it!
1140//============================================================
1141EXP_OPTION const char* ddocNotInfo_GetResponderId_Type(const NotaryInfo* pNotary);
1142
1143//============================================================
1144// Returns OCSP responses thisUpdate atribute as string
1145// pNotary - Notary info
1146// pMBuf - buffer for thisUpdate value
1147// return error code OR ERR_OK.
1148//============================================================
1149EXP_OPTION int ddocNotInfo_GetThisUpdate(const NotaryInfo* pNotary, DigiDocMemBuf* pMBuf);
1150
1151//============================================================
1152// Returns OCSP responses producedAt atribute as time_t
1153// pNotary - Notary info
1154// pTime - address of time_t variable
1155// return error code OR ERR_OK.
1156//============================================================
1157int ddocNotInfo_GetProducedAt_timet(const NotaryInfo* pNotary, time_t* pTime);
1158
1159//============================================================
1160// Returns OCSP responses producedAt from xml as time_t
1161// pNotary - Notary info
1162// pTime - address of time_t variable
1163// return error code OR ERR_OK.
1164//============================================================
1165int ddocNotInfo_GetProducedAtXml_timet(const NotaryInfo* pNotary, time_t* pTime);
1166
1167//============================================================
1168// Returns OCSP responses thisUpdate atribute as time_t
1169// pNotary - Notary info
1170// pTime - address of time_t variable
1171// return error code OR ERR_OK.
1172//============================================================
1173int ddocNotInfo_GetThisUpdate_timet(const NotaryInfo* pNotary, time_t* pTime);
1174
1175//============================================================
1176// Returns OCSP responses nextUpdate atribute as string
1177// pNotary - Notary info
1178// pMBuf - buffer for thisUpdate value
1179// return error code OR ERR_OK.
1180//============================================================
1181EXP_OPTION int ddocNotInfo_GetNextUpdate(const NotaryInfo* pNotary, DigiDocMemBuf* pMBuf);
1182
1183//============================================================
1184// Returns OCSP responses IssuerNameHash atribute
1185// pNotary - Notary info
1186// pMBuf - buffer for IssuerNameHash value
1187// return error code OR ERR_OK.
1188//============================================================
1189int ddocNotInfo_GetIssuerNameHash(const NotaryInfo* pNotary, DigiDocMemBuf* pMBuf);
1190
1191//============================================================
1192// Returns OCSP responses IssuerKeyHash atribute
1193// pNotary - Notary info
1194// pMBuf - buffer for IssuerKeyHash value
1195// return error code OR ERR_OK.
1196//============================================================
1197int ddocNotInfo_GetIssuerKeyHash(const NotaryInfo* pNotary, DigiDocMemBuf* pMBuf);
1198
1199//============================================================
1200// Returns OCSP responses real digest from response data
1201// pNotary - Notary info
1202// pMBuf - buffer for digest value
1203// return error code OR ERR_OK.
1204//============================================================
1205int ddocNotInfo_GetOcspRealDigest(const SignedDoc* pSigDoc, const NotaryInfo* pNotary, DigiDocMemBuf* pMBuf);
1206
1207//============================================================
1208// Returns OCSP response digest as in XML document
1209// pNotary - Notary info
1210// return DigiDocMemBuf buffer pointer or NULL for error
1211//============================================================
1212EXP_OPTION const DigiDocMemBuf* ddocNotInfo_GetOcspDigest(const NotaryInfo* pNotary);
1213
1214//============================================================
1215// Sets OCSP response digest id as in XML document
1216// pNotary - Notary info
1217// data - new digest value
1218// len - length of value
1219// return DigiDocMemBuf buffer pointer or NULL for error
1220//============================================================
1221int ddocNotInfo_SetOcspDigest(NotaryInfo* pNotary, const char* data, long len);
1222
1223//============================================================
1224// Returns OCSP responses signature value
1225// pNotary - Notary info
1226// pMBuf - buffer for signature value
1227// return error code OR ERR_OK.
1228//============================================================
1229int ddocNotInfo_GetOcspSignatureValue(const NotaryInfo* pNotary, DigiDocMemBuf* pMBuf);
1230
1231
1232// Removes this NotaryInfo from signed doc and frees it's memory
1233EXP_OPTION int NotaryInfo_delete(SignatureInfo* pSigInfo);
1234
1235// Calculates and stores a signature for this SignatureInfo object
1236EXP_OPTION int calculateSigInfoSignature(const SignedDoc* pSigDoc, SignatureInfo* pSigInfo, int nSigType,
1237 const char* keyfile, const char* passwd, const char* certfile);
1238
1239//============================================================
1240// Adds a certificate to Notary and initializes Notary
1241// pNotary - Notary info
1242// cert - responders certificate
1243// return error code
1244//============================================================
1245int addNotaryInfoCert(SignedDoc *pSigDoc, NotaryInfo *pNotary, X509 *cert);
1246
1247//============================================================
1248// Removes Notary cert value and id after unsucessful verification attempt
1249// pSigInfo - signature info [REQUIRED]
1250// return error code
1251//============================================================
1252int removeNotaryInfoCert(SignatureInfo* pSigInfo);
1253
1254// Calculates <SignedProperties> digest
1255EXP_OPTION int calculateSignedPropertiesDigest(SignedDoc* pSigDoc, SignatureInfo* pSigInfo);
1256// Calculates <SignedInfo> digest
1257EXP_OPTION int calculateSignedInfoDigest(SignedDoc* pSigDoc, SignatureInfo* pSigInfo, byte* digBuf, int* digLen);
1258
1259//============================================================
1260// Returns 1 if this signature has 1 reference that was verified
1261// by wrong DataFile hash calculated not using xmlns atribute
1262// pSigInfo - signature info pointer
1263//============================================================
1264DIGIDOC_DEPRECATED EXP_OPTION int verifiedByWrongDataFileHash(const SignatureInfo* pSigInfo);
1265
1266//============================================================
1267// Returns 1 if one signature has 1 reference that was verified
1268// by wrong DataFile hash calculated not using xmlns atribute
1269// pSigDoc - signed doc container pointer
1270//============================================================
1271EXP_OPTION int hasSignatureWithWrongDataFileHash(const SignedDoc* pSigDoc);
1272
1273//============================================================
1274// Calculates and stores a signature for this SignatureInfo object
1275// Uses PKCS#12 file to sign the info
1276// pSigInfo - signature info object
1277// nSigType - signature type code
1278// szPkcs12File - PKCS#12 file
1279// passwd - key password
1280//============================================================
1281EXP_OPTION int calculateSignatureWithPkcs12(SignedDoc* pSigDoc, SignatureInfo* pSigInfo,
1282 const char* szPkcs12File, const char* passwd);
1283
1284#ifdef __cplusplus
1285}
1286#endif
1287
1288
1289#endif // __DIGIDOC_OBJ_H__
1290
1291
Definition DigiDocObj.h:87
Definition DigiDocObj.h:97
Definition DigiDocObj.h:110
Definition DigiDocObj.h:116
Definition DigiDocObj.h:122
Definition DigiDocObj.h:61
Definition DigiDocMem.h:32
Definition DigiDocObj.h:38
Definition DigiDocObj.h:139
Definition DigiDocObj.h:154
Definition DigiDocObj.h:47
Definition DigiDocObj.h:73
Definition DigiDocObj.h:177
Definition DigiDocObj.h:54