2015-04-02 13:08:27 -07: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-23 15:04:49 -07:00
|
|
|
|
2015-01-11 23:15:55 -08:00
|
|
|
#ifndef __ClearKeyDecryptionManager_h__
|
|
|
|
#define __ClearKeyDecryptionManager_h__
|
2014-09-23 15:04:49 -07:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include "ClearKeyUtils.h"
|
2014-12-18 12:54:34 -08:00
|
|
|
#include "RefCounted.h"
|
2014-09-23 15:04:49 -07:00
|
|
|
|
|
|
|
class ClearKeyDecryptor;
|
2015-01-11 23:15:55 -08:00
|
|
|
|
|
|
|
class ClearKeyDecryptionManager : public RefCounted
|
2014-09-23 15:04:49 -07:00
|
|
|
{
|
2015-01-11 23:15:55 -08:00
|
|
|
private:
|
2014-10-27 18:11:55 -07:00
|
|
|
ClearKeyDecryptionManager();
|
2015-01-11 23:15:55 -08:00
|
|
|
~ClearKeyDecryptionManager();
|
2014-09-23 15:04:49 -07:00
|
|
|
|
2015-01-11 23:15:55 -08:00
|
|
|
static ClearKeyDecryptionManager* sInstance;
|
2014-09-23 15:04:49 -07:00
|
|
|
|
2015-01-11 23:15:55 -08:00
|
|
|
public:
|
|
|
|
static ClearKeyDecryptionManager* Get();
|
2014-09-23 15:04:49 -07:00
|
|
|
|
2015-01-11 23:15:55 -08:00
|
|
|
bool HasSeenKeyId(const KeyId& aKeyId) const;
|
|
|
|
bool HasKeyForKeyId(const KeyId& aKeyId) const;
|
2014-09-23 15:04:49 -07:00
|
|
|
|
2015-01-11 23:15:55 -08:00
|
|
|
const Key& GetDecryptionKey(const KeyId& aKeyId);
|
2014-09-23 15:04:49 -07:00
|
|
|
|
2015-01-11 23:15:55 -08: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-23 15:04:49 -07:00
|
|
|
|
2015-01-11 23:15:55 -08:00
|
|
|
GMPErr Decrypt(uint8_t* aBuffer, uint32_t aBufferSize,
|
2015-01-15 13:37:54 -08:00
|
|
|
const GMPEncryptedBufferMetadata* aMetadata);
|
2014-09-23 15:04:49 -07:00
|
|
|
|
2015-01-11 23:15:55 -08:00
|
|
|
void Shutdown();
|
2014-12-18 12:54:34 -08:00
|
|
|
|
2014-09-23 15:04:49 -07:00
|
|
|
private:
|
2015-01-11 23:15:55 -08:00
|
|
|
bool IsExpectingKeyForKeyId(const KeyId& aKeyId) const;
|
2014-09-23 15:04:49 -07:00
|
|
|
|
|
|
|
std::map<KeyId, ClearKeyDecryptor*> mDecryptors;
|
|
|
|
};
|
|
|
|
|
2015-01-11 23:15:55 -08:00
|
|
|
#endif // __ClearKeyDecryptionManager_h__
|