Mir
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
mir::cookie::CookieFactory Class Referenceabstract

A source of moderately-difficult-to-spoof cookies. More...

#include <cookie_factory.h>

Inheritance diagram for mir::cookie::CookieFactory:
[legend]

Public Member Functions

 CookieFactory (CookieFactory const &factory)=delete
 
CookieFactoryoperator= (CookieFactory const &factory)=delete
 
virtual ~CookieFactory () noexcept=default
 
virtual MirCookie timestamp_to_cookie (uint64_t const &timestamp)=0
 Turns a timestamp into a MAC and returns a MirCookie. More...
 
virtual bool attest_timestamp (MirCookie const &cookie)=0
 Checks that a MirCookie is a valid MirCookie. More...
 

Static Public Member Functions

static size_t optimal_secret_size ()
 Optimal size for the provided Secret. More...
 
static std::unique_ptr< CookieFactorycreate_from_secret (Secret const &secret)
 Construction function used to create a CookieFactory. More...
 
static std::unique_ptr< CookieFactorycreate_saving_secret (Secret &save_secret)
 Construction function used to create a CookieFactory as well as a secret. More...
 
static std::unique_ptr< CookieFactorycreate_keeping_secret ()
 Construction function used to create a CookieFactory and a secret which it keeps internally. More...
 

Static Public Attributes

static unsigned const minimum_secret_size = 8
 Absolute minimum size of secret key the CookieFactory will accept. More...
 

Protected Member Functions

 CookieFactory ()=default
 

Detailed Description

A source of moderately-difficult-to-spoof cookies.

The primary motivation for this is to provide event timestamps that clients find it difficult to spoof. This is useful for focus grant and similar operations where shell behaviour should be dependent on the timestamp of the client event that caused the request.

Some spoofing protection is desirable; experience with X clients shows that they will go to some effort to attempt to bypass focus stealing prevention.

Constructor & Destructor Documentation

mir::cookie::CookieFactory::CookieFactory ( CookieFactory const &  factory)
delete
virtual mir::cookie::CookieFactory::~CookieFactory ( )
virtualdefaultnoexcept
mir::cookie::CookieFactory::CookieFactory ( )
protecteddefault

Member Function Documentation

virtual bool mir::cookie::CookieFactory::attest_timestamp ( MirCookie const &  cookie)
pure virtual

Checks that a MirCookie is a valid MirCookie.

Parameters
[in]cookieA created MirCookie
Returns
True when the MirCookie is valid, False when the MirCookie is not valid
std::unique_ptr< mir::cookie::CookieFactory > mir::cookie::CookieFactory::create_from_secret ( Secret const &  secret)
static

Construction function used to create a CookieFactory.

The secret size must be no less then minimum_secret_size otherwise an exception will be thrown

Parameters
[in]secretA filled in secret used to set the key for the hash function
Returns
A unique_ptr CookieFactory
std::unique_ptr< mir::cookie::CookieFactory > mir::cookie::CookieFactory::create_keeping_secret ( )
static

Construction function used to create a CookieFactory and a secret which it keeps internally.

Returns
A unique_ptr CookieFactory
std::unique_ptr< mir::cookie::CookieFactory > mir::cookie::CookieFactory::create_saving_secret ( Secret save_secret)
static

Construction function used to create a CookieFactory as well as a secret.

Parameters
[out]save_secretThe secret that was created.
Returns
A unique_ptr CookieFactory
CookieFactory& mir::cookie::CookieFactory::operator= ( CookieFactory const &  factory)
delete
size_t mir::cookie::CookieFactory::optimal_secret_size ( )
static

Optimal size for the provided Secret.

This is the maximum useful size of the secret key. Keys of greater size will be reduced to this size internally, and keys of smaller size may be internally extended to this size.

virtual MirCookie mir::cookie::CookieFactory::timestamp_to_cookie ( uint64_t const &  timestamp)
pure virtual

Turns a timestamp into a MAC and returns a MirCookie.

Parameters
[in]timestampThe timestamp
Returns
MirCookie with the stored MAC and timestamp

Member Data Documentation

unsigned const mir::cookie::CookieFactory::minimum_secret_size = 8
static

Absolute minimum size of secret key the CookieFactory will accept.

Code should be using optimum_secret_size(); this minimum size is provided as a user convenience to guard against catastrophically bad initialisation.


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

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Oct 8 16:20:16 UTC 2015