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

No SDK de Proteção MIP, 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.

Requisitos

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

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

Criar um manipulador 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 objeto mip::ProtectionDescriptor.
  2. Use o mip::ProtectionDescriptor para criar uma instância para mip::ProtectionHandler::PublishingSettings.
  3. Chame mip::ProtectionEngine::CreateProtectionHandlerForPublishingAsync() passando no objeto PublishingSettings, no observador e na promessa.

Criar no descritor

Para proteger o conteúdo que ainda não está protegido ou aplicar uma nova proteção ao conteúdo descriptografado, construa um mip::ProtectionDescriptor. Use-o para instanciar o mip::ProtectionHandler::PublishingSettings() objeto. O SDK retorna o resultado por meio 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 o ProtectionHandler objeto com êxito, você pode executar operações de proteção para criptografia e descriptografia. Busque a licença de publicação do manipulador e armazene-a com o conteúdo criptografado. Para buscar a licença de publicação, chame handler->GetSerializedPublishingLicense();.

Sem a licença de publicação correspondente, você não pode descriptografar o conteúdo protegido.

Criar o manipulador de consumo

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

  1. Extraia do conteúdo protegido uma licença de publicação serializada 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 no objeto ConsumptionSettings, no observador e na promessa.

Este exemplo pressupõe que a licença de publicação já foi lida de alguma origem e armazenada em 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();

Próximas Etapas