// Copyright 2012 Google Inc. All Rights Reserved. // // OEMCrypto Client - wrapper class for C-style OEMCrypto interface // #ifndef CDM_BASE_CRYPTO_ENGINE_H_ #define CDM_BASE_CRYPTO_ENGINE_H_ #include #include #include #include "crypto_session.h" #include "lock.h" #include "wv_cdm_types.h" namespace wvcdm { typedef std::map CryptoSessionMap; class CryptoEngine { friend class CryptoSession; private: CryptoEngine(); ~CryptoEngine(); public: // get an instance of Crypto engine static CryptoEngine* GetInstance(); bool Init(); bool Terminate(); bool ValidateKeybox(); CryptoSession* CreateSession(const CdmSessionId& session_id); CryptoSession* FindSession(const CdmSessionId& session_id); bool DestroySession(const CdmSessionId& session_id); bool DestroySessions(); bool GetToken(std::string* token); typedef enum { kSecurityLevelL1, kSecurityLevelL2, kSecurityLevelL3, kSecurityLevelUnknown } SecurityLevel; SecurityLevel GetSecurityLevel(); bool GetDeviceUniqueId(std::string* deviceId); bool GetSystemId(uint32_t* systemId); bool GetProvisioningId(std::string* provisioningId); private: void DeleteInstance(); static CryptoEngine* CreateSingleton(); CryptoSession* FindSessionInternal(const CdmSessionId& session_id); static CryptoEngine* crypto_engine_; static Lock crypto_engine_lock_; bool initialized_; mutable Lock crypto_lock_; mutable Lock sessions_lock_; CryptoSessionMap sessions_; CORE_DISALLOW_COPY_AND_ASSIGN(CryptoEngine); }; }; // namespace wvcdm #endif // CDM_BASE_CRYPTO_ENGINE_H_