00001 #ifndef _DIGISIG_H 00002 #define _DIGISIG_H 00003 00004 00005 #include <openssl/pkcs7.h> 00006 #include<set> 00007 00008 00009 enum ReqType {ISSUER, SUBJECT, FROM, TO }; 00010 00011 00017 class CDigiSig{ 00018 00019 public: 00020 CDigiSig(); 00021 virtual ~CDigiSig(); 00022 int Sign(const std::string& sPrivateKey, const std::string& sCommand, uint8_t* sig_buf, unsigned int & iSigLen); 00023 bool Verify(const std::string& sPublicKey, const std::string& sCommand, const uint8_t* sig_buf, unsigned int iSigLen); 00027 bool GetIssuerName(const std::string& sPublicKey, std::string& sIssuerName ); 00031 bool VerifyByCA(const std::string& sCert, const std::string& sFile); 00032 00036 bool GetSubjectName(const std::string& sPublicKey, std::string& sSubjectName ); 00037 00042 int SignSMIME(const std::string& sCert, const std::string& sPrivateKey, const std::string& sCommandFile, const std::string& sOutFile, const std::string& sTo, const std::string& sFrom, const std::string& sSubject, bool bAddNoCert=false); 00043 00044 00050 int VerifySMIME(const std::string& sFileToVerify, const std::string& sCAChain, const std::string& sDataFile, const std::string& sSignerCert=std::string()); 00051 00055 int ParseMIME(const std::string& sFile, ReqType req, std::string& sOut); 00056 int GetAllIssuer(const std::string& sCert, std::set<std::string>& sIssuerSet); 00057 00058 int GetSenderCertificate(const std::string& sMsg, const std::string& sFileToSave); 00059 int save_certs(const char *signerfile, STACK_OF(X509) *signers); 00060 00061 void print_file(const std::string& sFileName); 00062 00063 00064 private: 00065 bool GetParam(const std::string& sPublicKey, std::string& sParamName, const ReqType eReq ); 00066 int GetParamsFromPKCS7(const PKCS7 *p7, ReqType req, std::string& sOut); 00067 00068 00069 00070 00071 }; 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 #endif// _SIGNATURE_H