omadrm/drmengine/keystorage/src/DrmKeyStorage.cpp
changeset 0 95b198f216e5
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "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".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  OMA DRM 2.0 Key Storage
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <e32std.h>
       
    22 #include <asymmetric.h>
       
    23 #include <symmetric.h>
       
    24 #include <hash.h>
       
    25 #include <asn1dec.h>
       
    26 #include <x509cert.h>
       
    27 #include "DrmKeyStorage.h"
       
    28 
       
    29 #ifdef _DEBUG
       
    30 #define LOGGING
       
    31 #endif
       
    32 /*
       
    33 #ifdef LOGGING
       
    34 _LIT(KLogDir, "DRM");
       
    35 _LIT(KLogName, "KeyStorage.log");
       
    36 #include "flogger.h"
       
    37 #define LOG(string) \
       
    38     RFileLogger::Write(KLogDir, KLogName, \
       
    39         EFileLoggingModeAppend, string);
       
    40 #define LOGHEX(buffer) \
       
    41     RFileLogger::HexDump(KLogDir, KLogName, \
       
    42         EFileLoggingModeAppend, _S(""), _S(""), \
       
    43         buffer.Ptr(), buffer.Length());
       
    44 #else
       
    45 #define LOG(string)
       
    46 #define LOGHEX(buffer)      
       
    47 #endif
       
    48 */
       
    49 typedef MDrmKeyStorage*(*TStorageConstructor)(RLibrary);
       
    50 
       
    51 _LIT(KStdKeyStorageName, "drmstdkeystorage.dll");
       
    52 _LIT(KBb5KeyStorageName, "drmbb5keystorage.dll");
       
    53 static const TInt KConstructorOrdinal = 1;
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // MDrmKeyStorage::
       
    57 // 
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 MDrmKeyStorage::~MDrmKeyStorage()
       
    61     {
       
    62     }
       
    63 
       
    64 EXPORT_C MDrmKeyStorage* DrmKeyStorageNewL()
       
    65     {
       
    66     RLibrary library;
       
    67     MDrmKeyStorage* storage;
       
    68     TInt r;
       
    69     TStorageConstructor constructor;
       
    70     
       
    71     r = library.Load(KBb5KeyStorageName);
       
    72     if (r != KErrNone)
       
    73         {
       
    74         r = library.Load(KStdKeyStorageName);
       
    75         }
       
    76     User::LeaveIfError(r);
       
    77     constructor = reinterpret_cast<TStorageConstructor>(
       
    78         library.Lookup(KConstructorOrdinal));
       
    79     if (constructor == NULL)
       
    80         {
       
    81         User::Leave(KErrNotFound);
       
    82         }
       
    83     storage = reinterpret_cast<MDrmKeyStorage*>(constructor(library));
       
    84     return storage;
       
    85     }
       
    86 
       
    87 // end of file