sl@0: /* sl@0: * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * DSA shim classes definition sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: @released sl@0: */ sl@0: sl@0: #ifndef __DSASHIM_H__ sl@0: #define __DSASHIM_H__ sl@0: sl@0: #include sl@0: sl@0: namespace CryptoSpi sl@0: { sl@0: class CSigner; sl@0: class CVerifier; sl@0: class CKey; sl@0: } sl@0: sl@0: NONSHARABLE_CLASS(CDsaSignerShim) : public CDSASigner sl@0: { sl@0: public: sl@0: /** sl@0: Creates an CDsaSignerShim object which has the same interface sl@0: as CDSASigner but delegates all work to a Crypto SPI plug-in. sl@0: sl@0: @param aKey The signing key sl@0: @return A pointer to a CDsaSignerShim instance sl@0: */ sl@0: static CDsaSignerShim* NewL(const CDSAPrivateKey& aKey); sl@0: sl@0: /** sl@0: Creates an CDsaSignerShim object which has the same interface sl@0: as CDSASigner but delegates all work to a Crypto SPI plug-in. sl@0: sl@0: A pointer to the new object is placed on the cleanup stack sl@0: sl@0: @param aKey The signing key sl@0: @return A pointer to a CDsaSignerShim instance sl@0: */ sl@0: static CDsaSignerShim* NewLC(const CDSAPrivateKey& aKey); sl@0: sl@0: /** sl@0: Digitally signs the specified input message sl@0: Note that in order to be interoperable and compliant with the DSS, aInput sl@0: must be the result of a SHA-1 hash. sl@0: sl@0: @param aInput A SHA-1 hash of the message to sign sl@0: @return A pointer to a new CSignature object sl@0: @panic ECryptoPanicInputTooLarge If aInput is larger than MaxInputLength(), sl@0: which is likely to happen if the caller sl@0: has passed in something that has not been hashed. sl@0: */ sl@0: virtual CDSASignature* SignL(const TDesC8& aInput) const; sl@0: sl@0: //From MSignatureSystem sl@0: virtual TInt MaxInputLength() const; sl@0: sl@0: /// Destructor sl@0: ~CDsaSignerShim(); sl@0: sl@0: private: sl@0: /// Constructor sl@0: CDsaSignerShim(const CDSAPrivateKey& aKey); sl@0: void ConstructL(const CDSAPrivateKey& aKey); sl@0: sl@0: private: sl@0: /// SPI delegate sl@0: CryptoSpi::CSigner* iSignerImpl; sl@0: sl@0: /// SPI requires all key to passed as key-objects sl@0: CryptoSpi::CKey* iKey; sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(CDsaVerifierShim) : public CDSAVerifier sl@0: { sl@0: public: sl@0: /** sl@0: Creates an CDsaVerifierShim object which has the same interface sl@0: as CDSAVerifier but delegates all work to a Crypto SPI plug-in. sl@0: sl@0: @param aKey The verification key sl@0: @return A pointer to a CDsaVerifierShim instance sl@0: */ sl@0: static CDsaVerifierShim* NewL(const CDSAPublicKey& aKey); sl@0: sl@0: /** sl@0: Creates an CDsaVerifierShim object which has the same interface sl@0: as CDSAVerifier but delegates all work to a Crypto SPI plug-in. sl@0: sl@0: A pointer to the new object is placed on the cleanup stack sl@0: sl@0: @param aKey The verification key sl@0: @return A pointer to a CDsaVerifierShim instance sl@0: */ sl@0: static CDsaVerifierShim* NewLC(const CDSAPublicKey& aKey); sl@0: sl@0: //From CVerifier sl@0: virtual TBool VerifyL(const TDesC8& aInput, const CDSASignature& aSignature) const; sl@0: sl@0: //From MSignatureSystem sl@0: virtual TInt MaxInputLength() const; sl@0: sl@0: // Destructor sl@0: ~CDsaVerifierShim(); sl@0: sl@0: private: sl@0: // Constructor sl@0: CDsaVerifierShim(const CDSAPublicKey& aKey); sl@0: void ConstructL(const CDSAPublicKey& aKey); sl@0: sl@0: private: sl@0: /// SPI delegate sl@0: CryptoSpi::CVerifier* iVerifierImpl; sl@0: sl@0: /// SPI requires all key to passed as key-objects sl@0: CryptoSpi::CKey* iKey; sl@0: }; sl@0: sl@0: #endif // __DSASHIM_H__