2015-04-02 23:08:27 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2015, Mozilla Foundation and contributors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2014-09-24 02:04:49 +04:00
|
|
|
|
2015-01-12 10:15:55 +03:00
|
|
|
#ifndef __ClearKeyDecryptionManager_h__
|
|
|
|
#define __ClearKeyDecryptionManager_h__
|
2014-09-24 02:04:49 +04:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include "ClearKeyUtils.h"
|
2014-12-18 23:54:34 +03:00
|
|
|
#include "RefCounted.h"
|
2014-09-24 02:04:49 +04:00
|
|
|
|
|
|
|
class ClearKeyDecryptor;
|
2015-01-12 10:15:55 +03:00
|
|
|
|
|
|
|
class ClearKeyDecryptionManager : public RefCounted
|
2014-09-24 02:04:49 +04:00
|
|
|
{
|
2015-01-12 10:15:55 +03:00
|
|
|
private:
|
2014-10-28 04:11:55 +03:00
|
|
|
ClearKeyDecryptionManager();
|
2015-01-12 10:15:55 +03:00
|
|
|
~ClearKeyDecryptionManager();
|
2014-09-24 02:04:49 +04:00
|
|
|
|
2015-01-12 10:15:55 +03:00
|
|
|
static ClearKeyDecryptionManager* sInstance;
|
2014-09-24 02:04:49 +04:00
|
|
|
|
2015-01-12 10:15:55 +03:00
|
|
|
public:
|
|
|
|
static ClearKeyDecryptionManager* Get();
|
2014-09-24 02:04:49 +04:00
|
|
|
|
2015-01-12 10:15:55 +03:00
|
|
|
bool HasSeenKeyId(const KeyId& aKeyId) const;
|
|
|
|
bool HasKeyForKeyId(const KeyId& aKeyId) const;
|
2014-09-24 02:04:49 +04:00
|
|
|
|
2015-01-12 10:15:55 +03:00
|
|
|
const Key& GetDecryptionKey(const KeyId& aKeyId);
|
2014-09-24 02:04:49 +04:00
|
|
|
|
2015-01-12 10:15:55 +03:00
|
|
|
// Create a decryptor for the given KeyId if one does not already exist.
|
|
|
|
void InitKey(KeyId aKeyId, Key aKey);
|
|
|
|
void ExpectKeyId(KeyId aKeyId);
|
|
|
|
void ReleaseKeyId(KeyId aKeyId);
|
2014-09-24 02:04:49 +04:00
|
|
|
|
2015-01-12 10:15:55 +03:00
|
|
|
GMPErr Decrypt(uint8_t* aBuffer, uint32_t aBufferSize,
|
2015-01-16 00:37:54 +03:00
|
|
|
const GMPEncryptedBufferMetadata* aMetadata);
|
2014-09-24 02:04:49 +04:00
|
|
|
|
2015-01-12 10:15:55 +03:00
|
|
|
void Shutdown();
|
2014-12-18 23:54:34 +03:00
|
|
|
|
2014-09-24 02:04:49 +04:00
|
|
|
private:
|
2015-01-12 10:15:55 +03:00
|
|
|
bool IsExpectingKeyForKeyId(const KeyId& aKeyId) const;
|
2014-09-24 02:04:49 +04:00
|
|
|
|
|
|
|
std::map<KeyId, ClearKeyDecryptor*> mDecryptors;
|
|
|
|
};
|
|
|
|
|
2015-01-12 10:15:55 +03:00
|
|
|
#endif // __ClearKeyDecryptionManager_h__
|