First public contribution.
2 * Copyright (c) 1998-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.
24 #include <ecom/ecom.h>
25 #include <ecom/implementationproxy.h>
27 #include "pkcs8recog.h"
29 const TInt KRecognizerValue = 0x1020361C;
30 const TUid KUidMimeRecognizer = {KRecognizerValue};
32 _LIT8(KDataTypePkcs8KeyPair, "application/pkcs8");
33 _LIT8(KDataTypePkcs8EncryptedKeyPair, "application/pkcs8-encrypted");
35 const TInt KSupportedDataTypesNumber = 2;
38 // ----------------------------------------------------------------------------
39 // CApaPkcs8Recognizer
42 CApaPkcs8Recognizer::CApaPkcs8Recognizer()
43 : CApaDataRecognizerType(KUidMimeRecognizer, CApaDataRecognizerType::ENormal)
45 iCountDataTypes = KSupportedDataTypesNumber;
48 TUint CApaPkcs8Recognizer::PreferredBufSize()
50 return Max(KIsPKCS8DataMinLength, KIsEncryptedPKCS8DataMinLength);
53 TDataType CApaPkcs8Recognizer::SupportedDataTypeL(TInt aIndex) const
55 __ASSERT_DEBUG(aIndex >= 0 && aIndex < KSupportedDataTypesNumber,
56 User::Panic(_L("PKCS8RECOG"), 0));
60 return TDataType(KDataTypePkcs8KeyPair);
63 return TDataType(KDataTypePkcs8EncryptedKeyPair);
65 // Used to prevent warning about return paths not all returning a value
67 return TDataType(KDataTypePkcs8KeyPair);
71 void CApaPkcs8Recognizer::DoRecognizeL(const TDesC& /*aName*/, const TDesC8& aBuffer)
73 // Ensure length is sufficient for checking type pkcs8
74 if (aBuffer.Size() >= KIsPKCS8DataMinLength)
76 if (TASN1DecPKCS8::IsPKCS8Data(aBuffer))
78 iDataType = TDataType(KDataTypePkcs8KeyPair);
79 iConfidence = ECertain;
84 // Ensure length is sufficient for checking type pkcs8-encrypted
85 if (aBuffer.Size() >= KIsEncryptedPKCS8DataMinLength)
87 if (TASN1DecPKCS8::IsEncryptedPKCS8Data(aBuffer))
89 iDataType = TDataType(KDataTypePkcs8EncryptedKeyPair);
90 iConfidence = ECertain;
95 // type not recognized
98 CApaDataRecognizerType* CApaPkcs8Recognizer::CreateRecognizerL()
100 return new (ELeave) CApaPkcs8Recognizer();
103 const TImplementationProxy ImplementationTable[] =
105 IMPLEMENTATION_PROXY_ENTRY(0x1020361B, CApaPkcs8Recognizer::CreateRecognizerL)
108 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
110 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
111 return ImplementationTable;