SDK da Proteção de Informações da Microsoft - Conceitos do manipulador de proteção

No MIP Protection SDK, o mip::ProtectionHandler expõe as funções para criptografar e descriptografar fluxos e buffers protegidos, executar verificações de acesso, obter a licença de publicação e obter atributos das informações protegidas.

Requerimentos

Criar um ProtectionHandler para trabalhar com um arquivo específico requer:

  • Uma mip::MipContext
  • Uma mip::ProtectionProfile
  • O mip::ProtectionEngine adicionado ao ProtectionProfile
  • Uma classe que herda mip::ProtectionHandler::Observer
  • Uma mip::ProtectionDescriptor ou licença de publicação

Criar um gestor de proteção

mip::ProtectionHandler Os objetos são construídos para operações de proteção ou consumo . O manipulador é criado usando uma das quatro funções, dependendo do cenário.

  • mip::ProtectionEngine->CreateProtectionHandlerForConsumptionAsync()
  • mip::ProtectionEngine->CreateProtectionHandlerForConsumption()
  • mip::ProtectionEngine->CreateProtectionHandlerForPublishingAsync()
  • mip::ProtectionEngine->CreateProtectionHandlerForPublishing()

Essas funções aceitam um mip::ProtectionHandler::PublishingSettings ou mip::ProtectionHandler::ConsumptionSettings objeto.

Criar um manipulador de publicação

A criação de um manipulador de publicação requer três etapas:

  1. Crie um mip::ProtectionDescriptor objeto.
  2. Use o mip::ProtectionDescriptor para instanciar mip::ProtectionHandler::PublishingSettings.
  3. Chame mip::ProtectionEngine::CreateProtectionHandlerForPublishingAsync() passando o PublishingSettings objeto, observador e promessa.

Criar a partir do descritor

Para proteger conteúdos que ainda não estão protegidos, ou para aplicar nova proteção a conteúdos desencriptados, construa um mip::ProtectionDescriptorarquivo . Usa-o para instanciar o mip::ProtectionHandler::PublishingSettings() objeto. O SDK devolve o resultado através do mip::ProtectionHandler::Observer.

// Create the protection descriptor, passing in a templateId.
auto descriptorBuilder = mip::ProtectionDescriptorBuilder::CreateFromTemplate(protectionOptions.templateId);
std::shared_ptr<mip::ProtectionDescriptor> descriptor = descriptorBuilder->Build();

// Define the handler promise, future, and observer.
auto handlerPromise = std::make_shared<std::promise<std::shared_ptr<mip::ProtectionHandler>>>();
auto handlerFuture = handlerPromise->get_future();
auto handlerObserver = std::make_shared<ProtectionHandlerObserverImpl>();

// Create the PublishingSettings object using the previously-created descriptor as input.
mip::ProtectionHandler::PublishingSettings publishingSettings = mip::ProtectionHandler::PublishingSettings(descriptor);

// Create/get the publishing handler from the publishing settings, observer, and promise.
mEngine->CreateProtectionHandlerForPublishingAsync(publishingSettings, handlerObserver, handlerPromise);
auto handler = handlerFuture.get();
return handler;

Depois de criar com sucesso o ProtectionHandler objeto, pode realizar operações de proteção para encriptação e desencriptação. Obtenha a licença de publicação do responsável e armazene-a com o conteúdo encriptado. Para obter a licença de publicação, chame handler->GetSerializedPublishingLicense();.

Sem a licença de publicação correspondente, não se pode desencriptar conteúdos protegidos.

Criar o manipulador de consumo

Criar um manipulador de consumo requer três passos:

  1. Extraia uma licença de publicação serializada a partir do conteúdo protegido como std::vector<uint8_t>.
  2. Use a licença de publicação serializada para instanciar mip::ProtectionHandler::ConsumptionSettings.
  3. Chame mip::ProtectionEngine::CreateProtectionHandlerForConsumptionAsync() passando o ConsumptionSettings objeto, observador e promessa.

Este exemplo pressupõe que a licença de publicação já tenha sido lida de alguma fonte e armazenada no std::vector<uint8_t> serializedPublishingLicense.

//TODO: Implement GetPublishingLicense()
//Snip implies that function reads PL from source file, database, stream, etc.
std::vector<uint8_t> serializedPublishingLicense = GetPublishingLicense(filePath);

// Define the handler promise, future, and observer.
auto handlerPromise = std::make_shared<std::promise<std::shared_ptr<mip::ProtectionHandler>>>();
auto handlerFuture = handlerPromise->get_future();
shared_ptr<ProtectionHandlerObserverImpl> handlerObserver = std::make_shared<ProtectionHandlerObserverImpl>();

// Create the consumption settings object from the publishing license.
mip::ProtectionHandler::ConsumptionSettings consumptionSettings = mip::ProtectionHandler::ConsumptionSettings(serializedPublishingLicense);

// Create/get the publishing handler from the publishing settings, observer, and promise.
mEngine->CreateProtectionHandlerForConsumptionAsync(consumptionSettings, handlerObserver, handlerPromise);
auto handler = handlerFuture.get();

Passos seguintes