Eneboo - Documentación para desarrolladores
src/libdigidoc/DigiDocVerify.h
Ir a la documentación de este archivo.
00001 #ifndef __DIGIDOC_VERIFY_H__
00002 #define __DIGIDOC_VERIFY_H__
00003 //==================================================
00004 // FILE:        DigiDocVerify.h
00005 // PROJECT:     Digi Doc
00006 // DESCRIPTION: DigiDoc verification routines
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/DigiDocObj.h>
00027 #include <libdigidoc/DigiDocMem.h>
00028 #include <openssl/x509.h>
00029 #include <openssl/ocsp.h>
00030 
00031 //==========< XML generation routines >========================
00032 
00033 #ifdef  __cplusplus
00034 extern "C" {
00035 #endif
00036 
00037 // structure used to report paths of data files
00038 typedef struct FilePath_st {
00039         char* szFileName;
00040         char* szPath;
00041 } FilePath;
00042 
00043 //--------------------------------------------------
00044 // Frees file paths array
00045 // pPaths - FilePaths array
00046 // nPaths - number of paths
00047 //--------------------------------------------------
00048 EXP_OPTION void FilePaths_free(FilePath* pPaths, int nPaths);
00049 
00050 //--------------------------------------------------
00051 // Finds all detatched files and returns their
00052 // names. The user can now set the path portion.
00053 // Allocaes new memory that caller must free 
00054 // with FilePaths_free()
00055 // pSigDoc - signed document
00056 // pPaths - pointer to FilePaths array
00057 // nPaths - pointer to number of paths
00058 //--------------------------------------------------
00059 EXP_OPTION int findDetatchedDataFiles(SignedDoc* pSigDoc, FilePath** pPaths, int* nPaths);
00060 
00061 // verifies files signature
00062 EXP_OPTION int verifyFileSignature(const char* szFileName, int nDigestType,
00063                                                 byte* pSigBuf, int nSigLen,
00064                                                 const char *certfile);
00065 EXP_OPTION int verifySignature(const char* szData, unsigned long dataLen, int nDigestType,
00066           byte* pSigBuf, int nSigLen, X509* cert);
00067 
00068 // Compares two byte arrays and returns 0 for OK
00069 EXP_OPTION int compareByteArrays(const byte* dig1, int len1, const byte* dig2, int len2);
00070 
00071 // verifies one doc's check digests in this signature
00072 EXP_OPTION int verifySigDocDigest(const SignedDoc* pSigDoc, const SignatureInfo* pSigInfo, 
00073                                  const DocInfo* pDocInfo, const char* szFileName, 
00074                                  const char* szDataFile);
00075 // verifies the mime digest of this doc in this signature
00076 EXP_OPTION int verifySigDocMimeDigest(const SignedDoc* pSigDoc, const SignatureInfo* pSigInfo, 
00077                                        const DocInfo* pDocInfo, const char* szFileName);
00078 
00079 // verifies this one signature
00080 EXP_OPTION int verifySignatureInfo(const SignedDoc* pSigDoc, const SignatureInfo* pSigInfo, 
00081                                                 const char* signerCA, const char* szDataFile, int bUseCA,
00082                                                 FilePath* pPaths, int nPaths);
00083 // verifies the whole document (returns on first err)
00084 EXP_OPTION int verifySigDoc(const SignedDoc* pSigDoc, const char* signerCA, 
00085                                                         const char** caFiles, const char* caPath, const char* notCert, 
00086                                                         const char* szDataFile, int bUseCA,
00087                                                         FilePath* pPaths, int nPaths);
00088 
00089 
00090 // Verifies the certificates signed attributes
00091 EXP_OPTION int verifySigCert(const SignatureInfo* pSigInfo);
00092 
00093 
00094 // Verfies NotaryInfo signature
00095 EXP_OPTION int verifyNotaryInfo(const SignedDoc* pSigDoc, const SignatureInfo* pSigInfo,
00096                                 const NotaryInfo* pNotInfo,  
00097                                 const char ** caFiles, const char *CApath, const char* notCertFile);
00098 
00099 // Verifies the certificates signed attributes
00100 EXP_OPTION int verifyNotCert(const SignatureInfo* pSigInfo, const NotaryInfo* pNotInfo);
00101 
00102 // Verfies NotaryInfo digest
00103 EXP_OPTION int verifyNotaryDigest(const SignedDoc* pSigDoc, const NotaryInfo* pNotInfo);
00104 
00105 // verifies signed doc 
00106 EXP_OPTION int verifySigDocCERT(const SignedDoc* pSigDoc, const void* signerCA, 
00107                                 const X509** caCerts, 
00108                                 const char* caPath, const X509* notCert, 
00109                                 const char* szDataFile, int bUseCA,
00110                                 FilePath* pPaths, int nPaths);
00111 
00112 
00113 // Verifies this signature
00114   EXP_OPTION int verifySignatureInfoCERT(const SignedDoc* pSigDoc, 
00115                                          const SignatureInfo* pSigInfo, 
00116                                          const void* signerCACert, const char* szDataFile, int bUseCA,
00117                                          FilePath* pPaths, int nPaths);
00118 // Checks if the cert has been signed by this CA-cert
00119 EXP_OPTION int isCertSignedByCERT(const X509* cert, const X509* caCert);
00120 
00121 
00122 // Verfies NotaryInfo signature
00123 EXP_OPTION int verifyNotaryInfoCERT(const SignedDoc* pSigDoc, 
00124                                     const SignatureInfo* pSigInfo,
00125                                     const NotaryInfo* pNotInfo,  
00126                                     const X509** caCerts, 
00127                                     const char *CApath, const X509* notCert);
00128 
00129 EXP_OPTION int verifySigDocSigPropDigest(const SignatureInfo* pSigInfo);
00130 
00131 // Calculates the digest of NotaryInfo
00132 EXP_OPTION int calculateNotaryInfoDigest(const SignedDoc* pSigDoc, 
00133                                         const NotaryInfo* pNotInfo, byte* digBuf, int* digLen);
00134 
00135 int readTagContents(char** data, const char* fileName, 
00136                                         const char* tagName, int nAttrs,
00137                                         const char** attNames, const char** attValues,
00138                                         int withTags);
00139 
00140   X509_ALGOR* setSignAlgorithm(const EVP_MD * type);
00141 
00142 int setup_verifyCERT(X509_STORE **newX509_STORE,
00143                      const char *CApath, 
00144                      const X509** certs);
00145                      
00146 EXP_OPTION int verifyEstIDSignature(const byte* digest, int digestLen, int nDigestType,
00147                                         byte* pSigBuf, int nSigLen, X509* cert);
00148 
00149 #ifdef  __cplusplus
00150 }
00151 #endif
00152 
00153 #endif // __DIGIDOC_VERIFY_H__
00154 
00155 
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'