wmdrm/inc/wmdrmkeystorage.h
changeset 0 95b198f216e5
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Declaration of the WMDRM key storage
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef WMDRMKEYSTORAGE_H
       
    20 #define WMDRMKEYSTORAGE_H
       
    21 
       
    22 #include <e32std.h>
       
    23 #include <e32base.h>
       
    24 
       
    25 const TInt KDeviceSpecificKeyLength = 16;
       
    26 
       
    27 /**
       
    28  *  Hardware key storage access via the Security Driver
       
    29  *
       
    30  *  @since S60 3.2
       
    31  */
       
    32 NONSHARABLE_CLASS( CWmDrmKeyStorage ): public CBase
       
    33     {
       
    34 public:
       
    35 
       
    36     /**
       
    37     * NewL
       
    38     * creates an instance of the CWmDrmKeyStorageClass
       
    39     *
       
    40     * @param    aKeyIndex   Index of the key to be used
       
    41     *           Optional parameter, not currently used   
       
    42     * @return   CWmDrmKeyStorage -object
       
    43     * @leave    Symbian OS or internal error code
       
    44     */
       
    45     IMPORT_C static CWmDrmKeyStorage* NewL( TInt aKeyIndex = 0 );
       
    46     
       
    47     /**
       
    48     * GetCertificateL
       
    49     * request the device certificate in 8bit buffer 
       
    50     * caller responsible for releasing the buffer
       
    51     *
       
    52     * @return   Device WMDRM certificate in an 8bit buffer
       
    53     * @leave    Symbian OS or internal error code
       
    54     */
       
    55     virtual HBufC8* GetCertificateL() = 0;
       
    56     
       
    57     /**
       
    58     * GetUniqueIdL
       
    59     *
       
    60     * request a 20byte unique Id such as SHA1 hash of some device 
       
    61     * specific value, single Unique Id per device
       
    62     *
       
    63     * caller is responsible for releasing the buffer 
       
    64     *
       
    65     * @return   Unique Id in an 8bit buffer
       
    66     * @leave    Symbian OS or internal error code
       
    67     */    
       
    68     virtual HBufC8* GetUniqueIdL() = 0;
       
    69     
       
    70     /**
       
    71     * GetUniqueIdRawL
       
    72     *
       
    73     * request a 20byte unique Id such as SHA1 hash of some device 
       
    74     * specific value, single Unique Id per device base 64 encoded
       
    75     * and in a 16bit buffer
       
    76     *
       
    77     * caller is responsible for releasing the buffer 
       
    78     *
       
    79     * @return   Base 64 encoded Unique Id in a 16bit buffer
       
    80     * @leave    Symbian OS or internal error code
       
    81     */     
       
    82     virtual HBufC* GetUniqueIdRawL() = 0;
       
    83     
       
    84     /**
       
    85     * GetUniqueIdL
       
    86     *
       
    87     * request a 20byte unique Id such as SHA1 hash of some device 
       
    88     * specific value, single Unique Id per device result is base 64 encoded
       
    89     *
       
    90     * caller is responsible for releasing the buffer 
       
    91     *
       
    92     * @return   Unique Id in an 8bit buffer base 64 encoded
       
    93     * @leave    Symbian OS or internal error code
       
    94     */  
       
    95     virtual HBufC8* GetUniqueIdB64L() = 0;
       
    96 
       
    97     /**
       
    98     * GetPublicKeyL
       
    99     *
       
   100     * request the WMDRM public key of the device in an 8bit descriptor
       
   101     *
       
   102     * caller is responsible for releasing the buffer 
       
   103     *
       
   104     * @return   WMDRM public key in an 8bit buffer
       
   105     * @leave    Symbian OS or internal error code
       
   106     */    
       
   107     virtual HBufC8* GetPublicKeyL() = 0;
       
   108     
       
   109     /**
       
   110     * GetPublicKeyB64L
       
   111     *
       
   112     * request the WMDRM public key of the device in an 8bit descriptor
       
   113     * base 64 encoded
       
   114     *
       
   115     * caller is responsible for releasing the buffer 
       
   116     *
       
   117     * @return   WMDRM public key in an 8bit buffer base 64 encoded
       
   118     * @leave    Symbian OS or internal error code
       
   119     */     
       
   120     virtual HBufC8* GetPublicKeyB64L() = 0;
       
   121 
       
   122     /**
       
   123     * SignEcDsaL
       
   124     *
       
   125     * Signs the data using the device WMDRM private key
       
   126     *
       
   127     * caller is responsible for releasing the buffer 
       
   128     *
       
   129     * @param    aData       Data buffer from which the hash is calculated
       
   130     * @return   EcDsa signature in an 8bit descriptor
       
   131     * @leave    Symbian OS or internal error code
       
   132     */     
       
   133     virtual HBufC8* SignEcDsaL( const TDesC8& aData ) = 0;
       
   134     
       
   135     /**
       
   136     * VerifyEcDsaL
       
   137     *
       
   138     * Verifies using the WMDRM public key that the signature is valid
       
   139     *
       
   140     * @param    aData       Data buffer from which the hash is calculated
       
   141     * @param    aSignature  The signature to be checked against
       
   142     * @return   ETrue if the signature check succeeded, 
       
   143                 EFalse if the signature check failed
       
   144     * @leave    Symbian OS or internal error code
       
   145     */     
       
   146     virtual TBool VerifyEcDsaL( const TDesC8& aData, const TDesC8& aSignature ) = 0;
       
   147     
       
   148     
       
   149     /**
       
   150     * VerifyEcDsaL
       
   151     *
       
   152     * Verifies using the given key that the signature is valid
       
   153     *
       
   154     * @param    aKey        The key in 8bit buffer to be used for signature
       
   155     *                       calculation
       
   156     * @param    aData       Data buffer from which the hash is calculated
       
   157     * @param    aSignature  The signature to be checked against    
       
   158     * @return   ETrue if the signature check succeeded , 
       
   159                 EFalse if the signature check failed
       
   160     * @leave    Symbian OS or internal error code
       
   161     */     
       
   162     virtual TBool VerifyEcDsaL( const TDesC8& aKey, const TDesC8& aData, const TDesC8& aSignature ) = 0;
       
   163     
       
   164     
       
   165     /**
       
   166     * DecryptEcIesL
       
   167     *
       
   168     * Decrypts the EcIes encrypted data using the device private key
       
   169     *
       
   170     * caller is responsible for releasing the buffer 
       
   171     *
       
   172     * @param    aData       Data buffer containing the encrypted data
       
   173     * @return   Decrypted data in 8bit descriptor
       
   174     * @leave    Symbian OS or internal error code
       
   175     */     
       
   176     virtual HBufC8* DecryptEcIesL( const TDesC8& aData ) = 0;
       
   177 
       
   178     /**
       
   179     * EncryptEcIesL
       
   180     *
       
   181     * Encrypts the data using the device WMDRM private key
       
   182     *
       
   183     * caller is responsible for releasing the buffer 
       
   184     *
       
   185     * @param    aData       Data buffer to be encrypted
       
   186     * @return   Encrypted data in 8bit descriptor
       
   187     * @leave    Symbian OS or internal error code
       
   188     */
       
   189     virtual HBufC8* EncryptEcIesL( const TDesC8& aData ) = 0;
       
   190     
       
   191     /**
       
   192     * EncryptEcIesL
       
   193     *
       
   194     * Encrypts the data using the given key
       
   195     *
       
   196     * caller is responsible for releasing the buffer 
       
   197     *
       
   198     * @param    aKey        Key to be used for EcIes encryption in an 8bit buffer
       
   199     * @param    aData       Data buffer to be encrypted
       
   200     * @return   Encrypted data in 8bit descriptor
       
   201     * @leave    Symbian OS or internal error code
       
   202     */    
       
   203     virtual HBufC8* EncryptEcIesL( const TDesC8& aKey, const TDesC8& aData ) = 0;
       
   204 
       
   205 
       
   206     /**
       
   207     * GetDeviceSpecificKeyL
       
   208     *
       
   209     * request a device specific 16 byte key in an 8bit descriptor
       
   210     *
       
   211     * caller is responsible for releasing the buffer 
       
   212     *
       
   213     * @param    aKey    Device specific 16 byte key in an 8bit buffer
       
   214     * @leave    Symbian OS or internal error code
       
   215     */  
       
   216     virtual void GetDeviceSpecificKeyL(
       
   217         TBuf8<KDeviceSpecificKeyLength>& aKey) = 0;
       
   218 
       
   219     /**
       
   220     * GetSymmetricKeyL
       
   221     *
       
   222     * request the WMDRM symmetric key from the WMDRM certificate in 
       
   223     * an 8bit descriptor
       
   224     *
       
   225     * caller is responsible for releasing the buffer 
       
   226     *
       
   227     * @return   WMDRM symmetric key in an 8bit buffer
       
   228     * @leave    Symbian OS or internal error code
       
   229     */  
       
   230     virtual HBufC8* GetSymmetricKeyL() = 0;
       
   231     };
       
   232 
       
   233 #endif // WMDRMKEYSTORAGE_H