breakdeps/DRMEngine/DrmStdKeyStorage.cpp
author Tom Pritchard <tomp@symbian.org>
Wed, 27 Oct 2010 15:05:33 +0100
changeset 90 62156f66dbad
parent 88 ca165d35976d
permissions -rw-r--r--
Breaking DRM's dependency Etel so that AVKON can start. The ROM now boots, but doesn't seem to have any items in the matrix menu at all.
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() );
90
62156f66dbad Breaking DRM's dependency Etel so that AVKON can start. The ROM now boots, but doesn't seem to have any items in the matrix menu at all.
Tom Pritchard <tomp@symbian.org>
parents: 88
diff changeset
   167
#if 0
88
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   168
    TUnloadModule* module = ( TUnloadModule* ) aAny;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   169
    module->iServer->UnloadPhoneModule( *( module->iName ) );
90
62156f66dbad Breaking DRM's dependency Etel so that AVKON can start. The ROM now boots, but doesn't seem to have any items in the matrix menu at all.
Tom Pritchard <tomp@symbian.org>
parents: 88
diff changeset
   170
#endif
88
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
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
// ============================ MEMBER FUNCTIONS ===============================
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   175
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
// CDrmStdKeyStorage* CDrmStdKeyStorage::NewL
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
// -----------------------------------------------------------------------------
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
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
   182
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   183
    CDrmStdKeyStorage* self = new (ELeave) CDrmStdKeyStorage(aLibrary);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   184
    CleanupStack::PushL(self);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   185
    self->ConstructL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   186
    CleanupStack::Pop();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   187
    return self;
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
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
// CDrmStdKeyStorage::CDrmStdKeyStorage
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
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   194
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   195
CDrmStdKeyStorage::CDrmStdKeyStorage(RLibrary aLibrary):
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   196
    iFileMan(NULL),
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   197
    iRootSelected(EFalse),
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   198
    iKey(NULL),
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   199
    iImei(NULL),
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   200
    iLibrary(aLibrary)
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
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
// CDrmStdKeyStorage::ConstructL
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
// -----------------------------------------------------------------------------
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
void CDrmStdKeyStorage::ConstructL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   210
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   211
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   212
    LOG(_L("CDrmStdKeyStorage::ConstructL ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   213
    User::LeaveIfError(iFs.Connect());
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   214
    iFileMan = CFileMan::NewL(iFs);
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
    FeatureManager::InitializeLibL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   217
    
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   218
#ifdef __DRM_OMA2 
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   219
    if ( FeatureManager::FeatureSupported( KFeatureIdFfOmadrm2Support ) )
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
        TRAP_IGNORE( SelectDefaultRootL() );
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
#endif
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
    FeatureManager::UnInitializeLib();
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
    iDeviceSpecificKey.Copy(KDefaultKey);
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
    LOG(_L("CDrmStdKeyStorage::ConstructL <-"));
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
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
// MDrmKeyStorage::~MDrmKeyStorage
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
//
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
MDrmKeyStorage::~MDrmKeyStorage()
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
    }
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
// DrmStdKeyStorage::~CDrmStdKeyStorage
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
//
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
CDrmStdKeyStorage::~CDrmStdKeyStorage()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   248
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   249
    LOG(_L("CDrmStdKeyStorage::~CDrmStdKeyStorage ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   250
    delete iFileMan;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   251
    delete iKey;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   252
    delete iImei; iImei = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   253
    iFs.Close();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   254
    //iLibrary.Close();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   255
    LOG(_L("CDrmStdKeyStorage::~CDrmStdKeyStorage <-"));
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
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
// DrmStdKeyStorage::ModulusSize
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
//
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
TInt 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
    LOG(_L("CDrmStdKeyStorage::ModulusSize ->"));
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
    if(iKey == NULL)
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
        return KErrGeneral;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   271
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   272
    LOG(_L("CDrmStdKeyStorage::ModulusSize <-"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   273
    return iKey->N().BitCount();
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
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
// DrmStdKeyStorage::SelectTrustedRootL
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
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   280
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   281
void CDrmStdKeyStorage::SelectTrustedRootL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   282
    const TDesC8& aRootKeyHash)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   283
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   284
    TFileName fileName;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   285
    TEntry entry;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   286
    TInt i;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   287
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   288
    LOG(_L("CDrmStdKeyStorage::SelectTrustedRootL ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   289
    LOG(aRootKeyHash);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   290
    if (aRootKeyHash.Length() != 0)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   291
        {
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
#ifndef RD_MULTIPLE_DRIVE
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
        fileName.Copy(KKeyStoragePath);
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
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   298
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   299
        TFileName tempPath;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   300
        TInt driveNumber( -1 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   301
        TChar driveLetter;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   302
        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   303
        iFs.DriveToChar( driveNumber, 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
        tempPath.Format( KKeyStoragePath, (TUint)driveLetter );
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
        fileName.Copy(tempPath);
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
#endif
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
        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
   312
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   313
            fileName.AppendNumFixedWidth(aRootKeyHash[i], EHex, 2);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   314
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   315
        fileName.Append('\\');
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   316
        if (iFs.Entry(fileName, entry) != KErrNone)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   317
            {
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
#ifndef RD_MULTIPLE_DRIVE
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
            fileName.Copy(KRomKeyStoragePath);
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
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   324
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   325
            DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   326
            iFs.DriveToChar( driveNumber, 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
            tempPath.Format( KRomKeyStoragePath, (TUint)driveLetter );
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
            fileName.Copy(tempPath);
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
#endif
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
            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
   335
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   336
                fileName.AppendNumFixedWidth(aRootKeyHash[i], EHex, 2);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   337
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   338
            fileName.Append('\\');
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   339
            // check that the path exists
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   340
            User::LeaveIfError(iFs.Entry(fileName, entry));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   341
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   342
        User::LeaveIfError(iFs.SetSessionPath(fileName));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   343
        InitializeKeyL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   344
        CheckRootForCmlaL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   345
        iRootSelected = ETrue;
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
    else
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
        SelectDefaultRootL();
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
    LOG(_L("CDrmStdKeyStorage::SelectTrustedRootL <-"));
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
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
// DrmStdKeyStorage::SelectDefaultRootL
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
// -----------------------------------------------------------------------------
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
void CDrmStdKeyStorage::SelectDefaultRootL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   360
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   361
    CDir* dir = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   362
    TFileName dirName;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   363
    TBool found = EFalse;
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
    LOG(_L("CDrmStdKeyStorage::SelectDefaultRootL ->"));
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
#ifndef RD_MULTIPLE_DRIVE
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
    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
   370
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   371
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   372
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   373
    TFileName tempPath;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   374
    TInt driveNumber( -1 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   375
    TChar driveLetter;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   376
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   377
    iFs.DriveToChar( driveNumber, 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
    tempPath.Format( KKeyStoragePath, (TUint)driveLetter );
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
    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
   382
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   383
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   384
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   385
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   386
        __UHEAP_MARK;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   387
        LOG(_L("  Checking keys on C:"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   388
        CleanupStack::PushL(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   389
        if (dir->Count() >= 1)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   390
            {
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
#ifndef RD_MULTIPLE_DRIVE
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
            dirName.Copy(KKeyStoragePath);
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
#else //RD_MULTIPLE_DRIVE
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
            dirName.Copy(tempPath);
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
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   401
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   402
            dirName.Append((*dir)[0].iName);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   403
            dirName.Append('\\');
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   404
            User::LeaveIfError(iFs.SetSessionPath(dirName));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   405
            found = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   406
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   407
        CleanupStack::PopAndDestroy(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   408
        __UHEAP_MARKEND;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   409
        }
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
#ifndef RD_MULTIPLE_DRIVE
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
    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
   414
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   415
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   416
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   417
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   418
    iFs.DriveToChar( driveNumber, 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
    tempPath.Format( KRomKeyStoragePath, (TUint)driveLetter );
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
    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
   423
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   424
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   425
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   426
        LOG(_L("  Checking keys on Z:"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   427
        CleanupStack::PushL(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   428
        if (dir->Count() < 1)
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
            User::Leave(KErrGeneral);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   431
            }
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
#ifndef RD_MULTIPLE_DRIVE
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
        dirName.Copy(KRomKeyStoragePath);
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
#else //RD_MULTIPLE_DRIVE
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
        dirName.Copy(tempPath);
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
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   442
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   443
        dirName.Append((*dir)[0].iName);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   444
        dirName.Append('\\');
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   445
        User::LeaveIfError(iFs.SetSessionPath(dirName));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   446
        CleanupStack::PopAndDestroy(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   447
        found = ETrue;
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
    if (!found)
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
        User::Leave(KErrGeneral);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   452
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   453
    InitializeKeyL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   454
    CheckRootForCmlaL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   455
    iRootSelected = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   456
    LOG(_L("CDrmStdKeyStorage::SelectDefaultRootL <-"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   457
    }
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
TBool CDrmStdKeyStorage::SelectedRootIsCmla()
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
    return iRootIsCmla;
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
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
// DrmStdKeyStorage::GetTrustedRootsL
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
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   469
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   470
void CDrmStdKeyStorage::GetTrustedRootsL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   471
    RPointerArray<HBufC8>& aRootList)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   472
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   473
    CDir* dir = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   474
    TInt i;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   475
    TInt j;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   476
    TBuf8<SHA1_HASH> hash;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   477
    TEntry entry;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   478
    TUint8 c;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   479
    TInt r = KErrNone;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   480
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   481
    LOG(_L("CDrmStdKeyStorage::GetTrustedRootsL ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   482
    aRootList.ResetAndDestroy();
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
#ifndef RD_MULTIPLE_DRIVE
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
    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
   487
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   488
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   489
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   490
    TFileName tempPath;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   491
    TInt driveNumber( -1 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   492
    TChar driveLetter;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   493
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   494
    iFs.DriveToChar( driveNumber, 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
    tempPath.Format( KKeyStoragePath, (TUint)driveLetter );
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
    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
   499
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   500
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   501
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   502
        LOG(_L("  Getting roots on C:"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   503
        CleanupStack::PushL(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   504
        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
   505
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   506
            entry = (*dir)[i];
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   507
            hash.SetLength(0);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   508
            LOG(entry.iName);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   509
            r = KErrNone;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   510
            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
   511
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   512
                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
   513
                r = lex.Val(c, EHex);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   514
                hash.Append(c);
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
            if (r == KErrNone)
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
                aRootList.Append(hash.AllocL());
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   519
                }
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
        CleanupStack::PopAndDestroy(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   522
        }
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
#ifndef RD_MULTIPLE_DRIVE
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
    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
   527
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   528
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   529
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   530
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   531
    iFs.DriveToChar( driveNumber, 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
    tempPath.Format( KRomKeyStoragePath, (TUint)driveLetter );
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
    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
   536
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   537
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   538
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   539
        LOG(_L("  Getting roots on Z:"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   540
        CleanupStack::PushL(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   541
        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
   542
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   543
            LOG(entry.iName);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   544
            entry = (*dir)[i];
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   545
            hash.SetLength(0);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   546
            r = KErrNone;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   547
            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
   548
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   549
                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
   550
                r = lex.Val(c, EHex);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   551
                hash.Append(c);
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
            if (r == KErrNone)
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
                aRootList.Append(hash.AllocL());
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   556
                }
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
        CleanupStack::PopAndDestroy(dir);
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
    LOG(_L("CDrmStdKeyStorage::GetTrustedRootsL <-"));
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
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
// DrmStdKeyStorage::GetCertificateChainL
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
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   567
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   568
void CDrmStdKeyStorage::GetCertificateChainL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   569
    RPointerArray<HBufC8>& aCertChain)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   570
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   571
    TFileName fileName;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   572
    TInt i;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   573
    CDir* dir = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   574
    HBufC8* cert = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   575
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   576
    LOG(_L("CDrmStdKeyStorage::GetCertificateChainL ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   577
    if (!iRootSelected)
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
        User::Leave(KErrGeneral);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   580
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   581
    aCertChain.ResetAndDestroy();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   582
    ReadFileL(iFs, KDeviceCertFileName, cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   583
    aCertChain.Append(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   584
    iFs.GetDir(KSingingCertPattern, KEntryAttNormal, ESortByName, dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   585
    CleanupStack::PushL(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   586
    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
   587
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   588
        ReadFileL(iFs, (*dir)[i].iName, cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   589
        aCertChain.AppendL(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   590
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   591
    CleanupStack::PopAndDestroy(); // dir
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   592
    LOG(_L("CDrmStdKeyStorage::GetCertificateChainL <-"));
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
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
// CDrmStdKeyStorage::RsaSignL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   597
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   598
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   599
HBufC8* CDrmStdKeyStorage::RsaSignL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   600
    const TDesC8& 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
    return ModularExponentiateWithKeyL(aInput);
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
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
// CDrmStdKeyStorage::RsaDecryptL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   607
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   608
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   609
HBufC8* CDrmStdKeyStorage::RsaDecryptL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   610
    const TDesC8& 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
    return ModularExponentiateWithKeyL(aInput);
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
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
// CDrmStdKeyStorage::ImportDataL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   617
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   618
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   619
void CDrmStdKeyStorage::ImportDataL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   620
    const TDesC8& aPrivateKey,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   621
    const RArray<TPtrC8>& aCertificateChain)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   622
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   623
    TInt i;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   624
    TInt n;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   625
    HBufC8* publicKey = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   626
    CX509Certificate* cert = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   627
    CSHA1* hasher = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   628
    TBuf8<SHA1_HASH> publicKeyHash;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   629
    TFileName fileName;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   630
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   631
    LOG(_L("CDrmStdKeyStorage::ImportDataL ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   632
    n = aCertificateChain.Count();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   633
    cert = CX509Certificate::NewLC(aCertificateChain[n - 1]);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   634
    publicKey = cert->DataElementEncoding(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   635
        CX509Certificate::ESubjectPublicKeyInfo)->AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   636
    CleanupStack::PushL(publicKey);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   637
    hasher = CSHA1::NewL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   638
    CleanupStack::PushL(hasher);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   639
    hasher->Update(*publicKey);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   640
    publicKeyHash.Copy(hasher->Final());
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
#ifndef RD_MULTIPLE_DRIVE
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
    fileName.Copy(KKeyStoragePath);
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
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   647
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   648
    TInt driveNumber( -1 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   649
    TChar driveLetter;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   650
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   651
    iFs.DriveToChar( driveNumber, driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   652
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   653
    TFileName keyStorageDir;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   654
    keyStorageDir.Format( KKeyStoragePath, (TUint)driveLetter );
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
    fileName.Copy(keyStorageDir);
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
#endif
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
    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
   661
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   662
        fileName.AppendNumFixedWidth(publicKeyHash[i], EHex, 2);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   663
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   664
    fileName.Append('\\');
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   665
    iFileMan->Delete(fileName, CFileMan::ERecurse);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   666
    iFs.MkDirAll(fileName);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   667
    iFs.SetSessionPath(fileName);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   668
    WriteFileL(iFs, KDeviceKeyFileName, aPrivateKey);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   669
    fileName.Copy(fileName);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   670
    WriteFileL(iFs, KDeviceCertFileName, aCertificateChain[0]);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   671
    for (i = 1; i < n; i++)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   672
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   673
        fileName.SetLength(0);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   674
        fileName.AppendFormat(KSingingCertFmt, i - 1);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   675
        WriteFileL(iFs, fileName, aCertificateChain[i]);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   676
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   677
    CleanupStack::PopAndDestroy(3); // hasher, publicKey, cert
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   678
    LOG(_L("CDrmStdKeyStorage::ImportDataL <-"));
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
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
// CDrmStdKeyStorage::GetDeviceSpecificKeyL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   683
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   684
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   685
void CDrmStdKeyStorage::GetDeviceSpecificKeyL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   686
    TBuf8<KDeviceSpecificKeyLength>& aKey)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   687
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   688
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   689
    HBufC8* key = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   690
    TInt n;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   691
    CSHA1* hasher = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   692
    TBuf8<SHA1_HASH> hash;
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
    if (iDeviceSpecificKey.Compare(KDefaultKey) == 0)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   695
        {
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
        GetImeiL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   698
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   699
        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
   700
        TPtr8 ptr( buf->Des() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   701
        ptr.Copy( *iImei );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   702
        ptr.Append(VID_DEFAULT);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   703
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   704
        hasher = CSHA1::NewL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   705
        CleanupStack::PushL(hasher);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   706
        hasher->Update(ptr);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   707
        hash.Copy(hasher->Final());
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   708
        key=hash.AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   709
        CleanupStack::PopAndDestroy(2,buf); // hasher,buf;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   710
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   711
        n = Min(key->Length(), KDeviceSpecificKeyLength);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   712
        iDeviceSpecificKey.Copy(key->Right(n));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   713
        delete key;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   714
        n = KDeviceSpecificKeyLength - n;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   715
        while (n > 0)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   716
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   717
            iDeviceSpecificKey.Append(0);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   718
            n--;
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
        }
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
    aKey.Copy(iDeviceSpecificKey);
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
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
// CDrmStdKeyStorage::InitializeKeyL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   727
// -----------------------------------------------------------------------------
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
void CDrmStdKeyStorage::InitializeKeyL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   730
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   731
    HBufC8* key = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   732
    TASN1DecInteger encInt;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   733
    TInt pos = 0;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   734
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   735
    LOG(_L("CDrmStdKeyStorage::InitializeKeyL ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   736
    delete iKey;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   737
    iKey = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   738
    ReadFileL(iFs, KDeviceKeyFileName, key);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   739
    CleanupStack::PushL(key);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   740
    TASN1DecGeneric gen(*key);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   741
    gen.InitL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   742
    pos += gen.LengthDERHeader();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   743
    if (gen.Tag() != EASN1Sequence)
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
        User::Leave(KErrArgument);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   746
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   747
    encInt.DecodeDERShortL(*key, pos); // version
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   748
    RInteger modulus = 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(modulus);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   750
    RInteger publicExponent = 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(publicExponent);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   752
    RInteger privateExponent = encInt.DecodeDERLongL(*key, pos);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   753
    CleanupStack::PushL(privateExponent);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   754
    iKey = CRSAPrivateKeyStandard::NewL(modulus, privateExponent);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   755
    CleanupStack::Pop(); // privateExponent
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   756
    CleanupStack::PopAndDestroy();// publicExponent
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   757
    CleanupStack::Pop(); // modulus
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   758
    CleanupStack::PopAndDestroy(); // key
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   759
    LOG(_L("CDrmStdKeyStorage::InitializeKeyL <-"));
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
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
// CDrmStdKeyStorage::ModularExponentiateWithKeyL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   764
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   765
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   766
HBufC8* CDrmStdKeyStorage::ModularExponentiateWithKeyL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   767
    const TDesC8& aInput)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   768
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   769
    RInteger result;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   770
    RInteger input;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   771
    HBufC8* output;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   772
    TInt keyLength = KKeyLength;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   773
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   774
    LOG(_L("CDrmStdKeyStorage::ModularExponentiateWithKeyL ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   775
    input = OS2IPL(aInput);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   776
    CleanupClosePushL(input);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   777
    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
   778
    CleanupClosePushL(result);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   779
    output = I2OSPL(result,  keyLength);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   780
    CleanupStack::PopAndDestroy(2); // result, input
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   781
    LOG(_L("CDrmStdKeyStorage::ModularExponentiateWithKeyL <-"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   782
    return output;
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
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
// CDrmStdKeyStorage::CheckRootForCmlaL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   787
// -----------------------------------------------------------------------------
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
void CDrmStdKeyStorage::CheckRootForCmlaL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   790
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   791
    CDir* dir = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   792
    HBufC8* buffer = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   793
    HBufC* name = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   794
    CX509Certificate* cert = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   795
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   796
    LOG(_L("CDrmStdKeyStorage::CheckRootForCmlaL ->"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   797
    __UHEAP_MARK;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   798
    iFs.GetDir(KSingingCertPattern, KEntryAttNormal, ESortByName, dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   799
    CleanupStack::PushL(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   800
    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
   801
    CleanupStack::PushL(buffer);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   802
    cert = CX509Certificate::NewL(*buffer);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   803
    CleanupStack::PushL(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   804
    name = cert->SubjectName().DisplayNameL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   805
    CleanupStack::PushL(name);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   806
    if (name->Find(KCmla) != KErrNotFound)
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
        iRootIsCmla = ETrue;
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
    else
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
        iRootIsCmla = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   813
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   814
    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
   815
    LOG(_L("CDrmStdKeyStorage::CheckRootForCmlaL <-"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   816
    __UHEAP_MARKEND;
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
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
// CDrmStdKeyStorage::GetRdbSerialNumberL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   821
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   822
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   823
void CDrmStdKeyStorage::GetRdbSerialNumberL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   824
    TBuf8<KRdbSerialNumberLength>& aSerialNumber)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   825
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   826
    HBufC8* buffer = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   827
    TUint att;
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
#ifndef RD_MULTIPLE_DRIVE
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
    if (iFs.Att(KSerialNumberFile, att) != KErrNone)
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
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   834
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   835
    TInt driveNumber( -1 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   836
    TChar driveLetter;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   837
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   838
    iFs.DriveToChar( driveNumber, driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   839
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   840
    TFileName serialNoFile;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   841
    serialNoFile.Format( KSerialNumberFile, (TUint)driveLetter );
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
    if (iFs.Att(serialNoFile, att) != KErrNone)
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
#endif
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
        GenerateNewRdbSerialNumberL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   848
        }
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
#ifndef RD_MULTIPLE_DRIVE
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
    ReadFileL(iFs, KSerialNumberFile, buffer);
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
#else //RD_MULTIPLE_DRIVE
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
    ReadFileL(iFs, serialNoFile, buffer);
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
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   859
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   860
    aSerialNumber.Copy(*buffer);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   861
    delete buffer;
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
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
// CDrmStdKeyStorage::GenerateNewRdbSerialNumberL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   866
// -----------------------------------------------------------------------------
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
void CDrmStdKeyStorage::GenerateNewRdbSerialNumberL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   869
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   870
    TBuf8<KRdbSerialNumberLength> serialNumber;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   871
    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
   872
                  KRdbSerialNumberLength,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   873
                  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
    RandomDataGetL(random,KRdbSerialNumberLength);
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
#ifndef RD_MULTIPLE_DRIVE
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
    WriteFileL(iFs, KSerialNumberFile, random);
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
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   882
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   883
    TInt driveNumber( -1 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   884
    TChar driveLetter;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   885
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   886
    iFs.DriveToChar( driveNumber, driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   887
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   888
    TFileName serialNoFile;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   889
    serialNoFile.Format( KSerialNumberFile, (TUint)driveLetter );
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
    WriteFileL(iFs, serialNoFile, random);
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
#endif
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
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
// CDrmStdKeyStorage::UdtEncryptL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   899
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   900
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   901
HBufC8* CDrmStdKeyStorage::UdtEncryptL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   902
    const TDesC8& aInput)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   903
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   904
    HBufC8* buffer = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   905
    HBufC8* output = HBufC8::NewMaxLC( 256 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   906
    CX509Certificate* cert = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   907
    CRSAPublicKey* key = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   908
    TX509KeyFactory factory;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   909
    CRSAPKCS1v15Encryptor* encryptor = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   910
    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
   911
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   912
#ifndef RD_MULTIPLE_DRIVE
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
    ReadFileL(iFs, KUdtCertFileName, buffer);
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
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   917
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   918
    TInt driveNumber( -1 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   919
    TChar driveLetter;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   920
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   921
    iFs.DriveToChar( driveNumber, driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   922
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   923
    TFileName udtCertFile;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   924
    udtCertFile.Format( KUdtCertFileName, (TUint)driveLetter );
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
    ReadFileL(iFs, udtCertFile, buffer);
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
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   929
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   930
    CleanupStack::PushL(buffer);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   931
    cert = CX509Certificate::NewL(*buffer);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   932
    CleanupStack::PushL(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   933
    key = factory.RSAPublicKeyL(cert->PublicKey().KeyData());
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   934
    CleanupStack::PushL(key);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   935
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   936
    encryptor = CRSAPKCS1v15Encryptor::NewLC(*key);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   937
    encryptor->EncryptL(aInput, result);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   938
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   939
    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
   940
    CleanupStack::Pop();// output
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   941
    return output;
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
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
// CDrmStdKeyStorage::GetRootCertificatesL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   946
// -----------------------------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   947
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   948
void CDrmStdKeyStorage::GetRootCertificatesL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   949
          RPointerArray<HBufC8>& aRootCerts)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   950
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   951
    CDir* dir = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   952
    CDir* rootCerts = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   953
    TFileName dirName;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   954
    HBufC8* cert = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   955
    TInt i = 0;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   956
    TBuf<256> 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
    iFs.SessionPath( path );
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
#ifndef RD_MULTIPLE_DRIVE
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
    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
   963
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   964
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   965
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   966
    TFileName tempPath;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   967
    TInt driveNumber( -1 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   968
    TChar driveLetter;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   969
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   970
    iFs.DriveToChar( driveNumber, 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
    tempPath.Format( KKeyStoragePath, (TUint)driveLetter );
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
    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
   975
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   976
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   977
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   978
        CleanupStack::PushL(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   979
        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
   980
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   981
            if ((*dir)[i].IsDir())
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   982
                {
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
#ifndef RD_MULTIPLE_DRIVE
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
                dirName.Copy(KKeyStoragePath);
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
#else //RD_MULTIPLE_DRIVE
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
                dirName.Copy(tempPath);
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
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   993
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   994
                dirName.Append((*dir)[i].iName);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   995
                dirName.Append('\\');
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   996
                User::LeaveIfError(iFs.SetSessionPath(dirName));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   997
                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
   998
                CleanupStack::PushL(rootCerts);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   999
                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
  1000
                CleanupStack::PushL(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1001
                aRootCerts.AppendL(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1002
                CleanupStack::Pop(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1003
                CleanupStack::PopAndDestroy(); // rootCerts
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1004
                }
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
        CleanupStack::PopAndDestroy(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1007
        }
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
#ifndef RD_MULTIPLE_DRIVE
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
    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
  1012
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1013
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1014
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1015
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1016
    iFs.DriveToChar( driveNumber, 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
    tempPath.Format( KRomKeyStoragePath, (TUint)driveLetter );
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
    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
  1021
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1022
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1023
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1024
        CleanupStack::PushL(dir);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1025
        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
  1026
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1027
            if ((*dir)[i].IsDir())
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1028
                {
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
#ifndef RD_MULTIPLE_DRIVE
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
                dirName.Copy(KRomKeyStoragePath);
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
#else //RD_MULTIPLE_DRIVE
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
                dirName.Copy(tempPath);
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
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1039
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1040
                dirName.Append((*dir)[i].iName);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1041
                dirName.Append('\\');
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1042
                User::LeaveIfError(iFs.SetSessionPath(dirName));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1043
                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
  1044
                CleanupStack::PushL(rootCerts);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1045
                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
  1046
                CleanupStack::PushL(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1047
                aRootCerts.AppendL(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1048
                CleanupStack::Pop(cert);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1049
                CleanupStack::PopAndDestroy(); // rootCerts
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1050
                }
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
        CleanupStack::PopAndDestroy(dir);
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
    iFs.SetSessionPath( path );
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
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
// CDrmStdKeyStorage::GetIMEIL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1059
// -----------------------------------------------------------------------------
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
const TDesC& CDrmStdKeyStorage::GetImeiL()
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
    if ( 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
        return *iImei;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1066
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1067
90
62156f66dbad Breaking DRM's dependency Etel so that AVKON can start. The ROM now boots, but doesn't seem to have any items in the matrix menu at all.
Tom Pritchard <tomp@symbian.org>
parents: 88
diff changeset
  1068
#if 1// (defined __WINS__ || defined WINSCW)
88
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1069
    // Default IMEI used for emulator
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1070
    _LIT( KDefaultSerialNumber, "123456789123456789" );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1071
    iImei = KDefaultSerialNumber().AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1072
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1073
    return *iImei;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1074
#else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1075
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1076
    TInt error( KErrNone );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1077
    TInt count( 0 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1078
    TInt count2( 0 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1079
    TUint32 caps( 0 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1080
    TBool found (EFalse);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1081
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1082
    RTelServer etelServer;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1083
    RMobilePhone phone;
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
    TUint KMaxImeiTries = 5;
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
    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
  1088
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1089
        error = etelServer.Connect();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1090
        if ( error )
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
            User::After( TTimeIntervalMicroSeconds32( KWaitingTime ) );
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
        else
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
            break;
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
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1099
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1100
    User::LeaveIfError( error );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1101
    CleanupClosePushL( etelServer );
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
    User::LeaveIfError( etelServer.LoadPhoneModule( KMmTsyModuleName ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1104
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1105
    TUnloadModule unload;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1106
    unload.iServer = &etelServer;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1107
    unload.iName = &KMmTsyModuleName;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1108
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1109
    TCleanupItem item( DoUnloadPhoneModule, &unload );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1110
    CleanupStack::PushL( item );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1111
    User::LeaveIfError( etelServer.EnumeratePhones( count ) );
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
    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
  1114
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1115
        RTelServer::TPhoneInfo phoneInfo;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1116
        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
  1117
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1118
        if ( phoneInfo.iName.CompareF(KMmTsyModuleName()) == 0 )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1119
           {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1120
            User::LeaveIfError( etelServer.GetPhoneInfo( count2, phoneInfo ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1121
            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
  1122
            CleanupClosePushL( phone );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1123
            found = ETrue;
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
        }
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
    if ( !found )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1128
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1129
        // Not found.
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1130
        User::Leave( KErrNotFound );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1131
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1132
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1133
    User::LeaveIfError( phone.GetIdentityCaps( caps ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1134
    if (!( caps & RMobilePhone::KCapsGetSerialNumber ))
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
         User::Leave( KErrNotFound );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1137
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1138
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1139
    RMobilePhone::TMobilePhoneIdentityV1 id;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1140
    TRequestStatus status;
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
    phone.GetPhoneId( status, id );
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::WaitForRequest( status );
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
    User::LeaveIfError( status.Int() );
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
    iImei = id.iSerialNumber.AllocL();
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
    CleanupStack::PopAndDestroy( 3 ); // phone, item, etelServer
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1151
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1152
    HBufC8* buf = HBufC8::NewL( iImei->Size() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1153
    TPtr8 ptr( buf->Des() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1154
    ptr.Copy( *iImei );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1155
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1156
    LOG(_L("IMEI:"));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1157
    LOGHEX(ptr);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1158
    delete buf;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1159
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1160
    return *iImei;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1161
#endif /* __WINS__ , WINSCW */
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
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
// CDrmStdKeyStorage::RandomDataGetL
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
//
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
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
  1172
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1173
    if ( aLength <= 0 )
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
         User::Leave(KErrArgument);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1176
        }
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
    TInt size = aData.MaxSize();
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
    if( size < aLength )
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
        User::Leave(KErrOverflow);
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1183
        }
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
    TRandom::Random( aData );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1186
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1187
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1188
// end of file