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.
22 const TInt KDESBlockBytes = 8;
23 const TInt KDESKeyBytes = 8;
33 typedef TUint8 TKeyDES[KDESKeyBytes];
34 const TInt KKnownWeakKeysCount = 16;
36 const TKeyDES weak_keys[KKnownWeakKeysCount] =
39 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
40 {0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE},
41 {0x1E,0x1E,0x1E,0x1E,0x0E,0x0E,0x0E,0x0E},
42 {0xE0,0xE0,0xE0,0xE0,0xF0,0xF0,0xF0,0xF0},
43 {0x00,0xFE,0x00,0xFE,0x00,0xFE,0x00,0xFE},
44 {0xFE,0x00,0xFE,0x00,0xFE,0x00,0xFE,0x00},
45 {0x1E,0xE0,0x1E,0xE0,0x0E,0xF0,0x0E,0xF0},
46 {0xE0,0x1E,0xE0,0x1E,0xF0,0x0E,0xF0,0x0E},
47 {0x00,0xE0,0x00,0xE0,0x00,0xF0,0x00,0xF0},
48 {0xE0,0x00,0xE0,0x00,0xF0,0x00,0xF0,0x00},
49 {0x1E,0xFE,0x1E,0xFE,0x0E,0xFE,0x0E,0xFE},
50 {0xFE,0x1E,0xFE,0x1E,0xFE,0x0E,0xFE,0x0E},
51 {0x00,0x1E,0x00,0x1E,0x00,0x0E,0x00,0x0E},
52 {0x1E,0x00,0x1E,0x00,0x0E,0x00,0x0E,0x00},
53 {0xE0,0xFE,0xE0,0xFE,0xF0,0xFE,0xF0,0xFE},
54 {0xFE,0xE0,0xFE,0xE0,0xFE,0xF0,0xFE,0xF0}
57 EXPORT_C TBool CDES::IsWeakKey(const TDesC8& aKey)
62 for(; index < KDESKeyBytes; index++)
64 key[index] = aKey[index] & 0xFE;
68 //Compare key with potential weak keys without parity
69 for (index=0; index < KKnownWeakKeysCount; index++)
71 if (Mem::Compare(weak_keys[index], KDESKeyBytes, &key[0], KDESKeyBytes)==0)
81 EXPORT_C CDESEncryptor* CDESEncryptor::NewL(const TDesC8& aKey, TBool /*aCheckWeakKey*/)
83 return CDESEncryptorShim::NewL(aKey);
86 EXPORT_C CDESEncryptor* CDESEncryptor::NewLC(const TDesC8& aKey, TBool /*aCheckWeakKey*/)
88 return CDESEncryptorShim::NewLC(aKey);
91 CDESEncryptor::CDESEncryptor()
96 EXPORT_C CDESDecryptor* CDESDecryptor::NewL(const TDesC8& aKey, TBool /*aCheckWeakKey*/)
98 return CDESDecryptorShim::NewL(aKey);
101 EXPORT_C CDESDecryptor* CDESDecryptor::NewLC(const TDesC8& aKey, TBool /*aCheckWeakKey*/)
103 return CDESDecryptorShim::NewLC(aKey);
106 CDESDecryptor::CDESDecryptor()
110 // All these methods have been replaced by the shim
111 #ifdef _BullseyeCoverage
112 #pragma suppress_warnings on
113 #pragma BullseyeCoverage off
114 #pragma suppress_warnings off
117 void CDES::Transform(TDes8& /*aBlock*/)
119 // Method replaced by shim
123 TInt CDES::BlockSize() const
125 // Method replaced by shim
127 return KDESBlockBytes;
130 TInt CDES::KeySize() const
132 // Method replaced by shim
139 // Method replaced by shim
143 void CDES::SetKey(const TDesC8& /*aKey*/, TUint32* /*aKeyBuffer*/)
145 // Method replaced by shim
149 void CDES::ConstructL(const TDesC8& /*aKey*/, TBool /*aCheckWeakKey*/)
151 // Method replaced by shim
155 void CDESDecryptor::SetKey(const TDesC8& /*aKey*/, TUint32* /*aKeyBuffer*/)
157 // Method replaced by shim