author Gregory Szorc <>
Tue, 24 Feb 2015 15:16:54 -0800
changeset 245746 6d143a910f5ecf67d9dec302087aa20777ec6772
parent 233073 ce51003483e4df7dd5afa6abb5fe4800f5795a8c
child 255798 38f4f036b6119f8c3d00480426c505fb07a80306
permissions -rw-r--r--
Bug 1132771 - Add Files to with ability to define Bugzilla component The Files sub-context allows us to attach metadata to files based on pattern matching rules. Patterns are matched against files in a last-write-wins fashion. The sub-context defines the BUG_COMPONENT variable, which is a 2-tuple (actually a named tuple) defining the Bugzilla product and component for files. There are no consumers yet. But an eventual use case will be to suggest a bug component for a patch/commit. Another will be to automatically suggest a bug component for a failing test.

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at */

#ifndef __ClearKeyUtils_h__
#define __ClearKeyUtils_h__

#include <stdint.h>
#include <string>
#include <vector>
#include "gmp-decryption.h"

#define CLEARKEY_KEY_LEN ((size_t)16)

#if 0
void CK_Log(const char* aFmt, ...);
#define CK_LOGE(...) CK_Log(__VA_ARGS__)
#define CK_LOGD(...) CK_Log(__VA_ARGS__)
#define CK_LOGW(...) CK_Log(__VA_ARGS__)
#define CK_LOGE(...)
#define CK_LOGD(...)
#define CK_LOGW(...)

struct GMPPlatformAPI;
extern GMPPlatformAPI* GetPlatform();

typedef std::vector<uint8_t> KeyId;
typedef std::vector<uint8_t> Key;

struct KeyIdPair
  KeyId mKeyId;
  Key mKey;

class ClearKeyUtils
  static void DecryptAES(const std::vector<uint8_t>& aKey,
                         std::vector<uint8_t>& aData, std::vector<uint8_t>& aIV);

  static void ParseInitData(const uint8_t* aInitData, uint32_t aInitDataSize,
                            std::vector<Key>& aOutKeys);

  static void MakeKeyRequest(const std::vector<KeyId>& aKeyIds,
                             std::string& aOutRequest,
                             GMPSessionType aSessionType);

  static bool ParseJWK(const uint8_t* aKeyData, uint32_t aKeyDataSize,
                       std::vector<KeyIdPair>& aOutKeys,
                       GMPSessionType aSessionType);
  static const char* SessionTypeToString(GMPSessionType aSessionType);

  static bool IsValidSessionId(const char* aBuff, uint32_t aLength);

template<class Container, class Element>
inline bool
Contains(const Container& aContainer, const Element& aElement)
  return aContainer.find(aElement) != aContainer.end();

#endif // __ClearKeyUtils_h__