secureswitools/swisistools/source/signsislib/sissignaturecertificatechain.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * SIGNATURECERTIFICATECHAIN.H
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file 
       
    22  @publishedPartner
       
    23  @released
       
    24 */
       
    25 
       
    26 #ifndef __SIGNATURECERTIFICATECHAIN_H__
       
    27 #define __SIGNATURECERTIFICATECHAIN_H__
       
    28 
       
    29 #include <vector>
       
    30 
       
    31 #include "signaturedata.h"
       
    32 #include "certchaindata.h"
       
    33 #include "sisarray.h"
       
    34 #include "certificateinfo.h"
       
    35 #include "siscertificatechain.h"
       
    36 
       
    37 
       
    38 class CSISController;
       
    39 class CSignature;
       
    40 class CSignatureCertChainData;
       
    41 
       
    42 /**
       
    43  * This class represents SISSignatureCertificateChain field in 
       
    44  * SISX file format. Refer software install file format document 
       
    45  * for more details.
       
    46  * 
       
    47  * SISSignatureCertificateChain contains the signatures used to 
       
    48  * sign the SIS file and the certificate chain needed to
       
    49  * validate the signatures
       
    50  */
       
    51 class CSisSignatureCertificateChain
       
    52 	{
       
    53 public:
       
    54 	/**
       
    55 	 * Constructor.
       
    56 	 */
       
    57 	explicit CSisSignatureCertificateChain (CSignatureCertChainData& aSisSignatureCertChain);
       
    58 	/**
       
    59 	 * Cleanup owned resources.
       
    60 	 */
       
    61 	~CSisSignatureCertificateChain();
       
    62 
       
    63 public:
       
    64 	/**
       
    65 	 * Function creates an instance of CSignature class (which represents a signature)
       
    66 	 * and then call its Sign method to actually sign the content. Then the instance 
       
    67 	 * of CSignature is added in the already existing list of signatures.
       
    68 	 *  
       
    69 	 * @param aAlgorithm Algorithm by which the content needs to be signed.
       
    70 	 * @param aCertificate public Key
       
    71 	 * @param aPrivateKey private key to sign the content.
       
    72 	 * @param aPassPhrase pass phrase by which the private key is encrypted.
       
    73 	 * @param aBuffer content to be signed.
       
    74 	 * @param aBufferSize content length.
       
    75 	 */
       
    76 	void Sign (	const CSISSignatureAlgorithm::TAlgorithm aAlgorithm, const std::wstring& aCertificate,
       
    77 				const std::wstring& aPrivateKey, const std::wstring& aPassPhrase,  const TUint8* aBuffer, const TUint32 aBufferSize);
       
    78 	/**
       
    79 	 * Function to veriify the signature of the controller. 
       
    80 	 * @param aController Controller whose signature needs to be verified.
       
    81 	 * @param aParentHeaderSize controller's header position.
       
    82 	 */
       
    83 	void VerifySignature (const CSISController* aController, const TSISStream::pos_type aParentHeaderSize) const;
       
    84 
       
    85 	/**
       
    86 	 * Function to extract certificate chain. All the certificates present
       
    87 	 * in the chain will be extracted into a single certificate file (.pem)
       
    88 	 * @param aCertFileName Certificate chain file name
       
    89 	 */
       
    90 
       
    91 	void ExtractCertificateChain (std::string& aCertFileName);
       
    92 	
       
    93 	/**
       
    94 	 * Retrieve the certificate chain. Where each certificate of the
       
    95 	 * chain is represented by CCertificateInfo class.
       
    96 	 */
       
    97 	inline const std::vector<CCertificateInfo*>& CertChain() const;
       
    98 
       
    99 private:
       
   100 	CSisSignatureCertificateChain (const CSisSignatureCertificateChain& aInitialiser):iSisSignatureCertChain(aInitialiser.iSisSignatureCertChain)
       
   101 	{}
       
   102 
       
   103 protected:
       
   104 	std::vector<CSignature*>	iSignatures;
       
   105 	CSignatureCertChainData&	iSisSignatureCertChain;
       
   106 	CSisCertificateChain*		iCertificateChain;
       
   107 	};
       
   108 
       
   109 
       
   110 inline void CSisSignatureCertificateChain::ExtractCertificateChain (std::string& aCertFileName)
       
   111 	{
       
   112 	iCertificateChain->ExtractCertificateChain (aCertFileName);
       
   113 	}
       
   114 
       
   115 inline const std::vector<CCertificateInfo*>& CSisSignatureCertificateChain::CertChain() const
       
   116 	{
       
   117 	return iCertificateChain->CertChain();
       
   118 	}
       
   119 
       
   120 #endif // __SIGNATURECERTIFICATECHAIN_H__
       
   121