breakdeps/DRMEngine/DrmStdKeyStorage.cpp
author Tom Pritchard <tomp@symbian.org>
Wed, 27 Oct 2010 13:24:02 +0100
changeset 88 ca165d35976d
child 90 62156f66dbad
permissions -rw-r--r--
Adding parts of the DRM Engine to be rebuilt
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
88
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     1
/*
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     2
* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     3
* All rights reserved.
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     8
*
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     9
* Initial Contributors:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    11
*
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    12
* Contributors:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    13
*
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    14
* Description:  OMA DRM 2.0 Key Storage
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    15
*
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    16
*/
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    17
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    18
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    19
// INCLUDE FILES
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    20
#include <e32std.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    21
#include <asymmetric.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    22
#include <symmetric.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    23
#include <hash.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    24
#include <asn1dec.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    25
#include <x509cert.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    26
#include <etelmm.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    27
#include <mmtsy_names.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    28
#include <featmgr.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    29
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    30
#ifdef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    31
#include <driveinfo.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    32
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    33
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    34
#include "DrmKeyStorage.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    35
#include "DrmStdKeyStorage.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    36
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    37
#ifdef _DEBUG
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    38
#define LOGGING
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    39
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    40
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    41
#ifdef LOGGING
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    42
_LIT(KLogDir, "DRM");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    43
_LIT(KLogName, "KeyStorage.log");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    44
#include "flogger.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    45
#define LOG(string) \
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    46
    RFileLogger::Write(KLogDir, KLogName, \
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    47
        EFileLoggingModeAppend, string);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    48
#define LOGHEX(buffer) \
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    49
    RFileLogger::HexDump(KLogDir, KLogName, \
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    50
        EFileLoggingModeAppend, _S(""), _S(""), \
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    51
        buffer.Ptr(), buffer.Length());
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    52
#else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    53
#define LOG(string)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    54
#define LOGHEX(buffer)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    55
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    56
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    57
#pragma message("Compiling DRM Std KeyStorage..")
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    58
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    59
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    60
// LOCAL CONSTANTS AND MACROS
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    61
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    62
const TInt KKeyLength = 128;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    63
const TInt KWaitingTime = 2000000; // 2 sec
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    64
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    65
#ifdef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    66
_LIT(KKeyStoragePath, "%c:\\private\\101F51F2\\PKI\\");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    67
_LIT(KRomKeyStoragePath, "%c:\\private\\101F51F2\\PKI\\");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    68
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    69
#else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    70
_LIT(KKeyStoragePath, "c:\\private\\101F51F2\\PKI\\");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    71
_LIT(KRomKeyStoragePath, "z:\\private\\101F51F2\\PKI\\");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    72
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    73
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    74
_LIT(KDeviceKeyFileName, "DevicePrivateKey.der");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    75
_LIT(KDeviceCertFileName, "DeviceCert.der");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    76
_LIT(KSingingCertFmt, "SigningCert%02d.der");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    77
_LIT(KSingingCertPattern, "SigningCert*");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    78
_LIT8(KDefaultKey, "0000000000000000");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    79
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    80
#ifdef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    81
_LIT(KSerialNumberFile, "%c:\\private\\101F51F2\\rdbserial.dat");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    82
_LIT(KUdtCertFileName, "%c:\\private\\101F51F2\\PKI\\UdtCertificate.der");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    83
#else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    84
_LIT(KSerialNumberFile, "c:\\private\\101F51F2\\rdbserial.dat");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    85
_LIT(KUdtCertFileName, "z:\\private\\101F51F2\\PKI\\UdtCertificate.der");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    86
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    87
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    88
_LIT(KCmla, "CMLA");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    89
_LIT(KPadding, "\x0");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    90
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    91
NONSHARABLE_STRUCT( TUnloadModule )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    92
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    93
    RTelServer* iServer;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    94
    const TDesC* iName;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    95
    };
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    96
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    97
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    98
// ============================ LOCAL FUNCTIONS ================================
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    99
LOCAL_C void DoUnloadPhoneModule( TAny* aAny );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   100
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   101
LOCAL_C void WriteFileL(RFs& aFs, const TDesC& aName, const TDesC8& aData)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   102
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   103
    RFile file;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   104
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   105
    User::LeaveIfError(file.Replace(aFs, aName, EFileWrite));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   106
    User::LeaveIfError(file.Write(aData));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   107
    file.Close();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   108
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   109
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   110
LOCAL_C void ReadFileL(RFs& aFs, const TDesC& aName, HBufC8*& aContent)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   111
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   112
    RFile file;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   113
    TInt size = 0;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   114
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   115
    User::LeaveIfError(file.Open(aFs, aName, EFileRead));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   116
    CleanupClosePushL(file);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   117
    User::LeaveIfError(file.Size(size));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   118
    aContent = HBufC8::NewLC(size);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   119
    TPtr8 ptr(aContent->Des());
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   120
    User::LeaveIfError(file.Read(ptr, size));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   121
    CleanupStack::Pop(); //aContent
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   122
    CleanupStack::PopAndDestroy(); // file
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   123
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   124
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   125
HBufC8* I2OSPL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   126
    RInteger& aInt, TInt& aKeySize )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   127
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   128
    HBufC8* integer = aInt.BufferLC();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   129
    if (integer->Length() < aKeySize)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   130
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   131
        HBufC8* r = HBufC8::NewLC(aKeySize);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   132
        TPtr8 ptr(r->Des());
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   133
        for(TInt i = integer->Length(); i < aKeySize; i++)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   134
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   135
            ptr.Append(KPadding());
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   136
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   137
        ptr.Append(*integer);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   138
        CleanupStack::Pop(r);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   139
        CleanupStack::PopAndDestroy(integer);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   140
        return r;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   141
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   142
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   143
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   144
        CleanupStack::Pop(integer);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   145
        return integer;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   146
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   147
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   148
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   149
RInteger OS2IPL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   150
    const TDesC8& aOctetStream)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   151
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   152
    RInteger r;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   153
    TInt i;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   154
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   155
    r = RInteger::NewL(0);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   156
    for (i = 0; i < aOctetStream.Length(); i++)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   157
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   158
        r *= 256;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   159
        r += aOctetStream[i];
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   160
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   161
    return r;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   162
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   163
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   164
void DoUnloadPhoneModule( TAny* aAny )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   165
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   166
    __ASSERT_DEBUG( aAny, User::Invariant() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   167
    TUnloadModule* module = ( TUnloadModule* ) aAny;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   168
    module->iServer->UnloadPhoneModule( *( module->iName ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   169
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   170
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   171
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   172
// ============================ MEMBER FUNCTIONS ===============================
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   173
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   174
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   175
// CDrmStdKeyStorage* CDrmStdKeyStorage::NewL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   176
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   177
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   178
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   179
EXPORT_C CDrmStdKeyStorage* CDrmStdKeyStorage::NewL(RLibrary aLibrary)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   180
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   181
    CDrmStdKeyStorage* self = new (ELeave) CDrmStdKeyStorage(aLibrary);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   182
    CleanupStack::PushL(self);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   183
    self->ConstructL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   184
    CleanupStack::Pop();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   185
    return self;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   186
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   187
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   188
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   189
// CDrmStdKeyStorage::CDrmStdKeyStorage
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   190
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   191
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   192
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   193
CDrmStdKeyStorage::CDrmStdKeyStorage(RLibrary aLibrary):
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   194
    iFileMan(NULL),
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   195
    iRootSelected(EFalse),
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   196
    iKey(NULL),
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   197
    iImei(NULL),
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   198
    iLibrary(aLibrary)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   199
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   200
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   201
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   202
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   203
// CDrmStdKeyStorage::ConstructL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   204
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   205
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   206
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   207
void CDrmStdKeyStorage::ConstructL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   208
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   209
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   210
    LOG(_L("CDrmStdKeyStorage::ConstructL ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   211
    User::LeaveIfError(iFs.Connect());
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   212
    iFileMan = CFileMan::NewL(iFs);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   213
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   214
    FeatureManager::InitializeLibL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   215
    
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   216
#ifdef __DRM_OMA2 
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   217
    if ( FeatureManager::FeatureSupported( KFeatureIdFfOmadrm2Support ) )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   218
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   219
        TRAP_IGNORE( SelectDefaultRootL() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   220
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   221
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   222
    
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   223
    FeatureManager::UnInitializeLib();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   224
    
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   225
    iDeviceSpecificKey.Copy(KDefaultKey);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   226
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   227
    LOG(_L("CDrmStdKeyStorage::ConstructL <-"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   228
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   229
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   230
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   231
// MDrmKeyStorage::~MDrmKeyStorage
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   232
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   233
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   234
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   235
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   236
MDrmKeyStorage::~MDrmKeyStorage()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   237
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   238
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   239
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   240
// DrmStdKeyStorage::~CDrmStdKeyStorage
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   241
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   242
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   243
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   244
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   245
CDrmStdKeyStorage::~CDrmStdKeyStorage()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   246
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   247
    LOG(_L("CDrmStdKeyStorage::~CDrmStdKeyStorage ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   248
    delete iFileMan;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   249
    delete iKey;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   250
    delete iImei; iImei = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   251
    iFs.Close();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   252
    //iLibrary.Close();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   253
    LOG(_L("CDrmStdKeyStorage::~CDrmStdKeyStorage <-"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   254
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   255
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   256
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   257
// DrmStdKeyStorage::ModulusSize
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   258
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   259
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   260
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   261
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   262
TInt CDrmStdKeyStorage::ModulusSize()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   263
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   264
    LOG(_L("CDrmStdKeyStorage::ModulusSize ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   265
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   266
    if(iKey == NULL)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   267
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   268
        return KErrGeneral;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   269
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   270
    LOG(_L("CDrmStdKeyStorage::ModulusSize <-"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   271
    return iKey->N().BitCount();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   272
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   273
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   274
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   275
// DrmStdKeyStorage::SelectTrustedRootL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   276
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   277
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   278
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   279
void CDrmStdKeyStorage::SelectTrustedRootL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   280
    const TDesC8& aRootKeyHash)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   281
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   282
    TFileName fileName;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   283
    TEntry entry;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   284
    TInt i;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   285
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   286
    LOG(_L("CDrmStdKeyStorage::SelectTrustedRootL ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   287
    LOG(aRootKeyHash);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   288
    if (aRootKeyHash.Length() != 0)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   289
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   290
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   291
#ifndef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   292
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   293
        fileName.Copy(KKeyStoragePath);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   294
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   295
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   296
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   297
        TFileName tempPath;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   298
        TInt driveNumber( -1 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   299
        TChar driveLetter;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   300
        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   301
        iFs.DriveToChar( driveNumber, driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   302
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   303
        tempPath.Format( KKeyStoragePath, (TUint)driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   304
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   305
        fileName.Copy(tempPath);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   306
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   307
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   308
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   309
        for (i = 0; i < SHA1_HASH; i++)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   310
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   311
            fileName.AppendNumFixedWidth(aRootKeyHash[i], EHex, 2);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   312
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   313
        fileName.Append('\\');
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   314
        if (iFs.Entry(fileName, entry) != KErrNone)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   315
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   316
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   317
#ifndef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   318
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   319
            fileName.Copy(KRomKeyStoragePath);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   320
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   321
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   322
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   323
            DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   324
            iFs.DriveToChar( driveNumber, driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   325
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   326
            tempPath.Format( KRomKeyStoragePath, (TUint)driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   327
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   328
            fileName.Copy(tempPath);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   329
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   330
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   331
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   332
            for (i = 0; i < SHA1_HASH; i++)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   333
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   334
                fileName.AppendNumFixedWidth(aRootKeyHash[i], EHex, 2);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   335
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   336
            fileName.Append('\\');
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   337
            // check that the path exists
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   338
            User::LeaveIfError(iFs.Entry(fileName, entry));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   339
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   340
        User::LeaveIfError(iFs.SetSessionPath(fileName));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   341
        InitializeKeyL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   342
        CheckRootForCmlaL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   343
        iRootSelected = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   344
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   345
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   346
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   347
        SelectDefaultRootL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   348
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   349
    LOG(_L("CDrmStdKeyStorage::SelectTrustedRootL <-"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   350
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   351
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   352
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   353
// DrmStdKeyStorage::SelectDefaultRootL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   354
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   355
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   356
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   357
void CDrmStdKeyStorage::SelectDefaultRootL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   358
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   359
    CDir* dir = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   360
    TFileName dirName;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   361
    TBool found = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   362
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   363
    LOG(_L("CDrmStdKeyStorage::SelectDefaultRootL ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   364
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   365
#ifndef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   366
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   367
    if (iFs.GetDir(KKeyStoragePath, KEntryAttDir, ESortByName, dir) == KErrNone)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   368
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   369
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   370
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   371
    TFileName tempPath;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   372
    TInt driveNumber( -1 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   373
    TChar driveLetter;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   374
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   375
    iFs.DriveToChar( driveNumber, driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   376
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   377
    tempPath.Format( KKeyStoragePath, (TUint)driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   378
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   379
    if (iFs.GetDir(tempPath, KEntryAttDir, ESortByName, dir) == KErrNone)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   380
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   381
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   382
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   383
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   384
        __UHEAP_MARK;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   385
        LOG(_L("  Checking keys on C:"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   386
        CleanupStack::PushL(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   387
        if (dir->Count() >= 1)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   388
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   389
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   390
#ifndef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   391
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   392
            dirName.Copy(KKeyStoragePath);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   393
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   394
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   395
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   396
            dirName.Copy(tempPath);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   397
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   398
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   399
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   400
            dirName.Append((*dir)[0].iName);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   401
            dirName.Append('\\');
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   402
            User::LeaveIfError(iFs.SetSessionPath(dirName));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   403
            found = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   404
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   405
        CleanupStack::PopAndDestroy(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   406
        __UHEAP_MARKEND;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   407
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   408
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   409
#ifndef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   410
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   411
    if (!found && iFs.GetDir(KRomKeyStoragePath, KEntryAttDir, ESortByName, dir) == KErrNone)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   412
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   413
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   414
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   415
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   416
    iFs.DriveToChar( driveNumber, driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   417
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   418
    tempPath.Format( KRomKeyStoragePath, (TUint)driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   419
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   420
    if (!found && iFs.GetDir(tempPath, KEntryAttDir, ESortByName, dir) == KErrNone)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   421
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   422
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   423
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   424
        LOG(_L("  Checking keys on Z:"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   425
        CleanupStack::PushL(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   426
        if (dir->Count() < 1)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   427
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   428
            User::Leave(KErrGeneral);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   429
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   430
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   431
#ifndef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   432
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   433
        dirName.Copy(KRomKeyStoragePath);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   434
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   435
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   436
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   437
        dirName.Copy(tempPath);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   438
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   439
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   440
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   441
        dirName.Append((*dir)[0].iName);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   442
        dirName.Append('\\');
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   443
        User::LeaveIfError(iFs.SetSessionPath(dirName));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   444
        CleanupStack::PopAndDestroy(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   445
        found = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   446
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   447
    if (!found)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   448
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   449
        User::Leave(KErrGeneral);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   450
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   451
    InitializeKeyL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   452
    CheckRootForCmlaL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   453
    iRootSelected = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   454
    LOG(_L("CDrmStdKeyStorage::SelectDefaultRootL <-"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   455
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   456
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   457
TBool CDrmStdKeyStorage::SelectedRootIsCmla()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   458
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   459
    return iRootIsCmla;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   460
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   461
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   462
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   463
// DrmStdKeyStorage::GetTrustedRootsL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   464
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   465
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   466
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   467
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   468
void CDrmStdKeyStorage::GetTrustedRootsL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   469
    RPointerArray<HBufC8>& aRootList)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   470
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   471
    CDir* dir = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   472
    TInt i;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   473
    TInt j;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   474
    TBuf8<SHA1_HASH> hash;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   475
    TEntry entry;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   476
    TUint8 c;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   477
    TInt r = KErrNone;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   478
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   479
    LOG(_L("CDrmStdKeyStorage::GetTrustedRootsL ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   480
    aRootList.ResetAndDestroy();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   481
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   482
#ifndef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   483
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   484
    if (iFs.GetDir(KKeyStoragePath, KEntryAttDir, ESortByName, dir) == KErrNone)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   485
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   486
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   487
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   488
    TFileName tempPath;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   489
    TInt driveNumber( -1 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   490
    TChar driveLetter;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   491
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   492
    iFs.DriveToChar( driveNumber, driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   493
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   494
    tempPath.Format( KKeyStoragePath, (TUint)driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   495
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   496
    if (iFs.GetDir(tempPath, KEntryAttDir, ESortByName, dir) == KErrNone)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   497
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   498
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   499
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   500
        LOG(_L("  Getting roots on C:"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   501
        CleanupStack::PushL(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   502
        for (i = 0; i < dir->Count(); i++)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   503
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   504
            entry = (*dir)[i];
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   505
            hash.SetLength(0);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   506
            LOG(entry.iName);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   507
            r = KErrNone;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   508
            for (j = 0; r == KErrNone && j < SHA1_HASH; j++)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   509
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   510
                TLex lex(entry.iName.Mid(j * 2, 2));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   511
                r = lex.Val(c, EHex);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   512
                hash.Append(c);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   513
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   514
            if (r == KErrNone)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   515
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   516
                aRootList.Append(hash.AllocL());
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   517
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   518
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   519
        CleanupStack::PopAndDestroy(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   520
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   521
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   522
#ifndef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   523
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   524
    if (iFs.GetDir(KRomKeyStoragePath, KEntryAttDir, ESortByName, dir) == KErrNone)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   525
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   526
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   527
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   528
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   529
    iFs.DriveToChar( driveNumber, driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   530
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   531
    tempPath.Format( KRomKeyStoragePath, (TUint)driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   532
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   533
    if (iFs.GetDir(tempPath, KEntryAttDir, ESortByName, dir) == KErrNone)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   534
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   535
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   536
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   537
        LOG(_L("  Getting roots on Z:"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   538
        CleanupStack::PushL(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   539
        for (i = 0; i < dir->Count(); i++)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   540
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   541
            LOG(entry.iName);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   542
            entry = (*dir)[i];
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   543
            hash.SetLength(0);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   544
            r = KErrNone;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   545
            for (j = 0; r == KErrNone && j < SHA1_HASH; j++)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   546
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   547
                TLex lex(entry.iName.Mid(j * 2, 2));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   548
                r = lex.Val(c, EHex);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   549
                hash.Append(c);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   550
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   551
            if (r == KErrNone)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   552
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   553
                aRootList.Append(hash.AllocL());
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   554
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   555
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   556
        CleanupStack::PopAndDestroy(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   557
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   558
    LOG(_L("CDrmStdKeyStorage::GetTrustedRootsL <-"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   559
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   560
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   561
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   562
// DrmStdKeyStorage::GetCertificateChainL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   563
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   564
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   565
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   566
void CDrmStdKeyStorage::GetCertificateChainL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   567
    RPointerArray<HBufC8>& aCertChain)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   568
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   569
    TFileName fileName;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   570
    TInt i;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   571
    CDir* dir = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   572
    HBufC8* cert = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   573
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   574
    LOG(_L("CDrmStdKeyStorage::GetCertificateChainL ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   575
    if (!iRootSelected)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   576
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   577
        User::Leave(KErrGeneral);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   578
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   579
    aCertChain.ResetAndDestroy();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   580
    ReadFileL(iFs, KDeviceCertFileName, cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   581
    aCertChain.Append(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   582
    iFs.GetDir(KSingingCertPattern, KEntryAttNormal, ESortByName, dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   583
    CleanupStack::PushL(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   584
    for (i = 0; i < dir->Count(); i++)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   585
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   586
        ReadFileL(iFs, (*dir)[i].iName, cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   587
        aCertChain.AppendL(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   588
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   589
    CleanupStack::PopAndDestroy(); // dir
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   590
    LOG(_L("CDrmStdKeyStorage::GetCertificateChainL <-"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   591
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   592
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   593
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   594
// CDrmStdKeyStorage::RsaSignL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   595
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   596
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   597
HBufC8* CDrmStdKeyStorage::RsaSignL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   598
    const TDesC8& aInput)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   599
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   600
    return ModularExponentiateWithKeyL(aInput);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   601
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   602
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   603
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   604
// CDrmStdKeyStorage::RsaDecryptL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   605
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   606
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   607
HBufC8* CDrmStdKeyStorage::RsaDecryptL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   608
    const TDesC8& aInput)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   609
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   610
    return ModularExponentiateWithKeyL(aInput);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   611
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   612
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   613
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   614
// CDrmStdKeyStorage::ImportDataL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   615
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   616
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   617
void CDrmStdKeyStorage::ImportDataL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   618
    const TDesC8& aPrivateKey,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   619
    const RArray<TPtrC8>& aCertificateChain)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   620
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   621
    TInt i;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   622
    TInt n;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   623
    HBufC8* publicKey = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   624
    CX509Certificate* cert = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   625
    CSHA1* hasher = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   626
    TBuf8<SHA1_HASH> publicKeyHash;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   627
    TFileName fileName;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   628
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   629
    LOG(_L("CDrmStdKeyStorage::ImportDataL ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   630
    n = aCertificateChain.Count();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   631
    cert = CX509Certificate::NewLC(aCertificateChain[n - 1]);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   632
    publicKey = cert->DataElementEncoding(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   633
        CX509Certificate::ESubjectPublicKeyInfo)->AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   634
    CleanupStack::PushL(publicKey);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   635
    hasher = CSHA1::NewL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   636
    CleanupStack::PushL(hasher);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   637
    hasher->Update(*publicKey);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   638
    publicKeyHash.Copy(hasher->Final());
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   639
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   640
#ifndef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   641
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   642
    fileName.Copy(KKeyStoragePath);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   643
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   644
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   645
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   646
    TInt driveNumber( -1 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   647
    TChar driveLetter;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   648
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   649
    iFs.DriveToChar( driveNumber, driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   650
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   651
    TFileName keyStorageDir;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   652
    keyStorageDir.Format( KKeyStoragePath, (TUint)driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   653
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   654
    fileName.Copy(keyStorageDir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   655
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   656
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   657
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   658
    for (i = 0; i < SHA1_HASH; i++)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   659
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   660
        fileName.AppendNumFixedWidth(publicKeyHash[i], EHex, 2);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   661
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   662
    fileName.Append('\\');
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   663
    iFileMan->Delete(fileName, CFileMan::ERecurse);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   664
    iFs.MkDirAll(fileName);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   665
    iFs.SetSessionPath(fileName);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   666
    WriteFileL(iFs, KDeviceKeyFileName, aPrivateKey);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   667
    fileName.Copy(fileName);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   668
    WriteFileL(iFs, KDeviceCertFileName, aCertificateChain[0]);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   669
    for (i = 1; i < n; i++)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   670
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   671
        fileName.SetLength(0);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   672
        fileName.AppendFormat(KSingingCertFmt, i - 1);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   673
        WriteFileL(iFs, fileName, aCertificateChain[i]);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   674
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   675
    CleanupStack::PopAndDestroy(3); // hasher, publicKey, cert
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   676
    LOG(_L("CDrmStdKeyStorage::ImportDataL <-"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   677
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   678
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   679
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   680
// CDrmStdKeyStorage::GetDeviceSpecificKeyL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   681
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   682
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   683
void CDrmStdKeyStorage::GetDeviceSpecificKeyL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   684
    TBuf8<KDeviceSpecificKeyLength>& aKey)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   685
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   686
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   687
    HBufC8* key = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   688
    TInt n;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   689
    CSHA1* hasher = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   690
    TBuf8<SHA1_HASH> hash;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   691
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   692
    if (iDeviceSpecificKey.Compare(KDefaultKey) == 0)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   693
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   694
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   695
        GetImeiL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   696
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   697
        HBufC8* buf = HBufC8::NewLC( iImei->Size() + sizeof(VID_DEFAULT) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   698
        TPtr8 ptr( buf->Des() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   699
        ptr.Copy( *iImei );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   700
        ptr.Append(VID_DEFAULT);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   701
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   702
        hasher = CSHA1::NewL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   703
        CleanupStack::PushL(hasher);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   704
        hasher->Update(ptr);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   705
        hash.Copy(hasher->Final());
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   706
        key=hash.AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   707
        CleanupStack::PopAndDestroy(2,buf); // hasher,buf;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   708
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   709
        n = Min(key->Length(), KDeviceSpecificKeyLength);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   710
        iDeviceSpecificKey.Copy(key->Right(n));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   711
        delete key;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   712
        n = KDeviceSpecificKeyLength - n;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   713
        while (n > 0)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   714
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   715
            iDeviceSpecificKey.Append(0);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   716
            n--;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   717
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   718
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   719
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   720
    aKey.Copy(iDeviceSpecificKey);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   721
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   722
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   723
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   724
// CDrmStdKeyStorage::InitializeKeyL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   725
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   726
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   727
void CDrmStdKeyStorage::InitializeKeyL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   728
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   729
    HBufC8* key = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   730
    TASN1DecInteger encInt;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   731
    TInt pos = 0;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   732
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   733
    LOG(_L("CDrmStdKeyStorage::InitializeKeyL ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   734
    delete iKey;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   735
    iKey = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   736
    ReadFileL(iFs, KDeviceKeyFileName, key);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   737
    CleanupStack::PushL(key);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   738
    TASN1DecGeneric gen(*key);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   739
    gen.InitL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   740
    pos += gen.LengthDERHeader();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   741
    if (gen.Tag() != EASN1Sequence)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   742
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   743
        User::Leave(KErrArgument);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   744
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   745
    encInt.DecodeDERShortL(*key, pos); // version
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   746
    RInteger modulus = encInt.DecodeDERLongL(*key, pos);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   747
    CleanupStack::PushL(modulus);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   748
    RInteger publicExponent = encInt.DecodeDERLongL(*key, pos);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   749
    CleanupStack::PushL(publicExponent);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   750
    RInteger privateExponent = encInt.DecodeDERLongL(*key, pos);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   751
    CleanupStack::PushL(privateExponent);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   752
    iKey = CRSAPrivateKeyStandard::NewL(modulus, privateExponent);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   753
    CleanupStack::Pop(); // privateExponent
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   754
    CleanupStack::PopAndDestroy();// publicExponent
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   755
    CleanupStack::Pop(); // modulus
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   756
    CleanupStack::PopAndDestroy(); // key
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   757
    LOG(_L("CDrmStdKeyStorage::InitializeKeyL <-"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   758
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   759
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   760
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   761
// CDrmStdKeyStorage::ModularExponentiateWithKeyL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   762
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   763
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   764
HBufC8* CDrmStdKeyStorage::ModularExponentiateWithKeyL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   765
    const TDesC8& aInput)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   766
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   767
    RInteger result;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   768
    RInteger input;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   769
    HBufC8* output;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   770
    TInt keyLength = KKeyLength;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   771
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   772
    LOG(_L("CDrmStdKeyStorage::ModularExponentiateWithKeyL ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   773
    input = OS2IPL(aInput);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   774
    CleanupClosePushL(input);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   775
    result = TInteger::ModularExponentiateL(input,iKey->D(), iKey->N());
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   776
    CleanupClosePushL(result);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   777
    output = I2OSPL(result,  keyLength);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   778
    CleanupStack::PopAndDestroy(2); // result, input
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   779
    LOG(_L("CDrmStdKeyStorage::ModularExponentiateWithKeyL <-"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   780
    return output;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   781
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   782
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   783
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   784
// CDrmStdKeyStorage::CheckRootForCmlaL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   785
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   786
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   787
void CDrmStdKeyStorage::CheckRootForCmlaL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   788
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   789
    CDir* dir = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   790
    HBufC8* buffer = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   791
    HBufC* name = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   792
    CX509Certificate* cert = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   793
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   794
    LOG(_L("CDrmStdKeyStorage::CheckRootForCmlaL ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   795
    __UHEAP_MARK;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   796
    iFs.GetDir(KSingingCertPattern, KEntryAttNormal, ESortByName, dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   797
    CleanupStack::PushL(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   798
    ReadFileL(iFs, (*dir)[dir->Count() - 1].iName, buffer);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   799
    CleanupStack::PushL(buffer);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   800
    cert = CX509Certificate::NewL(*buffer);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   801
    CleanupStack::PushL(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   802
    name = cert->SubjectName().DisplayNameL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   803
    CleanupStack::PushL(name);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   804
    if (name->Find(KCmla) != KErrNotFound)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   805
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   806
        iRootIsCmla = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   807
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   808
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   809
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   810
        iRootIsCmla = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   811
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   812
    CleanupStack::PopAndDestroy(4); // name, cert, buffer, dir
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   813
    LOG(_L("CDrmStdKeyStorage::CheckRootForCmlaL <-"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   814
    __UHEAP_MARKEND;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   815
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   816
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   817
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   818
// CDrmStdKeyStorage::GetRdbSerialNumberL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   819
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   820
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   821
void CDrmStdKeyStorage::GetRdbSerialNumberL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   822
    TBuf8<KRdbSerialNumberLength>& aSerialNumber)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   823
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   824
    HBufC8* buffer = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   825
    TUint att;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   826
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   827
#ifndef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   828
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   829
    if (iFs.Att(KSerialNumberFile, att) != KErrNone)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   830
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   831
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   832
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   833
    TInt driveNumber( -1 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   834
    TChar driveLetter;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   835
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   836
    iFs.DriveToChar( driveNumber, driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   837
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   838
    TFileName serialNoFile;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   839
    serialNoFile.Format( KSerialNumberFile, (TUint)driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   840
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   841
    if (iFs.Att(serialNoFile, att) != KErrNone)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   842
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   843
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   844
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   845
        GenerateNewRdbSerialNumberL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   846
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   847
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   848
#ifndef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   849
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   850
    ReadFileL(iFs, KSerialNumberFile, buffer);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   851
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   852
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   853
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   854
    ReadFileL(iFs, serialNoFile, buffer);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   855
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   856
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   857
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   858
    aSerialNumber.Copy(*buffer);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   859
    delete buffer;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   860
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   861
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   862
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   863
// CDrmStdKeyStorage::GenerateNewRdbSerialNumberL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   864
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   865
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   866
void CDrmStdKeyStorage::GenerateNewRdbSerialNumberL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   867
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   868
    TBuf8<KRdbSerialNumberLength> serialNumber;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   869
    TPtr8 random( const_cast<TUint8*>(serialNumber.Ptr()),
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   870
                  KRdbSerialNumberLength,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   871
                  KRdbSerialNumberLength );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   872
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   873
    RandomDataGetL(random,KRdbSerialNumberLength);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   874
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   875
#ifndef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   876
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   877
    WriteFileL(iFs, KSerialNumberFile, random);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   878
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   879
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   880
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   881
    TInt driveNumber( -1 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   882
    TChar driveLetter;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   883
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   884
    iFs.DriveToChar( driveNumber, driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   885
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   886
    TFileName serialNoFile;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   887
    serialNoFile.Format( KSerialNumberFile, (TUint)driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   888
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   889
    WriteFileL(iFs, serialNoFile, random);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   890
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   891
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   892
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   893
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   894
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   895
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   896
// CDrmStdKeyStorage::UdtEncryptL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   897
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   898
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   899
HBufC8* CDrmStdKeyStorage::UdtEncryptL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   900
    const TDesC8& aInput)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   901
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   902
    HBufC8* buffer = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   903
    HBufC8* output = HBufC8::NewMaxLC( 256 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   904
    CX509Certificate* cert = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   905
    CRSAPublicKey* key = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   906
    TX509KeyFactory factory;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   907
    CRSAPKCS1v15Encryptor* encryptor = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   908
    TPtr8 result(const_cast<TUint8*>(output->Ptr()), 0, 256);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   909
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   910
#ifndef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   911
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   912
    ReadFileL(iFs, KUdtCertFileName, buffer);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   913
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   914
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   915
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   916
    TInt driveNumber( -1 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   917
    TChar driveLetter;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   918
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   919
    iFs.DriveToChar( driveNumber, driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   920
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   921
    TFileName udtCertFile;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   922
    udtCertFile.Format( KUdtCertFileName, (TUint)driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   923
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   924
    ReadFileL(iFs, udtCertFile, buffer);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   925
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   926
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   927
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   928
    CleanupStack::PushL(buffer);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   929
    cert = CX509Certificate::NewL(*buffer);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   930
    CleanupStack::PushL(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   931
    key = factory.RSAPublicKeyL(cert->PublicKey().KeyData());
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   932
    CleanupStack::PushL(key);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   933
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   934
    encryptor = CRSAPKCS1v15Encryptor::NewLC(*key);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   935
    encryptor->EncryptL(aInput, result);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   936
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   937
    CleanupStack::PopAndDestroy(4); // encryptor, key, cert, buffer
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   938
    CleanupStack::Pop();// output
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   939
    return output;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   940
    };
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   941
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   942
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   943
// CDrmStdKeyStorage::GetRootCertificatesL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   944
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   945
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   946
void CDrmStdKeyStorage::GetRootCertificatesL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   947
          RPointerArray<HBufC8>& aRootCerts)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   948
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   949
    CDir* dir = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   950
    CDir* rootCerts = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   951
    TFileName dirName;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   952
    HBufC8* cert = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   953
    TInt i = 0;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   954
    TBuf<256> path;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   955
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   956
    iFs.SessionPath( path );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   957
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   958
#ifndef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   959
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   960
    if (iFs.GetDir(KKeyStoragePath, KEntryAttDir, ESortByName, dir) == KErrNone)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   961
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   962
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   963
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   964
    TFileName tempPath;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   965
    TInt driveNumber( -1 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   966
    TChar driveLetter;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   967
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   968
    iFs.DriveToChar( driveNumber, driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   969
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   970
    tempPath.Format( KKeyStoragePath, (TUint)driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   971
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   972
    if (iFs.GetDir(tempPath, KEntryAttDir, ESortByName, dir) == KErrNone)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   973
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   974
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   975
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   976
        CleanupStack::PushL(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   977
        for(i = 0; i < dir->Count(); i++)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   978
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   979
            if ((*dir)[i].IsDir())
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   980
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   981
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   982
#ifndef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   983
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   984
                dirName.Copy(KKeyStoragePath);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   985
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   986
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   987
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   988
                dirName.Copy(tempPath);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   989
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   990
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   991
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   992
                dirName.Append((*dir)[i].iName);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   993
                dirName.Append('\\');
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   994
                User::LeaveIfError(iFs.SetSessionPath(dirName));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   995
                User::LeaveIfError(iFs.GetDir(KSingingCertPattern, KEntryAttNormal, ESortByName, rootCerts));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   996
                CleanupStack::PushL(rootCerts);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   997
                ReadFileL(iFs, (*rootCerts)[rootCerts->Count() - 1].iName, cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   998
                CleanupStack::PushL(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   999
                aRootCerts.AppendL(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1000
                CleanupStack::Pop(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1001
                CleanupStack::PopAndDestroy(); // rootCerts
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1002
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1003
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1004
        CleanupStack::PopAndDestroy(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1005
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1006
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1007
#ifndef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1008
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1009
    if (iFs.GetDir(KRomKeyStoragePath, KEntryAttDir, ESortByName, dir) == KErrNone)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1010
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1011
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1012
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1013
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1014
    iFs.DriveToChar( driveNumber, driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1015
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1016
    tempPath.Format( KRomKeyStoragePath, (TUint)driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1017
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1018
    if (iFs.GetDir(tempPath, KEntryAttDir, ESortByName, dir) == KErrNone)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1019
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1020
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1021
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1022
        CleanupStack::PushL(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1023
        for(i = 0; i < dir->Count(); i++)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1024
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1025
            if ((*dir)[i].IsDir())
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1026
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1027
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1028
#ifndef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1029
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1030
                dirName.Copy(KRomKeyStoragePath);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1031
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1032
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1033
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1034
                dirName.Copy(tempPath);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1035
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1036
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1037
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1038
                dirName.Append((*dir)[i].iName);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1039
                dirName.Append('\\');
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1040
                User::LeaveIfError(iFs.SetSessionPath(dirName));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1041
                User::LeaveIfError(iFs.GetDir(KSingingCertPattern, KEntryAttNormal, ESortByName, rootCerts));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1042
                CleanupStack::PushL(rootCerts);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1043
                ReadFileL(iFs, (*rootCerts)[rootCerts->Count() - 1].iName, cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1044
                CleanupStack::PushL(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1045
                aRootCerts.AppendL(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1046
                CleanupStack::Pop(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1047
                CleanupStack::PopAndDestroy(); // rootCerts
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1048
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1049
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1050
        CleanupStack::PopAndDestroy(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1051
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1052
    iFs.SetSessionPath( path );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1053
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1054
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1055
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1056
// CDrmStdKeyStorage::GetIMEIL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1057
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1058
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1059
const TDesC& CDrmStdKeyStorage::GetImeiL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1060
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1061
    if ( iImei )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1062
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1063
        return *iImei;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1064
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1065
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1066
#if (defined __WINS__ || defined WINSCW)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1067
    // Default IMEI used for emulator
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1068
    _LIT( KDefaultSerialNumber, "123456789123456789" );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1069
    iImei = KDefaultSerialNumber().AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1070
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1071
    return *iImei;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1072
#else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1073
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1074
    TInt error( KErrNone );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1075
    TInt count( 0 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1076
    TInt count2( 0 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1077
    TUint32 caps( 0 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1078
    TBool found (EFalse);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1079
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1080
    RTelServer etelServer;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1081
    RMobilePhone phone;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1082
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1083
    TUint KMaxImeiTries = 5;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1084
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1085
    for ( TUint8 i = 0; i < KMaxImeiTries; ++i )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1086
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1087
        error = etelServer.Connect();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1088
        if ( error )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1089
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1090
            User::After( TTimeIntervalMicroSeconds32( KWaitingTime ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1091
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1092
        else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1093
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1094
            break;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1095
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1096
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1097
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1098
    User::LeaveIfError( error );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1099
    CleanupClosePushL( etelServer );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1100
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1101
    User::LeaveIfError( etelServer.LoadPhoneModule( KMmTsyModuleName ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1102
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1103
    TUnloadModule unload;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1104
    unload.iServer = &etelServer;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1105
    unload.iName = &KMmTsyModuleName;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1106
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1107
    TCleanupItem item( DoUnloadPhoneModule, &unload );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1108
    CleanupStack::PushL( item );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1109
    User::LeaveIfError( etelServer.EnumeratePhones( count ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1110
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1111
    for ( count2 = 0; count2 < count && !found; ++count2 )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1112
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1113
        RTelServer::TPhoneInfo phoneInfo;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1114
        User::LeaveIfError( etelServer.GetTsyName( count2, phoneInfo.iName ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1115
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1116
        if ( phoneInfo.iName.CompareF(KMmTsyModuleName()) == 0 )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1117
           {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1118
            User::LeaveIfError( etelServer.GetPhoneInfo( count2, phoneInfo ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1119
            User::LeaveIfError( phone.Open( etelServer, phoneInfo.iName ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1120
            CleanupClosePushL( phone );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1121
            found = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1122
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1123
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1124
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1125
    if ( !found )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1126
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1127
        // Not found.
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1128
        User::Leave( KErrNotFound );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1129
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1130
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1131
    User::LeaveIfError( phone.GetIdentityCaps( caps ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1132
    if (!( caps & RMobilePhone::KCapsGetSerialNumber ))
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1133
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1134
         User::Leave( KErrNotFound );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1135
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1136
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1137
    RMobilePhone::TMobilePhoneIdentityV1 id;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1138
    TRequestStatus status;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1139
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1140
    phone.GetPhoneId( status, id );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1141
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1142
    User::WaitForRequest( status );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1143
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1144
    User::LeaveIfError( status.Int() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1145
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1146
    iImei = id.iSerialNumber.AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1147
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1148
    CleanupStack::PopAndDestroy( 3 ); // phone, item, etelServer
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1149
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1150
    HBufC8* buf = HBufC8::NewL( iImei->Size() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1151
    TPtr8 ptr( buf->Des() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1152
    ptr.Copy( *iImei );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1153
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1154
    LOG(_L("IMEI:"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1155
    LOGHEX(ptr);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1156
    delete buf;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1157
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1158
    return *iImei;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1159
#endif /* __WINS__ , WINSCW */
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1160
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1161
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1162
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1163
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1164
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1165
// CDrmStdKeyStorage::RandomDataGetL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1166
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1167
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1168
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1169
void CDrmStdKeyStorage::RandomDataGetL( TDes8& aData, const TInt aLength )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1170
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1171
    if ( aLength <= 0 )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1172
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1173
         User::Leave(KErrArgument);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1174
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1175
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1176
    TInt size = aData.MaxSize();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1177
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1178
    if( size < aLength )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1179
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1180
        User::Leave(KErrOverflow);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1181
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1182
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1183
    TRandom::Random( aData );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1184
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1185
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1186
// end of file