First public contribution.
2 * Copyright (c) 2002-2009 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.
15 * ** IMPORTANT ** PublishedPartner API's in this file are published to 3rd party developers via the
16 * Symbian website. Changes to these API's should be treated as PublishedAll API changes and the Security TA should be consulted.
34 * Abstract base class for triple-DES.
36 * Implements features common to triple-DES encryption and decryption.
39 class C3DES : public CDES
42 virtual void Transform(TDes8& aBlock);
44 virtual TInt BlockSize() const;
45 virtual TInt KeySize() const;
49 virtual void ConstructL(const TDesC8& aKey);
51 * Initialises the three key schedule arrays from the specified key.
53 * @param aKey The key to be used for encryption. The key length
54 * must be K3DESKeySize = 24 bytes.
56 virtual void DoSetKey(const TDesC8& aKey) = 0;
59 /** The second key schedule array */
60 TUint32 iK2[KDESScheduleSizeInWords]; // = 32
61 /** The third key schedule array */
62 TUint32 iK3[KDESScheduleSizeInWords];
66 * Concrete class for triple-DES encryption.
69 class C3DESEncryptor : public C3DES
73 * Creates an instance of this class.
75 * @param aKey The key to be used for encryption. The key length
76 * must be K3DESKeySize = 24 bytes.
77 * @return A pointer to the new C3DESEncryptor object.
79 * @leave KErrKeyNotWeakEnough If the key size is larger than that allowed by the
80 * cipher strength restrictions of the crypto library.
81 * See TCrypto::IsSymmetricWeakEnoughL()
83 IMPORT_C static C3DESEncryptor* NewL(const TDesC8& aKey);
86 * Creates an instance of this class and leaves it on the cleanup stack.
88 * @param aKey The key to be used for encryption. The key length
89 * must be K3DESKeySize = 24 bytes.
90 * @return A pointer to the new C3DESEncryptor object.
92 * @leave KErrKeyNotWeakEnough If the key size is larger than that allowed by the
93 * cipher strength restrictions of the crypto library.
94 * See TCrypto::IsSymmetricWeakEnoughL()
96 IMPORT_C static C3DESEncryptor* NewLC(const TDesC8& aKey);
98 virtual void DoSetKey(const TDesC8& aKey);
102 * Concrete class for triple-DES decryption.
105 class C3DESDecryptor : public C3DES
109 * Creates an instance of this class.
111 * @param aKey The key to be used for decryption. The key length
112 * must be K3DESKeySize = 24 bytes.
113 * @return A pointer to the new C3DESDecryptor object.
115 * @leave KErrKeyNotWeakEnough If the key size is larger than that allowed by the
116 * cipher strength restrictions of the crypto library.
117 * See TCrypto::IsSymmetricWeakEnoughL()
119 IMPORT_C static C3DESDecryptor* NewL(const TDesC8& aKey);
122 * Creates an instance of this class and leaves it on the cleanup stack.
124 * @param aKey The key to be used for decryption. The key length
125 * must be K3DESKeySize = 24 bytes.
126 * @return A pointer to the new C3DESDecryptor object.
128 * @leave KErrKeyNotWeakEnough If the key size is larger than that allowed by the
129 * cipher strength restrictions of the crypto library.
130 * See TCrypto::IsSymmetricWeakEnoughL()
132 IMPORT_C static C3DESDecryptor* NewLC(const TDesC8& aKey);
134 virtual void DoSetKey(const TDesC8& aKey);