williamr@4: /* williamr@4: * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@4: * All rights reserved. williamr@4: * This component and the accompanying materials are made available williamr@4: * under the terms of the License "Eclipse Public License v1.0" williamr@4: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@4: * williamr@4: * Initial Contributors: williamr@4: * Nokia Corporation - initial contribution. williamr@4: * williamr@4: * Contributors: williamr@4: * williamr@4: * Description: williamr@4: * crypto parameters interface williamr@4: * williamr@4: */ williamr@4: williamr@4: williamr@4: /** williamr@4: @file williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@4: williamr@4: #ifndef __CRYPTOPARAMS_H__ williamr@4: #define __CRYPTOPARAMS_H__ williamr@4: williamr@4: #include williamr@4: williamr@4: namespace CryptoSpi williamr@4: { williamr@4: /** williamr@4: Abstract base class for generic crypto parameters to enable plug-in williamr@4: specific parameters and the externalisation of plug-ins. The type williamr@4: of the sub-class is identified by the GetType method. williamr@4: williamr@4: All sub-class contain copies of (instead of references to) the williamr@4: supplied values. williamr@4: */ williamr@4: NONSHARABLE_CLASS(CCryptoParam) : public CBase williamr@4: { williamr@4: public: williamr@4: williamr@4: /** williamr@4: The definition of the data type of the embedded value. williamr@4: Other data types may be added in future so applications williamr@4: should not panic if the type is not recognised. williamr@4: */ williamr@4: enum TParamType williamr@4: { williamr@4: /** williamr@4: RCryptoIntParam williamr@4: */ williamr@4: EInt = 1, williamr@4: /** williamr@4: RCryptoBigIntParam williamr@4: */ williamr@4: EBigInt = 2, williamr@4: /** williamr@4: RCryptoDesC8Param williamr@4: */ williamr@4: EDesC8 = 3, williamr@4: /** williamr@4: RCryptoDesC16Param williamr@4: */ williamr@4: EDesC16 = 4, williamr@4: }; williamr@4: williamr@4: /** williamr@4: Returns the data type of the crypto parameter williamr@4: @return The data type of the crypto parameter williamr@4: */ williamr@4: IMPORT_C TInt Type() const; williamr@4: williamr@4: /** williamr@4: Returns the Uid of the crypto parameter williamr@4: @return The Uid of the crypto parameter williamr@4: */ williamr@4: IMPORT_C TUid Uid() const; williamr@4: williamr@4: /** williamr@4: Destructor williamr@4: */ williamr@4: IMPORT_C ~CCryptoParam(); williamr@4: williamr@4: protected: williamr@4: /** williamr@4: * @internalComponent williamr@4: * williamr@4: * Constructor williamr@4: * @param aType The data type identifier for the sub-class. williamr@4: * @param aUid The Uid of the cryptoparam williamr@4: */ williamr@4: CCryptoParam(TParamType aType, TUid aUid); williamr@4: williamr@4: protected: williamr@4: /** williamr@4: The data type of the embedded value williamr@4: */ williamr@4: TParamType iType; williamr@4: williamr@4: /** williamr@4: The Uid of the crypto parameter williamr@4: */ williamr@4: TUid iUid; williamr@4: }; williamr@4: williamr@4: /** williamr@4: CryptoParam class that wraps a TInt williamr@4: */ williamr@4: NONSHARABLE_CLASS(CCryptoIntParam) : public CCryptoParam williamr@4: { williamr@4: public: williamr@4: /** williamr@4: Factory method for allocating a new CCryptoIntParam object williamr@4: that contains a copy of the supplied TInt williamr@4: @param aValue The TInt to be wrapped (copied) williamr@4: @param aUid The UID of the CryptoParam williamr@4: @return A pointer to a CCryptoIntParam instance williamr@4: */ williamr@4: IMPORT_C static CCryptoIntParam* NewL(TInt aValue, TUid aUid); williamr@4: williamr@4: /** williamr@4: Factory method for allocating a new CCryptoIntParam object williamr@4: that contains a copy of the supplied TInt williamr@4: Leaves the pointer of the CryptoParam on the cleanup stack williamr@4: @param aValue The TInt to be wrapped (copied) williamr@4: @param aUid The UID of the CryptoParam williamr@4: @return A pointer to a CCryptoIntParam instance williamr@4: */ williamr@4: IMPORT_C static CCryptoIntParam* NewLC(TInt aValue, TUid aUid); williamr@4: williamr@4: /** williamr@4: Returns the embedded value. williamr@4: @return The embedded integer williamr@4: */ williamr@4: IMPORT_C TInt Value() const; williamr@4: williamr@4: /** williamr@4: Destructor williamr@4: */ williamr@4: IMPORT_C ~CCryptoIntParam(); williamr@4: williamr@4: private: williamr@4: /** williamr@4: Constructor williamr@4: @param aValue The integer to wrap williamr@4: @param aUid The UID of the crypto parameter williamr@4: */ williamr@4: CCryptoIntParam(TInt aValue, TUid aUid); williamr@4: williamr@4: private: williamr@4: /** williamr@4: The embedded value williamr@4: */ williamr@4: TInt iValue; williamr@4: }; williamr@4: williamr@4: /** williamr@4: Crypto param class the wraps an RInteger williamr@4: */ williamr@4: NONSHARABLE_CLASS(CCryptoBigIntParam) : public CCryptoParam williamr@4: { williamr@4: public: williamr@4: /** williamr@4: Factory method for allocating a new CCryptoBigIntParam object williamr@4: that contains a copy of the supplied TInteger object. williamr@4: @param aValue The TInteger to be wrapped (copied) williamr@4: @param aUid The UID of the CryptoParam williamr@4: @return A pointer to a CCryptoBigIntParam instance williamr@4: */ williamr@4: IMPORT_C static CCryptoBigIntParam* NewL(const TInteger& aValue, TUid aUid); williamr@4: williamr@4: /** williamr@4: Factory method for allocating a new CCryptoBigIntParam object williamr@4: that contains a copy of the supplied TInteger object. williamr@4: Leaves the pointer of the CryptoParam onto the cleanup stack. williamr@4: @param aValue The TInteger to be wrapped (copied) williamr@4: @param aUid The UID of the CryptoParam williamr@4: @return A pointer to a CCryptoBigIntParam instance williamr@4: */ williamr@4: IMPORT_C static CCryptoBigIntParam* NewLC(const TInteger& aValue, TUid aUid); williamr@4: williamr@4: /** williamr@4: Returns the embedded value. williamr@4: @return A reference to the embedded TInteger williamr@4: */ williamr@4: IMPORT_C const TInteger& Value() const; williamr@4: williamr@4: /** williamr@4: Destructor williamr@4: */ williamr@4: IMPORT_C ~CCryptoBigIntParam(); williamr@4: williamr@4: private: williamr@4: /** williamr@4: Constructor williamr@4: */ williamr@4: CCryptoBigIntParam(); williamr@4: williamr@4: /** williamr@4: Constructor williamr@4: @param aUid The UID of the crypto parameter williamr@4: */ williamr@4: CCryptoBigIntParam(TUid aUid); williamr@4: williamr@4: /** williamr@4: Second Phase Constructor williamr@4: @param aValue The TInteger to wrap williamr@4: */ williamr@4: void ConstructL(const TInteger& aValue); williamr@4: williamr@4: private: williamr@4: /** williamr@4: The copied RInteger williamr@4: */ williamr@4: RInteger iValue; williamr@4: }; williamr@4: williamr@4: /** williamr@4: Crypto param class that wraps an 8-bit constant descriptor williamr@4: */ williamr@4: NONSHARABLE_CLASS(CCryptoDesC8Param) : public CCryptoParam williamr@4: { williamr@4: public: williamr@4: /** williamr@4: Factory method for allocating a new CCryptoDesC8Param object williamr@4: that contains a copy of the supplied RInteger object. williamr@4: @param aValue The TDesC* to be wrapped (copied) williamr@4: @param aUid The Uid of the CryptoParam williamr@4: @return A pointer to a CCryptoDesC8Param instance williamr@4: */ williamr@4: IMPORT_C static CCryptoDesC8Param* NewL(const TDesC8& aValue, TUid aUid); williamr@4: williamr@4: /** williamr@4: Factory method for allocating a new CCryptoDesC8Param object williamr@4: that contains a copy of the supplied RInteger object. williamr@4: Leaves the pointer of the CryptoParam on the cleanup stack williamr@4: @param aValue The TDesC* to be wrapped (copied) williamr@4: @param aUid The Uid of the CryptoParam williamr@4: @return A pointer to a CCryptoDesC8Param instance williamr@4: */ williamr@4: IMPORT_C static CCryptoDesC8Param* NewLC(const TDesC8& aValue, TUid aUid); williamr@4: williamr@4: /** williamr@4: Returns the embedded value. williamr@4: @return A reference to the embedded TDesC8 williamr@4: */ williamr@4: IMPORT_C const TDesC8& Value() const; williamr@4: williamr@4: /** williamr@4: Destructor williamr@4: */ williamr@4: IMPORT_C ~CCryptoDesC8Param(); williamr@4: williamr@4: private: williamr@4: /** williamr@4: Constructor williamr@4: */ williamr@4: CCryptoDesC8Param(); williamr@4: williamr@4: /** williamr@4: Constructor williamr@4: @param aUid The UID of the crypto parameter williamr@4: */ williamr@4: CCryptoDesC8Param(TUid aUid); williamr@4: williamr@4: /** williamr@4: Second Phase Constructor williamr@4: @param aValue The DesC8 to wrap williamr@4: */ williamr@4: void ConstructL(const TDesC8& aValue); williamr@4: williamr@4: private: williamr@4: /** williamr@4: The copied descriptor williamr@4: */ williamr@4: HBufC8* iValue; williamr@4: }; williamr@4: williamr@4: /** williamr@4: Crypto param class that wraps an 16-bit constant descriptor williamr@4: */ williamr@4: NONSHARABLE_CLASS(CCryptoDesC16Param) : public CCryptoParam williamr@4: { williamr@4: public: williamr@4: /** williamr@4: Factory method for allocating a new CCryptoDesC8Param object williamr@4: that contains a copy of the supplied RInteger object. williamr@4: @param aValue The TDesC* to be wrapped (copied) williamr@4: @param aUid The Uid of the CryptoParam williamr@4: @return A pointer to a CCryptoDesC8Param instance williamr@4: */ williamr@4: IMPORT_C static CCryptoDesC16Param* NewL(const TDesC16& aValue, TUid aUid); williamr@4: williamr@4: /** williamr@4: Factory method for allocating a new CCryptoDesC16Param object williamr@4: that contains a copy of the supplied RInteger object. williamr@4: Leaves the pointer of the CryptoParam on the cleanup stack williamr@4: @param aValue The TDesC* to be wrapped (copied) williamr@4: @param aUid The Uid of the CryptoParam williamr@4: @return A pointer to a CCryptoDesC16Param instance williamr@4: */ williamr@4: IMPORT_C static CCryptoDesC16Param* NewLC(const TDesC16& aValue, TUid aUid); williamr@4: williamr@4: /** williamr@4: Returns the embedded value. williamr@4: @return A reference to the embedded TDesC16 williamr@4: */ williamr@4: IMPORT_C const TDesC16& Value() const; williamr@4: williamr@4: /** williamr@4: Destructor williamr@4: */ williamr@4: IMPORT_C ~CCryptoDesC16Param(); williamr@4: williamr@4: private: williamr@4: /** williamr@4: Constructor williamr@4: */ williamr@4: CCryptoDesC16Param(); williamr@4: williamr@4: /** williamr@4: Constructor williamr@4: @param aUid The UID of the crypto parameter williamr@4: */ williamr@4: CCryptoDesC16Param(TUid aUid); williamr@4: williamr@4: /** williamr@4: Second Phase Constructor williamr@4: @param aValue The DesC16 to wrap williamr@4: */ williamr@4: void ConstructL(const TDesC16& aValue); williamr@4: williamr@4: private: williamr@4: /** williamr@4: The copied descriptor williamr@4: */ williamr@4: HBufC16* iValue; williamr@4: }; williamr@4: williamr@4: NONSHARABLE_CLASS(CCryptoParams) : public CBase williamr@4: { williamr@4: public: williamr@4: IMPORT_C static CCryptoParams* NewL(void); williamr@4: IMPORT_C static CCryptoParams* NewLC(void); williamr@4: williamr@4: /** williamr@4: * Various adding methods (CCryptoParams takes a copy) williamr@4: */ williamr@4: IMPORT_C void AddL(const TInteger& aParam, TUid aUid); williamr@4: IMPORT_C void AddL(const TInt aParam, TUid aUid); williamr@4: IMPORT_C void AddL(const TDesC8& aParam, TUid aUid); williamr@4: IMPORT_C void AddL(const TDesC16& aParam, TUid aUid); williamr@4: williamr@4: /** williamr@4: * Various retrieving methods williamr@4: */ williamr@4: IMPORT_C const TInteger& GetBigIntL(TUid aUid) const; williamr@4: IMPORT_C TInt GetTIntL(TUid aUid) const; williamr@4: IMPORT_C const TDesC8& GetTDesC8L(TUid aUid) const; williamr@4: IMPORT_C const TDesC16& GetTDesC16L(TUid aUid) const; williamr@4: IMPORT_C const RPointerArray& GetParams() const; williamr@4: williamr@4: /// Queries if a parameter with the specified uid is present williamr@4: IMPORT_C TBool IsPresent(TUid aUid) const; williamr@4: williamr@4: /// Return the count of parameters present williamr@4: IMPORT_C TInt Count(void) const; williamr@4: williamr@4: /// Copy the passed CCryptoParams williamr@4: IMPORT_C CCryptoParams& CopyL(const CCryptoParams& aParams); williamr@4: williamr@4: /// Destructor williamr@4: IMPORT_C virtual ~CCryptoParams(); williamr@4: williamr@4: protected: williamr@4: /** @internalComponent */ williamr@4: CCryptoParams(); williamr@4: williamr@4: /** @internalComponent */ williamr@4: void ConstructL(void); williamr@4: /** @internalComponent */ williamr@4: CCryptoParam* GetCryptoParam(TUid aUid) const; williamr@4: /** @internalComponent */ williamr@4: CCryptoParam* GetCryptoParamL(TUid aUid) const; williamr@4: williamr@4: private: williamr@4: RPointerArray iParams; williamr@4: }; williamr@4: } //End of namespace williamr@4: williamr@4: #endif // __CRYPTOPARAMS_H__ williamr@4: