First public contribution.
2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
30 #include <cryptospi/keys.h>
31 #include "asymmetriccipherimpl.h"
34 * Implementation of RSA encryption as described in PKCS#1 v1.5.
36 namespace SoftwareCrypto
38 using namespace CryptoSpi;
40 NONSHARABLE_CLASS(CRSAImpl) : public CAsymmetricCipherImpl
45 Creates an instance of an RSA asymmetric cipher plug-in.
47 @param aCryptoMode Whether to encrypt or decrypt
48 @param aPadding The padding scheme to use None, SSLv3, PKCS#7
49 @return A pointer to a CRSAImpl instance
51 static CRSAImpl* NewL(TUid aImplementationUid, const CKey& aKey,
52 TUid aCryptoMode, TUid aPadding);
55 Creates an instance of an RSA asymmetric cipher plug-in.
56 A pointer to the plug-in instance is placed on the cleanup stack.
58 @param aCryptoMode Whether to encrypt or decrypt
59 @param aPadding The padding scheme to use None, SSLv3, PKCS#7
60 @return A pointer to a CRSAImpl instance
62 static CRSAImpl* NewLC(TUid aImplementationUid, const CKey& aKey,
63 TUid aCryptoMode, TUid aPadding);
65 // Override CAsymmetricCipherImpl virtual functions
66 TUid ImplementationUid() const;
67 TBool IsValidKeyLengthL(TInt aKeyBytes) const;
68 TInt GetMaximumInputLengthL() const;
69 TInt GetMaximumOutputLengthL() const;
70 void ProcessL(const TDesC8& aInput, TDes8& aOutput);
71 // End of CAsymmetricCipherImpl
73 const CExtendedCharacteristics* GetExtendedCharacteristicsL();
74 static CExtendedCharacteristics* CreateExtendedCharacteristicsL();
82 @param aCryptoMode Whether to encrypt or decrypt
83 @param aPaddingMode The padding mode to use. None, SSL, PKCS#7
85 CRSAImpl(TUid aImplementationUid, TUid aCryptoMode, TUid aPaddingMode);
87 /// second phase of construction
88 void ConstructL(const CKey& aKey);
90 /// for internal usage, called from ProcessL
91 void EncryptL(const TDesC8& aInput, TDes8& aOutput) const;
92 void DecryptL(const TDesC8& aInput, TDes8& aOutput) const;
96 TUid iImplementationUid;
101 #endif // __RSAIMPL_H__