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

#include <hmac_serializable.h>

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

Public Member Functions

 HmacSerializable (TpmResourceManager &, std::function< TpmObjectSlot(TpmResourceManager &)>, uint32_t digest_size, Serializable *, const Serializable *aad)
 
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 Member Functions

std::optional< std::vector< uint8_t > > AppendAad (const uint8_t *sensitive, size_t sensitive_size) const
 

Private Attributes

TpmResourceManagerresource_manager_
 
std::function< TpmObjectSlot(TpmResourceManager &)> signing_key_fn_
 
uint32_t digest_size_
 
Serializable * wrapped_
 
const Serializable * aad_
 

Detailed Description

A keymaster::Serializable that wraps another keymaster::Serializable, protecting it from tampering while it is stored elsewhere. This stores the serialized data of the other type together with a signature over that serialized data. When deserializing, it will attempt to make the same signature over the data. If the signature or data has been tampered with, the signatures won't match and it won't attempt to deserialize the wrapped type.

The serialization format is: [uint32_t: wrapped_size] [wrapped_data] [uint32_t: signature_size] [signature_data]

While this class currently assumes all signatures will use the same key and algorithm and therefore be the same size, the serialization format is future-proof to accommodate signature changes.

Constructor & Destructor Documentation

◆ HmacSerializable()

cuttlefish::HmacSerializable::HmacSerializable ( TpmResourceManager resource_manager,
std::function< TpmObjectSlot(TpmResourceManager &)>  signing_key_fn,
uint32_t  digest_size,
Serializable *  wrapped,
const Serializable *  aad 
)

Member Function Documentation

◆ AppendAad()

std::optional< std::vector< uint8_t > > cuttlefish::HmacSerializable::AppendAad ( const uint8_t *  sensitive,
size_t  sensitive_size 
) const
private

◆ Deserialize()

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

◆ Serialize()

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

◆ SerializedSize()

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

Member Data Documentation

◆ aad_

const Serializable* cuttlefish::HmacSerializable::aad_
private

◆ digest_size_

uint32_t cuttlefish::HmacSerializable::digest_size_
private

◆ resource_manager_

TpmResourceManager& cuttlefish::HmacSerializable::resource_manager_
private

◆ signing_key_fn_

std::function<TpmObjectSlot(TpmResourceManager&)> cuttlefish::HmacSerializable::signing_key_fn_
private

◆ wrapped_

Serializable* cuttlefish::HmacSerializable::wrapped_
private

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