secureswitools/swisistools/source/signsislib/signsis.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2008-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 *
       
    16 */
       
    17 
       
    18 
       
    19 /**
       
    20  @file 
       
    21  @publishedPartner
       
    22  @released
       
    23 */
       
    24 
       
    25 #ifndef __SIGNING_H__
       
    26 #define __SIGNING_H__
       
    27 
       
    28 #include <iostream>
       
    29 
       
    30 #include "sisblob.h"
       
    31 #include "siscontents.h"
       
    32 #include "sissignaturealgorithm.h"
       
    33 
       
    34 // Forward declarations
       
    35 class CSISDataUnit;
       
    36 class CSISInstallBlock;
       
    37 class CSisSignatureCertificateChain;
       
    38 
       
    39 class CSignSis
       
    40 	{
       
    41 public:
       
    42 	/**
       
    43 	 * Parameterized constructor
       
    44 	 * @param aSisFileName sis file name
       
    45 	 */
       
    46 	explicit CSignSis(const std::wstring aSisFileName);
       
    47 	/**
       
    48 	 * Destructor
       
    49 	 */
       
    50 	~CSignSis();
       
    51 public:
       
    52 	/**
       
    53 	 * Sign the sis with given certificate and key
       
    54 	 * @param aOutputFileName - Signed sis file name
       
    55 	 * @param aCertificate - certificate path
       
    56 	 * @param aPrivateKey - private key path
       
    57 	 * @param aPassPhrase - password/passphrase by which the private key is encrypted.
       
    58 	 * @param aAlgorithm - algorithm used for signing.
       
    59 	 */
       
    60 	void SignSis(	const std::wstring& aOutputFileName, 
       
    61 					const std::wstring& aCertificate, 
       
    62 					const std::wstring& aPrivateKey, 
       
    63 					const std::wstring& aPassPhrase, 
       
    64 					const CSISSignatureAlgorithm::TAlgorithm aAlgorithm);
       
    65 	/**
       
    66 	 * Remove the most recent signature from the sis file.
       
    67 	 * @param aOutputFileName - Sis file with last signature removed
       
    68 	 */
       
    69 	void RemoveSignature(const std::wstring& aOutputFileName);
       
    70 	/**
       
    71 	 * Remove all signatures from the sis file.
       
    72 	 * @param aOutputFileName - Sis file name of the unsigned sis.
       
    73 	 */
       
    74 	void RemoveAllSignatures(const std::wstring& aOutputFileName);
       
    75 
       
    76 	/**
       
    77 	 * This function will verify CSISContents. In case the controller
       
    78 	 * is not a valid one it will throw an exception (CSISException).
       
    79 	 */
       
    80 	void Verify();
       
    81 	/**
       
    82 	 * Iterate through each of the files present in the install block. The hash value
       
    83 	 * associated with each file will be compared with a value re-computed from the file 
       
    84 	 * data. This is to ensure that a malicious file cannot be substituted after the 
       
    85 	 * sis file has been signed. In case of any abnormality the funtion will throw an 
       
    86 	 * exception (CSISException).
       
    87 	 * 
       
    88 	 * @param aInstallBlock Install block from which the files will be tested.
       
    89 	 * @param aDataUnit To retrieve file data.
       
    90 	 */
       
    91 	void VerifyHashAgainstFileData (const CSISInstallBlock& aInstallBlock, const CSISDataUnit& aDataUnit);
       
    92 
       
    93 private:
       
    94 	CSignSis(const CSignSis&){}
       
    95 
       
    96 private:
       
    97 	CSISContents	iSisContents;
       
    98 	};
       
    99 
       
   100 #endif // __SIGNING_H__
       
   101