/* Copyright (C) 2003 Frédéric Giudicelli (contact_nos@yahoo.com). All rights reserved. This product includes cryptographic software written by Eric Young (eay@cryptsoft.com) This program is released under the GPL with the additional exemption that compiling, linking, and/or using OpenSSL is allowed. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef ENTITY_CA_ASN1_H #define ENTITY_CA_ASN1_H #include #include #include #include #include #include "CA_Handler.h" #include "Entity.h" /*! This structure represent the local conf. */ typedef struct st_LOCAL_CA_CONF { ENTITY_CONF * conf; //!< The conf. INTERNAL_PKI_CA * cas; //!< The PKI internal CA. INTERNAL_CA_KEY * privkey; /*! When generating the real CA certificate we need to store temporaly the key, once the parent CA has generated our certificate we will call CA_Handler:Create, with the cert end this key. */ STACK_OF(X509) * parentCerts; //!< The parent certificates of the CA. }LOCAL_CA_CONF; DECLARE_ASN1_ITEM(LOCAL_CA_CONF) /*! This class is the representation of LOCAL_CA_CONF */ class LocalCaConf : public NewPKIObject, public LocalEntityConf { public: /*! \brief This is the constructor. */ LocalCaConf(); /*! \brief This is the constructor. * \param other [IN] the datas to copy from. */ LocalCaConf(const LocalCaConf & other); /*! \brief This is the destructor. */ ~LocalCaConf(); /*! \brief This function converts a LOCAL_CA_CONF to a LocalCaConf. * \param Datas [IN] the datas to load from. * \return true on success, false on failure. */ bool load_Datas(const LOCAL_CA_CONF * Datas); /*! \brief This function converts a LocalCaConf to a LOCAL_CA_CONF. * \param Datas [OUT] the datas to copy to. * \return true on success, false on failure. */ bool give_Datas(LOCAL_CA_CONF ** Datas) const; /*! \brief This function clears all the internals. */ void Clear(); /*! \brief This function returns the ASN1_ITEM of LOCAL_CA_CONF. * \return The ASN1_ITEM. */ static const ASN1_ITEM * get_ASN1_ITEM(); /*! \brief This function sets INTERNAL_PKI_CA::cas. * \param c_cas [IN] the datas. * \return true on success, false on failure. */ bool set_cas(const InternalPkiCa & c_cas); /*! \brief This function returns INTERNAL_PKI_CA::cas. * \return The value of INTERNAL_PKI_CA::cas. */ const InternalPkiCa & get_cas() const; /*! \brief This function returns INTERNAL_PKI_CA::cas. * \return The value of INTERNAL_PKI_CA::cas. */ InternalPkiCa & get_cas(); /*! \brief This function sets ENTITY_CONF::conf. * \param c_conf [IN] the datas. * \return true on success, false on failure. */ bool set_conf(const EntityConf & c_conf); /*! \brief This function returns ENTITY_CONF::conf. * \return The value of ENTITY_CONF::conf. */ const EntityConf & get_conf() const; /*! \brief This function returns ENTITY_CONF::conf. * \return The value of ENTITY_CONF::conf. */ EntityConf & get_conf(); /*! \brief This function sets X509::parentCerts. * \param c_parentcerts [IN] the datas. * \return true on success, false on failure. */ bool set_parentcerts(const mVector< PKI_CERT > & c_parentcerts); /*! \brief This function returns X509::parentCerts. * \return The value of X509::parentCerts. */ const mVector< PKI_CERT > & get_parentcerts() const; /*! \brief This function returns X509::parentCerts. * \return The value of X509::parentCerts. */ mVector< PKI_CERT > & get_parentcerts(); /*! \brief This function sets INTERNAL_CA_KEY::privkey. * \param c_privkey [IN] the datas. * \return true on success, false on failure. */ bool set_privkey(const InternalCaKey & c_privkey); /*! \brief This function returns INTERNAL_CA_KEY::privkey. * \return The value of INTERNAL_CA_KEY::privkey. */ const InternalCaKey & get_privkey() const; /*! \brief This function returns INTERNAL_CA_KEY::privkey. * \return The value of INTERNAL_CA_KEY::privkey. */ InternalCaKey & get_privkey(); /*! \brief This function converts the local instance to a Asn1EncryptSign. * \param cryptinfo [OUT] The result. * \param sig_pkey [IN] The signature private key. * \param crypt_pkey [IN] The encipherment public key. * \param sig_md [IN] The hash algorythm. * \param crypt_cypher [IN] The symetrical encipherment hash. * \return true on success, false on failure. */ bool to_SignEncrypt(Asn1EncryptSign & cryptinfo, const EVP_PKEY * sig_pkey, const EVP_PKEY * crypt_pkey, const EVP_MD * sig_md, const EVP_CIPHER * crypt_cypher) const; /*! \brief This function loads the local instance from a Asn1EncryptSign. * \param cryptinfo [IN] The signed and crypted datas. * \param sig_pkey [IN] The signature private key. * \param crypt_pkey [IN] The encipherment public key. * \return true on success, false on failure. */ bool from_SignEncrypt(const Asn1EncryptSign & cryptinfo, const EVP_PKEY * sig_pkey, const EVP_PKEY * crypt_pkey); /*! \brief This function copies a LocalCaConf to another. * \param other [IN] the datas to copy from. * \return true on success, false on failure. */ bool operator=(const LocalCaConf & other); /*! \brief This member is an empty instance of LocalCaConf. */ static LocalCaConf EmptyInstance; private: InternalPkiCa m_cas; EntityConf m_conf; mVector< PKI_CERT > m_parentcerts; InternalCaKey m_privkey; void resetAll(); void freeAll(); protected: }; #endif // #ifndef ENTITY_CA_ASN1_H