Android-cuttlefish cvd tool
Public Member Functions | Private Attributes | List of all members
cuttlefish::EncryptedSerializable Class Reference

#include <encrypted_serializable.h>

Inheritance diagram for cuttlefish::EncryptedSerializable:
Inheritance graph
[legend]
Collaboration diagram for cuttlefish::EncryptedSerializable:
Collaboration graph
[legend]

Public Member Functions

 EncryptedSerializable (TpmResourceManager &, std::function< TpmObjectSlot(TpmResourceManager &)>, Serializable &)
 
size_t SerializedSize () const override
 
uint8_t * Serialize (uint8_t *buf, const uint8_t *end) const override
 
bool Deserialize (const uint8_t **buf_ptr, const uint8_t *end) override
 

Private Attributes

TpmResourceManagerresource_manager_
 
std::function< TpmObjectSlot(TpmResourceManager &)> parent_key_fn_
 
keymaster::Serializable & wrapped_
 

Detailed Description

A keymaster::Serializable that wraps another keymaster::Serializable, encrypting the data with a TPM to ensure privacy.

This implementation randomly generates a unique key which only exists inside the TPM, and uses it to encrypt the data from the other Serializable instance. The encrypted data, together with information about the unique key is stored in the output data. The unique key information is something that can only be decoded using a TPM, which will detect if the key is corrupted. However, this implementation will not detect if the encrypted data is corrupted, which could break the other Serializable instance on deserialization. This class should be used with something else to verify that the data hasn't been tampered with.

The serialization format is: [tpm key public data] [tpm key private data] [uint32_t: block_size] [uint32_t: encrypted_length] [encrypted_data]

The actual length of [encrypted_data] in the serialized format is [encrypted_length] rounded up to the nearest multiple of [block_size]. [encrypted_length] is the true length of the data before encryption, without padding.

Constructor & Destructor Documentation

◆ EncryptedSerializable()

cuttlefish::EncryptedSerializable::EncryptedSerializable ( TpmResourceManager resource_manager,
std::function< TpmObjectSlot(TpmResourceManager &)>  parent_key_fn,
Serializable &  wrapped 
)

Member Function Documentation

◆ Deserialize()

bool cuttlefish::EncryptedSerializable::Deserialize ( const uint8_t **  buf_ptr,
const uint8_t *  end 
)
override

◆ Serialize()

uint8_t * cuttlefish::EncryptedSerializable::Serialize ( uint8_t *  buf,
const uint8_t *  end 
) const
override

◆ SerializedSize()

size_t cuttlefish::EncryptedSerializable::SerializedSize ( ) const
override

Member Data Documentation

◆ parent_key_fn_

std::function<TpmObjectSlot(TpmResourceManager&)> cuttlefish::EncryptedSerializable::parent_key_fn_
private

◆ resource_manager_

TpmResourceManager& cuttlefish::EncryptedSerializable::resource_manager_
private

◆ wrapped_

keymaster::Serializable& cuttlefish::EncryptedSerializable::wrapped_
private

The documentation for this class was generated from the following files: