Mir

Merge lp:~mir-team/mir/public-cookie-api into lp:mir

Proposed by Brandon Schaefer
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 3269
Proposed branch: lp:~mir-team/mir/public-cookie-api
Merge into: lp:mir
Diff against target: 4380 lines (+1209/-588)
103 files modified
3rd_party/CMakeLists.txt (+1/-0)
3rd_party/android-input/android/frameworks/base/include/androidfw/Input.h (+8/-6)
3rd_party/android-input/android/frameworks/base/include/androidfw/InputTransport.h (+4/-4)
3rd_party/android-input/android/frameworks/base/services/input/Input.cpp (+6/-6)
3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp (+10/-10)
debian/control (+2/-2)
debian/libmircookie2.install (+1/-1)
include/client/mir/events/event_builders.h (+21/-3)
include/client/mir_toolkit/events/event.h (+2/-0)
include/client/mir_toolkit/events/input/input_event.h (+18/-1)
include/client/mir_toolkit/mir_client_library.h (+1/-0)
include/client/mir_toolkit/mir_cookie.h (+71/-0)
include/client/mir_toolkit/mir_surface.h (+9/-0)
include/cookie/mir/cookie/authority.h (+57/-50)
include/cookie/mir/cookie/cookie.h (+57/-0)
include/server/mir/server.h (+4/-4)
include/server/mir/shell/abstract_shell.h (+1/-1)
include/server/mir/shell/shell.h (+1/-1)
include/server/mir/shell/shell_wrapper.h (+1/-1)
src/client/CMakeLists.txt (+3/-1)
src/client/events/event_builders.cpp (+62/-13)
src/client/input/android/android_input_lexicon.cpp (+7/-3)
src/client/input/input_event.cpp (+97/-1)
src/client/mir_cookie.cpp (+49/-0)
src/client/mir_cookie.h (+40/-0)
src/client/mir_surface.cpp (+5/-5)
src/client/mir_surface.h (+1/-2)
src/client/mir_surface_api.cpp (+2/-3)
src/client/rpc/mir_display_server.cpp (+1/-1)
src/client/rpc/mir_display_server.h (+1/-1)
src/client/symbols.map (+7/-0)
src/cookie/CMakeLists.txt (+5/-3)
src/cookie/authority.cpp (+97/-32)
src/cookie/format.h (+35/-0)
src/cookie/hmac_cookie.cpp (+53/-0)
src/cookie/hmac_cookie.h (+51/-0)
src/cookie/symbols.map (+5/-5)
src/include/common/mir/events/event_private.h (+4/-4)
src/include/common/mir/protobuf/display_server.h (+1/-1)
src/include/cookie/mir/cookie/blob.h (+19/-30)
src/include/server/mir/default_server_configuration.h (+3/-3)
src/include/server/mir/frontend/security_check_failed.h (+0/-34)
src/include/server/mir/frontend/shell.h (+1/-1)
src/include/server/mir/frontend/template_protobuf_message_processor.h (+2/-2)
src/include/server/mir/server_configuration.h (+2/-2)
src/protobuf/mir_protobuf.proto (+1/-2)
src/server/CMakeLists.txt (+1/-0)
src/server/default_server_configuration.cpp (+5/-5)
src/server/frontend/CMakeLists.txt (+0/-1)
src/server/frontend/default_configuration.cpp (+1/-1)
src/server/frontend/default_ipc_factory.cpp (+4/-4)
src/server/frontend/default_ipc_factory.h (+3/-3)
src/server/frontend/protobuf_message_processor.cpp (+4/-4)
src/server/frontend/security_check_failed.cpp (+0/-24)
src/server/frontend/session_mediator.cpp (+10/-10)
src/server/frontend/session_mediator.h (+4/-4)
src/server/frontend/shell_wrapper.cpp (+2/-2)
src/server/frontend/shell_wrapper.h (+1/-1)
src/server/input/android/input_sender.cpp (+3/-3)
src/server/input/default_configuration.cpp (+3/-3)
src/server/input/default_event_builder.cpp (+18/-11)
src/server/input/default_event_builder.h (+3/-3)
src/server/input/default_input_device_hub.cpp (+6/-6)
src/server/input/default_input_device_hub.h (+4/-4)
src/server/input/key_repeat_dispatcher.cpp (+7/-4)
src/server/input/key_repeat_dispatcher.h (+3/-3)
src/server/input/surface_input_dispatcher.cpp (+1/-2)
src/server/input/validator.cpp (+1/-1)
src/server/server.cpp (+2/-2)
src/server/shell/abstract_shell.cpp (+1/-1)
src/server/shell/frontend_shell.cpp (+2/-2)
src/server/shell/frontend_shell.h (+1/-1)
src/server/shell/shell_wrapper.cpp (+2/-2)
src/server/symbols.map (+6/-6)
tests/acceptance-tests/test_client_cookie.cpp (+72/-47)
tests/acceptance-tests/test_client_input.cpp (+1/-1)
tests/acceptance-tests/test_surface_modifications.cpp (+3/-4)
tests/acceptance-tests/test_surface_placement.cpp (+1/-2)
tests/acceptance-tests/test_surface_raise.cpp (+83/-54)
tests/acceptance-tests/test_surface_specification.cpp (+3/-4)
tests/include/mir/test/doubles/mock_shell.h (+1/-1)
tests/include/mir/test/doubles/stub_display_server.h (+1/-1)
tests/integration-tests/CMakeLists.txt (+1/-0)
tests/integration-tests/input/test_single_seat_setup.cpp (+3/-3)
tests/mir_test_doubles/CMakeLists.txt (+1/-0)
tests/unit-tests/CMakeLists.txt (+1/-0)
tests/unit-tests/client/input/test_android_input_receiver.cpp (+2/-2)
tests/unit-tests/client/input/test_xkb_mapper.cpp (+1/-2)
tests/unit-tests/frontend/test_event_sender.cpp (+1/-2)
tests/unit-tests/frontend/test_session_mediator.cpp (+10/-11)
tests/unit-tests/input/android/test_android_input_lexicon.cpp (+7/-10)
tests/unit-tests/input/android/test_android_input_sender.cpp (+8/-13)
tests/unit-tests/input/evdev/test_libinput_device.cpp (+3/-3)
tests/unit-tests/input/test_default_input_device_hub.cpp (+3/-3)
tests/unit-tests/input/test_event_builders.cpp (+7/-12)
tests/unit-tests/input/test_event_filter_chain_dispatcher.cpp (+1/-1)
tests/unit-tests/input/test_key_repeat_dispatcher.cpp (+5/-5)
tests/unit-tests/input/test_surface_input_dispatcher.cpp (+10/-10)
tests/unit-tests/input/test_validator.cpp (+1/-1)
tests/unit-tests/input/test_x11_platform.cpp (+2/-2)
tests/unit-tests/scene/test_abstract_shell.cpp (+4/-4)
tests/unit-tests/scene/test_surface.cpp (+2/-2)
tests/unit-tests/test_mir_cookie.cpp (+44/-36)
To merge this branch: bzr merge lp:~mir-team/mir/public-cookie-api
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Abstain
Mir CI Bot continuous-integration Approve
Andreas Pokorny (community) Approve
Alexandros Frantzis (community) Needs Fixing
Alberto Aguirre (community) Approve
Chris Halse Rogers Approve
Daniel van Vugt Abstain
Kevin DuBois (community) Approve
Review via email: mp+282279@code.launchpad.net

Commit message

Re-add support for get a MirCookie as well as Raising a surface with a MirCookie.

The MirCookie structure is now opaque.

Description of the change

Re-add support for get a MirCookie as well as Raising a surface with a MirCookie.

The MirCookie structure is now opaque.

Different APIs we have considered:
https://pastebin.canonical.com/147720/

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Should the mir_input_event_get_cookie use MirCookie* or just a uint8_t* (or char*?)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3243
https://mir-jenkins.ubuntu.com/job/mir-ci/31/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/31/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/31/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

> Should the mir_input_event_get_cookie use MirCookie* or just a uint8_t* (or
> char*?)

my vote is MirCookie*

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

After ROAF and I talking for a bit we settled on void* since we are send a stream of *unknown* bytes. Since not just the mac is being sent, so is the timestamp

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3244
https://mir-jenkins.ubuntu.com/job/mir-ci/45/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/45/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/45/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

The Story Of The Void*:
Brandon and I had a *long* back and forth about client API wrt MirCookie, ranging from having a MirCookie type that can be converted into a MirBlob, to essentially duplicating MirBlob's API against a MirCookie, to a non-opaque struct MirCookie { size_t length, void* data };

Neither of us were particularly happy with any of them.

The void* API here is (a) transparent - it's clear to everyone that they've just got a blob of data, (b) quick to implement, and (c) is minimally constraining for future, better, implementations with better APIs.

General comment: I'm pretty sure you don't need reinterpret_cast<> to go between void* and MirCookie*; static_cast<MirCookie*> should be sufficient. (Wheras you *do* need to reinterpret_cast between uint8_t* and uint64_t*)

42 + * \params[in] ev The input event
43 + * \params[in] cookie An allocated void* with exactly cookie_size bytes
44 + * \params[in] size The size of the MirCookie
45 + */
46 +void mir_input_event_copy_cookie(MirInputEvent const* ev, void* cookie, size_t size);

Two things: do we need to pass size in here? We're only going to assert that it's exactly mir_input_event_get_cookie_size(), right?

And: If we do keep the size, you need to update the comment; no MirCookie here ☺.

Also a couple of inline comments.

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3245
https://mir-jenkins.ubuntu.com/job/mir-ci/46/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/46/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/46/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3246
https://mir-jenkins.ubuntu.com/job/mir-ci/47/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/47/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/47/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

not too flummoxed about use of void*, especially if you & Chris gave it more thought than I had behind my comment. Some other things that I'm not too flummoxed about (esp given that (as I understand) this is needed in short order)

+ auto const* pev = mir_input_event_get_pointer_event(ev);
no need for * (a few other places)

+ // FIXME Moveing to 160bits soon
typo

+ void* cookie = malloc(size);
would be a bit better to use a RAII type in allocation for this test (and would eliminate the need for a destructor too)

768: std::mutex mutex;
A bit strange to have the mutex be public, and require locking it before accessing some members. Would be better encapsulated to have functions on the object to do that.

review: Approve
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> not too flummoxed about use of void*, especially if you & Chris gave it more
> thought than I had behind my comment. Some other things that I'm not too
> flummoxed about (esp given that (as I understand) this is needed in short
> order)
>
> + auto const* pev = mir_input_event_get_pointer_event(ev);
> no need for * (a few other places)

I was mainly doing that so you can see its a pointer (I like seeing types sometimes), but yeah auto captures that :). Fixed.

>
> + // FIXME Moveing to 160bits soon
> typo
>

Opps. Fixed.

> + void* cookie = malloc(size);
> would be a bit better to use a RAII type in allocation for this test (and
> would eliminate the need for a destructor too)
Yes! I attempted it but ran into issue when I was using the MirCookie* since the size was not known (should have just written my own destructor for the shared_ptr to cast and delete[].) Fixed.

>
> 768: std::mutex mutex;
> A bit strange to have the mutex be public, and require locking it before
> accessing some members. Would be better encapsulated to have functions on the
> object to do that.

Agreed, and it looks much cleaner :). Fixed.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

There's stuff I'm concerned about, but I'm out of time today to review properly - will get to it first thing tomorrow.

review: Abstain
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

(pushing coming in a few :)

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

void* is an incomplete type, soo to put it into a shared/unique ptr fails on a static_assert. I suppose for testing i could just cast it to a uint8_t, since its in bytes... or just leave it with a malloc/free :)

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3247
https://mir-jenkins.ubuntu.com/job/mir-ci/58/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/58/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/58/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3249
https://mir-jenkins.ubuntu.com/job/mir-ci/59/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/59/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/59/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Bunch of locking issues still in the tests; marked inline.

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3250
https://mir-jenkins.ubuntu.com/job/mir-ci/60/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/60/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/60/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3251
https://mir-jenkins.ubuntu.com/job/mir-ci/61/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/61/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/61/rebuild

review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Different APIs we have considered:
https://pastebin.canonical.com/147720/

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3250
http://jenkins.qa.ubuntu.com/job/mir-ci/6025/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5541
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4448
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5497
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/281
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/349
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/349/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/349
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/349/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5494
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5494/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7964
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26690
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/277
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/277/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/135
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26691

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6025/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

566 + void handle_input_event(MirInputEvent const* iev)
567 + {
568 + std::lock_guard<std::mutex> lk(mutex);
569 + if (mir_input_event_has_cookie(iev))
570 + {
571 + auto const size = mir_input_event_get_cookie_size(iev);
572 + std::vector<uint8_t> cookie(size);
573 +
574 + mir_input_event_copy_cookie(iev, cookie.data());
575 + out_cookies.push_back(cookie);
576 + }
577 +
578 + event_count++;
579 + }
580 +
581 + size_t get_event_count() const
582 + {
583 + std::lock_guard<std::mutex> lk(mutex);
584 + return event_count;
585 + }
586 +
587 + size_t cookie_size() const
588 + {
589 + std::lock_guard<std::mutex> lk(mutex);
590 + return out_cookies.size();
591 + }
592 +
593 + std::vector<uint8_t> back_cookie() const
594 + {
595 + std::lock_guard<std::mutex> lk(mutex);
596 + return out_cookies.back();
597 + }
598 +
599 + bool cookies_empty() const
600 + {
601 + std::lock_guard<std::mutex> lk(mutex);
602 + return out_cookies.empty();
603 + }

While not blocking, this seems to be a bit of a faff for the testcase vs just directly locking the mutex when necessary :).

Otherwise, I'm OK, pending possible API changes :)

review: Approve
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3252
https://mir-jenkins.ubuntu.com/job/mir-ci/63/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/63/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/63/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3253
https://mir-jenkins.ubuntu.com/job/mir-ci/64/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/64/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/64/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3252
http://jenkins.qa.ubuntu.com/job/mir-ci/6027/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5543
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4450
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5499
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/283
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/351
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/351/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/351
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/351/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5496
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5496/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7966
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26694
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/279
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/279/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/137
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26695

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6027/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Oh, whoops! Missed one thing, sorry.

This would appear to be a libmircookie ABI break, so should be accompanied by a SONAME bump.

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3254
https://mir-jenkins.ubuntu.com/job/mir-ci/65/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/65/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/65/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3253
http://jenkins.qa.ubuntu.com/job/mir-ci/6028/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5544
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4451
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5500
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/284
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/352
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/352/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/352
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/352/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5497
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5497/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7967
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26696
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/280
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/280/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/138
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26697

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6028/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

+ typedef struct MirCookie MirCookie;

Not needed (at the moment at least), and also may conflict with mir::cookie::MirCookie.

- virtual MirCookie timestamp_to_cookie(uint64_t const& timestamp) = 0;

A *Cookie*Factory that doesn't create cookies seems strange.

Needs discussion/fixing

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3255
https://mir-jenkins.ubuntu.com/job/mir-ci/66/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/66/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/66/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+// FIXME Remove me when we are no longer returning 8 byte MACS
+// We assert that what we return is 8 bytes, so lets test for that for now!
+TEST(MirCookieFactory, assert_8_bytes_for_mac)
+{
+ std::vector<uint8_t> secret{ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xde, 0x01 };
+ auto factory = mir::cookie::CookieFactory::create_from_secret(secret);
+ uint64_t mock_timestamp{0x322322322332};
+ auto mac = factory->timestamp_to_mac(mock_timestamp);
+
+ EXPECT_EQ(mac.size(), sizeof(uint64_t));
+}

sizeof(uint64_t) is not a synonym for 8 - although platforms with 16bit characters are of little interest to us.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Nits to fix and questions:

CookieFactory looks less and less like a "factory" interface. Would "CookieAuthority" be a better name?

~~~~

+ virtual bool attest_timestamp(MirCookie const* cookie) = 0;

This is the only place in the interface MirCookie is mentioned. Should we simply lose this function and require the user to call the other overload?

~~~~

+void mir_input_event_copy_cookie(MirInputEvent const* ev, void* cookie);

I'm always cautions of APIs that take a target buffer and no buffer size - while not bulletproof the latter is at least a reminder to the user to obtain the size.

~~~~

+void mir_surface_raise_with_cookie(MirSurface* surface, void const* cookie);

By using void* we loose the type safety that we have with other Mir APIs. Can you provide some justification for this design choice? E.g. will this function be primarily for clients that obtained the cookie from a non-Mir API?

~~~~

- * Copyright © 2015 Canonical Ltd.
+ * Copyright © 2016 Canonical Ltd.

Don't remove the 2015 copyright claim. (I know these headers are legally unnecessary and PITA, but let's try to do it right.)

~~~~

+ /* No mac == no size! */
+ return 0;

It should be a precondition that there's a MAC. I.e. the function should begin with something like:

    mir::require(mir_input_event_has_cookie(ev));

~~~~

+#include "mir/cookie.h"
#include "mir/cookie_factory.h"

The first include of the source file should be the corresponding header (to ensure it compiles by itself).

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3255
http://jenkins.qa.ubuntu.com/job/mir-ci/6030/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5547
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4454
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5503
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/285
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/354
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/354/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/354
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/354/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5500
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5500/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7969
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26699
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/281
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/281/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/139
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26703

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6030/rebuild

review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> +// FIXME Remove me when we are no longer returning 8 byte MACS
> +// We assert that what we return is 8 bytes, so lets test for that for now!
> +TEST(MirCookieFactory, assert_8_bytes_for_mac)
> +{
> + std::vector<uint8_t> secret{ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xde,
> 0x01 };
> + auto factory = mir::cookie::CookieFactory::create_from_secret(secret);
> + uint64_t mock_timestamp{0x322322322332};
> + auto mac = factory->timestamp_to_mac(mock_timestamp);
> +
> + EXPECT_EQ(mac.size(), sizeof(uint64_t));
> +}
>
> sizeof(uint64_t) is not a synonym for 8 - although platforms with 16bit
> characters are of little interest to us.

Hmm should I just not assert this then? Since really all im assert is that our mac == sizeof(uint64_t). So possibly I should just change the name.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> Nits to fix and questions:
>
> CookieFactory looks less and less like a "factory" interface. Would
> "CookieAuthority" be a better name?
>
> ~~~~

Agreed.

>
> + virtual bool attest_timestamp(MirCookie const* cookie) = 0;
>
> This is the only place in the interface MirCookie is mentioned. Should we
> simply lose this function and require the user to call the other overload?
>
> ~~~~

The reason for keeping this, is theres no way to de construct a MirCookie in the public. So once the content hub gets a mir cookie it wont know how to *attest* it.

>
> +void mir_input_event_copy_cookie(MirInputEvent const* ev, void* cookie);
>
> I'm always cautions of APIs that take a target buffer and no buffer size -
> while not bulletproof the latter is at least a reminder to the user to obtain
> the size.
>
> ~~~~

Thats sounds quite reasonable to me.
>
> +void mir_surface_raise_with_cookie(MirSurface* surface, void const* cookie);
>
> By using void* we loose the type safety that we have with other Mir APIs. Can
> you provide some justification for this design choice? E.g. will this
> function be primarily for clients that obtained the cookie from a non-Mir API?
>
> ~~~~

I agree, and will be switching to a MirCookie* for both the copy and these functions since void* and MirCookie* will both be incomplete types.

>
> - * Copyright © 2015 Canonical Ltd.
> + * Copyright © 2016 Canonical Ltd.
>
> Don't remove the 2015 copyright claim. (I know these headers are legally
> unnecessary and PITA, but let's try to do it right.)
>
> ~~~~

Opps. Yeah Ill fix those!

>
> + /* No mac == no size! */
> + return 0;
>
> It should be a precondition that there's a MAC. I.e. the function should begin
> with something like:
>
> mir::require(mir_input_event_has_cookie(ev));
>
> ~~~~

This is true, if we have a function that tells you if an event has a cookie we better require it to actually have one when attempting to construct it!.

>
> +#include "mir/cookie.h"
> #include "mir/cookie_factory.h"
>
> The first include of the source file should be the corresponding header (to
> ensure it compiles by itself).

Will fix!

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> + typedef struct MirCookie MirCookie;
>
> Not needed (at the moment at least), and also may conflict with
> mir::cookie::MirCookie.

Opps thought I removed all thoses... Had an idea at one point that I think made it into a file :)
>
> - virtual MirCookie timestamp_to_cookie(uint64_t const& timestamp) = 0;
>
> A *Cookie*Factory that doesn't create cookies seems strange.
>
> Needs discussion/fixing

Right it doesnt create any MirCookies but it creates what a cookie is. With alans comment, changing the name to:
CookieAuthority

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> > sizeof(uint64_t) is not a synonym for 8 - although platforms with 16bit
> > characters are of little interest to us.
>
> Hmm should I just not assert this then? Since really all im assert is that our
> mac == sizeof(uint64_t). So possibly I should just change the name.

On reflection, if unit8_t exists we're safe to assume 8 bit chars. (And if it doesn't we don't compile.)

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> > + virtual bool attest_timestamp(MirCookie const* cookie) = 0;
> >
> > This is the only place in the interface MirCookie is mentioned. Should we
> > simply lose this function and require the user to call the other overload?
> >
> > ~~~~
>
> The reason for keeping this, is theres no way to de construct a MirCookie in
> the public. So once the content hub gets a mir cookie it wont know how to
> *attest* it.

are you conflating ::MirCookie and mir::cookie::MirCookie?

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> > > + virtual bool attest_timestamp(MirCookie const* cookie) = 0;
> > >
> > > This is the only place in the interface MirCookie is mentioned. Should we
> > > simply lose this function and require the user to call the other overload?
> > >
> > > ~~~~
> >
> > The reason for keeping this, is theres no way to de construct a MirCookie in
> > the public. So once the content hub gets a mir cookie it wont know how to
> > *attest* it.
>
> are you conflating ::MirCookie and mir::cookie::MirCookie?

Well only mir::cookie::MirCookie should be used? The attest_timestamp is in the mir::cookie namespace. Not sure if they are different and being combined? I Could be wrong :)

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Though there will be an issue... if i move from a void* to a MirCookie* in the public API... not sure how to combine a MirCookie* into a mir::cookie::MirCookie*? Just cast it? I would like a MirCookie* vs void* :)

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3258
https://mir-jenkins.ubuntu.com/job/mir-ci/69/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/69/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/69/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Some concerns addressed. Abstaining until I have time to review again.

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3259
https://mir-jenkins.ubuntu.com/job/mir-ci/71/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/71/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/71/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3259
http://jenkins.qa.ubuntu.com/job/mir-ci/6034/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5555
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4462
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5511
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/287
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/358
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/358/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/358
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/358/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5508
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5508/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7973
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26718
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/283
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/283/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/140
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26720

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6034/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+/*
+ *
+ * \params[in] ev The input event
+ * \params[in] cookie An allocated void* with exactly cookie_size bytes
+ * \params[in] size The size of the allocated void*
+ */
+void mir_input_event_copy_cookie(MirInputEvent const* ev, MirCookie* cookie, size_t size);

When comments and code disagree, both are likely wrong.

While I'm not sure I fully understand the intended usage I suspect that have two scenarios:

1. Getting a MirCookie from an event.
2. Converting a MirCookie to and from a chunk of memory.

In neither of these does it make sense for a user to supply allocate and supply a pointer to an incomplete type.

How about:

MirCookie* mir_input_event_get_cookie(MirInputEvent const* ev);

and either:

MirCookie* mir_blob_to_mir_cookie(MirBlob* blob);
MirBlob* mir_blob_from_mir_cookie(MirCookie* cookie);

Or:

size_t mir_cookie_get_buffer_size(MirCookie* cookie);
void mir_cookie_to_buffer(MirCookie* cookie, void* buffer, size_t size);
MirCookie* mir_cookie_from_buffer(void const* buffer, size_t size);

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

[Just comment]

It (still) seems odd that CookieAuthority deals with both MirCookies and with pairs of timestamp and MAC. Surely a /cookie/ authority should deal with Cookies? Would it not make more sense as:

auto make_cookie(Timestamp t) -> unique_ptr<MirCookie>

auto authenticated_timestamp(MirCookie const& c) -> Timestamp

Having clients aware of the MAC seems like a leaky abstraction

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3261
https://mir-jenkins.ubuntu.com/job/mir-ci/89/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/89/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/89/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3262
https://mir-jenkins.ubuntu.com/job/mir-ci/91/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/90/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/91/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3263
https://mir-jenkins.ubuntu.com/job/mir-ci/92/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/92/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/92/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3264
https://mir-jenkins.ubuntu.com/job/mir-ci/93/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/93/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/93/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3265
https://mir-jenkins.ubuntu.com/job/mir-ci/95/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/95/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/95/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3266
https://mir-jenkins.ubuntu.com/job/mir-ci/96/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/96/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/96/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

394 +/* Returns an allocated MirCookie that you must release with mir_cookie_release
394 + *
395 + * \params[in] ev The input event
396 + * \return An allocated and ref'ed cookie
397 + */

There's no need to say “allocated” or “ref'ed” here.

394 +/* Returns the MirCookie associated with this input event.
394 + *
395 + * \params[in] ev The input event
396 + * \return A reference to the MirCookie associated with this input event.
397 + * This must be released with a call to mir_cookie_release().
398 + */

Likewise:
415 +/* Turns the user copyed buffer back into a MirCookie, which must be
416 + * released with mir_cookie_release
417 + *
418 + * \params[in] buffer The buffer used to get a MirCookie back
419 + * \return A newely allocated MirCookie
420 + */
421 +MirCookie const* mir_cookie_from_buffer(void const* buffer);

should maybe be:
415 +/* Create a MirCookie from a serialised representation.
417 + *
418 + * \params[in] buffer The buffer containing a serialised MirCookie.
418 + * The buffer may be freed immediately after this call.
419 + * \return A reference to a MirCookie.
418 + * This must be released with a call to mir_cookie_release().
420 + */
421 +MirCookie const* mir_cookie_from_buffer(void const* buffer);

This can never return NULL, right?

Actually: we should probably pass in the length of the buffer here and return NULL if it doesn't match what we expect. Clients will get this passed in from other sources, and it'll courteous to tell them if it's easy to detect that it's wrong.

443 +* \param [in] cookie The void* from the input event that you want to raise the window from.
Ba baw!

1143 + mir_surface_raise_with_cookie;
1144 + mir_input_event_has_cookie;
1145 + mir_cookie_get_size;
1146 + mir_input_event_get_cookie;
1147 + mir_cookie_copy_to_buffer;
1148 + mir_cookie_from_buffer;
1149 + mir_cookie_release;

These should be in MIR_CLIENT_unreleased, not MIR_CLIENT_DETAIL (which is pseudo-private implementation details).

+ if (raw_cookie.size() < cookie_size_from_format(mir::cookie::Format::HMAC_SHA_1_8))

Should be !=, right?

Why did you move mir::SecurityCheckFailed?

2029 + auto const& cookie_ptr = cookie_authority->unmarshall_cookie(cookie_bytes);

I'm surprised this passed valgrind? unmarshall_cookie() returns a std::unique_ptr<>, that you take a *reference* to, and then the std::unique_ptr<> gets *destroyed* at the end of the statement.

Likewise in a bunch of other places. Why doesn't this blow up?

A: http://herbsutter.com/2008/01/01/gotw-88-a-candidate-for-the-most-important-const/. I wonder why people think C++ is needlessly arcane‽.

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3267
https://mir-jenkins.ubuntu.com/job/mir-ci/104/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/104/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/104/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3267
https://mir-jenkins.ubuntu.com/job/mir-ci/106/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/106/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/106/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

First pass - cosmetic stuff

+/* Returns an allocated MirCookie that you must release with mir_cookie_release
+ *
+ * \params[in] ev The input event
+ * \return An allocated and ref'ed cookie
+ */
+MirCookie const* mir_input_event_get_cookie(MirInputEvent const* ev);

1. The /precondition/ that the event has a cookie is missing.

2. "An allocated and ref'ed cookie" is implementation detail the user isn't interested in.

~~~~

+ * \return The size needed to allocate a buffer
+ */
+size_t mir_cookie_get_size(MirCookie const* cookie);

While allocation is likely what the client will do, surely this is just the size of buffer needed by mir_cookie_copy_to_buffer().

~~~~

+ * \params[in] buffer The allocated buffer to copy the MirCookie into
+ * \params[in] size The size of the allocated buffer
+ */
+void mir_cookie_copy_to_buffer(MirCookie const* cookie, void* buffer, size_t size);

%s/allocated //

~~~~

+MirCookie const* mir_cookie_from_buffer(void const* buffer);

I think it would be useful validation for the buffer size to be supplied and checked. While not bulletproof the it is a reminder to the user that size matters.

~~~~

+* \param [in] cookie The void* from the input event that you want to raise the window from.
+*/
+void mir_surface_raise_with_cookie(MirSurface* surface, MirCookie const* cookie);

The comment and the code disagree

~~~~

+ HMAC_SHA_1_8

Is there a reason for the non standard naming style? https://unity.ubuntu.com/mir/cppguide/index.html?showone=Enumerator_Names#Enumerator_Names

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3270
https://mir-jenkins.ubuntu.com/job/mir-ci/110/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/110/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/110/rebuild

review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

From what I've been hearing, I think the terms "cookie" and "marshalling" are over-abstracting the situation. It's better to use more concrete nouns and verbs so the reader more easily understands what's going on. But this is not a review.

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3271
https://mir-jenkins.ubuntu.com/job/mir-ci/113/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/113/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/113/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3272
https://mir-jenkins.ubuntu.com/job/mir-ci/114/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/114/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/114/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3273
https://mir-jenkins.ubuntu.com/job/mir-ci/116/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/116/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/116/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3272
http://jenkins.qa.ubuntu.com/job/mir-ci/6093/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5633
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4540
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5589
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/311
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/417
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/417/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/417
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/417/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5586
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5586/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8029
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26885
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/307
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/307/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/163
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26892

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6093/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Ok, I think. Two inline nonblocking doc comments.

review: Approve
Revision history for this message
Alberto Aguirre (albaguirre) wrote :
Download full text (7.0 KiB)

Mostly cosmetic things.

mir::cookie::Array => mir::cookie::Blob

Comment suggestions
---
+
386 +/* Tells if the MirInputEvent has a MirCookie
387 + *
388 + * \params[in] ev The input event
389 + * \return True if the input event has a MirCookie
390 + */

change to:

+
386 +/* Query if an input event contains a cookie
387 + *
388 + * \params[in] ev The input event
389 + * \return True if the input event contains a cookie
390 + */

---

---
/* Returns the MirCookie associated with this input event.
 *
 * \pre The input event must have a MirCookie
 * \params[in] ev The input event
 * \return A reference to the MirCookie associated with this input event
 * This must be released with a call to mir_cookie_release()
 */

 change to:

/* Returns the cookie associated with an input event.
 *
 * \pre The input event must have a MirCookie
 * \params[in] ev An input event
 * \return The cookie associated with the given input event
 * The cookie must be released by calling mir_cookie_release
 */
---

/* The size of the buffer needed to serialize this MirCookie
 *
 * \params[in] cookie The MirCookie
 * \return The size needed for a buffer
 */
size_t mir_cookie_get_size(MirCookie const* cookie);

change to:

/* Queries the size needed to serialize a given cookie
 *
 * \params[in] cookie A cookie instance
 * \return The size of the serialized representation of the given cookie
 */
size_t mir_cookie_size(MirCookie const* cookie);
---

---
/* Copy the MirCookie into an allocated buffer
 *
 * \pre The size must be equal to mir_cookie_get_size
 * \params[in] cookie The MirCookie
 * \params[in] buffer The allocated buffer to copy the MirCookie into
 * \params[in] size The size of the allocated buffer
 */

 change to:

/* Serializes a cookie into the given buffer
 *
 * \pre The size must be equal to mir_cookie_get_size
 * \params[in] cookie A cookie instance
 * \params[in] buffer A buffer which is filled with the serialized representation
                      of the given cookie
 * \params[in] size The size of the given buffer
 */
void mir_cookie_copy_to_buffer(MirCookie const* cookie, void* buffer, size_t size);

To be consistent with mir_cookie_from_buffer
mir_cookie_copy_to_buffer => mir_cookie_to_buffer

---
/* Create a MirCookie from a serialised representation
 *
 * \pre The size must be equal to mir_cookie_get_size
 * \params[in] buffer The buffer containing a serialised MirCookie.
 * The buffer may be freed immediately after this call.
 * \return A reference to a MirCookie.
 * This must be released with a call to mir_cookie_release().
 */
MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size);

change to:

/* Create a cookie from a serialized representation
 *
 * \pre The size must be equal to mir_cookie_get_size
 * \params[in] buffer The buffer containing a serialized cookie.
 * The buffer may be freed immediately after this call.
 * \return A MirCookie instance. The instance must be re...

Read more...

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+#include "mir/cookie_array.h"

Seeing this caused me to notice an existing issue:

It really ought reflect the "namespace == directory" convention used elsewhere: #include "mir/cookie/array.h"

Not sure if we should fix, or just live with it as "mir/cookie_factory.h" is pre-existing.

review: Needs Information
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

Oops on the last one I meant:

---
void mir_cookie_copy_to_buffer(MirCookie const* cookie, void* buffer, size_t size)
{
    mir::require(size == mir::cookie::array_size);
    memcpy(buffer, cookie, size);
}
---

With a client side MirCookie class suggested above would just become:
void mir_cookie_copy_to_buffer(MirCookie const* cookie, void* buffer, size_t size)
{
    return cookie->copy_to(buffer, size);
}

and mir_cookie_release turns into:

+void mir_cookie_release(MirCookie const* cookie)
{
    delete cookie;
}

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3273
http://jenkins.qa.ubuntu.com/job/mir-ci/6100/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5644
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4551
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5600
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/318
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/424
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/424/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/424
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/424/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5597
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5597/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8038
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26908
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/314
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/314/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/170
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26918

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6100/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3276
https://mir-jenkins.ubuntu.com/job/mir-ci/125/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/125/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/125/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3277
https://mir-jenkins.ubuntu.com/job/mir-ci/126/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/126/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/126/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3278
https://mir-jenkins.ubuntu.com/job/mir-ci/127/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/127/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/127/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3279
https://mir-jenkins.ubuntu.com/job/mir-ci/128/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/128/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/128/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

LGTM.

review: Approve
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3281
https://mir-jenkins.ubuntu.com/job/mir-ci/130/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/130/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/130/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3285
https://mir-jenkins.ubuntu.com/job/mir-ci/132/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/131/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/132/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+/* Queries the size needed to serialize a given cookie
+ *
+ * \params[in] cookie A cookie instance
+ * \return The size of the serialized representation of the given cookie
+ */
+size_t mir_cookie_size(MirCookie const* cookie);

Would mir_cookie_buffer_size() be a clearer name?

~~~~

+/* Create a cookie from a serialized representation
+ *
+ * \pre The size must be equal to mir_cookie_size
+ * \params[in] buffer The buffer containing a serialized cookie.
+ * The buffer may be freed immediately after this call.
+ * \return A MirCookie instance. The instance must be released
+ with a call to mir_cookie_release.
+ */
+MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size);

The precondition is impossible for the client to check - mir_cookie_size() takes a parameter that isn't (in the general case) available to the client.

Perhaps we should drop the cookie parameter from mir_cookie_size()? Or do we expect different cookies to have different sizes?

~~~~

+class Cookie
+{
+public:
+ virtual ~Cookie() = default;
+
+ /**
+ * Returns the timestamp that the cookie is built with
+ *
+ * \return The timestamp
+ */
+ virtual uint64_t timestamp() const = 0;
+
+ /**
+ * Converts the cookie into a stream of bytes.
+ *
+ * \return The stream of bytes formatted
+ */
+ virtual std::vector<uint8_t> serialize() const = 0;
+};

interfaces should delete CopyAssign

~~~~

- void raise_surface_with_timestamp(
+ void raise_surface(

Is this API break necessary? It will break downstreams. (And is how it motivated by the purpose of this MP?)

~~~~

inline mir::cookie::Blob const& getCookie() const { return mCookie; }

so getCookie() returns a blob? Confusing! "getCookieAsBlob()"?

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Non-blocking questions and comments:

mev::make_event(MirInputDeviceId(android_event->getDeviceId()),
                                    kev->getEventTime(),
- kev->getMac(),
+ {std::begin(cookie), std::end(cookie)},
mia::mir_keyboard_action_from_android(kev->getAction(), kev->getRepeatCount()),
                                    kev->getKeyCode(),
kev->getScanCode(),

Why do we need to create a "std::vector<uint8_t>" temporary from a blob (called "cookie"!)? What stops make_event taking a blob const&?

~~~~

+ MirCookie() = delete;

What advantage is there for disabling default construction?

~~~~

+#include "cookie.h"

We usually write the full path in public headers. Vis:

#include "mir/cookie/cookie.h"

~~~~

+ * \return A unique_ptr Authority

I don't think it useful to mention unique_ptr in the doc comment. (And you don't do it consistently.)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3279
http://jenkins.qa.ubuntu.com/job/mir-ci/6108/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5658
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4565
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5614
    FAILURE: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/323/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/432
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/432/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/432
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/432/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5611
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5611/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8049
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26943
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/319
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/319/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/175/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26958

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6108/rebuild

review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> +/* Queries the size needed to serialize a given cookie
> + *
> + * \params[in] cookie A cookie instance
> + * \return The size of the serialized representation of the given
> cookie
> + */
> +size_t mir_cookie_size(MirCookie const* cookie);
>
> Would mir_cookie_buffer_size() be a clearer name?
>
> ~~~~

Yes it would. Changing.

>
> +/* Create a cookie from a serialized representation
> + *
> + * \pre The size must be equal to mir_cookie_size
> + * \params[in] buffer The buffer containing a serialized cookie.
> + * The buffer may be freed immediately after this call.
> + * \return A MirCookie instance. The instance must be released
> + with a call to mir_cookie_release.
> + */
> +MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size);
>
> The precondition is impossible for the client to check - mir_cookie_size()
> takes a parameter that isn't (in the general case) available to the client.
>
> Perhaps we should drop the cookie parameter from mir_cookie_size()? Or do we
> expect different cookies to have different sizes?
>
> ~~~~

While atm the cookie size is consistent, the cookie size is dependent on the cookie authority implementation.

As far as the size, the size for the buffer *must* be mir_cookie_size() and it *must* get that size to allocate said buffer. The only way they could have gotten an allocated buffer, would be by querying the size. So I would think its up to the user to pass the size_t size around which MUST be equal to the mir_cookie_size at one point.

>
> +class Cookie
> +{
> +public:
> + virtual ~Cookie() = default;
> +
> + /**
> + * Returns the timestamp that the cookie is built with
> + *
> + * \return The timestamp
> + */
> + virtual uint64_t timestamp() const = 0;
> +
> + /**
> + * Converts the cookie into a stream of bytes.
> + *
> + * \return The stream of bytes formatted
> + */
> + virtual std::vector<uint8_t> serialize() const = 0;
> +};
>
> interfaces should delete CopyAssign
>
> ~~~~

Reasonable, Changing.

>
> - void raise_surface_with_timestamp(
> + void raise_surface(
>
> Is this API break necessary? It will break downstreams. (And is how it
> motivated by the purpose of this MP?)
>
> ~~~~

This API is new, (was removed from the API before the 0.18 release). So just trying to get the correct name for it.
>
> inline mir::cookie::Blob const& getCookie() const { return mCookie; }
>
> so getCookie() returns a blob? Confusing! "getCookieAsBlob()"?

Very confusing, and yes Ill go through and rename that.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> Non-blocking questions and comments:
>
> mev::make_event(MirInputDeviceId(android_event->getDeviceId()),
> kev->getEventTime(),
> - kev->getMac(),
> + {std::begin(cookie), std::end(cookie)},
> mia::mir_keyboard_action_from_android(kev->getAction(),
> kev->getRepeatCount()),
> kev->getKeyCode(),
> kev->getScanCode(),
>
> Why do we need to create a "std::vector<uint8_t>" temporary from a blob
> (called "cookie"!)? What stops make_event taking a blob const&?
>
> ~~~~
>

Since blob const& is a std::array<uint8_t, 17> and the event_builder.h is c++ public API. Since its a public API I move back to std::array so we dont depend on a fix size for the cookie.
> + MirCookie() = delete;
>
> What advantage is there for disabling default construction?
>
>
> ~~~~
>
> +#include "cookie.h"
>
> We usually write the full path in public headers. Vis:
>
> #include "mir/cookie/cookie.h"
>
> ~~~~

Makes sesne, and reads better. Changing.

>
> + * \return A unique_ptr Authority
>
> I don't think it useful to mention unique_ptr in the doc comment. (And you
> don't do it consistently.)

Changing.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> MirCookie() = delete;
> What advantage is there for disabling default construction?

Mainly to force the creation of only valid MirCookies. So if we ever get one we know it must have been created through one of its explicit CTOR.

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

From what I see at the ClientCookies fixture. The test body does not wait for the client surface to be exposed and focused. So there is a chance that the SurfaceInputDispatcher does not forward the event to the client. I.e. you could cut some code out of the TestClientInput fixture. CI does not seem to affected by that problem, so you might as well do that some time after the release.

Is there a reason why you do not throw SecurityCheckErrors with BOOST_THROW_EXCEPTION?

review: Needs Information
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3286
https://mir-jenkins.ubuntu.com/job/mir-ci/136/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/136/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/136/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size)
+{
+ if (size != mir::cookie::default_blob_size)
+ return NULL;
+
+ return new MirCookie(buffer, size);
+}

While it is extremely unlikely for operator new() (or any of the other code currently invoked here) to throw I think we should trap exceptions and not allow them to propagate from a C API.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> Is there a reason why you do not throw SecurityCheckErrors with
> BOOST_THROW_EXCEPTION?

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> > Is there a reason why you do not throw SecurityCheckErrors with
> > BOOST_THROW_EXCEPTION?

Rats! the code changed while I was reading it.

review: Abstain
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> +MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size)
> +{
> + if (size != mir::cookie::default_blob_size)
> + return NULL;
> +
> + return new MirCookie(buffer, size);
> +}
>
> While it is extremely unlikely for operator new() (or any of the other code
> currently invoked here) to throw I think we should trap exceptions and not
> allow them to propagate from a C API.

Fixed!

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3287
https://mir-jenkins.ubuntu.com/job/mir-ci/137/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/137/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/137/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I've looked at this code too many times today to approve it. I'm not seeing what is there anymore.

review: Abstain
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3289
https://mir-jenkins.ubuntu.com/job/mir-ci/138/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/138/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/138/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

A first pass:

+ static std::unique_ptr<Authority> create_saving(Secret& save_secret);

The name 'create_saving' is not very clear.

+ std::copy_n(std::begin(cookie), cookie.size(), std::begin(kev.cookie));

The code as written could overflow the kev.cookie array.

+#include "../mir_cookie.h"

We generally try to avoid pulling headers from parent directories (but it's not a dealbreaker, and it seems we are doing it more on the client side).

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3290
https://mir-jenkins.ubuntu.com/job/mir-ci/139/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/139/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/139/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3291
https://mir-jenkins.ubuntu.com/job/mir-ci/141/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/141/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/141/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3285
http://jenkins.qa.ubuntu.com/job/mir-ci/6111/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5662
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4569
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5618
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/326
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/435
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/435/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/435
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/435/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5615
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5615/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8053
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26968
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/322
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/322/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/178
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26976

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6111/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3292
https://mir-jenkins.ubuntu.com/job/mir-ci/142/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/142/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/142/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3293
https://mir-jenkins.ubuntu.com/job/mir-ci/143/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/143/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/143/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3294
https://mir-jenkins.ubuntu.com/job/mir-ci/144/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/144/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/144/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3296
https://mir-jenkins.ubuntu.com/job/mir-ci/145/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/145/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/145/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3296
http://jenkins.qa.ubuntu.com/job/mir-ci/6117/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5672
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4579
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5628
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/329
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/441
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/441/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/441
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/441/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5625
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5625/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8060
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26990
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/325
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/325/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/181
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26991

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6117/rebuild

review: Approve (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

ok you resolved everything i saw in this or the upcoming MP

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

@"* I guess gcc 4.* assume const for auto = make_unique<..> which causes issues when attempting to return a derived class to a base class. You cannot return a const unique_ptr since it cannot be std::moved"

I guess you're wrong: that would make auto support implausibly broken.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+ * NULL will be returned if the buffer and size dont describe

s/dont/don't/

~~~~

+ * Construction function used to create a Authority. The secret size must be

s/a Authority/an Authority/

~~~~

+ // TODO Soon to be removed!
+ static std::unique_ptr<Authority> create_saving(Secret& save_secret);

Why?

~~~~

 /// Sets an override functor for creating the cookie factory.

s/factory/authority/

~~~~

+ mir::cookie::Blob copy_vector_to_cookie_blob(std::vector<uint8_t> const& vector)

It's local to the TU, so I wouldn't block, but I'd reserve "copy" for functions that take a target. I'd call it something like "as_blob".

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

This introduces a number of FIXME/TODO comments, without it being clear when or why they will addressed.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> This introduces a number of FIXME/TODO comments, without it being clear when
> or why they will addressed.

All removed in this branch:
https://code.launchpad.net/~mir-team/mir/160-bit-finally/+merge/283751

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> @"* I guess gcc 4.* assume const for auto = make_unique<..> which causes
> issues when attempting to return a derived class to a base class. You cannot
> return a const unique_ptr since it cannot be std::moved"
>
> I guess you're wrong: that would make auto support implausibly broken.

Re looking at the compiler error... just looks like problem with implicit conversions? Not sure how removing the auto fixed it for me now though :(
https://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4576/console

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> + * NULL will be returned if the buffer and size dont describe
>
> s/dont/don't/
>
> ~~~~
Fixing

>
> + * Construction function used to create a Authority. The secret size must be
>
> s/a Authority/an Authority/
>
> ~~~~
Fixing

>
> + // TODO Soon to be removed!
> + static std::unique_ptr<Authority> create_saving(Secret& save_secret);
>
> Why?
>
> ~~~~
Hmm that fixme shouldnt be there anymore? The reason was because we were going to create a lazy creation method for the secret. So we didnt depend on it on boot. Which ill be making a branch soon for that even though we've a work around in USC for the moment.
>
> /// Sets an override functor for creating the cookie factory.
>
> s/factory/authority/
>
> ~~~~
Fixing.
>
> + mir::cookie::Blob copy_vector_to_cookie_blob(std::vector<uint8_t> const&
> vector)
>
> It's local to the TU, so I wouldn't block, but I'd reserve "copy" for
> functions that take a target. I'd call it something like "as_blob".

Sounds good, fixing!

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

>+ // TODO Soon to be removed!
>+ static std::unique_ptr<Authority> create_saving(Secret& save_secret);
>
>Why?

Opps its a TODO, and yeah removed that this branch no need to have that TODO, and ill be address it very soon!

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3297
https://mir-jenkins.ubuntu.com/job/mir-ci/151/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/151/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/151/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3297
http://jenkins.qa.ubuntu.com/job/mir-ci/6123/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5678
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4585
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5634
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/332
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/447
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/447/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/447
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/447/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5631
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5631/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8066
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/27011
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/328
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/328/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/184
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/27017

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6123/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Doc fixes have been applied.

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

^-Network hiccup

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '3rd_party/CMakeLists.txt'
2--- 3rd_party/CMakeLists.txt 2016-01-20 23:59:18 +0000
3+++ 3rd_party/CMakeLists.txt 2016-01-25 13:42:04 +0000
4@@ -11,6 +11,7 @@
5 set(MIR_INPUT_ANDROID_COMPILE_FLAGS ${MIR_INPUT_ANDROID_COMPILE_FLAGS}
6 PARENT_SCOPE)
7
8+include_directories(${PROJECT_SOURCE_DIR}/src/include/cookie)
9 include_directories(${PROJECT_SOURCE_DIR}/src/include/common)
10 include_directories(${PROJECT_SOURCE_DIR}/src/include/platform)
11 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/android-deps)
12
13=== modified file '3rd_party/android-input/android/frameworks/base/include/androidfw/Input.h'
14--- 3rd_party/android-input/android/frameworks/base/include/androidfw/Input.h 2016-01-20 23:59:18 +0000
15+++ 3rd_party/android-input/android/frameworks/base/include/androidfw/Input.h 2016-01-25 13:42:04 +0000
16@@ -31,6 +31,8 @@
17
18 #include <chrono>
19
20+#include "mir/cookie/blob.h"
21+
22 #ifdef HAVE_ANDROID_OS
23 class SkMatrix;
24 #endif
25@@ -276,7 +278,7 @@
26
27 inline int32_t getRepeatCount() const { return mRepeatCount; }
28
29- inline uint64_t getMac() const { return mMac; }
30+ inline mir::cookie::Blob const& getCookieAsBlob() const { return mCookieBlob; }
31
32 inline std::chrono::nanoseconds getDownTime() const { return mDownTime; }
33
34@@ -299,7 +301,7 @@
35 int32_t scanCode,
36 int32_t metaState,
37 int32_t repeatCount,
38- uint64_t mac,
39+ mir::cookie::Blob const& cookie,
40 std::chrono::nanoseconds downTime,
41 std::chrono::nanoseconds eventTime);
42 void initialize(const KeyEvent& from);
43@@ -311,7 +313,7 @@
44 int32_t mScanCode;
45 int32_t mMetaState;
46 int32_t mRepeatCount;
47- uint64_t mMac;
48+ mir::cookie::Blob mCookieBlob;
49 std::chrono::nanoseconds mDownTime;
50 std::chrono::nanoseconds mEventTime;
51 };
52@@ -358,7 +360,7 @@
53
54 inline float getYPrecision() const { return mYPrecision; }
55
56- inline uint64_t getMac() const { return mMac; }
57+ inline mir::cookie::Blob const& getCookieAsBlob() const { return mCookieBlob; }
58
59 inline std::chrono::nanoseconds getDownTime() const { return mDownTime; }
60
61@@ -513,7 +515,7 @@
62 float yOffset,
63 float xPrecision,
64 float yPrecision,
65- uint64_t mac,
66+ mir::cookie::Blob const& cookie,
67 std::chrono::nanoseconds downTime,
68 std::chrono::nanoseconds eventTime,
69 size_t pointerCount,
70@@ -561,7 +563,7 @@
71 float mYOffset;
72 float mXPrecision;
73 float mYPrecision;
74- uint64_t mMac;
75+ mir::cookie::Blob mCookieBlob;
76 std::chrono::nanoseconds mDownTime;
77 Vector<PointerProperties> mPointerProperties;
78 Vector<std::chrono::nanoseconds> mSampleEventTimes;
79
80=== modified file '3rd_party/android-input/android/frameworks/base/include/androidfw/InputTransport.h'
81--- 3rd_party/android-input/android/frameworks/base/include/androidfw/InputTransport.h 2016-01-20 23:59:18 +0000
82+++ 3rd_party/android-input/android/frameworks/base/include/androidfw/InputTransport.h 2016-01-25 13:42:04 +0000
83@@ -62,7 +62,7 @@
84 struct Key {
85 uint32_t seq;
86 int64_t eventTime;
87- uint64_t mac;
88+ mir::cookie::Blob cookieBlob;
89 int32_t deviceId;
90 int32_t source;
91 int32_t action;
92@@ -81,7 +81,7 @@
93 struct Motion {
94 uint32_t seq;
95 int64_t eventTime;
96- uint64_t mac;
97+ mir::cookie::Blob cookieBlob;
98 int32_t deviceId;
99 int32_t source;
100 int32_t action;
101@@ -212,7 +212,7 @@
102 int32_t scanCode,
103 int32_t metaState,
104 int32_t repeatCount,
105- uint64_t mac,
106+ mir::cookie::Blob const& cookieBlob,
107 std::chrono::nanoseconds downTime,
108 std::chrono::nanoseconds eventTime);
109
110@@ -237,7 +237,7 @@
111 float yOffset,
112 float xPrecision,
113 float yPrecision,
114- uint64_t mac,
115+ mir::cookie::Blob const& cookieBlob,
116 std::chrono::nanoseconds downTime,
117 std::chrono::nanoseconds eventTime,
118 size_t pointerCount,
119
120=== modified file '3rd_party/android-input/android/frameworks/base/services/input/Input.cpp'
121--- 3rd_party/android-input/android/frameworks/base/services/input/Input.cpp 2016-01-20 23:59:18 +0000
122+++ 3rd_party/android-input/android/frameworks/base/services/input/Input.cpp 2016-01-25 13:42:04 +0000
123@@ -127,7 +127,7 @@
124 int32_t scanCode,
125 int32_t metaState,
126 int32_t repeatCount,
127- uint64_t mac,
128+ mir::cookie::Blob const& cookieBlob,
129 std::chrono::nanoseconds downTime,
130 std::chrono::nanoseconds eventTime) {
131 InputEvent::initialize(deviceId, source);
132@@ -137,7 +137,7 @@
133 mScanCode = scanCode;
134 mMetaState = metaState;
135 mRepeatCount = repeatCount;
136- mMac = mac;
137+ mCookieBlob = cookieBlob;
138 mDownTime = downTime;
139 mEventTime = eventTime;
140 }
141@@ -150,7 +150,7 @@
142 mScanCode = from.mScanCode;
143 mMetaState = from.mMetaState;
144 mRepeatCount = from.mRepeatCount;
145- mMac = from.mMac;
146+ mCookieBlob = from.mCookieBlob;
147 mDownTime = from.mDownTime;
148 mEventTime = from.mEventTime;
149 }
150@@ -294,7 +294,7 @@
151 float yOffset,
152 float xPrecision,
153 float yPrecision,
154- uint64_t mac,
155+ mir::cookie::Blob const& cookieBlob,
156 std::chrono::nanoseconds downTime,
157 std::chrono::nanoseconds eventTime,
158 size_t pointerCount,
159@@ -310,7 +310,7 @@
160 mYOffset = yOffset;
161 mXPrecision = xPrecision;
162 mYPrecision = yPrecision;
163- mMac = mac;
164+ mCookieBlob = cookieBlob;
165 mDownTime = downTime;
166 mPointerProperties.clear();
167 mPointerProperties.appendArray(pointerProperties, pointerCount);
168@@ -330,7 +330,7 @@
169 mYOffset = other->mYOffset;
170 mXPrecision = other->mXPrecision;
171 mYPrecision = other->mYPrecision;
172- mMac = other->mMac;
173+ mCookieBlob = other->mCookieBlob;
174 mDownTime = other->mDownTime;
175 mPointerProperties = other->mPointerProperties;
176
177
178=== modified file '3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp'
179--- 3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp 2016-01-20 23:59:18 +0000
180+++ 3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp 2016-01-25 13:42:04 +0000
181@@ -236,16 +236,16 @@
182 int32_t scanCode,
183 int32_t metaState,
184 int32_t repeatCount,
185- uint64_t mac,
186+ mir::cookie::Blob const& cookieBlob,
187 std::chrono::nanoseconds downTime,
188 std::chrono::nanoseconds eventTime) {
189 #if DEBUG_TRANSPORT_ACTIONS
190 ALOGD("channel '%s' publisher ~ publishKeyEvent: seq=%u, deviceId=%d, source=0x%x, "
191 "action=0x%x, flags=0x%x, keyCode=%d, scanCode=%d, metaState=0x%x, repeatCount=%d,"
192- "mac=%lu, downTime=%lld, eventTime=%lld",
193+ "downTime=%lld, eventTime=%lld",
194 c_str(mChannel->getName()), seq,
195 deviceId, source, action, flags, keyCode, scanCode, metaState, repeatCount,
196- mac, downTime, eventTime);
197+ downTime, eventTime);
198 #endif
199
200 if (!seq) {
201@@ -264,7 +264,7 @@
202 msg.body.key.scanCode = scanCode;
203 msg.body.key.metaState = metaState;
204 msg.body.key.repeatCount = repeatCount;
205- msg.body.key.mac = mac;
206+ msg.body.key.cookieBlob = cookieBlob;
207 msg.body.key.downTime = downTime.count();
208 msg.body.key.eventTime = eventTime.count();
209 return mChannel->sendMessage(&msg);
210@@ -283,7 +283,7 @@
211 float yOffset,
212 float xPrecision,
213 float yPrecision,
214- uint64_t mac,
215+ mir::cookie::Blob const& cookieBlob,
216 std::chrono::nanoseconds downTime,
217 std::chrono::nanoseconds eventTime,
218 size_t pointerCount,
219@@ -293,11 +293,11 @@
220 ALOGD("channel '%s' publisher ~ publishMotionEvent: seq=%u, deviceId=%d, source=0x%x, "
221 "action=0x%x, flags=0x%x, edgeFlags=0x%x, metaState=0x%x, buttonState=0x%x, "
222 "xOffset=%f, yOffset=%f, "
223- "xPrecision=%f, yPrecision=%f, mac=%lu, "
224+ "xPrecision=%f, yPrecision=%f,"
225 "downTime=%lld, eventTime=%lld, pointerCount=%d",
226 c_str(mChannel->getName()), seq,
227 deviceId, source, action, flags, edgeFlags, metaState, buttonState,
228- xOffset, yOffset, xPrecision, yPrecision, mac, downTime, eventTime, pointerCount);
229+ xOffset, yOffset, xPrecision, yPrecision, downTime, eventTime, pointerCount);
230 #endif
231
232 if (!seq) {
233@@ -325,7 +325,7 @@
234 msg.body.motion.yOffset = yOffset;
235 msg.body.motion.xPrecision = xPrecision;
236 msg.body.motion.yPrecision = yPrecision;
237- msg.body.motion.mac = mac;
238+ msg.body.motion.cookieBlob = cookieBlob;
239 msg.body.motion.downTime = downTime.count();
240 msg.body.motion.eventTime = eventTime.count();
241 msg.body.motion.pointerCount = pointerCount;
242@@ -882,7 +882,7 @@
243 msg->body.key.scanCode,
244 msg->body.key.metaState,
245 msg->body.key.repeatCount,
246- msg->body.key.mac,
247+ msg->body.key.cookieBlob,
248 std::chrono::nanoseconds(msg->body.key.downTime),
249 std::chrono::nanoseconds(msg->body.key.eventTime));
250 }
251@@ -908,7 +908,7 @@
252 msg->body.motion.yOffset,
253 msg->body.motion.xPrecision,
254 msg->body.motion.yPrecision,
255- msg->body.motion.mac,
256+ msg->body.motion.cookieBlob,
257 std::chrono::nanoseconds(msg->body.motion.downTime),
258 std::chrono::nanoseconds(msg->body.motion.eventTime),
259 pointerCount,
260
261=== modified file 'debian/control'
262--- debian/control 2016-01-21 23:54:16 +0000
263+++ debian/control 2016-01-25 13:42:04 +0000
264@@ -420,7 +420,7 @@
265 This package depends on a full set of graphics drivers for running Mir on top
266 of an existing Android driver stack.
267
268-Package: libmircookie1
269+Package: libmircookie2
270 Section: libs
271 Architecture: any
272 Multi-Arch: same
273@@ -439,7 +439,7 @@
274 Architecture: any
275 Multi-Arch: same
276 Pre-Depends: ${misc:Pre-Depends}
277-Depends: libmircookie1 (= ${binary:Version}),
278+Depends: libmircookie2 (= ${binary:Version}),
279 ${misc:Depends},
280 Description: Produce and verify spoof-resistant timestamps - development headers
281 libmircookie provides a simple mechanism for a group of cooperating processes
282
283=== renamed file 'debian/libmircookie1.install' => 'debian/libmircookie2.install'
284--- debian/libmircookie1.install 2015-09-08 21:22:41 +0000
285+++ debian/libmircookie2.install 2016-01-25 13:42:04 +0000
286@@ -1,1 +1,1 @@
287-/usr/lib/*/libmircookie.so.1
288+/usr/lib/*/libmircookie.so.2
289
290=== modified file 'include/client/mir/events/event_builders.h'
291--- include/client/mir/events/event_builders.h 2016-01-23 03:16:06 +0000
292+++ include/client/mir/events/event_builders.h 2016-01-25 13:42:04 +0000
293@@ -28,6 +28,7 @@
294 #include <memory>
295 #include <functional>
296 #include <chrono>
297+#include <vector>
298
299 namespace mir
300 {
301@@ -58,13 +59,18 @@
302
303 // Key event
304 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
305- uint64_t mac, MirKeyboardAction action, xkb_keysym_t key_code,
306+ std::vector<uint8_t> const& cookie, MirKeyboardAction action, xkb_keysym_t key_code,
307 int scan_code, MirInputEventModifiers modifiers);
308
309 void set_modifier(MirEvent& event, MirInputEventModifiers modifiers);
310 void set_cursor_position(MirEvent& event, mir::geometry::Point const& pos);
311 void set_button_state(MirEvent& event, MirPointerButtons button_state);
312
313+// Deprecated version with uint64_t mac
314+EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
315+ uint64_t mac, MirKeyboardAction action, xkb_keysym_t key_code,
316+ int scan_code, MirInputEventModifiers modifiers) __attribute__ ((deprecated));
317+
318 // Deprecated version without mac
319 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
320 MirKeyboardAction action, xkb_keysym_t key_code,
321@@ -72,7 +78,11 @@
322
323 // Touch event
324 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
325- uint64_t mac, MirInputEventModifiers modifiers);
326+ std::vector<uint8_t> const& mac, MirInputEventModifiers modifiers);
327+
328+// Deprecated version with uint64_t mac
329+EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
330+ uint64_t mac, MirInputEventModifiers modifiers) __attribute__ ((deprecated));
331
332 // Deprecated version without mac
333 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
334@@ -98,12 +108,20 @@
335 float hscroll_value, float vscroll_value) __attribute__ ((deprecated));
336
337 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
338- uint64_t mac, MirInputEventModifiers modifiers, MirPointerAction action,
339+ std::vector<uint8_t> const& mac, MirInputEventModifiers modifiers, MirPointerAction action,
340 MirPointerButtons buttons_pressed,
341 float x_axis_value, float y_axis_value,
342 float hscroll_value, float vscroll_value,
343 float relative_x_value, float relative_y_value);
344
345+// Deprecated version with uint64_t mac
346+EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
347+ uint64_t mac, MirInputEventModifiers modifiers, MirPointerAction action,
348+ MirPointerButtons buttons_pressed,
349+ float x_axis_value, float y_axis_value,
350+ float hscroll_value, float vscroll_value,
351+ float relative_x_value, float relative_y_value) __attribute__ ((deprecated));
352+
353 // Deprecated version without mac
354 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
355 MirInputEventModifiers modifiers, MirPointerAction action,
356
357=== modified file 'include/client/mir_toolkit/events/event.h'
358--- include/client/mir_toolkit/events/event.h 2016-01-22 19:03:16 +0000
359+++ include/client/mir_toolkit/events/event.h 2016-01-25 13:42:04 +0000
360@@ -58,6 +58,8 @@
361 typedef struct MirInputConfigurationEvent MirInputConfigurationEvent;
362 typedef struct MirSurfaceOutputEvent MirSurfaceOutputEvent;
363
364+typedef struct MirCookie MirCookie;
365+
366 typedef union MirEvent MirEvent;
367
368 #ifdef __cplusplus
369
370=== modified file 'include/client/mir_toolkit/events/input/input_event.h'
371--- include/client/mir_toolkit/events/input/input_event.h 2016-01-20 23:59:18 +0000
372+++ include/client/mir_toolkit/events/input/input_event.h 2016-01-25 13:42:04 +0000
373@@ -1,5 +1,5 @@
374 /*
375- * Copyright © 2014 Canonical Ltd.
376+ * Copyright © 2014-2016 Canonical Ltd.
377 *
378 * This program is free software: you can redistribute it and/or modify it
379 * under the terms of the GNU Lesser General Public License version 3,
380@@ -22,6 +22,7 @@
381 #include "mir_toolkit/events/event.h"
382
383 #include <stdint.h>
384+#include <stdbool.h>
385
386 #ifdef __cplusplus
387 /**
388@@ -132,6 +133,22 @@
389 */
390 MirPointerEvent const* mir_input_event_get_pointer_event(MirInputEvent const* ev);
391
392+/* Query if an input event contains a cookie
393+ *
394+ * \params[in] ev The input event
395+ * \return True if the input event contains a cookie
396+ */
397+bool mir_input_event_has_cookie(MirInputEvent const* ev);
398+
399+/* Returns the cookie associated with an input event.
400+ *
401+ * \pre The input event must have a MirCookie
402+ * \params[in] ev An input event
403+ * \return The cookie associated with the given input event
404+ * The cookie must be released by calling mir_cookie_release
405+ */
406+MirCookie const* mir_input_event_get_cookie(MirInputEvent const* ev);
407+
408 #ifdef __cplusplus
409 }
410 /**@}*/
411
412=== modified file 'include/client/mir_toolkit/mir_client_library.h'
413--- include/client/mir_toolkit/mir_client_library.h 2015-04-28 07:54:10 +0000
414+++ include/client/mir_toolkit/mir_client_library.h 2016-01-25 13:42:04 +0000
415@@ -25,5 +25,6 @@
416 #include <mir_toolkit/version.h>
417 #include <mir_toolkit/mir_platform_message.h>
418 #include <mir_toolkit/cursors.h>
419+#include <mir_toolkit/mir_cookie.h>
420
421 #endif /* MIR_CLIENT_LIBRARY_H */
422
423=== added file 'include/client/mir_toolkit/mir_cookie.h'
424--- include/client/mir_toolkit/mir_cookie.h 1970-01-01 00:00:00 +0000
425+++ include/client/mir_toolkit/mir_cookie.h 2016-01-25 13:42:04 +0000
426@@ -0,0 +1,71 @@
427+/*
428+* Copyright © 2016 Canonical Ltd.
429+ *
430+ * This program is free software: you can redistribute it and/or modify it
431+ * under the terms of the GNU Lesser General Public License version 3,
432+ * as published by the Free Software Foundation.
433+ *
434+ * This program is distributed in the hope that it will be useful,
435+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
436+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
437+ * GNU Lesser General Public License for more details.
438+ *
439+ * You should have received a copy of the GNU Lesser General Public License
440+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
441+ *
442+ * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
443+ */
444+
445+#ifndef MIR_TOOLKIT_MIR_COOKIE_H_
446+#define MIR_TOOLKIT_MIR_COOKIE_H_
447+
448+#include <stdint.h>
449+
450+#ifdef __cplusplus
451+/**
452+ * \addtogroup mir_toolkit
453+ * @{
454+ */
455+extern "C" {
456+#endif
457+
458+/* Queries the size needed to serialize a given cookie
459+ *
460+ * \params[in] cookie A cookie instance
461+ * \return The size of the serialized representation of the given cookie
462+ */
463+size_t mir_cookie_buffer_size(MirCookie const* cookie);
464+
465+/* Serializes a cookie into the given buffer
466+ *
467+ * \pre The size must be equal to mir_cookie_size
468+ * \params[in] cookie A cookie instance
469+ * \params[in] buffer A buffer which is filled with the serialized representation
470+ of the given cookie
471+ * \params[in] size The size of the given buffer
472+ */
473+void mir_cookie_to_buffer(MirCookie const* cookie, void* buffer, size_t size);
474+
475+/* Create a cookie from a serialized representation
476+ *
477+ * \params[in] buffer The buffer containing a serialized cookie.
478+ * The buffer may be freed immediately after this call.
479+ * \return A MirCookie instance. The instance must be released
480+ * with a call to mir_cookie_release.
481+ * NULL will be returned if the buffer and size don't describe
482+ * the contents of a MirCookie.
483+ */
484+MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size);
485+
486+/* Release the MirCookie
487+ *
488+ * \params[in] cookie The cookie to release
489+ */
490+void mir_cookie_release(MirCookie const* cookie);
491+
492+#ifdef __cplusplus
493+}
494+/**@}*/
495+#endif
496+
497+#endif // MIR_TOOLKIT_MIR_COOKIE_H_
498
499=== modified file 'include/client/mir_toolkit/mir_surface.h'
500--- include/client/mir_toolkit/mir_surface.h 2016-01-20 23:59:18 +0000
501+++ include/client/mir_toolkit/mir_surface.h 2016-01-25 13:42:04 +0000
502@@ -756,6 +756,15 @@
503 */
504 MirPersistentId* mir_persistent_id_from_string(char const* string_representation);
505
506+/*
507+* Attempts to raise the surface to the front.
508+*
509+* \param [in] surface The surface to raise
510+* \param [in] cookie A cookie instance obtained from an input event.
511+* An invalid cookie will terminate the client connection.
512+*/
513+void mir_surface_raise(MirSurface* surface, MirCookie const* cookie);
514+
515 #ifdef __cplusplus
516 }
517 /**@}*/
518
519=== added directory 'include/cookie/mir/cookie'
520=== renamed file 'include/cookie/mir/cookie_factory.h' => 'include/cookie/mir/cookie/authority.h'
521--- include/cookie/mir/cookie_factory.h 2016-01-20 23:59:18 +0000
522+++ include/cookie/mir/cookie/authority.h 2016-01-25 13:42:04 +0000
523@@ -1,5 +1,5 @@
524 /*
525- * Copyright © 2015 Canonical Ltd.
526+ * Copyright © 2015-2016 Canonical Ltd.
527 *
528 * This program is free software: you can redistribute it and/or modify
529 * it under the terms of the GNU General Public License version 3 as
530@@ -14,22 +14,29 @@
531 * along with this program. If not, see <http://www.gnu.org/licenses/>.
532 *
533 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
534+ * Brandon Schaefer <brandon.schaefer@canonical.com>
535 */
536
537-#ifndef MIR_COOKIE_COOKIE_FACTORY_H_
538-#define MIR_COOKIE_COOKIE_FACTORY_H_
539-
540-#include "mir_toolkit/cookie.h"
541+#ifndef MIR_COOKIE_AUTHORITY_H_
542+#define MIR_COOKIE_AUTHORITY_H_
543
544 #include <memory>
545+#include <stdexcept>
546 #include <vector>
547
548+#include "mir/cookie/cookie.h"
549+
550 namespace mir
551 {
552 namespace cookie
553 {
554 using Secret = std::vector<uint8_t>;
555
556+struct SecurityCheckError : std::runtime_error
557+{
558+ SecurityCheckError();
559+};
560+
561 /**
562 * \brief A source of moderately-difficult-to-spoof cookies.
563 *
564@@ -41,7 +48,7 @@
565 * to attempt to bypass focus stealing prevention.
566 *
567 */
568-class CookieFactory
569+class Authority
570 {
571 public:
572 /**
573@@ -54,60 +61,60 @@
574 static size_t optimal_secret_size();
575
576 /**
577- * Construction function used to create a CookieFactory. The secret size must be
578+ * Construction function used to create an Authority. The secret size must be
579 * no less then minimum_secret_size otherwise an exception will be thrown
580 *
581- * \param [in] secret A filled in secret used to set the key for the hash function
582- * \return A unique_ptr CookieFactory
583+ * \param [in] secret A secret used to set the key for the hash function
584+ * \return An Authority
585 */
586- static std::unique_ptr<CookieFactory> create_from_secret(Secret const& secret);
587+ static std::unique_ptr<Authority> create_from(Secret const& secret);
588
589 /**
590- * Construction function used to create a CookieFactory as well as a secret.
591+ * Construction function used to create an Authority as well as a secret.
592 *
593 * \param [out] save_secret The secret that was created.
594- * \return A unique_ptr CookieFactory
595- */
596- static std::unique_ptr<CookieFactory> create_saving_secret(Secret& save_secret);
597-
598- /**
599- * Construction function used to create a CookieFactory and a secret which it keeps internally.
600- *
601- * \return A unique_ptr CookieFactory
602- */
603- static std::unique_ptr<CookieFactory> create_keeping_secret();
604-
605- CookieFactory(CookieFactory const& factory) = delete;
606- CookieFactory& operator=(CookieFactory const& factory) = delete;
607- virtual ~CookieFactory() noexcept = default;
608-
609- /**
610- * Turns a timestamp into a MAC and returns a MirCookie.
611- *
612- * \param [in] timestamp The timestamp
613- * \return MirCookie with the stored MAC and timestamp
614- */
615- virtual MirCookie timestamp_to_cookie(uint64_t const& timestamp) = 0;
616-
617- /**
618- * Checks that a MirCookie is a valid MirCookie.
619- *
620- * \param [in] cookie A created MirCookie
621- * \return True when the MirCookie is valid, False when the MirCookie is not valid
622- */
623- virtual bool attest_timestamp(MirCookie const& cookie) = 0;
624-
625- /**
626- * Absolute minimum size of secret key the CookieFactory will accept.
627- *
628- * Code should be using optimum_secret_size(); this minimum size is provided
629- * as a user convenience to guard against catastrophically bad initialisation.
630- */
631+ * \return An Authority
632+ */
633+ static std::unique_ptr<Authority> create_saving(Secret& save_secret);
634+
635+ /**
636+ * Construction function used to create an Authority and a secret which it keeps internally.
637+ *
638+ * \return An Authority
639+ */
640+ static std::unique_ptr<Authority> create();
641+
642+ Authority(Authority const& authority) = delete;
643+ Authority& operator=(Authority const& authority) = delete;
644+ virtual ~Authority() noexcept = default;
645+
646+ /**
647+ * Creates a cookie from a timestamp.
648+ *
649+ * \param [in] timestamp A timestamp
650+ * \return A cookie instance
651+ */
652+ virtual std::unique_ptr<Cookie> make_cookie(uint64_t const& timestamp) = 0;
653+
654+ /**
655+ * Creates a cookie from a serialized representation
656+ *
657+ * \param [in] blob A blob of bytes representing a serialized cookie
658+ * \return A cookie instance
659+ */
660+ virtual std::unique_ptr<Cookie> make_cookie(std::vector<uint8_t> const& raw_cookie) = 0;
661+
662+ /**
663+ * Absolute minimum size of secret key the Authority will accept.
664+ *
665+ * Code should be using optimum_secret_size(); this minimum size is provided
666+ * as a user convenience to guard against catastrophically bad initialisation.
667+ */
668 static unsigned const minimum_secret_size = 8;
669 protected:
670- CookieFactory() = default;
671+ Authority() = default;
672 };
673
674 }
675 }
676-#endif // MIR_COOKIE_COOKIE_FACTORY_H_
677+#endif // MIR_COOKIE_COOKIE_AUTHORITY_H_
678
679=== added file 'include/cookie/mir/cookie/cookie.h'
680--- include/cookie/mir/cookie/cookie.h 1970-01-01 00:00:00 +0000
681+++ include/cookie/mir/cookie/cookie.h 2016-01-25 13:42:04 +0000
682@@ -0,0 +1,57 @@
683+/*
684+ * Copyright © 2016 Canonical Ltd.
685+ *
686+ * This program is free software: you can redistribute it and/or modify
687+ * it under the terms of the GNU General Public License version 3 as
688+ * published by the Free Software Foundation.
689+ *
690+ * This program is distributed in the hope that it will be useful,
691+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
692+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
693+ * GNU General Public License for more details.
694+ *
695+ * You should have received a copy of the GNU General Public License
696+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
697+ *
698+ * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
699+ */
700+
701+#ifndef MIR_COOKIE_COOKIE_H_
702+#define MIR_COOKIE_COOKIE_H_
703+
704+#include <stdint.h>
705+#include <vector>
706+
707+namespace mir
708+{
709+namespace cookie
710+{
711+
712+class Cookie
713+{
714+public:
715+ Cookie() = default;
716+ virtual ~Cookie() = default;
717+
718+ Cookie(Cookie const& cookie) = delete;
719+ Cookie& operator=(Cookie const& cookie) = delete;
720+
721+ /**
722+ * Returns the timestamp that the cookie is built with
723+ *
724+ * \return The timestamp
725+ */
726+ virtual uint64_t timestamp() const = 0;
727+
728+ /**
729+ * Converts the cookie into a stream of bytes.
730+ *
731+ * \return The stream of bytes formatted
732+ */
733+ virtual std::vector<uint8_t> serialize() const = 0;
734+};
735+
736+}
737+}
738+
739+#endif // MIR_COOKIE_COOKIE_H_
740
741=== removed directory 'include/cookie/mir_toolkit'
742=== modified file 'include/server/mir/server.h'
743--- include/server/mir/server.h 2016-01-20 23:59:18 +0000
744+++ include/server/mir/server.h 2016-01-25 13:42:04 +0000
745@@ -37,7 +37,7 @@
746 namespace cookie
747 {
748 using Secret = std::vector<uint8_t>;
749-class CookieFactory;
750+class Authority;
751 }
752 namespace shell
753 {
754@@ -86,11 +86,11 @@
755 /// This must remain valid while apply_settings() and run() are called.
756 void set_command_line(int argc, char const* argv[]);
757
758- /// Sets an override functor for creating the cookie factory.
759+ /// Sets an override functor for creating the cookie authority.
760 /// A secret can be saved and any process this secret is shared
761 /// with can verify Mir-generated cookies, or produce their own.
762- void override_the_cookie_factory(
763- std::function<std::shared_ptr<cookie::CookieFactory>()> const& cookie_factory_builder);
764+ void override_the_cookie_authority(
765+ std::function<std::shared_ptr<cookie::Authority>()> const& cookie_authority_builder);
766
767 /// Applies any configuration options, hooks, or custom implementations.
768 /// Must be called before calling run() or accessing any mir subsystems.
769
770=== modified file 'include/server/mir/shell/abstract_shell.h'
771--- include/server/mir/shell/abstract_shell.h 2016-01-20 23:59:18 +0000
772+++ include/server/mir/shell/abstract_shell.h 2016-01-25 13:42:04 +0000
773@@ -71,7 +71,7 @@
774 std::shared_ptr<scene::Surface> const& surface,
775 MirSurfaceAttrib attrib) override;
776
777- void raise_surface_with_timestamp(
778+ void raise_surface(
779 std::shared_ptr<scene::Session> const& session,
780 std::shared_ptr<scene::Surface> const& surface,
781 uint64_t timestamp) override;
782
783=== modified file 'include/server/mir/shell/shell.h'
784--- include/server/mir/shell/shell.h 2016-01-20 23:59:18 +0000
785+++ include/server/mir/shell/shell.h 2016-01-25 13:42:04 +0000
786@@ -95,7 +95,7 @@
787 std::shared_ptr<scene::Surface> const& surface,
788 MirSurfaceAttrib attrib) = 0;
789
790- virtual void raise_surface_with_timestamp(
791+ virtual void raise_surface(
792 std::shared_ptr<scene::Session> const& session,
793 std::shared_ptr<scene::Surface> const& surface,
794 uint64_t timestamp) = 0;
795
796=== modified file 'include/server/mir/shell/shell_wrapper.h'
797--- include/server/mir/shell/shell_wrapper.h 2016-01-20 23:59:18 +0000
798+++ include/server/mir/shell/shell_wrapper.h 2016-01-25 13:42:04 +0000
799@@ -80,7 +80,7 @@
800 std::shared_ptr<scene::Surface> const& surface,
801 MirSurfaceAttrib attrib) override;
802
803- void raise_surface_with_timestamp(
804+ void raise_surface(
805 std::shared_ptr<scene::Session> const& session,
806 std::shared_ptr<scene::Surface> const& surface,
807 uint64_t timestamp) override;
808
809=== modified file 'src/client/CMakeLists.txt'
810--- src/client/CMakeLists.txt 2016-01-22 03:09:31 +0000
811+++ src/client/CMakeLists.txt 2016-01-25 13:42:04 +0000
812@@ -20,9 +20,9 @@
813 include_directories(
814 ${PROTOBUF_INCLUDE_DIRS}
815 ${CMAKE_CURRENT_BINARY_DIR}
816- ${PROJECT_SOURCE_DIR}/include/cookie
817 ${PROJECT_SOURCE_DIR}/include/client
818 ${PROJECT_SOURCE_DIR}/src/include/client
819+ ${PROJECT_SOURCE_DIR}/src/include/cookie
820 ${DRM_INCLUDE_DIRS}
821 )
822
823@@ -49,6 +49,7 @@
824 event.cpp
825 event_printer.cpp
826 mir_blob.cpp
827+ mir_cookie.cpp
828 mir_connection.cpp
829 mir_connection_api.cpp
830 mir_wait_handle.cpp
831@@ -95,6 +96,7 @@
832 set(LINKS
833 mircommon
834 mirprotobuf
835+ mircookie
836
837 ${XKBCOMMON_LIBRARIES}
838 )
839
840=== modified file 'src/client/events/event_builders.cpp'
841--- src/client/events/event_builders.cpp 2016-01-23 03:16:06 +0000
842+++ src/client/events/event_builders.cpp 2016-01-25 13:42:04 +0000
843@@ -24,11 +24,14 @@
844
845 #include "mir/events/event_builders.h"
846 #include "mir/events/event_private.h"
847+#include "mir/cookie/blob.h"
848 #include "mir/input/xkb_mapper.h"
849
850 #include <string.h>
851
852 #include <boost/throw_exception.hpp>
853+
854+#include <algorithm>
855 #include <stdexcept>
856
857 namespace mi = mir::input;
858@@ -36,6 +39,25 @@
859 namespace mev = mir::events;
860 namespace geom = mir::geometry;
861
862+namespace
863+{
864+ mir::cookie::Blob vector_to_cookie_as_blob(std::vector<uint8_t> const& vector)
865+ {
866+ mir::cookie::Blob blob{{}};
867+
868+ if (vector.size() > blob.size())
869+ {
870+ throw std::runtime_error("Vector size " + std::to_string(vector.size()) +
871+ " is larger then array size: " +
872+ std::to_string(blob.size()));
873+ }
874+
875+ std::copy_n(vector.begin(), vector.size(), blob.begin());
876+
877+ return blob;
878+ }
879+}
880+
881 mir::EventUPtr mev::make_event(mf::SurfaceId const& surface_id, MirOrientation orientation)
882 {
883 auto e = make_empty_event();
884@@ -137,7 +159,7 @@
885 }
886
887 mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
888- uint64_t mac, MirKeyboardAction action, xkb_keysym_t key_code,
889+ std::vector<uint8_t> const& cookie, MirKeyboardAction action, xkb_keysym_t key_code,
890 int scan_code, MirInputEventModifiers modifiers)
891 {
892 auto e = make_empty_event();
893@@ -147,7 +169,7 @@
894 kev.device_id = device_id;
895 kev.source_id = AINPUT_SOURCE_KEYBOARD;
896 kev.event_time = timestamp;
897- kev.mac = mac;
898+ kev.cookie = vector_to_cookie_as_blob(cookie);
899 kev.action = action;
900 kev.key_code = key_code;
901 kev.scan_code = scan_code;
902@@ -156,7 +178,6 @@
903 return e;
904 }
905
906-
907 void mev::set_modifier(MirEvent& event, MirInputEventModifiers modifiers)
908 {
909 switch(event.type)
910@@ -199,16 +220,24 @@
911 event.motion.buttons = button_state;
912 }
913
914+// Deprecated version with uint64_t mac
915+mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
916+ uint64_t /*mac*/, MirKeyboardAction action, xkb_keysym_t key_code,
917+ int scan_code, MirInputEventModifiers modifiers)
918+{
919+ return make_event(device_id, timestamp, std::vector<uint8_t>{}, action, key_code, scan_code, modifiers);
920+}
921+
922 // Deprecated version without mac
923 mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
924 MirKeyboardAction action, xkb_keysym_t key_code,
925 int scan_code, MirInputEventModifiers modifiers)
926 {
927- return make_event(device_id, timestamp, 0, action, key_code, scan_code, modifiers);
928+ return make_event(device_id, timestamp, std::vector<uint8_t>{}, action, key_code, scan_code, modifiers);
929 }
930
931 mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
932- uint64_t mac, MirInputEventModifiers modifiers)
933+ std::vector<uint8_t> const& cookie, MirInputEventModifiers modifiers)
934 {
935 auto e = make_empty_event();
936
937@@ -216,18 +245,25 @@
938 auto& mev = e->motion;
939 mev.device_id = device_id;
940 mev.event_time = timestamp;
941- mev.mac = mac;
942+ mev.cookie = vector_to_cookie_as_blob(cookie);
943 mev.modifiers = modifiers;
944 mev.source_id = AINPUT_SOURCE_TOUCHSCREEN;
945
946 return e;
947 }
948
949+// Deprecated version with uint64_t mac
950+mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
951+ uint64_t /*mac*/, MirInputEventModifiers modifiers)
952+{
953+ return make_event(device_id, timestamp, std::vector<uint8_t>{}, modifiers);
954+}
955+
956 // Deprecated version without mac
957 mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
958 MirInputEventModifiers modifiers)
959 {
960- return make_event(device_id, timestamp, 0, modifiers);
961+ return make_event(device_id, timestamp, std::vector<uint8_t>{}, modifiers);
962 }
963
964 void mev::add_touch(MirEvent &event, MirTouchId touch_id, MirTouchAction action,
965@@ -248,7 +284,7 @@
966 }
967
968 mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
969- uint64_t mac, MirInputEventModifiers modifiers, MirPointerAction action,
970+ std::vector<uint8_t> const& cookie, MirInputEventModifiers modifiers, MirPointerAction action,
971 MirPointerButtons buttons_pressed,
972 float x_axis_value, float y_axis_value,
973 float hscroll_value, float vscroll_value,
974@@ -260,7 +296,7 @@
975 auto& mev = e->motion;
976 mev.device_id = device_id;
977 mev.event_time = timestamp;
978- mev.mac = mac;
979+ mev.cookie = vector_to_cookie_as_blob(cookie);
980 mev.modifiers = modifiers;
981 mev.source_id = AINPUT_SOURCE_MOUSE;
982 mev.buttons = buttons_pressed;
983@@ -278,6 +314,19 @@
984 return e;
985 }
986
987+// Deprecated version with uint64_t mac
988+mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
989+ uint64_t /*mac*/, MirInputEventModifiers modifiers, MirPointerAction action,
990+ MirPointerButtons buttons_pressed,
991+ float x_axis_value, float y_axis_value,
992+ float hscroll_value, float vscroll_value,
993+ float relative_x_value, float relative_y_value)
994+{
995+ return make_event(device_id, timestamp, std::vector<uint8_t>{}, modifiers, action,
996+ buttons_pressed, x_axis_value, y_axis_value, hscroll_value,
997+ vscroll_value, relative_x_value, relative_y_value);
998+}
999+
1000 // Deprecated version without mac
1001 mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
1002 MirInputEventModifiers modifiers, MirPointerAction action,
1003@@ -286,19 +335,19 @@
1004 float hscroll_value, float vscroll_value,
1005 float relative_x_value, float relative_y_value)
1006 {
1007- return make_event(device_id, timestamp, 0, modifiers, action,
1008+ return make_event(device_id, timestamp, std::vector<uint8_t>{}, modifiers, action,
1009 buttons_pressed, x_axis_value, y_axis_value, hscroll_value,
1010 vscroll_value, relative_x_value, relative_y_value);
1011 }
1012
1013 // Deprecated version without relative axis
1014 mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
1015- uint64_t mac, MirInputEventModifiers modifiers, MirPointerAction action,
1016+ uint64_t /*mac*/, MirInputEventModifiers modifiers, MirPointerAction action,
1017 MirPointerButtons buttons_pressed,
1018 float x_axis_value, float y_axis_value,
1019 float hscroll_value, float vscroll_value)
1020 {
1021- return make_event(device_id, timestamp, mac, modifiers, action, buttons_pressed,
1022+ return make_event(device_id, timestamp, std::vector<uint8_t>{}, modifiers, action, buttons_pressed,
1023 x_axis_value, y_axis_value, hscroll_value, vscroll_value, 0, 0);
1024 }
1025
1026@@ -309,7 +358,7 @@
1027 float x_axis_value, float y_axis_value,
1028 float hscroll_value, float vscroll_value)
1029 {
1030- return make_event(device_id, timestamp, 0, modifiers, action, buttons_pressed,
1031+ return make_event(device_id, timestamp, std::vector<uint8_t>{}, modifiers, action, buttons_pressed,
1032 x_axis_value, y_axis_value, hscroll_value, vscroll_value, 0, 0);
1033 }
1034
1035
1036=== modified file 'src/client/input/android/android_input_lexicon.cpp'
1037--- src/client/input/android/android_input_lexicon.cpp 2016-01-20 23:59:18 +0000
1038+++ src/client/input/android/android_input_lexicon.cpp 2016-01-25 13:42:04 +0000
1039@@ -20,6 +20,7 @@
1040 #include "mir/input/android/android_input_lexicon.h"
1041 #include "mir/input/android/event_conversion_helpers.h"
1042 #include "mir/events/event_builders.h"
1043+#include "mir/cookie/blob.h"
1044
1045 #include <androidfw/Input.h>
1046
1047@@ -38,9 +39,10 @@
1048 case AINPUT_EVENT_TYPE_KEY:
1049 {
1050 auto kev = static_cast<const droidinput::KeyEvent*>(android_event);
1051+ auto const cookie = kev->getCookieAsBlob();
1052 return mev::make_event(MirInputDeviceId(android_event->getDeviceId()),
1053 kev->getEventTime(),
1054- kev->getMac(),
1055+ {std::begin(cookie), std::end(cookie)},
1056 mia::mir_keyboard_action_from_android(kev->getAction(), kev->getRepeatCount()),
1057 kev->getKeyCode(),
1058 kev->getScanCode(),
1059@@ -51,9 +53,10 @@
1060 if (mia::android_source_id_is_pointer_device(android_event->getSource()))
1061 {
1062 auto mev = static_cast<const droidinput::MotionEvent*>(android_event);
1063+ auto const cookie = mev->getCookieAsBlob();
1064 return mev::make_event(MirInputDeviceId(android_event->getDeviceId()),
1065 mev->getEventTime(),
1066- mev->getMac(),
1067+ {std::begin(cookie), std::end(cookie)},
1068 mia::mir_modifiers_from_android(mev->getMetaState()),
1069 mia::mir_pointer_action_from_masked_android(mev->getAction() & AMOTION_EVENT_ACTION_MASK),
1070 mia::mir_pointer_buttons_from_android(mev->getButtonState()),
1071@@ -66,9 +69,10 @@
1072 else
1073 {
1074 auto mev = static_cast<const droidinput::MotionEvent*>(android_event);
1075+ auto const cookie = mev->getCookieAsBlob();
1076 auto ev = mev::make_event(MirInputDeviceId(android_event->getDeviceId()),
1077 mev->getEventTime(),
1078- mev->getMac(),
1079+ {std::begin(cookie), std::end(cookie)},
1080 mia::mir_modifiers_from_android(mev->getMetaState()));
1081 auto action = mev->getAction();
1082 size_t index_with_action = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
1083
1084=== modified file 'src/client/input/input_event.cpp'
1085--- src/client/input/input_event.cpp 2016-01-20 23:59:18 +0000
1086+++ src/client/input/input_event.cpp 2016-01-25 13:42:04 +0000
1087@@ -1,5 +1,5 @@
1088 /*
1089- * Copyright © 2014 Canonical Ltd.
1090+ * Copyright © 2014-2016 Canonical Ltd.
1091 *
1092 * This program is free software: you can redistribute it and/or modify it
1093 * under the terms of the GNU Lesser General Public License version 3,
1094@@ -18,9 +18,16 @@
1095
1096 #define MIR_LOG_COMPONENT "input-event-access"
1097
1098+#include "mir/cookie/cookie.h"
1099 #include "mir/event_type_to_string.h"
1100 #include "mir/events/event_private.h"
1101 #include "mir/log.h"
1102+#include "mir/require.h"
1103+#include "mir_toolkit/mir_cookie.h"
1104+
1105+#include "../mir_cookie.h"
1106+
1107+#include <string.h>
1108
1109 namespace ml = mir::logging;
1110
1111@@ -395,3 +402,92 @@
1112 abort();
1113 }
1114 }
1115+
1116+bool mir_input_event_has_cookie(MirInputEvent const* ev)
1117+{
1118+ switch (mir_input_event_get_type(ev))
1119+ {
1120+ case mir_input_event_type_key:
1121+ return true;
1122+ case mir_input_event_type_pointer:
1123+ {
1124+ auto const pev = mir_input_event_get_pointer_event(ev);
1125+ auto const pev_action = mir_pointer_event_action(pev);
1126+ return (pev_action == mir_pointer_action_button_up ||
1127+ pev_action == mir_pointer_action_button_down);
1128+ }
1129+ case mir_input_event_type_touch:
1130+ {
1131+ auto const tev = mir_input_event_get_touch_event(ev);
1132+ auto const point_count = mir_touch_event_point_count(tev);
1133+ for (size_t i = 0; i < point_count; i++)
1134+ {
1135+ auto const tev_action = mir_touch_event_action(tev, i);
1136+ if (tev_action == mir_touch_action_up ||
1137+ tev_action == mir_touch_action_down)
1138+ {
1139+ return true;
1140+ }
1141+ }
1142+ break;
1143+ }
1144+ }
1145+
1146+ return false;
1147+}
1148+
1149+size_t mir_cookie_buffer_size(MirCookie const* cookie) try
1150+{
1151+ return cookie->size();
1152+} catch (...)
1153+{
1154+ abort();
1155+}
1156+
1157+MirCookie const* mir_input_event_get_cookie(MirInputEvent const* iev) try
1158+{
1159+ auto const ev = old_ev_from_new(iev);
1160+
1161+ switch (ev->type)
1162+ {
1163+ case mir_event_type_motion:
1164+ return new MirCookie(ev->motion.cookie);
1165+ case mir_event_type_key:
1166+ return new MirCookie(ev->key.cookie);
1167+ default:
1168+ {
1169+ mir::log_critical("expected a key or motion events, type was: " + mir::event_type_to_string(ev->type));
1170+ abort();
1171+ }
1172+ }
1173+} catch (...)
1174+{
1175+ abort();
1176+}
1177+
1178+void mir_cookie_to_buffer(MirCookie const* cookie, void* buffer, size_t size) try
1179+{
1180+ return cookie->copy_to(buffer, size);
1181+} catch (...)
1182+{
1183+ abort();
1184+}
1185+
1186+MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size) try
1187+{
1188+ if (size != mir::cookie::default_blob_size)
1189+ return NULL;
1190+
1191+ return new MirCookie(buffer, size);
1192+} catch (...)
1193+{
1194+ abort();
1195+}
1196+
1197+void mir_cookie_release(MirCookie const* cookie) try
1198+{
1199+ delete cookie;
1200+} catch (...)
1201+{
1202+ abort();
1203+}
1204
1205=== added file 'src/client/mir_cookie.cpp'
1206--- src/client/mir_cookie.cpp 1970-01-01 00:00:00 +0000
1207+++ src/client/mir_cookie.cpp 2016-01-25 13:42:04 +0000
1208@@ -0,0 +1,49 @@
1209+/*
1210+ * Copyright © 2016 Canonical Ltd.
1211+ *
1212+ * This program is free software: you can redistribute it and/or modify it
1213+ * under the terms of the GNU Lesser General Public License version 3,
1214+ * as published by the Free Software Foundation.
1215+ *
1216+ * This program is distributed in the hope that it will be useful,
1217+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1218+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1219+ * GNU Lesser General Public License for more details.
1220+ *
1221+ * You should have received a copy of the GNU Lesser General Public License
1222+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1223+ *
1224+ * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
1225+ */
1226+
1227+#include "mir_cookie.h"
1228+
1229+#include "mir/require.h"
1230+
1231+#include <string.h>
1232+
1233+MirCookie::MirCookie(void const* buffer, size_t size)
1234+{
1235+ memcpy(blob_.data(), buffer, size);
1236+}
1237+
1238+MirCookie::MirCookie(mir::cookie::Blob const& blob) :
1239+ blob_(blob)
1240+{
1241+}
1242+
1243+void MirCookie::copy_to(void* buffer, size_t size) const
1244+{
1245+ mir::require(size == blob_.size());
1246+ memcpy(buffer, blob_.data(), size);
1247+}
1248+
1249+size_t MirCookie::size() const
1250+{
1251+ return blob_.size();
1252+}
1253+
1254+mir::cookie::Blob MirCookie::blob() const
1255+{
1256+ return blob_;
1257+}
1258
1259=== added file 'src/client/mir_cookie.h'
1260--- src/client/mir_cookie.h 1970-01-01 00:00:00 +0000
1261+++ src/client/mir_cookie.h 2016-01-25 13:42:04 +0000
1262@@ -0,0 +1,40 @@
1263+/*
1264+ * Copyright © 2016 Canonical Ltd.
1265+ *
1266+ * This program is free software: you can redistribute it and/or modify it
1267+ * under the terms of the GNU Lesser General Public License version 3,
1268+ * as published by the Free Software Foundation.
1269+ *
1270+ * This program is distributed in the hope that it will be useful,
1271+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1272+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1273+ * GNU Lesser General Public License for more details.
1274+ *
1275+ * You should have received a copy of the GNU Lesser General Public License
1276+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1277+ *
1278+ * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
1279+ */
1280+
1281+
1282+#ifndef MIR_CLIENT_MIR_COOKIE_H_
1283+#define MIR_CLIENT_MIR_COOKIE_H_
1284+
1285+#include "mir/cookie/blob.h"
1286+
1287+class MirCookie
1288+{
1289+public:
1290+ explicit MirCookie(void const* buffer, size_t size);
1291+ explicit MirCookie(mir::cookie::Blob const& blob);
1292+
1293+ void copy_to(void* buffer, size_t size) const;
1294+ size_t size() const;
1295+
1296+ mir::cookie::Blob blob() const;
1297+
1298+private:
1299+ mir::cookie::Blob blob_;
1300+};
1301+
1302+#endif // MIR_CLIENT_MIR_COOKIE_H_
1303
1304=== modified file 'src/client/mir_surface.cpp'
1305--- src/client/mir_surface.cpp 2016-01-23 03:16:06 +0000
1306+++ src/client/mir_surface.cpp 2016-01-25 13:42:04 +0000
1307@@ -29,7 +29,8 @@
1308 #include "mir/dispatch/threaded_dispatcher.h"
1309 #include "mir/input/input_platform.h"
1310 #include "mir/input/xkb_mapper.h"
1311-#include "mir_toolkit/cookie.h"
1312+#include "mir/cookie/cookie.h"
1313+#include "mir_cookie.h"
1314
1315 #include <cassert>
1316 #include <unistd.h>
1317@@ -485,7 +486,7 @@
1318 return configure(mir_surface_attrib_preferred_orientation, mode);
1319 }
1320
1321-void MirSurface::raise_surface_with_cookie(MirCookie const& cookie)
1322+void MirSurface::raise_surface(MirCookie const* cookie)
1323 {
1324 mp::RaiseRequest raise_request;
1325
1326@@ -494,10 +495,9 @@
1327
1328 auto const event_cookie = raise_request.mutable_cookie();
1329
1330- event_cookie->set_timestamp(cookie.timestamp);
1331- event_cookie->set_mac(cookie.mac);
1332+ event_cookie->set_cookie(cookie->blob().data(), cookie->size());
1333
1334- server->raise_surface_with_cookie(
1335+ server->raise_surface(
1336 &raise_request,
1337 void_response.get(),
1338 google::protobuf::NewCallback(google::protobuf::DoNothing));
1339
1340=== modified file 'src/client/mir_surface.h'
1341--- src/client/mir_surface.h 2016-01-20 23:59:18 +0000
1342+++ src/client/mir_surface.h 2016-01-25 13:42:04 +0000
1343@@ -31,7 +31,6 @@
1344 #include "mir_toolkit/common.h"
1345 #include "mir_toolkit/mir_client_library.h"
1346 #include "mir/graphics/native_buffer.h"
1347-#include "mir/cookie_factory.h"
1348
1349 #include <memory>
1350 #include <functional>
1351@@ -175,7 +174,7 @@
1352 MirOrientation get_orientation() const;
1353 MirWaitHandle* set_preferred_orientation(MirOrientationMode mode);
1354
1355- void raise_surface_with_cookie(MirCookie const& cookie);
1356+ void raise_surface(MirCookie const* cookie);
1357
1358 MirWaitHandle* configure_cursor(MirCursorConfiguration const* cursor);
1359
1360
1361=== modified file 'src/client/mir_surface_api.cpp'
1362--- src/client/mir_surface_api.cpp 2016-01-20 23:59:18 +0000
1363+++ src/client/mir_surface_api.cpp 2016-01-25 13:42:04 +0000
1364@@ -20,7 +20,6 @@
1365
1366 #include "mir_toolkit/mir_surface.h"
1367 #include "mir_toolkit/mir_wait.h"
1368-#include "mir_toolkit/cookie.h"
1369 #include "mir/require.h"
1370
1371 #include "mir_connection.h"
1372@@ -486,13 +485,13 @@
1373 return result;
1374 }
1375
1376-void mir_surface_raise_with_cookie(MirSurface* surf, MirCookie const cookie)
1377+void mir_surface_raise(MirSurface* surf, MirCookie const* cookie)
1378 {
1379 mir::require(mir_surface_is_valid(surf));
1380
1381 try
1382 {
1383- surf->raise_surface_with_cookie(cookie);
1384+ surf->raise_surface(cookie);
1385 }
1386 catch (std::exception const& ex)
1387 {
1388
1389=== modified file 'src/client/rpc/mir_display_server.cpp'
1390--- src/client/rpc/mir_display_server.cpp 2016-01-20 23:59:18 +0000
1391+++ src/client/rpc/mir_display_server.cpp 2016-01-25 13:42:04 +0000
1392@@ -210,7 +210,7 @@
1393 {
1394 channel->call_method(std::string(__func__), request, response, done);
1395 }
1396-void mclr::DisplayServer::raise_surface_with_cookie(
1397+void mclr::DisplayServer::raise_surface(
1398 mir::protobuf::RaiseRequest const* request,
1399 mir::protobuf::Void* response,
1400 google::protobuf::Closure* done)
1401
1402=== modified file 'src/client/rpc/mir_display_server.h'
1403--- src/client/rpc/mir_display_server.h 2016-01-20 23:59:18 +0000
1404+++ src/client/rpc/mir_display_server.h 2016-01-25 13:42:04 +0000
1405@@ -139,7 +139,7 @@
1406 mir::protobuf::StreamConfiguration const* request,
1407 mir::protobuf::Void* response,
1408 google::protobuf::Closure* done) override;
1409- void raise_surface_with_cookie(
1410+ void raise_surface(
1411 mir::protobuf::RaiseRequest const* request,
1412 mir::protobuf::Void* response,
1413 google::protobuf::Closure* done) override;
1414
1415=== modified file 'src/client/symbols.map'
1416--- src/client/symbols.map 2016-01-23 03:16:06 +0000
1417+++ src/client/symbols.map 2016-01-25 13:42:04 +0000
1418@@ -210,6 +210,13 @@
1419 MIR_CLIENT_unreleased {
1420 global:
1421 mir_connection_get_graphics_module;
1422+ mir_surface_raise;
1423+ mir_input_event_has_cookie;
1424+ mir_cookie_buffer_size;
1425+ mir_input_event_get_cookie;
1426+ mir_cookie_to_buffer;
1427+ mir_cookie_from_buffer;
1428+ mir_cookie_release;
1429 mir_keymap_event_get_keymap_buffer;
1430 mir_keymap_event_get_device_id;
1431 local:
1432
1433=== modified file 'src/cookie/CMakeLists.txt'
1434--- src/cookie/CMakeLists.txt 2016-01-22 03:09:31 +0000
1435+++ src/cookie/CMakeLists.txt 2016-01-25 13:42:04 +0000
1436@@ -12,17 +12,19 @@
1437 )
1438
1439 include_directories(
1440+ ${PROJECT_SOURCE_DIR}/src/include/cookie
1441 ${PROJECT_SOURCE_DIR}/include/cookie
1442 ${NETTLE_INCLUDE_DIRS}
1443 )
1444
1445-set(MIRCOOKIE_ABI 1)
1446+set(MIRCOOKIE_ABI 2)
1447 set(symbol_map ${CMAKE_SOURCE_DIR}/src/cookie/symbols.map)
1448
1449 mir_add_library_with_symbols(mircookie SHARED
1450
1451 ${symbol_map}
1452- cookie_factory.cpp
1453+ authority.cpp
1454+ hmac_cookie.cpp
1455 )
1456
1457 set_target_properties(mircookie
1458@@ -41,7 +43,7 @@
1459 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
1460
1461 install(
1462- DIRECTORY ${CMAKE_SOURCE_DIR}/include/cookie/mir ${CMAKE_SOURCE_DIR}/include/cookie/mir_toolkit
1463+ DIRECTORY ${CMAKE_SOURCE_DIR}/include/cookie/mir
1464 DESTINATION "include/mircookie"
1465 )
1466
1467
1468=== renamed file 'src/cookie/cookie_factory.cpp' => 'src/cookie/authority.cpp'
1469--- src/cookie/cookie_factory.cpp 2016-01-20 23:59:18 +0000
1470+++ src/cookie/authority.cpp 2016-01-25 13:42:04 +0000
1471@@ -1,5 +1,5 @@
1472 /*
1473- * Copyright © 2015 Canonical Ltd.
1474+ * Copyright © 2015-2016 Canonical Ltd.
1475 *
1476 * This program is free software: you can redistribute it and/or modify
1477 * it under the terms of the GNU General Public License version 3 as
1478@@ -14,9 +14,13 @@
1479 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1480 *
1481 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
1482+ * Brandon Schaefer <brandon.schaefer@canonical.com>
1483 */
1484
1485-#include "mir/cookie_factory.h"
1486+#include "mir/cookie/authority.h"
1487+#include "mir/cookie/blob.h"
1488+#include "hmac_cookie.h"
1489+#include "format.h"
1490
1491 #include <algorithm>
1492 #include <random>
1493@@ -29,6 +33,7 @@
1494 #include <sys/stat.h>
1495 #include <fcntl.h>
1496 #include <sys/select.h>
1497+#include <string.h>
1498
1499 #include <boost/throw_exception.hpp>
1500
1501@@ -37,6 +42,19 @@
1502 std::string const random_device_path{"/dev/random"};
1503 std::string const urandom_device_path{"/dev/urandom"};
1504 int const wait_seconds{30};
1505+
1506+size_t cookie_size_from_format(mir::cookie::Format const& format)
1507+{
1508+ switch (format)
1509+ {
1510+ case mir::cookie::Format::hmac_sha_1_8:
1511+ return mir::cookie::default_blob_size;
1512+ default:
1513+ break;
1514+ }
1515+
1516+ return 0;
1517+}
1518 }
1519
1520 static mir::cookie::Secret get_random_data(unsigned size)
1521@@ -94,10 +112,15 @@
1522 return buffer;
1523 }
1524
1525-class CookieFactoryNettle : public mir::cookie::CookieFactory
1526+mir::cookie::SecurityCheckError::SecurityCheckError() :
1527+ runtime_error("Invalid Cookie")
1528+{
1529+}
1530+
1531+class AuthorityNettle : public mir::cookie::Authority
1532 {
1533 public:
1534- CookieFactoryNettle(mir::cookie::Secret const& secret)
1535+ AuthorityNettle(mir::cookie::Secret const& secret)
1536 {
1537 if (secret.size() < minimum_secret_size)
1538 BOOST_THROW_EXCEPTION(std::logic_error("Secret size " + std::to_string(secret.size()) + " is to small, require " +
1539@@ -106,41 +129,83 @@
1540 hmac_sha1_set_key(&ctx, secret.size(), secret.data());
1541 }
1542
1543- virtual ~CookieFactoryNettle() noexcept = default;
1544-
1545- MirCookie timestamp_to_cookie(uint64_t const& timestamp) override
1546- {
1547- MirCookie cookie { timestamp, 0 };
1548- calculate_mac(cookie);
1549+ virtual ~AuthorityNettle() noexcept = default;
1550+
1551+
1552+ std::unique_ptr<mir::cookie::Cookie> make_cookie(uint64_t const& timestamp) override
1553+ {
1554+ return std::make_unique<mir::cookie::HMACCookie>(timestamp, calculate_cookie(timestamp), mir::cookie::Format::hmac_sha_1_8);
1555+ }
1556+
1557+ std::unique_ptr<mir::cookie::Cookie> make_cookie(std::vector<uint8_t> const& raw_cookie) override
1558+ {
1559+ /*
1560+ SHA_1 Format:
1561+ 1 byte = FORMAT
1562+ 8 btyes = TIMESTAMP
1563+ 8 BYTES = MAC
1564+ */
1565+
1566+ if (raw_cookie.size() != cookie_size_from_format(mir::cookie::Format::hmac_sha_1_8))
1567+ {
1568+ BOOST_THROW_EXCEPTION(mir::cookie::SecurityCheckError());
1569+ }
1570+
1571+ mir::cookie::Format format = static_cast<mir::cookie::Format>(raw_cookie[0]);
1572+ if (format != mir::cookie::Format::hmac_sha_1_8)
1573+ {
1574+ BOOST_THROW_EXCEPTION(mir::cookie::SecurityCheckError());
1575+ }
1576+
1577+ uint64_t timestamp = 0;
1578+
1579+ auto ptr = raw_cookie.data();
1580+ ptr++;
1581+
1582+ memcpy(&timestamp, ptr, 8);
1583+ ptr += sizeof(timestamp);
1584+
1585+ // FIXME Soon to be 20 bytes
1586+ std::vector<uint8_t> mac(8);
1587+ memcpy(mac.data(), ptr, mac.size());
1588+
1589+ std::unique_ptr<mir::cookie::Cookie> cookie =
1590+ std::make_unique<mir::cookie::HMACCookie>(timestamp, mac, mir::cookie::Format::hmac_sha_1_8);
1591+
1592+ if (!verify_cookie(timestamp, cookie))
1593+ {
1594+ BOOST_THROW_EXCEPTION(mir::cookie::SecurityCheckError());
1595+ }
1596+
1597 return cookie;
1598 }
1599
1600- bool attest_timestamp(MirCookie const& cookie) override
1601- {
1602- return verify_mac(cookie);
1603- }
1604-
1605 private:
1606- void calculate_mac(MirCookie& cookie)
1607+ std::vector<uint8_t> calculate_cookie(uint64_t const& timestamp)
1608 {
1609- hmac_sha1_update(&ctx, sizeof(cookie.timestamp), reinterpret_cast<uint8_t*>(&cookie.timestamp));
1610- hmac_sha1_digest(&ctx, sizeof(cookie.mac), reinterpret_cast<uint8_t*>(&cookie.mac));
1611+ // FIXME Soon to change to 160bits, for now uint64_t
1612+ std::vector<uint8_t> mac(sizeof(uint64_t));
1613+ hmac_sha1_update(&ctx, sizeof(timestamp), reinterpret_cast<uint8_t const*>(&timestamp));
1614+ hmac_sha1_digest(&ctx, sizeof(uint64_t), reinterpret_cast<uint8_t*>(mac.data()));
1615+
1616+ return mac;
1617 }
1618
1619- bool verify_mac(MirCookie const& cookie)
1620+ bool verify_cookie(uint64_t const& timestamp, std::unique_ptr<mir::cookie::Cookie> const& cookie)
1621 {
1622- decltype(cookie.mac) calculated_mac;
1623- uint8_t* message = reinterpret_cast<uint8_t*>(const_cast<decltype(cookie.timestamp)*>(&cookie.timestamp));
1624- hmac_sha1_update(&ctx, sizeof(cookie.timestamp), message);
1625- hmac_sha1_digest(&ctx, sizeof(calculated_mac), reinterpret_cast<uint8_t*>(&calculated_mac));
1626-
1627- return calculated_mac == cookie.mac;
1628+ auto const calculated_cookie = make_cookie(timestamp);
1629+
1630+ auto const this_stream = cookie->serialize();
1631+ auto const other_stream = calculated_cookie->serialize();
1632+
1633+ // FIXME Need to do a constant memcmp here!
1634+ return std::equal(std::begin(this_stream), std::end(this_stream), std::begin(other_stream));
1635 }
1636
1637 struct hmac_sha1_ctx ctx;
1638 };
1639
1640-size_t mir::cookie::CookieFactory::optimal_secret_size()
1641+size_t mir::cookie::Authority::optimal_secret_size()
1642 {
1643 // Secret keys smaller than this are internally zero-extended to this size.
1644 // Secret keys larger than this are internally hashed to this size.
1645@@ -148,19 +213,19 @@
1646 return hmac_sha1_block_size;
1647 }
1648
1649-std::unique_ptr<mir::cookie::CookieFactory> mir::cookie::CookieFactory::create_from_secret(mir::cookie::Secret const& secret)
1650+std::unique_ptr<mir::cookie::Authority> mir::cookie::Authority::create_from(mir::cookie::Secret const& secret)
1651 {
1652- return std::make_unique<CookieFactoryNettle>(secret);
1653+ return std::make_unique<AuthorityNettle>(secret);
1654 }
1655
1656-std::unique_ptr<mir::cookie::CookieFactory> mir::cookie::CookieFactory::create_saving_secret(mir::cookie::Secret& save_secret)
1657+std::unique_ptr<mir::cookie::Authority> mir::cookie::Authority::create_saving(mir::cookie::Secret& save_secret)
1658 {
1659 save_secret = get_random_data(optimal_secret_size());
1660- return std::make_unique<CookieFactoryNettle>(save_secret);
1661+ return std::make_unique<AuthorityNettle>(save_secret);
1662 }
1663
1664-std::unique_ptr<mir::cookie::CookieFactory> mir::cookie::CookieFactory::create_keeping_secret()
1665+std::unique_ptr<mir::cookie::Authority> mir::cookie::Authority::create()
1666 {
1667 auto secret = get_random_data(optimal_secret_size());
1668- return std::make_unique<CookieFactoryNettle>(secret);
1669+ return std::make_unique<AuthorityNettle>(secret);
1670 }
1671
1672=== added file 'src/cookie/format.h'
1673--- src/cookie/format.h 1970-01-01 00:00:00 +0000
1674+++ src/cookie/format.h 2016-01-25 13:42:04 +0000
1675@@ -0,0 +1,35 @@
1676+/*
1677+ * Copyright © 2016 Canonical Ltd.
1678+ *
1679+ * This program is free software: you can redistribute it and/or modify
1680+ * it under the terms of the GNU General Public License version 3 as
1681+ * published by the Free Software Foundation.
1682+ *
1683+ * This program is distributed in the hope that it will be useful,
1684+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1685+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1686+ * GNU General Public License for more details.
1687+ *
1688+ * You should have received a copy of the GNU General Public License
1689+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1690+ *
1691+ * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
1692+ */
1693+
1694+#ifndef MIR_COOKIE_COOKIE_FORMAT_H_
1695+#define MIR_COOKIE_COOKIE_FORMAT_H_
1696+
1697+#include <stdint.h>
1698+
1699+namespace mir
1700+{
1701+namespace cookie
1702+{
1703+enum class Format : uint8_t
1704+{
1705+ hmac_sha_1_8,
1706+};
1707+}
1708+}
1709+
1710+#endif // MIR_COOKIE_COOKIE_FORMAT_H_
1711
1712=== added file 'src/cookie/hmac_cookie.cpp'
1713--- src/cookie/hmac_cookie.cpp 1970-01-01 00:00:00 +0000
1714+++ src/cookie/hmac_cookie.cpp 2016-01-25 13:42:04 +0000
1715@@ -0,0 +1,53 @@
1716+/*
1717+ * Copyright © 2016 Canonical Ltd.
1718+ *
1719+ * This program is free software: you can redistribute it and/or modify
1720+ * it under the terms of the GNU General Public License version 3 as
1721+ * published by the Free Software Foundation.
1722+ *
1723+ * This program is distributed in the hope that it will be useful,
1724+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1725+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1726+ * GNU General Public License for more details.
1727+ *
1728+ * You should have received a copy of the GNU General Public License
1729+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1730+ *
1731+ * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
1732+ */
1733+
1734+#include "hmac_cookie.h"
1735+
1736+#include <string.h>
1737+
1738+mir::cookie::HMACCookie::HMACCookie(uint64_t const& timestamp,
1739+ std::vector<uint8_t> const& mac,
1740+ mir::cookie::Format const& format) :
1741+ timestamp_(timestamp),
1742+ mac_(mac),
1743+ format_(format)
1744+{
1745+}
1746+
1747+uint64_t mir::cookie::HMACCookie::timestamp() const
1748+{
1749+ return timestamp_;
1750+}
1751+
1752+std::vector<uint8_t> mir::cookie::HMACCookie::serialize() const
1753+{
1754+ std::vector<uint8_t> serialized_cookie(sizeof(format_) + sizeof(timestamp_) + mac_.size());
1755+
1756+ auto cookie_ptr = serialized_cookie.data();
1757+
1758+ cookie_ptr[0] = static_cast<uint8_t>(format_);
1759+ cookie_ptr += sizeof(format_);
1760+
1761+ auto timestamp_ptr = reinterpret_cast<uint8_t const*>(&timestamp_);
1762+ memcpy(cookie_ptr, timestamp_ptr, sizeof(timestamp_));
1763+ cookie_ptr += sizeof(timestamp_);
1764+
1765+ memcpy(cookie_ptr, mac_.data(), mac_.size());
1766+
1767+ return serialized_cookie;
1768+}
1769
1770=== added file 'src/cookie/hmac_cookie.h'
1771--- src/cookie/hmac_cookie.h 1970-01-01 00:00:00 +0000
1772+++ src/cookie/hmac_cookie.h 2016-01-25 13:42:04 +0000
1773@@ -0,0 +1,51 @@
1774+/*
1775+ * Copyright © 2016 Canonical Ltd.
1776+ *
1777+ * This program is free software: you can redistribute it and/or modify
1778+ * it under the terms of the GNU General Public License version 3 as
1779+ * published by the Free Software Foundation.
1780+ *
1781+ * This program is distributed in the hope that it will be useful,
1782+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1783+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1784+ * GNU General Public License for more details.
1785+ *
1786+ * You should have received a copy of the GNU General Public License
1787+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1788+ *
1789+ * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
1790+ */
1791+
1792+#ifndef MIR_COOKIE_HMAC_COOKIE_H_
1793+#define MIR_COOKIE_HMAC_COOKIE_H_
1794+
1795+#include "mir/cookie/cookie.h"
1796+#include "format.h"
1797+
1798+namespace mir
1799+{
1800+namespace cookie
1801+{
1802+
1803+class HMACCookie : public mir::cookie::Cookie
1804+{
1805+public:
1806+ HMACCookie() = delete;
1807+
1808+ explicit HMACCookie(uint64_t const& timestamp,
1809+ std::vector<uint8_t> const& mac,
1810+ mir::cookie::Format const& format);
1811+
1812+ uint64_t timestamp() const override;
1813+ std::vector<uint8_t> serialize() const override;
1814+
1815+private:
1816+ uint64_t timestamp_;
1817+ std::vector<uint8_t> mac_;
1818+ mir::cookie::Format format_;
1819+};
1820+
1821+}
1822+}
1823+
1824+#endif // MIR_COOKIE_HMAC_COOKIE_H_
1825
1826=== modified file 'src/cookie/symbols.map'
1827--- src/cookie/symbols.map 2016-01-20 23:59:18 +0000
1828+++ src/cookie/symbols.map 2016-01-25 13:42:04 +0000
1829@@ -1,10 +1,10 @@
1830-MIR_COOKIE_1 {
1831+MIR_COOKIE_2 {
1832 global:
1833 extern "C++" {
1834- mir::cookie::CookieFactory::optimal_secret_size*;
1835- mir::cookie::CookieFactory::create_from_secret*;
1836- mir::cookie::CookieFactory::create_saving_secret*;
1837- mir::cookie::CookieFactory::create_keeping_secret*;
1838+ mir::cookie::Authority::optimal_secret_size*;
1839+ mir::cookie::Authority::create_from*;
1840+ mir::cookie::Authority::create_saving*;
1841+ mir::cookie::Authority::create*;
1842 };
1843 local: *;
1844 };
1845
1846=== modified file 'src/include/common/mir/events/event_private.h'
1847--- src/include/common/mir/events/event_private.h 2016-01-23 03:16:06 +0000
1848+++ src/include/common/mir/events/event_private.h 2016-01-25 13:42:04 +0000
1849@@ -29,10 +29,10 @@
1850 #include <stdint.h>
1851 #include "mir_toolkit/event.h"
1852 #include "mir_toolkit/common.h"
1853+#include "mir/cookie/blob.h"
1854
1855 #include <xkbcommon/xkbcommon.h>
1856-#include <chrono>
1857-
1858+#include <array>
1859 #include <chrono>
1860
1861 #ifdef __cplusplus
1862@@ -61,7 +61,7 @@
1863 int32_t scan_code;
1864
1865 std::chrono::nanoseconds event_time;
1866- uint64_t mac;
1867+ mir::cookie::Blob cookie;
1868 };
1869
1870 typedef struct
1871@@ -99,7 +99,7 @@
1872
1873 MirPointerButtons buttons;
1874 std::chrono::nanoseconds event_time;
1875- uint64_t mac;
1876+ mir::cookie::Blob cookie;
1877
1878 size_t pointer_count;
1879 MirMotionPointer pointer_coordinates[MIR_INPUT_EVENT_MAX_POINTER_COUNT];
1880
1881=== modified file 'src/include/common/mir/protobuf/display_server.h'
1882--- src/include/common/mir/protobuf/display_server.h 2016-01-20 23:59:18 +0000
1883+++ src/include/common/mir/protobuf/display_server.h 2016-01-25 13:42:04 +0000
1884@@ -135,7 +135,7 @@
1885 mir::protobuf::StreamConfiguration const* request,
1886 mir::protobuf::Void* response,
1887 google::protobuf::Closure* done) = 0;
1888- virtual void raise_surface_with_cookie(
1889+ virtual void raise_surface(
1890 mir::protobuf::RaiseRequest const* request,
1891 mir::protobuf::Void* response,
1892 google::protobuf::Closure* done) = 0;
1893
1894=== added directory 'src/include/cookie'
1895=== added directory 'src/include/cookie/mir'
1896=== added directory 'src/include/cookie/mir/cookie'
1897=== renamed file 'include/cookie/mir_toolkit/cookie.h' => 'src/include/cookie/mir/cookie/blob.h'
1898--- include/cookie/mir_toolkit/cookie.h 2015-09-17 08:57:46 +0000
1899+++ src/include/cookie/mir/cookie/blob.h 2016-01-25 13:42:04 +0000
1900@@ -1,5 +1,5 @@
1901 /*
1902- * Copyright © 2015 Canonical Ltd.
1903+ * Copyright © 2015-2016 Canonical Ltd.
1904 *
1905 * This program is free software: you can redistribute it and/or modify
1906 * it under the terms of the GNU General Public License version 3 as
1907@@ -13,32 +13,21 @@
1908 * You should have received a copy of the GNU General Public License
1909 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1910 *
1911- * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
1912- */
1913-
1914-#ifndef MIR_TOOLKIT_COOKIE_FACTORY_H_
1915-#define MIR_TOOLKIT_COOKIE_FACTORY_H_
1916-
1917-#include <stdint.h>
1918-
1919-/**
1920- * \addtogroup mir_toolkit
1921- * @{
1922- */
1923-/* This is C code. Not C++. */
1924-#ifdef __cplusplus
1925-extern "C" {
1926-#endif
1927-
1928-typedef struct MirCookie
1929-{
1930- uint64_t timestamp;
1931- uint64_t mac;
1932-} MirCookie;
1933-
1934-#ifdef __cplusplus
1935-}
1936-#endif
1937-/**@}*/
1938-
1939-#endif // MIR_TOOLKIT_COOKIE_FACTORY_H_
1940+ * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
1941+ */
1942+
1943+#ifndef MIR_COOKIE_BLOB_H_
1944+#define MIR_COOKIE_BLOB_H_
1945+
1946+#include <array>
1947+
1948+namespace mir
1949+{
1950+namespace cookie
1951+{
1952+size_t const default_blob_size = 17;
1953+using Blob = std::array<uint8_t, default_blob_size>;
1954+}
1955+}
1956+
1957+#endif // MIR_COOKIE_BLOB_H_
1958
1959=== modified file 'src/include/server/mir/default_server_configuration.h'
1960--- src/include/server/mir/default_server_configuration.h 2016-01-20 23:59:18 +0000
1961+++ src/include/server/mir/default_server_configuration.h 2016-01-25 13:42:04 +0000
1962@@ -33,7 +33,7 @@
1963
1964 namespace cookie
1965 {
1966-class CookieFactory;
1967+class Authority;
1968 }
1969 namespace dispatch
1970 {
1971@@ -170,7 +170,7 @@
1972 std::shared_ptr<graphics::Platform> the_graphics_platform() override;
1973 std::shared_ptr<input::InputDispatcher> the_input_dispatcher() override;
1974 std::shared_ptr<EmergencyCleanup> the_emergency_cleanup() override;
1975- std::shared_ptr<cookie::CookieFactory> the_cookie_factory() override;
1976+ std::shared_ptr<cookie::Authority> the_cookie_authority() override;
1977 /**
1978 * Function to call when a "fatal" error occurs. This implementation allows
1979 * the default strategy to be overridden by --on-fatal-error-abort to force a
1980@@ -416,7 +416,7 @@
1981 CachedPtr<shell::Shell> shell;
1982 CachedPtr<shell::ShellReport> shell_report;
1983 CachedPtr<scene::ApplicationNotRespondingDetector> application_not_responding_detector;
1984- CachedPtr<cookie::CookieFactory> cookie_factory;
1985+ CachedPtr<cookie::Authority> cookie_authority;
1986
1987 private:
1988 std::shared_ptr<options::Configuration> const configuration_options;
1989
1990=== removed file 'src/include/server/mir/frontend/security_check_failed.h'
1991--- src/include/server/mir/frontend/security_check_failed.h 2015-10-30 17:24:29 +0000
1992+++ src/include/server/mir/frontend/security_check_failed.h 1970-01-01 00:00:00 +0000
1993@@ -1,34 +0,0 @@
1994-/*
1995- * Copyright © 2015 Canonical Ltd.
1996- *
1997- * This program is free software: you can redistribute it and/or modify
1998- * it under the terms of the GNU General Public License version 3 as
1999- * published by the Free Software Foundation.
2000- *
2001- * This program is distributed in the hope that it will be useful,
2002- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2003- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2004- * GNU General Public License for more details.
2005- *
2006- * You should have received a copy of the GNU General Public License
2007- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2008- *
2009- * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
2010- */
2011-
2012-#ifndef MIR_SECURITY_CHECK_FAILED_H_
2013-#define MIR_SECURITY_CHECK_FAILED_H_
2014-
2015-#include <stdexcept>
2016-
2017-namespace mir
2018-{
2019-
2020-struct SecurityCheckFailed : std::runtime_error
2021-{
2022- SecurityCheckFailed();
2023-};
2024-
2025-}
2026-
2027-#endif /* MIR_SECURITY_CHECK_FAILED_H_ */
2028
2029=== modified file 'src/include/server/mir/frontend/shell.h'
2030--- src/include/server/mir/frontend/shell.h 2016-01-20 23:59:18 +0000
2031+++ src/include/server/mir/frontend/shell.h 2016-01-25 13:42:04 +0000
2032@@ -82,7 +82,7 @@
2033 SurfaceId surface_id,
2034 MirSurfaceAttrib attrib) = 0;
2035
2036- virtual void raise_surface_with_timestamp(
2037+ virtual void raise_surface(
2038 std::shared_ptr<Session> const& session,
2039 SurfaceId surface_id,
2040 uint64_t timestamp) = 0;
2041
2042=== modified file 'src/include/server/mir/frontend/template_protobuf_message_processor.h'
2043--- src/include/server/mir/frontend/template_protobuf_message_processor.h 2016-01-20 23:59:18 +0000
2044+++ src/include/server/mir/frontend/template_protobuf_message_processor.h 2016-01-25 13:42:04 +0000
2045@@ -21,7 +21,7 @@
2046 #define MIR_FRONTEND_TEMPLATE_PROTOBUF_MESSAGE_PROCESSOR_H_
2047
2048 #include "mir/frontend/message_processor.h"
2049-#include "mir/frontend/security_check_failed.h"
2050+#include "mir/cookie/authority.h"
2051
2052 #include <google/protobuf/stubs/common.h>
2053 #include <boost/exception/diagnostic_information.hpp>
2054@@ -76,7 +76,7 @@
2055 &result_message,
2056 callback.get());
2057 }
2058- catch (mir::SecurityCheckFailed const& /*err*/)
2059+ catch (mir::cookie::SecurityCheckError const& /*err*/)
2060 {
2061 throw;
2062 }
2063
2064=== modified file 'src/include/server/mir/server_configuration.h'
2065--- src/include/server/mir/server_configuration.h 2016-01-20 23:59:18 +0000
2066+++ src/include/server/mir/server_configuration.h 2016-01-25 13:42:04 +0000
2067@@ -24,7 +24,7 @@
2068 {
2069 namespace cookie
2070 {
2071-class CookieFactory;
2072+class Authority;
2073 }
2074 namespace compositor
2075 {
2076@@ -79,7 +79,7 @@
2077 virtual std::shared_ptr<DisplayChanger> the_display_changer() = 0;
2078 virtual std::shared_ptr<graphics::Platform> the_graphics_platform() = 0;
2079 virtual std::shared_ptr<EmergencyCleanup> the_emergency_cleanup() = 0;
2080- virtual std::shared_ptr<cookie::CookieFactory> the_cookie_factory() = 0;
2081+ virtual std::shared_ptr<cookie::Authority> the_cookie_authority() = 0;
2082 virtual auto the_fatal_error_strategy() -> void (*)(char const* reason, ...) = 0;
2083 virtual std::shared_ptr<scene::ApplicationNotRespondingDetector> the_application_not_responding_detector() = 0;
2084
2085
2086=== modified file 'src/protobuf/mir_protobuf.proto'
2087--- src/protobuf/mir_protobuf.proto 2016-01-20 23:59:18 +0000
2088+++ src/protobuf/mir_protobuf.proto 2016-01-25 13:42:04 +0000
2089@@ -343,8 +343,7 @@
2090 }
2091
2092 message Cookie {
2093- required uint64 timestamp = 1;
2094- required uint64 mac = 2;
2095+ required bytes cookie = 1;
2096 }
2097
2098 message RaiseRequest {
2099
2100=== modified file 'src/server/CMakeLists.txt'
2101--- src/server/CMakeLists.txt 2016-01-22 03:09:31 +0000
2102+++ src/server/CMakeLists.txt 2016-01-25 13:42:04 +0000
2103@@ -14,6 +14,7 @@
2104 ${PROJECT_SOURCE_DIR}/src/include/client
2105 ${PROJECT_SOURCE_DIR}/src/include/server
2106 ${PROJECT_SOURCE_DIR}/include/cookie
2107+ ${PROJECT_SOURCE_DIR}/src/include/cookie
2108 ${GLIB_INCLUDE_DIRS}
2109 )
2110 add_definitions(-DMIR_SERVER_INPUT_PLATFORM_VERSION="${MIR_SERVER_INPUT_PLATFORM_VERSION}")
2111
2112=== modified file 'src/server/default_server_configuration.cpp'
2113--- src/server/default_server_configuration.cpp 2016-01-20 23:59:18 +0000
2114+++ src/server/default_server_configuration.cpp 2016-01-25 13:42:04 +0000
2115@@ -24,7 +24,7 @@
2116 #include "mir/default_server_status_listener.h"
2117 #include "mir/emergency_cleanup.h"
2118 #include "mir/default_configuration.h"
2119-#include "mir/cookie_factory.h"
2120+#include "mir/cookie/authority.h"
2121
2122 #include "mir/logging/dumb_console_logger.h"
2123 #include "mir/options/program_option.h"
2124@@ -186,15 +186,15 @@
2125 });
2126 }
2127
2128-std::shared_ptr<mir::cookie::CookieFactory> mir::DefaultServerConfiguration::the_cookie_factory()
2129+std::shared_ptr<mir::cookie::Authority> mir::DefaultServerConfiguration::the_cookie_authority()
2130 {
2131- return cookie_factory(
2132+ return cookie_authority(
2133 []()
2134 {
2135- static_assert(secret_size >= mir::cookie::CookieFactory::minimum_secret_size,
2136+ static_assert(secret_size >= mir::cookie::Authority::minimum_secret_size,
2137 "Secret size is smaller then the minimum secret size");
2138
2139- return mir::cookie::CookieFactory::create_keeping_secret();
2140+ return mir::cookie::Authority::create();
2141 });
2142 }
2143
2144
2145=== modified file 'src/server/frontend/CMakeLists.txt'
2146--- src/server/frontend/CMakeLists.txt 2016-01-20 23:59:18 +0000
2147+++ src/server/frontend/CMakeLists.txt 2016-01-25 13:42:04 +0000
2148@@ -28,7 +28,6 @@
2149 reordering_message_sender.cpp
2150 reordering_message_sender.h
2151 event_sink_factory.h
2152- security_check_failed.cpp
2153 )
2154
2155 add_library(
2156
2157=== modified file 'src/server/frontend/default_configuration.cpp'
2158--- src/server/frontend/default_configuration.cpp 2016-01-20 23:59:18 +0000
2159+++ src/server/frontend/default_configuration.cpp 2016-01-25 13:42:04 +0000
2160@@ -163,5 +163,5 @@
2161 the_cursor_images(),
2162 the_coordinate_translator(),
2163 the_application_not_responding_detector(),
2164- the_cookie_factory());
2165+ the_cookie_authority());
2166 }
2167
2168=== modified file 'src/server/frontend/default_ipc_factory.cpp'
2169--- src/server/frontend/default_ipc_factory.cpp 2016-01-20 23:59:18 +0000
2170+++ src/server/frontend/default_ipc_factory.cpp 2016-01-25 13:42:04 +0000
2171@@ -26,7 +26,7 @@
2172 #include "mir/frontend/session_authorizer.h"
2173 #include "mir/frontend/event_sink.h"
2174 #include "mir/graphics/graphic_buffer_allocator.h"
2175-#include "mir/cookie_factory.h"
2176+#include "mir/cookie/authority.h"
2177
2178 namespace mf = mir::frontend;
2179 namespace mg = mir::graphics;
2180@@ -44,7 +44,7 @@
2181 std::shared_ptr<mi::CursorImages> const& cursor_images,
2182 std::shared_ptr<scene::CoordinateTranslator> const& translator,
2183 std::shared_ptr<scene::ApplicationNotRespondingDetector> const& anr_detector,
2184- std::shared_ptr<mir::cookie::CookieFactory> const& cookie_factory) :
2185+ std::shared_ptr<mir::cookie::Authority> const& cookie_authority) :
2186 shell(shell),
2187 no_prompt_shell(std::make_shared<NoPromptShell>(shell)),
2188 sm_report(sm_report),
2189@@ -57,7 +57,7 @@
2190 cursor_images(cursor_images),
2191 translator{translator},
2192 anr_detector{anr_detector},
2193- cookie_factory(cookie_factory)
2194+ cookie_authority(cookie_authority)
2195 {
2196 }
2197
2198@@ -132,5 +132,5 @@
2199 cursor_images,
2200 translator,
2201 anr_detector,
2202- cookie_factory);
2203+ cookie_authority);
2204 }
2205
2206=== modified file 'src/server/frontend/default_ipc_factory.h'
2207--- src/server/frontend/default_ipc_factory.h 2016-01-20 23:59:18 +0000
2208+++ src/server/frontend/default_ipc_factory.h 2016-01-25 13:42:04 +0000
2209@@ -25,7 +25,7 @@
2210 {
2211 namespace cookie
2212 {
2213-class CookieFactory;
2214+class Authority;
2215 }
2216 namespace graphics
2217 {
2218@@ -66,7 +66,7 @@
2219 std::shared_ptr<input::CursorImages> const& cursor_images,
2220 std::shared_ptr<scene::CoordinateTranslator> const& translator,
2221 std::shared_ptr<scene::ApplicationNotRespondingDetector> const& anr_detector,
2222- std::shared_ptr<cookie::CookieFactory> const& cookie_factory);
2223+ std::shared_ptr<cookie::Authority> const& cookie_authority);
2224
2225 std::shared_ptr<detail::DisplayServer> make_ipc_server(
2226 SessionCredentials const &creds,
2227@@ -101,7 +101,7 @@
2228 std::shared_ptr<input::CursorImages> const cursor_images;
2229 std::shared_ptr<scene::CoordinateTranslator> const translator;
2230 std::shared_ptr<scene::ApplicationNotRespondingDetector> const anr_detector;
2231- std::shared_ptr<cookie::CookieFactory> const cookie_factory;
2232+ std::shared_ptr<cookie::Authority> const cookie_authority;
2233 };
2234 }
2235 }
2236
2237=== modified file 'src/server/frontend/protobuf_message_processor.cpp'
2238--- src/server/frontend/protobuf_message_processor.cpp 2016-01-20 23:59:18 +0000
2239+++ src/server/frontend/protobuf_message_processor.cpp 2016-01-25 13:42:04 +0000
2240@@ -18,7 +18,7 @@
2241
2242 #include "display_server.h"
2243 #include "protobuf_message_processor.h"
2244-#include "mir/frontend/security_check_failed.h"
2245+#include "mir/cookie/authority.h"
2246 #include "mir/frontend/message_processor_report.h"
2247 #include "mir/frontend/protobuf_message_sender.h"
2248 #include "mir/frontend/template_protobuf_message_processor.h"
2249@@ -136,7 +136,7 @@
2250 result_message.get(),
2251 callback);
2252 }
2253- catch (mir::SecurityCheckFailed const& /*err*/)
2254+ catch (mir::cookie::SecurityCheckError const& /*err*/)
2255 {
2256 throw;
2257 }
2258@@ -315,9 +315,9 @@
2259 {
2260 invoke(this, display_server.get(), &DisplayServer::configure_buffer_stream, invocation);
2261 }
2262- else if ("raise_surface_with_cookie" == invocation.method_name())
2263+ else if ("raise_surface" == invocation.method_name())
2264 {
2265- invoke(this, display_server.get(), &DisplayServer::raise_surface_with_cookie, invocation);
2266+ invoke(this, display_server.get(), &DisplayServer::raise_surface, invocation);
2267 }
2268 else if ("translate_surface_to_screen" == invocation.method_name())
2269 {
2270
2271=== removed file 'src/server/frontend/security_check_failed.cpp'
2272--- src/server/frontend/security_check_failed.cpp 2015-10-30 17:24:29 +0000
2273+++ src/server/frontend/security_check_failed.cpp 1970-01-01 00:00:00 +0000
2274@@ -1,24 +0,0 @@
2275-/*
2276- * Copyright © 2015 Canonical Ltd.
2277- *
2278- * This program is free software: you can redistribute it and/or modify it
2279- * under the terms of the GNU General Public License version 3,
2280- * as published by the Free Software Foundation.
2281- *
2282- * This program is distributed in the hope that it will be useful,
2283- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2284- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2285- * GNU General Public License for more details.
2286- *
2287- * You should have received a copy of the GNU General Public License
2288- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2289- *
2290- * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
2291- */
2292-
2293-#include "mir/frontend/security_check_failed.h"
2294-
2295-mir::SecurityCheckFailed::SecurityCheckFailed() :
2296- runtime_error("Invalid MirCookie")
2297-{
2298-}
2299
2300=== modified file 'src/server/frontend/session_mediator.cpp'
2301--- src/server/frontend/session_mediator.cpp 2016-01-20 23:59:18 +0000
2302+++ src/server/frontend/session_mediator.cpp 2016-01-25 13:42:04 +0000
2303@@ -46,10 +46,9 @@
2304 #include "mir/frontend/screencast.h"
2305 #include "mir/frontend/prompt_session.h"
2306 #include "mir/frontend/buffer_stream.h"
2307-#include "mir/frontend/security_check_failed.h"
2308 #include "mir/scene/prompt_session_creation_parameters.h"
2309 #include "mir/fd.h"
2310-#include "mir/cookie_factory.h"
2311+#include "mir/cookie/authority.h"
2312 #include "mir/module_properties.h"
2313
2314 #include "mir/geometry/rectangles.h"
2315@@ -90,7 +89,7 @@
2316 std::shared_ptr<mi::CursorImages> const& cursor_images,
2317 std::shared_ptr<scene::CoordinateTranslator> const& translator,
2318 std::shared_ptr<scene::ApplicationNotRespondingDetector> const& anr_detector,
2319- std::shared_ptr<mir::cookie::CookieFactory> const& cookie_factory) :
2320+ std::shared_ptr<mir::cookie::Authority> const& cookie_authority) :
2321 client_pid_(0),
2322 shell(shell),
2323 ipc_operations(ipc_operations),
2324@@ -106,7 +105,7 @@
2325 cursor_images(cursor_images),
2326 translator{translator},
2327 anr_detector{anr_detector},
2328- cookie_factory(cookie_factory),
2329+ cookie_authority(cookie_authority),
2330 buffer_stream_tracker{static_cast<size_t>(client_buffer_cache_size)}
2331 {
2332 }
2333@@ -1022,7 +1021,7 @@
2334 done->Run();
2335 }
2336
2337-void mf::SessionMediator::raise_surface_with_cookie(
2338+void mf::SessionMediator::raise_surface(
2339 mir::protobuf::RaiseRequest const* request,
2340 mir::protobuf::Void*,
2341 google::protobuf::Closure* done)
2342@@ -1034,11 +1033,12 @@
2343 auto const cookie = request->cookie();
2344 auto const surface_id = request->surface_id();
2345
2346- MirCookie const mir_cookie = {cookie.timestamp(), cookie.mac()};
2347- if (!cookie_factory->attest_timestamp(mir_cookie))
2348- throw mir::SecurityCheckFailed();
2349-
2350- shell->raise_surface_with_timestamp(session, mf::SurfaceId{surface_id.value()}, cookie.timestamp());
2351+ auto cookie_string = cookie.cookie();
2352+
2353+ std::vector<uint8_t> cookie_bytes(cookie_string.begin(), cookie_string.end());
2354+ auto const cookie_ptr = cookie_authority->make_cookie(cookie_bytes);
2355+
2356+ shell->raise_surface(session, mf::SurfaceId{surface_id.value()}, cookie_ptr->timestamp());
2357
2358 done->Run();
2359 }
2360
2361=== modified file 'src/server/frontend/session_mediator.h'
2362--- src/server/frontend/session_mediator.h 2016-01-20 23:59:18 +0000
2363+++ src/server/frontend/session_mediator.h 2016-01-25 13:42:04 +0000
2364@@ -40,7 +40,7 @@
2365 {
2366 namespace cookie
2367 {
2368-class CookieFactory;
2369+class Authority;
2370 }
2371 namespace graphics
2372 {
2373@@ -105,7 +105,7 @@
2374 std::shared_ptr<input::CursorImages> const& cursor_images,
2375 std::shared_ptr<scene::CoordinateTranslator> const& translator,
2376 std::shared_ptr<scene::ApplicationNotRespondingDetector> const& anr_detector,
2377- std::shared_ptr<cookie::CookieFactory> const& cookie_factory);
2378+ std::shared_ptr<cookie::Authority> const& cookie_authority);
2379
2380 ~SessionMediator() noexcept;
2381
2382@@ -215,7 +215,7 @@
2383 mir::protobuf::StreamConfiguration const* request,
2384 mir::protobuf::Void*,
2385 google::protobuf::Closure* done) override;
2386- void raise_surface_with_cookie(
2387+ void raise_surface(
2388 mir::protobuf::RaiseRequest const* request,
2389 mir::protobuf::Void*,
2390 google::protobuf::Closure* done) override;
2391@@ -259,7 +259,7 @@
2392 std::shared_ptr<input::CursorImages> const cursor_images;
2393 std::shared_ptr<scene::CoordinateTranslator> const translator;
2394 std::shared_ptr<scene::ApplicationNotRespondingDetector> const anr_detector;
2395- std::shared_ptr<cookie::CookieFactory> const cookie_factory;
2396+ std::shared_ptr<cookie::Authority> const cookie_authority;
2397
2398 BufferStreamTracker buffer_stream_tracker;
2399
2400
2401=== modified file 'src/server/frontend/shell_wrapper.cpp'
2402--- src/server/frontend/shell_wrapper.cpp 2016-01-20 23:59:18 +0000
2403+++ src/server/frontend/shell_wrapper.cpp 2016-01-25 13:42:04 +0000
2404@@ -99,10 +99,10 @@
2405 return wrapped->get_surface_attribute(session, surface_id, attrib);
2406 }
2407
2408-void mf::ShellWrapper::raise_surface_with_timestamp(
2409+void mf::ShellWrapper::raise_surface(
2410 std::shared_ptr<Session> const& session,
2411 SurfaceId surface_id,
2412 uint64_t timestamp)
2413 {
2414- wrapped->raise_surface_with_timestamp(session, surface_id, timestamp);
2415+ wrapped->raise_surface(session, surface_id, timestamp);
2416 }
2417
2418=== modified file 'src/server/frontend/shell_wrapper.h'
2419--- src/server/frontend/shell_wrapper.h 2016-01-20 23:59:18 +0000
2420+++ src/server/frontend/shell_wrapper.h 2016-01-25 13:42:04 +0000
2421@@ -75,7 +75,7 @@
2422 SurfaceId surface_id,
2423 MirSurfaceAttrib attrib) override;
2424
2425- void raise_surface_with_timestamp(
2426+ void raise_surface(
2427 std::shared_ptr<Session> const& session,
2428 SurfaceId surface_id,
2429 uint64_t timestamp) override;
2430
2431=== modified file 'src/server/input/android/input_sender.cpp'
2432--- src/server/input/android/input_sender.cpp 2016-01-20 23:59:18 +0000
2433+++ src/server/input/android/input_sender.cpp 2016-01-25 13:42:04 +0000
2434@@ -247,7 +247,7 @@
2435 mir_keyboard_event_scan_code(key_event),
2436 mia::android_modifiers_from_mir(mir_keyboard_event_modifiers(key_event)),
2437 repeat_count,
2438- event.key.mac,
2439+ event.key.cookie,
2440 event_time,
2441 event_time);
2442 }
2443@@ -324,7 +324,7 @@
2444 ret = publisher.publishMotionEvent(seq, mir_input_event_get_device_id(input_event), AINPUT_SOURCE_TOUCHSCREEN,
2445 state_change.android_action, flags, edge_flags,
2446 mia::android_modifiers_from_mir(mir_touch_event_modifiers(touch)),
2447- button_state, x_offset, y_offset, x_precision, y_precision, event.motion.mac,
2448+ button_state, x_offset, y_offset, x_precision, y_precision, event.motion.cookie,
2449 event_time, event_time, contacts_in_event, properties, coords);
2450 }
2451
2452@@ -361,7 +361,7 @@
2453 mia::android_pointer_action_from_mir(mir_pointer_event_action(pointer), mir_pointer_event_buttons(pointer)),
2454 flags, edge_flags, mia::android_modifiers_from_mir(mir_pointer_event_modifiers(pointer)),
2455 mia::android_pointer_buttons_from_mir(mir_pointer_event_buttons(pointer)), x_offset, y_offset, x_precision,
2456- y_precision, event.motion.mac, event_time, event_time, 1, &pointer_properties, &pointer_coord);
2457+ y_precision, event.motion.cookie, event_time, event_time, 1, &pointer_properties, &pointer_coord);
2458 }
2459
2460
2461
2462=== modified file 'src/server/input/default_configuration.cpp'
2463--- src/server/input/default_configuration.cpp 2016-01-20 23:59:18 +0000
2464+++ src/server/input/default_configuration.cpp 2016-01-25 13:42:04 +0000
2465@@ -147,7 +147,7 @@
2466 auto enable_repeat = options->get<bool>(options::enable_key_repeat_opt);
2467
2468 return std::make_shared<mi::KeyRepeatDispatcher>(
2469- the_event_filter_chain_dispatcher(), the_main_loop(), the_cookie_factory(),
2470+ the_event_filter_chain_dispatcher(), the_main_loop(), the_cookie_authority(),
2471 enable_repeat, key_repeat_timeout, key_repeat_delay);
2472 });
2473 }
2474@@ -278,7 +278,7 @@
2475 the_touch_visualizer(),
2476 the_cursor_listener(),
2477 the_input_region(),
2478- the_cookie_factory());
2479+ the_cookie_authority());
2480 });
2481 }
2482
2483@@ -293,6 +293,6 @@
2484 the_touch_visualizer(),
2485 the_cursor_listener(),
2486 the_input_region(),
2487- the_cookie_factory());
2488+ the_cookie_authority());
2489 });
2490 }
2491
2492=== modified file 'src/server/input/default_event_builder.cpp'
2493--- src/server/input/default_event_builder.cpp 2016-01-20 23:59:18 +0000
2494+++ src/server/input/default_event_builder.cpp 2016-01-25 13:42:04 +0000
2495@@ -19,29 +19,31 @@
2496
2497 #include "default_event_builder.h"
2498 #include "mir/events/event_builders.h"
2499-#include "mir/cookie_factory.h"
2500+#include "mir/cookie/authority.h"
2501 #include "mir/events/event_private.h"
2502
2503+#include <algorithm>
2504+
2505 namespace me = mir::events;
2506 namespace mi = mir::input;
2507
2508 mi::DefaultEventBuilder::DefaultEventBuilder(MirInputDeviceId device_id,
2509- std::shared_ptr<mir::cookie::CookieFactory> const& cookie_factory)
2510+ std::shared_ptr<mir::cookie::Authority> const& cookie_authority)
2511 : device_id(device_id),
2512- cookie_factory(cookie_factory)
2513+ cookie_authority(cookie_authority)
2514 {
2515 }
2516
2517 mir::EventUPtr mi::DefaultEventBuilder::key_event(Timestamp timestamp, MirKeyboardAction action, xkb_keysym_t key_code,
2518 int scan_code)
2519 {
2520- uint64_t mac = cookie_factory->timestamp_to_cookie(timestamp.count()).mac;
2521- return me::make_event(device_id, timestamp, mac, action, key_code, scan_code, mir_input_event_modifier_none);
2522+ auto const cookie = cookie_authority->make_cookie(timestamp.count());
2523+ return me::make_event(device_id, timestamp, cookie->serialize(), action, key_code, scan_code, mir_input_event_modifier_none);
2524 }
2525
2526 mir::EventUPtr mi::DefaultEventBuilder::touch_event(Timestamp timestamp)
2527 {
2528- return me::make_event(device_id, timestamp, 0, mir_input_event_modifier_none);
2529+ return me::make_event(device_id, timestamp, std::vector<uint8_t>{}, mir_input_event_modifier_none);
2530 }
2531
2532 void mi::DefaultEventBuilder::add_touch(MirEvent& event, MirTouchId touch_id, MirTouchAction action,
2533@@ -51,8 +53,9 @@
2534 {
2535 if (action == mir_touch_action_up || action == mir_touch_action_down)
2536 {
2537- auto cookie = cookie_factory->timestamp_to_cookie(event.motion.event_time.count());
2538- event.motion.mac = cookie.mac;
2539+ auto const cookie = cookie_authority->make_cookie(event.motion.event_time.count());
2540+ auto const serialized_cookie = cookie->serialize();
2541+ std::copy_n(std::begin(serialized_cookie), event.motion.cookie.size(), std::begin(event.motion.cookie));
2542 }
2543
2544 me::add_touch(event, touch_id, action, tooltype, x_axis_value, y_axis_value, pressure_value, touch_major_value,
2545@@ -65,10 +68,14 @@
2546 {
2547 const float x_axis_value = 0;
2548 const float y_axis_value = 0;
2549- uint64_t mac = 0;
2550+ std::vector<uint8_t> vec_cookie{};
2551+ // FIXME Moving to 160bits soon
2552 if (action == mir_pointer_action_button_up || action == mir_pointer_action_button_down)
2553- mac = cookie_factory->timestamp_to_cookie(timestamp.count()).mac;
2554- return me::make_event(device_id, timestamp, mac, mir_input_event_modifier_none, action, buttons_pressed, x_axis_value, y_axis_value,
2555+ {
2556+ auto const cookie = cookie_authority->make_cookie(timestamp.count());
2557+ vec_cookie = cookie->serialize();
2558+ }
2559+ return me::make_event(device_id, timestamp, vec_cookie, mir_input_event_modifier_none, action, buttons_pressed, x_axis_value, y_axis_value,
2560 hscroll_value, vscroll_value, relative_x_value, relative_y_value);
2561 }
2562
2563
2564=== modified file 'src/server/input/default_event_builder.h'
2565--- src/server/input/default_event_builder.h 2016-01-20 23:59:18 +0000
2566+++ src/server/input/default_event_builder.h 2016-01-25 13:42:04 +0000
2567@@ -27,7 +27,7 @@
2568 {
2569 namespace cookie
2570 {
2571-class CookieFactory;
2572+class Authority;
2573 }
2574 namespace input
2575 {
2576@@ -35,7 +35,7 @@
2577 {
2578 public:
2579 explicit DefaultEventBuilder(MirInputDeviceId device_id,
2580- std::shared_ptr<cookie::CookieFactory> const& cookie_factory);
2581+ std::shared_ptr<cookie::Authority> const& cookie_authority);
2582
2583 EventUPtr key_event(Timestamp timestamp, MirKeyboardAction action, xkb_keysym_t key_code, int scan_code) override;
2584
2585@@ -52,7 +52,7 @@
2586
2587 private:
2588 MirInputDeviceId const device_id;
2589- std::shared_ptr<cookie::CookieFactory> const cookie_factory;
2590+ std::shared_ptr<cookie::Authority> const cookie_authority;
2591 };
2592 }
2593 }
2594
2595=== modified file 'src/server/input/default_input_device_hub.cpp'
2596--- src/server/input/default_input_device_hub.cpp 2016-01-20 23:59:18 +0000
2597+++ src/server/input/default_input_device_hub.cpp 2016-01-25 13:42:04 +0000
2598@@ -29,7 +29,7 @@
2599 #include "mir/dispatch/multiplexing_dispatchable.h"
2600 #include "mir/dispatch/action_queue.h"
2601 #include "mir/server_action_queue.h"
2602-#include "mir/cookie_factory.h"
2603+#include "mir/cookie/authority.h"
2604 #define MIR_LOG_COMPONENT "Input"
2605 #include "mir/log.h"
2606
2607@@ -49,13 +49,13 @@
2608 std::shared_ptr<TouchVisualizer> const& touch_visualizer,
2609 std::shared_ptr<CursorListener> const& cursor_listener,
2610 std::shared_ptr<InputRegion> const& input_region,
2611- std::shared_ptr<mir::cookie::CookieFactory> const& cookie_factory)
2612+ std::shared_ptr<mir::cookie::Authority> const& cookie_authority)
2613 : input_dispatcher(input_dispatcher),
2614 input_dispatchable{input_multiplexer},
2615 observer_queue(observer_queue),
2616 device_queue(std::make_shared<dispatch::ActionQueue>()),
2617 input_region(input_region),
2618- cookie_factory(cookie_factory),
2619+ cookie_authority(cookie_authority),
2620 seat(touch_visualizer, cursor_listener, input_region),
2621 device_id_generator{0}
2622 {
2623@@ -78,7 +78,7 @@
2624 {
2625 // send input device info to observer loop..
2626 devices.push_back(std::make_unique<RegisteredDevice>(
2627- device, create_new_device_id(), input_dispatcher, input_dispatchable, cookie_factory, this, &seat));
2628+ device, create_new_device_id(), input_dispatcher, input_dispatchable, cookie_authority, this, &seat));
2629
2630 auto const& dev = devices.back();
2631 seat.add_device(dev->id());
2632@@ -142,10 +142,10 @@
2633 MirInputDeviceId device_id,
2634 std::shared_ptr<InputDispatcher> const& dispatcher,
2635 std::shared_ptr<dispatch::MultiplexingDispatchable> const& multiplexer,
2636- std::shared_ptr<mir::cookie::CookieFactory> const& cookie_factory,
2637+ std::shared_ptr<mir::cookie::Authority> const& cookie_authority,
2638 DefaultInputDeviceHub* hub,
2639 Seat* seat)
2640- : device_id(device_id), builder(device_id, cookie_factory), device(dev), dispatcher(dispatcher),
2641+ : device_id(device_id), builder(device_id, cookie_authority), device(dev), dispatcher(dispatcher),
2642 multiplexer(multiplexer), hub(hub), seat(seat)
2643 {
2644 }
2645
2646=== modified file 'src/server/input/default_input_device_hub.h'
2647--- src/server/input/default_input_device_hub.h 2016-01-20 23:59:18 +0000
2648+++ src/server/input/default_input_device_hub.h 2016-01-25 13:42:04 +0000
2649@@ -38,7 +38,7 @@
2650 class ServerActionQueue;
2651 namespace cookie
2652 {
2653-class CookieFactory;
2654+class Authority;
2655 }
2656 namespace dispatch
2657 {
2658@@ -65,7 +65,7 @@
2659 std::shared_ptr<TouchVisualizer> const& touch_visualizer,
2660 std::shared_ptr<CursorListener> const& cursor_listener,
2661 std::shared_ptr<InputRegion> const& input_region,
2662- std::shared_ptr<cookie::CookieFactory> const& cookie_factory);
2663+ std::shared_ptr<cookie::Authority> const& cookie_authority);
2664
2665 // InputDeviceRegistry - calls from mi::Platform
2666 void add_device(std::shared_ptr<InputDevice> const& device) override;
2667@@ -85,7 +85,7 @@
2668 std::shared_ptr<ServerActionQueue> const observer_queue;
2669 std::shared_ptr<dispatch::ActionQueue> const device_queue;
2670 std::shared_ptr<InputRegion> const input_region;
2671- std::shared_ptr<cookie::CookieFactory> const cookie_factory;
2672+ std::shared_ptr<cookie::Authority> const cookie_authority;
2673 Seat seat;
2674
2675 struct RegisteredDevice : public InputSink
2676@@ -95,7 +95,7 @@
2677 MirInputDeviceId dev_id,
2678 std::shared_ptr<InputDispatcher> const& dispatcher,
2679 std::shared_ptr<dispatch::MultiplexingDispatchable> const& multiplexer,
2680- std::shared_ptr<cookie::CookieFactory> const& cookie_factory,
2681+ std::shared_ptr<cookie::Authority> const& cookie_authority,
2682 DefaultInputDeviceHub* hub,
2683 Seat* seat);
2684 void handle_input(MirEvent& event) override;
2685
2686=== modified file 'src/server/input/key_repeat_dispatcher.cpp'
2687--- src/server/input/key_repeat_dispatcher.cpp 2016-01-20 23:59:18 +0000
2688+++ src/server/input/key_repeat_dispatcher.cpp 2016-01-25 13:42:04 +0000
2689@@ -21,10 +21,11 @@
2690 #include "mir/time/alarm_factory.h"
2691 #include "mir/time/alarm.h"
2692 #include "mir/events/event_private.h"
2693-#include "mir/cookie_factory.h"
2694+#include "mir/cookie/authority.h"
2695
2696 #include <boost/throw_exception.hpp>
2697
2698+#include <algorithm>
2699 #include <stdexcept>
2700 #include <string.h>
2701
2702@@ -33,13 +34,13 @@
2703 mi::KeyRepeatDispatcher::KeyRepeatDispatcher(
2704 std::shared_ptr<mi::InputDispatcher> const& next_dispatcher,
2705 std::shared_ptr<mir::time::AlarmFactory> const& factory,
2706- std::shared_ptr<mir::cookie::CookieFactory> const& cookie_factory,
2707+ std::shared_ptr<mir::cookie::Authority> const& cookie_authority,
2708 bool repeat_enabled,
2709 std::chrono::milliseconds repeat_timeout,
2710 std::chrono::milliseconds repeat_delay)
2711 : next_dispatcher(next_dispatcher),
2712 alarm_factory(factory),
2713- cookie_factory(cookie_factory),
2714+ cookie_authority(cookie_authority),
2715 repeat_enabled(repeat_enabled),
2716 repeat_timeout(repeat_timeout),
2717 repeat_delay(repeat_delay)
2718@@ -119,7 +120,9 @@
2719 std::lock_guard<std::mutex> lg(repeat_state_mutex);
2720
2721 ev.key.event_time = std::chrono::steady_clock::now().time_since_epoch();
2722- ev.key.mac = cookie_factory->timestamp_to_cookie(ev.key.event_time.count()).mac;
2723+ auto const cookie = cookie_authority->make_cookie(ev.key.event_time.count());
2724+ auto const serialized_cookie = cookie->serialize();
2725+ std::copy_n(std::begin(serialized_cookie), ev.key.cookie.size(), std::begin(ev.key.cookie));
2726 next_dispatcher->dispatch(ev);
2727
2728 capture_alarm->reschedule_in(repeat_delay);
2729
2730=== modified file 'src/server/input/key_repeat_dispatcher.h'
2731--- src/server/input/key_repeat_dispatcher.h 2016-01-20 23:59:18 +0000
2732+++ src/server/input/key_repeat_dispatcher.h 2016-01-25 13:42:04 +0000
2733@@ -30,7 +30,7 @@
2734 {
2735 namespace cookie
2736 {
2737-class CookieFactory;
2738+class Authority;
2739 }
2740 namespace time
2741 {
2742@@ -45,7 +45,7 @@
2743 public:
2744 KeyRepeatDispatcher(std::shared_ptr<InputDispatcher> const& next_dispatcher,
2745 std::shared_ptr<time::AlarmFactory> const& factory,
2746- std::shared_ptr<cookie::CookieFactory> const& cookie_factory,
2747+ std::shared_ptr<cookie::Authority> const& cookie_authority,
2748 bool repeat_enabled,
2749 std::chrono::milliseconds repeat_timeout, /* timeout before sending first repeat */
2750 std::chrono::milliseconds repeat_delay /* delay between repeated keys */);
2751@@ -60,7 +60,7 @@
2752
2753 std::shared_ptr<InputDispatcher> const next_dispatcher;
2754 std::shared_ptr<time::AlarmFactory> const alarm_factory;
2755- std::shared_ptr<cookie::CookieFactory> const cookie_factory;
2756+ std::shared_ptr<cookie::Authority> const cookie_authority;
2757 bool const repeat_enabled;
2758 std::chrono::milliseconds repeat_timeout;
2759 std::chrono::milliseconds repeat_delay;
2760
2761=== modified file 'src/server/input/surface_input_dispatcher.cpp'
2762--- src/server/input/surface_input_dispatcher.cpp 2016-01-20 23:59:18 +0000
2763+++ src/server/input/surface_input_dispatcher.cpp 2016-01-25 13:42:04 +0000
2764@@ -24,7 +24,6 @@
2765 #include "mir/scene/surface.h"
2766 #include "mir/events/event_builders.h"
2767 #include "mir/events/event_private.h"
2768-#include "mir/cookie_factory.h"
2769
2770 #include <string.h>
2771
2772@@ -221,7 +220,7 @@
2773
2774 deliver(surface, &*mev::make_event(mir_input_event_get_device_id(iev),
2775 std::chrono::nanoseconds(mir_input_event_get_event_time(iev)),
2776- 0, // FIXME Revet cookie API, fix incoming for 0.19
2777+ std::vector<uint8_t>{},
2778 mir_pointer_event_modifiers(pev),
2779 action, mir_pointer_event_buttons(pev),
2780 mir_pointer_event_axis_value(pev,mir_pointer_axis_x),
2781
2782=== modified file 'src/server/input/validator.cpp'
2783--- src/server/input/validator.cpp 2016-01-20 23:59:18 +0000
2784+++ src/server/input/validator.cpp 2016-01-25 13:42:04 +0000
2785@@ -244,7 +244,7 @@
2786 MirTouchEvent const* last_ev = nullptr;
2787 auto default_ev = mev::make_event(id,
2788 std::chrono::high_resolution_clock::now().time_since_epoch(),
2789- 0, /* No need for a mac, since there's no pointer count for a default event */
2790+ std::vector<uint8_t>{}, /* No need for a mac, since there's no pointer count for a default event */
2791 mir_input_event_modifier_none);
2792
2793 if (it == last_event_by_device.end())
2794
2795=== modified file 'src/server/server.cpp'
2796--- src/server/server.cpp 2016-01-20 23:59:18 +0000
2797+++ src/server/server.cpp 2016-01-25 13:42:04 +0000
2798@@ -31,7 +31,7 @@
2799 #include "mir/main_loop.h"
2800 #include "mir/report_exception.h"
2801 #include "mir/run_mir.h"
2802-#include "mir/cookie_factory.h"
2803+#include "mir/cookie/authority.h"
2804
2805 // TODO these are used to frig a stub renderer when running headless
2806 #include "mir/compositor/renderer.h"
2807@@ -67,7 +67,7 @@
2808 MACRO(session_mediator_report)\
2809 MACRO(shell)\
2810 MACRO(application_not_responding_detector)\
2811- MACRO(cookie_factory)\
2812+ MACRO(cookie_authority)\
2813 MACRO(coordinate_translator)
2814
2815 #define FOREACH_ACCESSOR(MACRO)\
2816
2817=== modified file 'src/server/shell/abstract_shell.cpp'
2818--- src/server/shell/abstract_shell.cpp 2016-01-20 23:59:18 +0000
2819+++ src/server/shell/abstract_shell.cpp 2016-01-25 13:42:04 +0000
2820@@ -164,7 +164,7 @@
2821 return surface->query(attrib);
2822 }
2823
2824-void msh::AbstractShell::raise_surface_with_timestamp(
2825+void msh::AbstractShell::raise_surface(
2826 std::shared_ptr<ms::Session> const& session,
2827 std::shared_ptr<ms::Surface> const& surface,
2828 uint64_t timestamp)
2829
2830=== modified file 'src/server/shell/frontend_shell.cpp'
2831--- src/server/shell/frontend_shell.cpp 2016-01-20 23:59:18 +0000
2832+++ src/server/shell/frontend_shell.cpp 2016-01-25 13:42:04 +0000
2833@@ -148,12 +148,12 @@
2834 return wrapped->get_surface_attribute(surface, attrib);
2835 }
2836
2837-void msh::FrontendShell::raise_surface_with_timestamp(
2838+void msh::FrontendShell::raise_surface(
2839 std::shared_ptr<mf::Session> const& session,
2840 mf::SurfaceId surface_id,
2841 uint64_t timestamp)
2842 {
2843 auto const scene_session = std::dynamic_pointer_cast<ms::Session>(session);
2844 auto const surface = scene_session->surface(surface_id);
2845- wrapped->raise_surface_with_timestamp(scene_session, surface, timestamp);
2846+ wrapped->raise_surface(scene_session, surface, timestamp);
2847 }
2848
2849=== modified file 'src/server/shell/frontend_shell.h'
2850--- src/server/shell/frontend_shell.h 2016-01-20 23:59:18 +0000
2851+++ src/server/shell/frontend_shell.h 2016-01-25 13:42:04 +0000
2852@@ -87,7 +87,7 @@
2853 mf::SurfaceId surface_id,
2854 MirSurfaceAttrib attrib) override;
2855
2856- void raise_surface_with_timestamp(
2857+ void raise_surface(
2858 std::shared_ptr<mf::Session> const& session,
2859 mf::SurfaceId surface_id,
2860 uint64_t timestamp) override;
2861
2862=== modified file 'src/server/shell/shell_wrapper.cpp'
2863--- src/server/shell/shell_wrapper.cpp 2016-01-20 23:59:18 +0000
2864+++ src/server/shell/shell_wrapper.cpp 2016-01-25 13:42:04 +0000
2865@@ -112,12 +112,12 @@
2866 return wrapped->get_surface_attribute(surface, attrib);
2867 }
2868
2869-void msh::ShellWrapper::raise_surface_with_timestamp(
2870+void msh::ShellWrapper::raise_surface(
2871 std::shared_ptr<ms::Session> const& session,
2872 std::shared_ptr<ms::Surface> const& surface,
2873 uint64_t timestamp)
2874 {
2875- wrapped->raise_surface_with_timestamp(session, surface, timestamp);
2876+ wrapped->raise_surface(session, surface, timestamp);
2877 }
2878
2879 void msh::ShellWrapper::add_display(geometry::Rectangle const& area)
2880
2881=== modified file 'src/server/symbols.map'
2882--- src/server/symbols.map 2016-01-20 23:59:18 +0000
2883+++ src/server/symbols.map 2016-01-25 13:42:04 +0000
2884@@ -165,7 +165,7 @@
2885 mir::Server::open_prompt_socket*;
2886 mir::Server::override_the_application_not_responding_detector*;
2887 mir::Server::override_the_compositor*;
2888- mir::Server::override_the_cookie_factory*;
2889+ mir::Server::override_the_cookie_authority*;
2890 mir::Server::override_the_coordinate_translator*;
2891 mir::Server::override_the_cursor_images*;
2892 mir::Server::override_the_display_buffer_compositor_factory*;
2893@@ -240,7 +240,7 @@
2894 mir::shell::AbstractShell::modify_surface*;
2895 mir::shell::AbstractShell::open_session*;
2896 mir::shell::AbstractShell::raise*;
2897- mir::shell::AbstractShell::raise_surface_with_timestamp*;
2898+ mir::shell::AbstractShell::raise_surface*;
2899 mir::shell::AbstractShell::remove_display*;
2900 mir::shell::AbstractShell::set_focus_to*;
2901 mir::shell::AbstractShell::set_surface_attribute*;
2902@@ -282,7 +282,7 @@
2903 mir::shell::ShellWrapper::modify_surface*;
2904 mir::shell::ShellWrapper::open_session*;
2905 mir::shell::ShellWrapper::raise*;
2906- mir::shell::ShellWrapper::raise_surface_with_timestamp*;
2907+ mir::shell::ShellWrapper::raise_surface*;
2908 mir::shell::ShellWrapper::remove_display*;
2909 mir::shell::ShellWrapper::set_focus_to*;
2910 mir::shell::ShellWrapper::set_surface_attribute*;
2911@@ -395,7 +395,7 @@
2912 non-virtual?thunk?to?mir::shell::AbstractShell::modify_surface*;
2913 non-virtual?thunk?to?mir::shell::AbstractShell::open_session*;
2914 non-virtual?thunk?to?mir::shell::AbstractShell::raise*;
2915- non-virtual?thunk?to?mir::shell::AbstractShell::raise_surface_with_timestamp*;
2916+ non-virtual?thunk?to?mir::shell::AbstractShell::raise_surface*;
2917 non-virtual?thunk?to?mir::shell::AbstractShell::remove_display*;
2918 non-virtual?thunk?to?mir::shell::AbstractShell::set_focus_to*;
2919 non-virtual?thunk?to?mir::shell::AbstractShell::set_surface_attribute*;
2920@@ -422,7 +422,7 @@
2921 non-virtual?thunk?to?mir::shell::ShellWrapper::modify_surface*;
2922 non-virtual?thunk?to?mir::shell::ShellWrapper::open_session*;
2923 non-virtual?thunk?to?mir::shell::ShellWrapper::raise*;
2924- non-virtual?thunk?to?mir::shell::ShellWrapper::raise_surface_with_timestamp*;
2925+ non-virtual?thunk?to?mir::shell::ShellWrapper::raise_surface*;
2926 non-virtual?thunk?to?mir::shell::ShellWrapper::remove_display*;
2927 non-virtual?thunk?to?mir::shell::ShellWrapper::set_focus_to*;
2928 non-virtual?thunk?to?mir::shell::ShellWrapper::set_surface_attribute*;
2929@@ -677,7 +677,7 @@
2930 mir::DefaultServerConfiguration::the_buffer_stream_factory*;
2931 mir::DefaultServerConfiguration::the_clock*;
2932 mir::DefaultServerConfiguration::the_composite_event_filter*;
2933- mir::DefaultServerConfiguration::the_cookie_factory*;
2934+ mir::DefaultServerConfiguration::the_cookie_authority*;
2935 mir::DefaultServerConfiguration::the_event_filter_chain_dispatcher*;
2936 mir::DefaultServerConfiguration::the_surface_input_dispatcher;
2937 mir::DefaultServerConfiguration::the_compositor*;
2938
2939=== modified file 'tests/acceptance-tests/test_client_cookie.cpp'
2940--- tests/acceptance-tests/test_client_cookie.cpp 2016-01-20 23:59:18 +0000
2941+++ tests/acceptance-tests/test_client_cookie.cpp 2016-01-25 13:42:04 +0000
2942@@ -1,5 +1,5 @@
2943 /*
2944- * Copyright © 2015 Canonical Ltd.
2945+ * Copyright © 2015-2016 Canonical Ltd.
2946 *
2947 * This program is free software: you can redistribute it and/or modify
2948 * it under the terms of the GNU General Public License version 3 as
2949@@ -23,12 +23,14 @@
2950 #include "mir_test_framework/stub_server_platform_factory.h"
2951 #include "mir_test_framework/connected_client_with_a_surface.h"
2952 #include "mir/test/spin_wait.h"
2953-#include "mir/cookie_factory.h"
2954+#include "mir/cookie/authority.h"
2955
2956 #include "boost/throw_exception.hpp"
2957
2958 #include <linux/input.h>
2959
2960+#include <mutex>
2961+
2962 namespace mtf = mir_test_framework;
2963 namespace mt = mir::test;
2964 namespace mi = mir::input;
2965@@ -45,8 +47,8 @@
2966 public:
2967 ClientCookies()
2968 {
2969- server.override_the_cookie_factory([this] ()
2970- { return mir::cookie::CookieFactory::create_saving_secret(cookie_secret); });
2971+ server.override_the_cookie_authority([this] ()
2972+ { return mir::cookie::Authority::create_saving(cookie_secret); });
2973 }
2974
2975 void SetUp() override
2976@@ -63,9 +65,6 @@
2977 mir_buffer_stream_swap_buffers_sync(mir_surface_get_buffer_stream(surface));
2978 }
2979
2980- std::vector<uint8_t> cookie_secret;
2981- std::vector<MirCookie> out_cookies;
2982-
2983 std::unique_ptr<mtf::FakeInputDevice> fake_keyboard{
2984 mtf::add_fake_input_device(mi::InputDeviceInfo{"keyboard", "keyboard-uid" , mi::DeviceCapability::keyboard})
2985 };
2986@@ -76,21 +75,49 @@
2987 mtf::add_fake_input_device(mi::InputDeviceInfo{
2988 "touch screen", "touch-screen-uid", mi::DeviceCapability::touchscreen | mi::DeviceCapability::multitouch})
2989 };
2990+
2991+ std::vector<std::vector<uint8_t>> out_cookies;
2992+ std::vector<uint8_t> cookie_secret;
2993+ size_t event_count{0};
2994+ mutable std::mutex mutex;
2995 };
2996
2997 namespace
2998 {
2999-// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19
3000-void cookie_capturing_callback(MirSurface*, MirEvent const* /*ev*/, void* /*ctx*/)
3001+
3002+void cookie_capturing_callback(MirSurface*, MirEvent const* ev, void* ctx)
3003 {
3004+ auto const event_type = mir_event_get_type(ev);
3005+ auto client_cookie = static_cast<ClientCookies*>(ctx);
3006+
3007+ if (event_type == mir_event_type_input)
3008+ {
3009+ auto const* iev = mir_event_get_input_event(ev);
3010+
3011+ std::lock_guard<std::mutex> lk(client_cookie->mutex);
3012+ if (mir_input_event_has_cookie(iev))
3013+ {
3014+ auto cookie = mir_input_event_get_cookie(iev);
3015+ size_t size = mir_cookie_buffer_size(cookie);
3016+
3017+ std::vector<uint8_t> cookie_bytes(size);
3018+ mir_cookie_to_buffer(cookie, cookie_bytes.data(), size);
3019+
3020+ mir_cookie_release(cookie);
3021+ client_cookie->out_cookies.push_back(cookie_bytes);
3022+ }
3023+
3024+ client_cookie->event_count++;
3025+ }
3026 }
3027
3028-bool wait_for_n_events(size_t n, std::vector<MirCookie>& cookies)
3029+bool wait_for_n_events(size_t n, ClientCookies* client_cookie)
3030 {
3031 bool all_events = mt::spin_wait_for_condition_or_timeout(
3032- [&n, &cookies]
3033+ [&n, &client_cookie]
3034 {
3035- return cookies.size() >= n;
3036+ std::lock_guard<std::mutex> lk(client_cookie->mutex);
3037+ return client_cookie->event_count >= n;
3038 },
3039 std::chrono::seconds{max_wait});
3040
3041@@ -99,41 +126,52 @@
3042 }
3043 }
3044
3045-// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19
3046-TEST_F(ClientCookies, DISABLED_keyboard_events_have_attestable_cookies)
3047+TEST_F(ClientCookies, keyboard_events_have_cookies)
3048 {
3049 fake_keyboard->emit_event(mis::a_key_down_event().of_scancode(KEY_M));
3050- if (wait_for_n_events(1, out_cookies))
3051+
3052+ int events = 1;
3053+ if (wait_for_n_events(events, this))
3054 {
3055- auto factory = mir::cookie::CookieFactory::create_from_secret(cookie_secret);
3056- EXPECT_TRUE(factory->attest_timestamp(out_cookies.back()));
3057+ std::lock_guard<std::mutex> lk(mutex);
3058+
3059+ ASSERT_FALSE(out_cookies.empty());
3060+ auto authority = mir::cookie::Authority::create_from(cookie_secret);
3061+
3062+ EXPECT_NO_THROW(authority->make_cookie(out_cookies.back()));
3063 }
3064 }
3065
3066-// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19
3067-TEST_F(ClientCookies, DISABLED_pointer_motion_events_do_not_have_attestable_cookies)
3068+TEST_F(ClientCookies, pointer_motion_events_do_not_have_cookies)
3069 {
3070+ // with movement generates 2 events
3071 fake_pointer->emit_event(mis::a_pointer_event().with_movement(1, 1));
3072- if (wait_for_n_events(1, out_cookies))
3073+
3074+ int events = 2;
3075+ if (wait_for_n_events(events, this))
3076 {
3077- auto factory = mir::cookie::CookieFactory::create_from_secret(cookie_secret);
3078- EXPECT_FALSE(factory->attest_timestamp(out_cookies.back()));
3079+ std::lock_guard<std::mutex> lk(mutex);
3080+ EXPECT_EQ(event_count, events);
3081+ EXPECT_TRUE(out_cookies.empty());
3082 }
3083 }
3084
3085-TEST_F(ClientCookies, DISABLED_pointer_click_events_have_attestable_cookies)
3086+TEST_F(ClientCookies, pointer_click_events_have_cookies)
3087 {
3088 fake_pointer->emit_event(mis::a_button_down_event().of_button(BTN_LEFT).with_action(mis::EventAction::Down));
3089 fake_pointer->emit_event(mis::a_button_up_event().of_button(BTN_LEFT));
3090- if (wait_for_n_events(2, out_cookies))
3091+
3092+ int events = 2;
3093+ if (wait_for_n_events(events, this))
3094 {
3095- auto factory = mir::cookie::CookieFactory::create_from_secret(cookie_secret);
3096- EXPECT_TRUE(factory->attest_timestamp(out_cookies.back()));
3097+ std::lock_guard<std::mutex> lk(mutex);
3098+ ASSERT_FALSE(out_cookies.empty());
3099+ auto authority = mir::cookie::Authority::create_from(cookie_secret);
3100+ EXPECT_NO_THROW(authority->make_cookie(out_cookies.back()));
3101 }
3102 }
3103
3104-// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19
3105-TEST_F(ClientCookies, DISABLED_touch_motion_events_do_not_have_attestable_cookies)
3106+TEST_F(ClientCookies, touch_motion_events_do_not_have_cookies)
3107 {
3108 fake_touch_screen->emit_event(
3109 mis::a_touch_event()
3110@@ -146,24 +184,11 @@
3111 .at_position({1, 1})
3112 );
3113
3114- if (wait_for_n_events(2, out_cookies))
3115- {
3116- auto factory = mir::cookie::CookieFactory::create_from_secret(cookie_secret);
3117- EXPECT_FALSE(factory->attest_timestamp(out_cookies.back()));
3118- }
3119-}
3120-
3121-// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19
3122-TEST_F(ClientCookies, DISABLED_touch_click_events_have_attestable_cookies)
3123-{
3124- fake_touch_screen->emit_event(
3125- mis::a_touch_event()
3126- .at_position({0, 0})
3127- );
3128-
3129- if (wait_for_n_events(1, out_cookies))
3130- {
3131- auto factory = mir::cookie::CookieFactory::create_from_secret(cookie_secret);
3132- EXPECT_TRUE(factory->attest_timestamp(out_cookies.back()));
3133+ int events = 1;
3134+ if (wait_for_n_events(events, this))
3135+ {
3136+ std::lock_guard<std::mutex> lk(mutex);
3137+ EXPECT_GE(event_count, events);
3138+ EXPECT_EQ(out_cookies.size(), 1);
3139 }
3140 }
3141
3142=== modified file 'tests/acceptance-tests/test_client_input.cpp'
3143--- tests/acceptance-tests/test_client_input.cpp 2016-01-23 03:16:06 +0000
3144+++ tests/acceptance-tests/test_client_input.cpp 2016-01-25 13:42:04 +0000
3145@@ -587,7 +587,7 @@
3146 EXPECT_CALL(first_client, handle_input(mt::KeyDownEvent()))
3147 .WillOnce(mt::WakeUp(&first_client.all_events_received));
3148
3149- auto key_event = mir::events::make_event(MirInputDeviceId{0}, 0ns, 0, mir_keyboard_action_down, 0, KEY_M,
3150+ auto key_event = mir::events::make_event(MirInputDeviceId{0}, 0ns, std::vector<uint8_t>{}, mir_keyboard_action_down, 0, KEY_M,
3151 mir_input_event_modifier_none);
3152
3153 server.the_shell()->focused_surface()->consume(key_event.get());
3154
3155=== modified file 'tests/acceptance-tests/test_surface_modifications.cpp'
3156--- tests/acceptance-tests/test_surface_modifications.cpp 2016-01-20 23:59:18 +0000
3157+++ tests/acceptance-tests/test_surface_modifications.cpp 2016-01-25 13:42:04 +0000
3158@@ -83,11 +83,10 @@
3159 auto const hscroll_value = 0.0;
3160 auto const vscroll_value = 0.0;
3161 auto const action = mir_pointer_action_button_down;
3162- auto const mac = 0;
3163 auto const relative_x_value = 0.0;
3164 auto const relative_y_value = 0.0;
3165
3166- auto const click_event = mev::make_event(device_id, timestamp, mac, modifiers,
3167+ auto const click_event = mev::make_event(device_id, timestamp, cookie, modifiers,
3168 action, mir_pointer_button_tertiary, x_axis_value, y_axis_value,
3169 hscroll_value, vscroll_value, relative_x_value, relative_y_value);
3170
3171@@ -103,11 +102,10 @@
3172 auto const hscroll_value = 0.0;
3173 auto const vscroll_value = 0.0;
3174 auto const action = mir_pointer_action_motion;
3175- auto const mac = 0;
3176 auto const relative_x_value = 0.0;
3177 auto const relative_y_value = 0.0;
3178
3179- auto const drag_event = mev::make_event(device_id, timestamp, mac, modifiers,
3180+ auto const drag_event = mev::make_event(device_id, timestamp, cookie, modifiers,
3181 action, mir_pointer_button_tertiary, x_axis_value, y_axis_value,
3182 hscroll_value, vscroll_value, relative_x_value, relative_y_value);
3183
3184@@ -146,6 +144,7 @@
3185 std::chrono::nanoseconds const timestamp = std::chrono::nanoseconds(39);
3186 NiceMock<MockSurfaceObserver> surface_observer;
3187 std::weak_ptr<ms::Surface> shell_surface;
3188+ std::vector<uint8_t> cookie;
3189 };
3190
3191 MATCHER_P(WidthEq, value, "")
3192
3193=== modified file 'tests/acceptance-tests/test_surface_placement.cpp'
3194--- tests/acceptance-tests/test_surface_placement.cpp 2016-01-20 23:59:18 +0000
3195+++ tests/acceptance-tests/test_surface_placement.cpp 2016-01-25 13:42:04 +0000
3196@@ -127,12 +127,11 @@
3197 auto const hscroll_value = 0.0;
3198 auto const vscroll_value = 0.0;
3199 auto const action = mir_pointer_action_button_down;
3200- auto const mac = 0;
3201 auto const relative_x_value = 0.0;
3202 auto const relative_y_value = 0.0;
3203
3204
3205- auto const click_event = mev::make_event(device_id, std::chrono::nanoseconds(1), mac, modifiers,
3206+ auto const click_event = mev::make_event(device_id, std::chrono::nanoseconds(1), std::vector<uint8_t>{}, modifiers,
3207 action, depressed_buttons, x_axis_value, y_axis_value, hscroll_value,
3208 vscroll_value, relative_x_value, relative_y_value);
3209
3210
3211=== modified file 'tests/acceptance-tests/test_surface_raise.cpp'
3212--- tests/acceptance-tests/test_surface_raise.cpp 2015-11-30 21:08:18 +0000
3213+++ tests/acceptance-tests/test_surface_raise.cpp 2016-01-25 13:42:04 +0000
3214@@ -1,5 +1,5 @@
3215 /*
3216- * Copyright © 2015 Canonical Ltd.
3217+ * Copyright © 2015-2016 Canonical Ltd.
3218 *
3219 * This program is free software: you can redistribute it and/or modify
3220 * it under the terms of the GNU General Public License version 3 as
3221@@ -24,7 +24,7 @@
3222 #include "mir_test_framework/any_surface.h"
3223 #include "mir/test/wait_condition.h"
3224 #include "mir/test/spin_wait.h"
3225-#include "mir/cookie_factory.h"
3226+#include "mir/cookie/authority.h"
3227
3228 #include "mir_toolkit/mir_client_library.h"
3229
3230@@ -33,6 +33,8 @@
3231 #include <gtest/gtest.h>
3232 #include <gmock/gmock.h>
3233
3234+#include <mutex>
3235+
3236 namespace mtf = mir_test_framework;
3237 namespace mt = mir::test;
3238 namespace mi = mir::input;
3239@@ -42,7 +44,6 @@
3240 {
3241 std::chrono::seconds const max_wait{4};
3242 void cookie_capturing_callback(MirSurface* surface, MirEvent const* ev, void* ctx);
3243-void lifecycle_changed(MirConnection* /* connection */, MirLifecycleState state, void* ctx);
3244 }
3245
3246 struct RaiseSurfaces : mtf::ConnectedClientHeadlessServer
3247@@ -77,17 +78,14 @@
3248 std::chrono::seconds{max_wait});
3249
3250 EXPECT_TRUE(surface_fullscreen);
3251-
3252- mir_connection_set_lifecycle_event_callback(connection, lifecycle_changed, this);
3253 }
3254
3255 MirSurface* surface1;
3256 MirSurface* surface2;
3257
3258- std::vector<MirCookie> key_cookies;
3259- std::vector<MirCookie> pointer_cookies;
3260-
3261- MirLifecycleState lifecycle_state{mir_lifecycle_state_resumed};
3262+ std::vector<std::vector<uint8_t>> out_cookies;
3263+ size_t event_count{0};
3264+ mutable std::mutex mutex;
3265
3266 std::unique_ptr<mtf::FakeInputDevice> fake_keyboard{
3267 mtf::add_fake_input_device(mi::InputDeviceInfo{"keyboard", "keyboard-uid", mi::DeviceCapability::keyboard})
3268@@ -99,23 +97,41 @@
3269
3270 namespace
3271 {
3272-// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19
3273-void cookie_capturing_callback(MirSurface* /*surface*/, MirEvent const* /*ev*/, void* /*ctx*/)
3274-{
3275-}
3276-
3277-void lifecycle_changed(MirConnection* /*connection*/, MirLifecycleState state, void* ctx)
3278-{
3279- auto client = reinterpret_cast<RaiseSurfaces*>(ctx);
3280- client->lifecycle_state = state;
3281-}
3282-
3283-bool wait_for_n_events(size_t n, std::vector<MirCookie>& cookies)
3284+
3285+void cookie_capturing_callback(MirSurface* /*surface*/, MirEvent const* ev, void* ctx)
3286+{
3287+ auto const event_type = mir_event_get_type(ev);
3288+ auto raise_surfaces = static_cast<RaiseSurfaces*>(ctx);
3289+
3290+ if (event_type == mir_event_type_input)
3291+ {
3292+ auto const* iev = mir_event_get_input_event(ev);
3293+
3294+ std::lock_guard<std::mutex> lk(raise_surfaces->mutex);
3295+ if (mir_input_event_has_cookie(iev))
3296+ {
3297+ auto cookie = mir_input_event_get_cookie(iev);
3298+ size_t size = mir_cookie_buffer_size(cookie);
3299+
3300+ std::vector<uint8_t> cookie_bytes(size);
3301+ mir_cookie_to_buffer(cookie, cookie_bytes.data(), size);
3302+
3303+ mir_cookie_release(cookie);
3304+
3305+ raise_surfaces->out_cookies.push_back(cookie_bytes);
3306+ }
3307+
3308+ raise_surfaces->event_count++;
3309+ }
3310+}
3311+
3312+bool wait_for_n_events(size_t n, RaiseSurfaces const* raise_surfaces)
3313 {
3314 bool all_events = mt::spin_wait_for_condition_or_timeout(
3315- [&n, &cookies]
3316+ [&n, &raise_surfaces]
3317 {
3318- return cookies.size() >= n;
3319+ std::lock_guard<std::mutex> lk(raise_surfaces->mutex);
3320+ return raise_surfaces->event_count >= n;
3321 },
3322 std::chrono::seconds{max_wait});
3323
3324@@ -123,30 +139,55 @@
3325 return all_events;
3326 }
3327
3328-}
3329-
3330-// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19
3331-TEST_F(RaiseSurfaces, DISABLED_key_event_with_cookie)
3332+bool attempt_focus(MirSurface* surface, MirCookie const* cookie)
3333+{
3334+ mir_surface_raise(surface, cookie);
3335+ bool surface_becomes_focused = mt::spin_wait_for_condition_or_timeout(
3336+ [&surface]
3337+ {
3338+ return mir_surface_get_focus(surface) == mir_surface_focused;
3339+ },
3340+ std::chrono::seconds{max_wait});
3341+
3342+ return surface_becomes_focused;
3343+}
3344+
3345+}
3346+
3347+TEST_F(RaiseSurfaces, key_event_with_cookie)
3348 {
3349 fake_keyboard->emit_event(mis::a_key_down_event().of_scancode(KEY_M));
3350- if (wait_for_n_events(1, key_cookies))
3351+
3352+ int events = 1;
3353+ if (wait_for_n_events(events, this))
3354 {
3355+ std::lock_guard<std::mutex> lk(mutex);
3356+ ASSERT_FALSE(out_cookies.empty());
3357 EXPECT_EQ(mir_surface_get_focus(surface2), mir_surface_focused);
3358- // EXPECT_TRUE attempt_focus surface2 key_cookies.back()
3359+
3360+ MirCookie const* cookie = mir_cookie_from_buffer(out_cookies.back().data(), out_cookies.back().size());
3361+ attempt_focus(surface2, cookie);
3362+
3363+ mir_cookie_release(cookie);
3364 }
3365 }
3366
3367-// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19
3368-TEST_F(RaiseSurfaces, DISABLED_older_timestamp_does_not_focus)
3369+TEST_F(RaiseSurfaces, older_timestamp_does_not_focus)
3370 {
3371 fake_keyboard->emit_event(mis::a_key_down_event().of_scancode(KEY_M));
3372 fake_keyboard->emit_event(mis::a_key_up_event().of_scancode(KEY_M));
3373- if (wait_for_n_events(2, key_cookies))
3374+
3375+ int events = 2;
3376+ if (wait_for_n_events(events, this))
3377 {
3378- EXPECT_TRUE(key_cookies.front().timestamp < key_cookies.back().timestamp);
3379+ std::lock_guard<std::mutex> lk(mutex);
3380+ ASSERT_FALSE(out_cookies.empty());
3381 EXPECT_EQ(mir_surface_get_focus(surface2), mir_surface_focused);
3382
3383- // mir_surface_raise_with_cookie
3384+ MirCookie const* cookie = mir_cookie_from_buffer(out_cookies.front().data(), out_cookies.front().size());
3385+ mir_surface_raise(surface1, cookie);
3386+
3387+ mir_cookie_release(cookie);
3388
3389 // Need to wait for this call to actually go through
3390 std::this_thread::sleep_for(std::chrono::milliseconds{1000});
3391@@ -154,33 +195,21 @@
3392 }
3393 }
3394
3395-// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19
3396-TEST_F(RaiseSurfaces, DISABLED_motion_events_dont_prevent_raise)
3397+TEST_F(RaiseSurfaces, motion_events_dont_prevent_raise)
3398 {
3399 fake_keyboard->emit_event(mis::a_key_down_event().of_scancode(KEY_M));
3400 fake_keyboard->emit_event(mis::a_key_up_event().of_scancode(KEY_M));
3401- if (wait_for_n_events(2, key_cookies))
3402+ if (wait_for_n_events(2, this))
3403 {
3404 fake_pointer->emit_event(mis::a_pointer_event().with_movement(1, 1));
3405- if (wait_for_n_events(1, pointer_cookies))
3406+ if (wait_for_n_events(1, this))
3407 {
3408+ std::lock_guard<std::mutex> lk(mutex);
3409+ ASSERT_FALSE(out_cookies.empty());
3410 EXPECT_EQ(mir_surface_get_focus(surface2), mir_surface_focused);
3411- // EXPECT_TRUE attempt_focus surface1 key_cookies.back()
3412+ MirCookie const* cookie = mir_cookie_from_buffer(out_cookies.back().data(), out_cookies.back().size());
3413+ EXPECT_TRUE(attempt_focus(surface1, cookie));
3414+ mir_cookie_release(cookie);
3415 }
3416 }
3417 }
3418-
3419-// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19
3420-TEST_F(RaiseSurfaces, DISABLED_client_connection_close_invalid_cookie)
3421-{
3422- // mir_surface_raise_with_cookie
3423-
3424- bool connection_close = mt::spin_wait_for_condition_or_timeout(
3425- [this]
3426- {
3427- return lifecycle_state == mir_lifecycle_connection_lost;
3428- },
3429- std::chrono::seconds{max_wait});
3430-
3431- EXPECT_TRUE(connection_close);
3432-}
3433
3434=== modified file 'tests/acceptance-tests/test_surface_specification.cpp'
3435--- tests/acceptance-tests/test_surface_specification.cpp 2016-01-20 23:59:18 +0000
3436+++ tests/acceptance-tests/test_surface_specification.cpp 2016-01-25 13:42:04 +0000
3437@@ -116,11 +116,10 @@
3438 auto const hscroll_value = 0.0;
3439 auto const vscroll_value = 0.0;
3440 auto const action = mir_pointer_action_button_down;
3441- auto const mac = 0;
3442 auto const relative_x_value = 0.0;
3443 auto const relative_y_value = 0.0;
3444
3445- auto const click_event = mev::make_event(device_id, timestamp, mac, modifiers,
3446+ auto const click_event = mev::make_event(device_id, timestamp, cookie, modifiers,
3447 action, mir_pointer_button_tertiary,
3448 x_axis_value, y_axis_value,
3449 hscroll_value, vscroll_value,
3450@@ -138,11 +137,10 @@
3451 auto const hscroll_value = 0.0;
3452 auto const vscroll_value = 0.0;
3453 auto const action = mir_pointer_action_motion;
3454- auto const mac = 0;
3455 auto const relative_x_value = 0.0;
3456 auto const relative_y_value = 0.0;
3457
3458- auto const drag_event = mev::make_event(device_id, timestamp, mac, modifiers,
3459+ auto const drag_event = mev::make_event(device_id, timestamp, cookie, modifiers,
3460 action, mir_pointer_button_tertiary,
3461 x_axis_value, y_axis_value,
3462 hscroll_value, vscroll_value,
3463@@ -172,6 +170,7 @@
3464 private:
3465 std::shared_ptr<mtd::WrapShellToTrackLatestSurface> shell;
3466 mt::Signal signal_change;
3467+ std::vector<uint8_t> cookie;
3468
3469 void init_pixel_format()
3470 {
3471
3472=== modified file 'tests/include/mir/test/doubles/mock_shell.h'
3473--- tests/include/mir/test/doubles/mock_shell.h 2016-01-20 23:59:18 +0000
3474+++ tests/include/mir/test/doubles/mock_shell.h 2016-01-25 13:42:04 +0000
3475@@ -70,7 +70,7 @@
3476 MOCK_METHOD3(get_surface_attribute, int(std::shared_ptr<frontend::Session> const& session,
3477 frontend::SurfaceId surface_id, MirSurfaceAttrib attrib));
3478
3479- MOCK_METHOD3(raise_surface_with_timestamp, void(std::shared_ptr<frontend::Session> const& session,
3480+ MOCK_METHOD3(raise_surface, void(std::shared_ptr<frontend::Session> const& session,
3481 frontend::SurfaceId surface_id, uint64_t timestamp));
3482 };
3483
3484
3485=== modified file 'tests/include/mir/test/doubles/stub_display_server.h'
3486--- tests/include/mir/test/doubles/stub_display_server.h 2016-01-20 23:59:18 +0000
3487+++ tests/include/mir/test/doubles/stub_display_server.h 2016-01-25 13:42:04 +0000
3488@@ -134,7 +134,7 @@
3489 mir::protobuf::StreamConfiguration const* /*request*/,
3490 mir::protobuf::Void* /*response*/,
3491 google::protobuf::Closure* /*done*/) {}
3492- void raise_surface_with_cookie(
3493+ void raise_surface(
3494 mir::protobuf::RaiseRequest const* /*request*/,
3495 mir::protobuf::Void* /*response*/,
3496 google::protobuf::Closure* /*done*/) {}
3497
3498=== modified file 'tests/integration-tests/CMakeLists.txt'
3499--- tests/integration-tests/CMakeLists.txt 2016-01-20 23:59:18 +0000
3500+++ tests/integration-tests/CMakeLists.txt 2016-01-25 13:42:04 +0000
3501@@ -6,6 +6,7 @@
3502 ${CMAKE_CURRENT_BINARY_DIR}
3503 ${PROJECT_SOURCE_DIR}/include/cookie
3504 ${PROJECT_SOURCE_DIR}/src/include/platform
3505+ ${PROJECT_SOURCE_DIR}/src/include/cookie
3506 ${PROJECT_SOURCE_DIR}/src/include/common
3507 ${PROJECT_SOURCE_DIR}/src/include/server
3508 ${PROJECT_SOURCE_DIR}/src/include/client
3509
3510=== modified file 'tests/integration-tests/input/test_single_seat_setup.cpp'
3511--- tests/integration-tests/input/test_single_seat_setup.cpp 2016-01-11 10:23:20 +0000
3512+++ tests/integration-tests/input/test_single_seat_setup.cpp 2016-01-25 13:42:04 +0000
3513@@ -27,7 +27,7 @@
3514 #include "mir/test/fake_shared.h"
3515
3516 #include "mir/dispatch/multiplexing_dispatchable.h"
3517-#include "mir/cookie_factory.h"
3518+#include "mir/cookie/authority.h"
3519
3520 #include "mir/input/cursor_listener.h"
3521 #include "mir/input/device.h"
3522@@ -67,13 +67,13 @@
3523 mtd::TriggeredMainLoop observer_loop;
3524 NiceMock<mtd::MockInputDispatcher> mock_dispatcher;
3525 NiceMock<mtd::MockInputRegion> mock_region;
3526- std::shared_ptr<mir::cookie::CookieFactory> cookie_factory = mir::cookie::CookieFactory::create_keeping_secret();
3527+ std::shared_ptr<mir::cookie::Authority> cookie_authority = mir::cookie::Authority::create();
3528 NiceMock<MockCursorListener> mock_cursor_listener;
3529 NiceMock<MockTouchVisualizer> mock_visualizer;
3530 mir::dispatch::MultiplexingDispatchable multiplexer;
3531 mi::DefaultInputDeviceHub hub{mt::fake_shared(mock_dispatcher), mt::fake_shared(multiplexer),
3532 mt::fake_shared(observer_loop), mt::fake_shared(mock_visualizer),
3533- mt::fake_shared(mock_cursor_listener), mt::fake_shared(mock_region), cookie_factory};
3534+ mt::fake_shared(mock_cursor_listener), mt::fake_shared(mock_region), cookie_authority};
3535 NiceMock<mtd::MockInputDeviceObserver> mock_observer;
3536 NiceMock<mtd::MockInputDevice> device{"device","dev-1", mi::DeviceCapability::unknown};
3537 NiceMock<mtd::MockInputDevice> another_device{"another_device","dev-2", mi::DeviceCapability::keyboard};
3538
3539=== modified file 'tests/mir_test_doubles/CMakeLists.txt'
3540--- tests/mir_test_doubles/CMakeLists.txt 2016-01-20 23:59:18 +0000
3541+++ tests/mir_test_doubles/CMakeLists.txt 2016-01-25 13:42:04 +0000
3542@@ -4,6 +4,7 @@
3543 ${PROJECT_SOURCE_DIR}/src/include/common
3544 ${PROJECT_SOURCE_DIR}/src/include/server
3545 ${PROJECT_SOURCE_DIR}/src/include/client
3546+ ${PROJECT_SOURCE_DIR}/src/include/cookie
3547
3548 ${Boost_INCLUDE_DIRS}
3549 ${CMAKE_SOURCE_DIR}
3550
3551=== modified file 'tests/unit-tests/CMakeLists.txt'
3552--- tests/unit-tests/CMakeLists.txt 2016-01-20 23:59:18 +0000
3553+++ tests/unit-tests/CMakeLists.txt 2016-01-25 13:42:04 +0000
3554@@ -26,6 +26,7 @@
3555 ${UMOCKDEV_INCLUDE_DIRS}
3556
3557 ${PROJECT_SOURCE_DIR}/include/cookie
3558+ ${PROJECT_SOURCE_DIR}/src/include/cookie
3559 ${PROJECT_SOURCE_DIR}/src/include/platform
3560 ${PROJECT_SOURCE_DIR}/src/include/server
3561 ${PROJECT_SOURCE_DIR}/src/include/client
3562
3563=== modified file 'tests/unit-tests/client/input/test_android_input_receiver.cpp'
3564--- tests/unit-tests/client/input/test_android_input_receiver.cpp 2016-01-20 23:59:18 +0000
3565+++ tests/unit-tests/client/input/test_android_input_receiver.cpp 2016-01-25 13:42:04 +0000
3566@@ -69,7 +69,7 @@
3567 testing_key_event_scan_code,
3568 0 /* meta_state */,
3569 0 /* repeat_count */,
3570- 0 /* mac */,
3571+ {{}} /* mac */,
3572 std::chrono::nanoseconds(0) /* down_time */,
3573 std::chrono::nanoseconds(0) /* event_time */);
3574 }
3575@@ -96,7 +96,7 @@
3576 0 /* y_offset */,
3577 0 /* x_precision */,
3578 0 /* y_precision */,
3579- 0 /* mac */,
3580+ {{}} /* mac */,
3581 std::chrono::nanoseconds(0) /* down_time */,
3582 t,
3583 default_pointer_count,
3584
3585=== modified file 'tests/unit-tests/client/input/test_xkb_mapper.cpp'
3586--- tests/unit-tests/client/input/test_xkb_mapper.cpp 2016-01-20 23:59:18 +0000
3587+++ tests/unit-tests/client/input/test_xkb_mapper.cpp 2016-01-25 13:42:04 +0000
3588@@ -35,8 +35,7 @@
3589
3590 static int map_key(mircv::XKBMapper &mapper, MirKeyboardAction action, int scan_code)
3591 {
3592- auto mac = 0;
3593- auto ev = mev::make_event(MirInputDeviceId(0), std::chrono::nanoseconds(0), mac, action,
3594+ auto ev = mev::make_event(MirInputDeviceId(0), std::chrono::nanoseconds(0), std::vector<uint8_t>{}, action,
3595 0, scan_code, mir_input_event_modifier_none);
3596
3597 mapper.update_state_and_map_event(*ev);
3598
3599=== modified file 'tests/unit-tests/frontend/test_event_sender.cpp'
3600--- tests/unit-tests/frontend/test_event_sender.cpp 2016-01-20 23:59:18 +0000
3601+++ tests/unit-tests/frontend/test_event_sender.cpp 2016-01-25 13:42:04 +0000
3602@@ -168,8 +168,7 @@
3603 {
3604 using namespace testing;
3605
3606- auto mac = 0;
3607- auto ev = mev::make_event(MirInputDeviceId(), std::chrono::nanoseconds(0), mac, MirKeyboardAction(),
3608+ auto ev = mev::make_event(MirInputDeviceId(), std::chrono::nanoseconds(0), std::vector<uint8_t>{}, MirKeyboardAction(),
3609 0, 0, MirInputEventModifiers());
3610
3611 EXPECT_CALL(mock_msg_sender, send(_, _, _))
3612
3613=== modified file 'tests/unit-tests/frontend/test_session_mediator.cpp'
3614--- tests/unit-tests/frontend/test_session_mediator.cpp 2016-01-20 23:59:18 +0000
3615+++ tests/unit-tests/frontend/test_session_mediator.cpp 2016-01-25 13:42:04 +0000
3616@@ -59,8 +59,7 @@
3617 #include "mir/test/signal.h"
3618 #include "mir/frontend/connector.h"
3619 #include "mir/frontend/event_sink.h"
3620-#include "mir/frontend/security_check_failed.h"
3621-#include "mir/cookie_factory.h"
3622+#include "mir/cookie/authority.h"
3623 #include "mir_protobuf.pb.h"
3624 #include "mir_protobuf_wire.pb.h"
3625
3626@@ -232,7 +231,7 @@
3627 std::make_shared<mtd::NullMessageSender>(),
3628 resource_cache, stub_screencast, &connector, nullptr, nullptr,
3629 std::make_shared<mtd::NullANRDetector>(),
3630- mir::cookie::CookieFactory::create_keeping_secret()}
3631+ mir::cookie::Authority::create()}
3632 {
3633 using namespace ::testing;
3634
3635@@ -257,7 +256,7 @@
3636 resource_cache, std::make_shared<mtd::NullScreencast>(),
3637 nullptr, nullptr, nullptr,
3638 std::make_shared<mtd::NullANRDetector>(),
3639- mir::cookie::CookieFactory::create_keeping_secret());
3640+ mir::cookie::Authority::create());
3641 }
3642
3643 MockConnector connector;
3644@@ -311,7 +310,7 @@
3645 std::make_shared<mtd::NullMessageSender>(),
3646 resource_cache, stub_screencast, context, nullptr, nullptr,
3647 std::make_shared<mtd::NullANRDetector>(),
3648- mir::cookie::CookieFactory::create_keeping_secret()};
3649+ mir::cookie::Authority::create()};
3650
3651 EXPECT_THAT(connects_handled_count, Eq(0));
3652
3653@@ -855,7 +854,7 @@
3654 std::make_shared<mtd::NullMessageSender>(),
3655 mt::fake_shared(mock_cache), stub_screencast, &connector, nullptr, nullptr,
3656 std::make_shared<mtd::NullANRDetector>(),
3657- mir::cookie::CookieFactory::create_keeping_secret()};
3658+ mir::cookie::Authority::create()};
3659
3660 mediator.connect(&connect_parameters, &connection, null_callback.get());
3661 mediator.create_surface(&surface_parameters, &surface_response, null_callback.get());
3662@@ -969,7 +968,7 @@
3663 nullptr,
3664 nullptr,
3665 std::make_shared<mtd::NullANRDetector>(),
3666- mir::cookie::CookieFactory::create_keeping_secret()};
3667+ mir::cookie::Authority::create()};
3668
3669 mp::Void null;
3670 mp::BufferRequest request;
3671@@ -1060,7 +1059,7 @@
3672 std::make_shared<mtd::NullMessageSender>(),
3673 resource_cache, stub_screencast, nullptr, nullptr, nullptr,
3674 std::make_shared<mtd::NullANRDetector>(),
3675- mir::cookie::CookieFactory::create_keeping_secret()};
3676+ mir::cookie::Authority::create()};
3677
3678 mp::Void null;
3679 mp::BufferRequest request;
3680@@ -1204,7 +1203,7 @@
3681 mock_sender,
3682 resource_cache, stub_screencast, nullptr, nullptr, nullptr,
3683 std::make_shared<mtd::NullANRDetector>(),
3684- mir::cookie::CookieFactory::create_keeping_secret()};
3685+ mir::cookie::Authority::create()};
3686
3687 ON_CALL(*shell, create_surface( _, _, _))
3688 .WillByDefault(
3689@@ -1308,6 +1307,6 @@
3690 mediator.connect(&connect_parameters, &connection, null_callback.get());
3691
3692 EXPECT_THROW({
3693- mediator.raise_surface_with_cookie(&raise_request, &void_response, null_callback.get());
3694- }, mir::SecurityCheckFailed);
3695+ mediator.raise_surface(&raise_request, &void_response, null_callback.get());
3696+ }, mir::cookie::SecurityCheckError);
3697 }
3698
3699=== modified file 'tests/unit-tests/input/android/test_android_input_lexicon.cpp'
3700--- tests/unit-tests/input/android/test_android_input_lexicon.cpp 2016-01-20 23:59:18 +0000
3701+++ tests/unit-tests/input/android/test_android_input_lexicon.cpp 2016-01-25 13:42:04 +0000
3702@@ -17,6 +17,7 @@
3703 */
3704
3705 #include "mir/input/android/android_input_lexicon.h"
3706+#include "mir/cookie/blob.h"
3707
3708 #include <androidfw/Input.h>
3709
3710@@ -39,13 +40,13 @@
3711 const int32_t scan_code = 6;
3712 const int32_t meta_state = AMETA_ALT_ON;
3713 const int32_t repeat_count = 0;
3714- const uint64_t mac = 11;
3715+ const mir::cookie::Blob cookie{{14}};
3716 auto const down_time = std::chrono::nanoseconds(9);
3717 auto const event_time = std::chrono::nanoseconds(10);
3718
3719 android_key_ev->initialize(device_id, source_id, action, flags, key_code,
3720 scan_code, meta_state, repeat_count,
3721- mac, down_time, event_time);
3722+ cookie, down_time, event_time);
3723
3724 auto mir_ev = mia::Lexicon::translate(android_key_ev);
3725
3726@@ -62,8 +63,6 @@
3727 EXPECT_EQ(key_code, mir_keyboard_event_key_code(kev));
3728 EXPECT_EQ(scan_code, mir_keyboard_event_scan_code(kev));
3729
3730- // FIXME Test the mac value once the public API has landed in 0.19
3731-
3732 delete android_key_ev;
3733 }
3734
3735@@ -84,7 +83,7 @@
3736 const float y_offset = 9;
3737 const float x_precision = 10;
3738 const float y_precision = 11;
3739- const uint64_t mac = 14;
3740+ const mir::cookie::Blob cookie{{14}};
3741 auto const down_time = std::chrono::nanoseconds(12);
3742 auto const event_time = std::chrono::nanoseconds(13);
3743 const size_t pointer_count = 1;
3744@@ -115,7 +114,7 @@
3745
3746 android_motion_ev->initialize(device_id, source_id, action, flags, edge_flags,
3747 meta_state, button_state, x_offset, y_offset,
3748- x_precision, y_precision, mac, down_time,
3749+ x_precision, y_precision, cookie, down_time,
3750 event_time, pointer_count, &pointer_properties, &pointer_coords);
3751
3752 auto mir_ev = mia::Lexicon::translate(android_motion_ev);
3753@@ -130,7 +129,6 @@
3754
3755 auto tev = mir_input_event_get_touch_event(iev);
3756 EXPECT_EQ(pointer_count, mir_touch_event_point_count(tev));
3757- // FIXME Test the mac value once the public API has landed in 0.19
3758
3759 EXPECT_EQ(pointer_id, mir_touch_event_id(tev, 0));
3760 // Notice these two coordinates are offset by x/y offset
3761@@ -161,7 +159,7 @@
3762 const float y_offset = 9;
3763 const float x_precision = 10;
3764 const float y_precision = 11;
3765- const uint64_t mac = 14;
3766+ const mir::cookie::Blob cookie{{14}};
3767 const std::chrono::nanoseconds down_time = std::chrono::nanoseconds(12);
3768 const std::chrono::nanoseconds event_time = std::chrono::nanoseconds(13);
3769 const size_t pointer_count = 2;
3770@@ -203,7 +201,7 @@
3771 android_motion_ev->initialize(device_id, source_id, action, flags,
3772 edge_flags, meta_state, 0,
3773 x_offset, y_offset, x_precision, y_precision,
3774- mac, down_time, event_time, pointer_count,
3775+ cookie, down_time, event_time, pointer_count,
3776 pointer_properties, pointer_coords);
3777
3778 auto mir_ev = mia::Lexicon::translate(android_motion_ev);
3779@@ -218,7 +216,6 @@
3780
3781 auto tev = mir_input_event_get_touch_event(iev);
3782 EXPECT_EQ(pointer_count, mir_touch_event_point_count(tev));
3783- // FIXME Test the mac value once the public API has landed in 0.19
3784
3785 for (unsigned i = 0; i < pointer_count; i++)
3786 {
3787
3788=== modified file 'tests/unit-tests/input/android/test_android_input_sender.cpp'
3789--- tests/unit-tests/input/android/test_android_input_sender.cpp 2016-01-20 23:59:18 +0000
3790+++ tests/unit-tests/input/android/test_android_input_sender.cpp 2016-01-25 13:42:04 +0000
3791@@ -31,11 +31,13 @@
3792 #include "mir/test/fake_shared.h"
3793 #include "mir/test/event_matchers.h"
3794
3795+
3796 #include "androidfw/Input.h"
3797 #include "androidfw/InputTransport.h"
3798
3799 #include "mir/input/input_report.h"
3800-#include "mir/cookie_factory.h"
3801+#include "mir/cookie/authority.h"
3802+#include "mir/cookie/blob.h"
3803
3804 #include <gtest/gtest.h>
3805 #include <gmock/gmock.h>
3806@@ -89,15 +91,6 @@
3807
3808 std::shared_ptr<ms::Observer> observer;
3809 };
3810-
3811-class StubCookieFactory : public mir::cookie::CookieFactory
3812-{
3813-public:
3814- MirCookie timestamp_to_cookie(uint64_t const&) override { return {0, 0};}
3815- bool attest_timestamp(MirCookie const&) override {return true;}
3816- StubCookieFactory() = default;
3817-};
3818-
3819 }
3820
3821 class AndroidInputSender : public ::testing::Test
3822@@ -113,11 +106,13 @@
3823 float const minor = 4;
3824 float const size = 8;
3825 mir::geometry::Displacement const movement{10, -10};
3826- StubCookieFactory cookie_factory;
3827- mi::DefaultEventBuilder builder{MirInputDeviceId(), mt::fake_shared(cookie_factory)};
3828+ std::shared_ptr<mir::cookie::Authority> const cookie_authority;
3829+ mi::DefaultEventBuilder builder;
3830
3831 AndroidInputSender()
3832- : key_event(builder.key_event(std::chrono::nanoseconds(1), mir_keyboard_action_down, 7, test_scan_code)),
3833+ : cookie_authority(mir::cookie::Authority::create_from({0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88})),
3834+ builder(MirInputDeviceId(), cookie_authority),
3835+ key_event(builder.key_event(std::chrono::nanoseconds(1), mir_keyboard_action_down, 7, test_scan_code)),
3836 motion_event(builder.touch_event(std::chrono::nanoseconds(-1))),
3837 pointer_event(builder.pointer_event(std::chrono::nanoseconds(123), mir_pointer_action_motion,
3838 mir_pointer_button_primary, 0.0f, 0.0f,
3839
3840=== modified file 'tests/unit-tests/input/evdev/test_libinput_device.cpp'
3841--- tests/unit-tests/input/evdev/test_libinput_device.cpp 2016-01-21 22:09:00 +0000
3842+++ tests/unit-tests/input/evdev/test_libinput_device.cpp 2016-01-25 13:42:04 +0000
3843@@ -31,7 +31,7 @@
3844 #include "mir/test/doubles/mock_libinput.h"
3845 #include "mir/test/gmock_fixes.h"
3846 #include "mir/udev/wrapper.h"
3847-#include "mir/cookie_factory.h"
3848+#include "mir/cookie/authority.h"
3849 #include "mir_test_framework/udev_environment.h"
3850
3851 #include <gmock/gmock.h>
3852@@ -74,8 +74,8 @@
3853
3854 struct MockEventBuilder : mi::EventBuilder
3855 {
3856- std::shared_ptr<mir::cookie::CookieFactory> const cookie_factory = mir::cookie::CookieFactory::create_keeping_secret();
3857- mi::DefaultEventBuilder builder{MirInputDeviceId{3}, cookie_factory};
3858+ std::shared_ptr<mir::cookie::Authority> const cookie_authority = mir::cookie::Authority::create();
3859+ mi::DefaultEventBuilder builder{MirInputDeviceId{3}, cookie_authority};
3860 MockEventBuilder()
3861 {
3862 ON_CALL(*this, key_event(_,_,_,_))
3863
3864=== modified file 'tests/unit-tests/input/test_default_input_device_hub.cpp'
3865--- tests/unit-tests/input/test_default_input_device_hub.cpp 2016-01-20 23:59:18 +0000
3866+++ tests/unit-tests/input/test_default_input_device_hub.cpp 2016-01-25 13:42:04 +0000
3867@@ -28,11 +28,11 @@
3868 #include "mir/test/event_matchers.h"
3869 #include "mir/test/fake_shared.h"
3870
3871-#include "mir/cookie_factory.h"
3872 #include "mir/dispatch/action_queue.h"
3873 #include "mir/dispatch/multiplexing_dispatchable.h"
3874 #include "mir/events/event_builders.h"
3875 #include "mir/input/cursor_listener.h"
3876+#include "mir/cookie/authority.h"
3877 #include "mir/input/device.h"
3878 #include "mir/input/input_device.h"
3879
3880@@ -54,13 +54,13 @@
3881 mtd::TriggeredMainLoop observer_loop;
3882 Nice<mtd::MockInputDispatcher> mock_dispatcher;
3883 Nice<mtd::MockInputRegion> mock_region;
3884- std::shared_ptr<mir::cookie::CookieFactory> cookie_factory = mir::cookie::CookieFactory::create_keeping_secret();
3885+ std::shared_ptr<mir::cookie::Authority> cookie_authority = mir::cookie::Authority::create();
3886 mtd::StubCursorListener stub_cursor_listener;
3887 mtd::StubTouchVisualizer stub_visualizer;
3888 mir::dispatch::MultiplexingDispatchable multiplexer;
3889 mi::DefaultInputDeviceHub hub{mt::fake_shared(mock_dispatcher), mt::fake_shared(multiplexer),
3890 mt::fake_shared(observer_loop), mt::fake_shared(stub_visualizer),
3891- mt::fake_shared(stub_cursor_listener), mt::fake_shared(mock_region), cookie_factory};
3892+ mt::fake_shared(stub_cursor_listener), mt::fake_shared(mock_region), cookie_authority};
3893 Nice<mtd::MockInputDeviceObserver> mock_observer;
3894 Nice<mtd::MockInputDevice> device{"device","dev-1", mi::DeviceCapability::unknown};
3895 Nice<mtd::MockInputDevice> another_device{"another_device","dev-2", mi::DeviceCapability::keyboard};
3896
3897=== modified file 'tests/unit-tests/input/test_event_builders.cpp'
3898--- tests/unit-tests/input/test_event_builders.cpp 2016-01-20 23:59:18 +0000
3899+++ tests/unit-tests/input/test_event_builders.cpp 2016-01-25 13:42:04 +0000
3900@@ -29,7 +29,7 @@
3901 {
3902 MirInputDeviceId const device_id = 7;
3903 std::chrono::nanoseconds const timestamp = std::chrono::nanoseconds(39);
3904- uint64_t const mac = 12;
3905+ std::vector<uint8_t> const cookie{};
3906 MirInputEventModifiers const modifiers = mir_input_event_modifier_meta;
3907 };
3908 }
3909@@ -41,7 +41,7 @@
3910 int const scan_code = 17;
3911
3912 auto ev = mev::make_event(device_id, timestamp,
3913- mac, action, key_code, scan_code, modifiers);
3914+ cookie, action, key_code, scan_code, modifiers);
3915 auto e = ev.get();
3916
3917 EXPECT_EQ(mir_event_type_input, mir_event_get_type(e));
3918@@ -52,7 +52,6 @@
3919 EXPECT_EQ(key_code, mir_keyboard_event_key_code(kev));
3920 EXPECT_EQ(scan_code, mir_keyboard_event_scan_code(kev));
3921 EXPECT_EQ(modifiers, mir_keyboard_event_modifiers(kev));
3922- // FIXME Test the mac value once the public API has landed in 0.19
3923 }
3924
3925 TEST_F(InputEventBuilder, makes_valid_touch_event)
3926@@ -69,7 +68,7 @@
3927 float size_values[] = {4, 9, 6};
3928
3929 auto ev = mev::make_event(device_id, timestamp,
3930- mac, modifiers);
3931+ cookie, modifiers);
3932 for (unsigned i = 0; i < touch_count; i++)
3933 {
3934 mev::add_touch(*ev, touch_ids[i], actions[i], tooltypes[i], x_axis_values[i], y_axis_values[i],
3935@@ -83,7 +82,6 @@
3936 auto tev = mir_input_event_get_touch_event(ie);
3937 EXPECT_EQ(modifiers, mir_touch_event_modifiers(tev));
3938 EXPECT_EQ(touch_count, mir_touch_event_point_count(tev));
3939- // FIXME Test the mac value once the public API has landed in 0.19
3940
3941 for (unsigned i = 0; i < touch_count; i++)
3942 {
3943@@ -106,7 +104,7 @@
3944 float x_axis_value = 3.9, y_axis_value = 7.4, hscroll_value = .9, vscroll_value = .3;
3945 auto const relative_x_value = 0.0;
3946 auto const relative_y_value = 0.0;
3947- auto ev = mev::make_event(device_id, timestamp, mac, modifiers,
3948+ auto ev = mev::make_event(device_id, timestamp, cookie, modifiers,
3949 action, depressed_buttons, x_axis_value, y_axis_value,
3950 hscroll_value, vscroll_value, relative_x_value, relative_y_value);
3951 auto e = ev.get();
3952@@ -117,7 +115,6 @@
3953 auto pev = mir_input_event_get_pointer_event(ie);
3954 EXPECT_EQ(modifiers, mir_pointer_event_modifiers(pev));
3955 EXPECT_EQ(action, mir_pointer_event_action(pev));
3956- // FIXME Test the mac value once the public API has landed in 0.19
3957 EXPECT_TRUE(mir_pointer_event_button_state(pev, mir_pointer_button_back));
3958 EXPECT_TRUE(mir_pointer_event_button_state(pev, mir_pointer_button_tertiary));
3959 EXPECT_FALSE(mir_pointer_event_button_state(pev, mir_pointer_button_primary));
3960@@ -136,7 +133,7 @@
3961 {
3962 MirTouchAction action = mir_touch_action_down;
3963
3964- auto ev = mev::make_event(device_id, timestamp, mac, modifiers);
3965+ auto ev = mev::make_event(device_id, timestamp, cookie, modifiers);
3966 mev::add_touch(*ev, 0, action, mir_touch_tooltype_finger, 0, 0, 0, 0, 0, 0);
3967 auto e = ev.get();
3968
3969@@ -152,7 +149,7 @@
3970 {
3971 MirTouchAction action = mir_touch_action_up;
3972
3973- auto ev = mev::make_event(device_id, timestamp, mac, modifiers);
3974+ auto ev = mev::make_event(device_id, timestamp, cookie, modifiers);
3975 mev::add_touch(*ev, 0, action, mir_touch_tooltype_finger, 0, 0, 0, 0, 0, 0);
3976 auto e = ev.get();
3977
3978@@ -162,7 +159,6 @@
3979 auto tev = mir_input_event_get_touch_event(ie);
3980
3981 EXPECT_EQ(action, mir_touch_event_action(tev, 0));
3982- // FIXME Test the mac value once the public API has landed in 0.19
3983 }
3984
3985 TEST_F(InputEventBuilder, map_to_hover_if_no_button_pressed)
3986@@ -171,7 +167,7 @@
3987 auto const relative_x_value = 0.0;
3988 auto const relative_y_value = 0.0;
3989 MirPointerAction action = mir_pointer_action_motion;
3990- auto ev = mev::make_event(device_id, timestamp, mac, modifiers,
3991+ auto ev = mev::make_event(device_id, timestamp, cookie, modifiers,
3992 action, 0, x_axis_value, y_axis_value,
3993 hscroll_value, vscroll_value, relative_x_value, relative_y_value);
3994 auto e = ev.get();
3995@@ -181,5 +177,4 @@
3996 auto pev = mir_input_event_get_pointer_event(ie);
3997 EXPECT_EQ(modifiers, mir_pointer_event_modifiers(pev));
3998 EXPECT_EQ(action, mir_pointer_event_action(pev));
3999- // FIXME Test the mac value once the public API has landed in 0.19
4000 }
4001
4002=== modified file 'tests/unit-tests/input/test_event_filter_chain_dispatcher.cpp'
4003--- tests/unit-tests/input/test_event_filter_chain_dispatcher.cpp 2016-01-20 23:59:18 +0000
4004+++ tests/unit-tests/input/test_event_filter_chain_dispatcher.cpp 2016-01-25 13:42:04 +0000
4005@@ -43,7 +43,7 @@
4006 struct EventFilterChainDispatcher : public ::testing::Test
4007 {
4008 mir::EventUPtr const event = mir::events::make_event(MirInputDeviceId(),
4009- std::chrono::nanoseconds(0), 0, MirKeyboardAction(),
4010+ std::chrono::nanoseconds(0), std::vector<uint8_t>{}, MirKeyboardAction(),
4011 xkb_keysym_t(), 0, MirInputEventModifiers());
4012 };
4013 }
4014
4015=== modified file 'tests/unit-tests/input/test_key_repeat_dispatcher.cpp'
4016--- tests/unit-tests/input/test_key_repeat_dispatcher.cpp 2016-01-20 23:59:18 +0000
4017+++ tests/unit-tests/input/test_key_repeat_dispatcher.cpp 2016-01-25 13:42:04 +0000
4018@@ -22,7 +22,7 @@
4019 #include "mir/events/event_builders.h"
4020 #include "mir/time/alarm.h"
4021 #include "mir/time/alarm_factory.h"
4022-#include "mir/cookie_factory.h"
4023+#include "mir/cookie/authority.h"
4024
4025 #include "mir/test/event_matchers.h"
4026 #include "mir/test/doubles/mock_input_dispatcher.h"
4027@@ -62,12 +62,12 @@
4028 struct KeyRepeatDispatcher : public testing::Test
4029 {
4030 KeyRepeatDispatcher()
4031- : dispatcher(mock_next_dispatcher, mock_alarm_factory, cookie_factory, true, repeat_time, repeat_delay)
4032+ : dispatcher(mock_next_dispatcher, mock_alarm_factory, cookie_authority, true, repeat_time, repeat_delay)
4033 {
4034 }
4035 std::shared_ptr<mtd::MockInputDispatcher> mock_next_dispatcher = std::make_shared<mtd::MockInputDispatcher>();
4036 std::shared_ptr<MockAlarmFactory> mock_alarm_factory = std::make_shared<MockAlarmFactory>();
4037- std::shared_ptr<mir::cookie::CookieFactory> cookie_factory = mir::cookie::CookieFactory::create_keeping_secret();
4038+ std::shared_ptr<mir::cookie::Authority> cookie_authority = mir::cookie::Authority::create();
4039 std::chrono::milliseconds const repeat_time{2};
4040 std::chrono::milliseconds const repeat_delay{1};
4041 mi::KeyRepeatDispatcher dispatcher;
4042@@ -90,11 +90,11 @@
4043 {
4044 mir::EventUPtr a_key_down_event()
4045 {
4046- return mev::make_event(0, std::chrono::nanoseconds(0), 0, mir_keyboard_action_down, 0, 0, mir_input_event_modifier_alt);
4047+ return mev::make_event(0, std::chrono::nanoseconds(0), std::vector<uint8_t>{}, mir_keyboard_action_down, 0, 0, mir_input_event_modifier_alt);
4048 }
4049 mir::EventUPtr a_key_up_event()
4050 {
4051- return mev::make_event(0, std::chrono::nanoseconds(0), 0, mir_keyboard_action_up, 0, 0, mir_input_event_modifier_alt);
4052+ return mev::make_event(0, std::chrono::nanoseconds(0), std::vector<uint8_t>{}, mir_keyboard_action_up, 0, 0, mir_input_event_modifier_alt);
4053 }
4054 }
4055
4056
4057=== modified file 'tests/unit-tests/input/test_surface_input_dispatcher.cpp'
4058--- tests/unit-tests/input/test_surface_input_dispatcher.cpp 2016-01-20 23:59:18 +0000
4059+++ tests/unit-tests/input/test_surface_input_dispatcher.cpp 2016-01-25 13:42:04 +0000
4060@@ -138,12 +138,12 @@
4061 }
4062 mir::EventUPtr press(int scan_code = 7)
4063 {
4064- return mev::make_event(id, std::chrono::nanoseconds(0), 0,
4065+ return mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{},
4066 mir_keyboard_action_down, 0, scan_code, mir_input_event_modifier_alt);
4067 }
4068 mir::EventUPtr release(int scan_code = 7)
4069 {
4070- return mev::make_event(id, std::chrono::nanoseconds(0), 0,
4071+ return mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{},
4072 mir_keyboard_action_up, 0, scan_code, mir_input_event_modifier_alt);
4073 }
4074 MirInputDeviceId const id;
4075@@ -159,7 +159,7 @@
4076
4077 mir::EventUPtr move_to(geom::Point const& location)
4078 {
4079- return mev::make_event(id, std::chrono::nanoseconds(0), 0,
4080+ return mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{},
4081 0, mir_pointer_action_motion, buttons,
4082 location.x.as_int(), location.y.as_int(),
4083 0, 0, 0, 0);
4084@@ -168,7 +168,7 @@
4085 {
4086 buttons &= ~button;
4087
4088- return mev::make_event(id, std::chrono::nanoseconds(0), 0,
4089+ return mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{},
4090 0, mir_pointer_action_button_up, buttons,
4091 location.x.as_int(), location.y.as_int(),
4092 0, 0, 0, 0);
4093@@ -177,7 +177,7 @@
4094 {
4095 buttons |= button;
4096
4097- return mev::make_event(id, std::chrono::nanoseconds(0), 0,
4098+ return mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{},
4099 0, mir_pointer_action_button_down, buttons,
4100 location.x.as_int(), location.y.as_int(),
4101 0, 0, 0, 0);
4102@@ -196,7 +196,7 @@
4103
4104 mir::EventUPtr move_to(geom::Point const& point)
4105 {
4106- auto ev = mev::make_event(id, std::chrono::nanoseconds(0), 0, 0);
4107+ auto ev = mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{}, 0);
4108 mev::add_touch(*ev, 0, mir_touch_action_change,
4109 mir_touch_tooltype_finger, point.x.as_int(), point.y.as_int(),
4110 touched ? 1.0 : 0.0,
4111@@ -209,7 +209,7 @@
4112 {
4113 touched = true;
4114
4115- auto ev = mev::make_event(id, std::chrono::nanoseconds(0), 0, 0);
4116+ auto ev = mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{}, 0);
4117 mev::add_touch(*ev, 0, mir_touch_action_down,
4118 mir_touch_tooltype_finger, point.x.as_int(), point.y.as_int(),
4119 1.0, 1.0, 1.0, 1.0);
4120@@ -219,7 +219,7 @@
4121 {
4122 touched = true;
4123
4124- auto ev = mev::make_event(id, std::chrono::nanoseconds(0), 0, 0);
4125+ auto ev = mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{}, 0);
4126 mev::add_touch(*ev, 0, mir_touch_action_down,
4127 mir_touch_tooltype_finger, point1.x.as_int(), point1.y.as_int(),
4128 1.0, 1.0, 1.0, 1.0);
4129@@ -232,7 +232,7 @@
4130 {
4131 touched = false;
4132
4133- auto ev = mev::make_event(id, std::chrono::nanoseconds(0), 0, 0);
4134+ auto ev = mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{}, 0);
4135 mev::add_touch(*ev, 0, mir_touch_action_up,
4136 mir_touch_tooltype_finger, point.x.as_int(), point.y.as_int(),
4137 0.0, 0.0, 0.0, 0.0);
4138@@ -242,7 +242,7 @@
4139 {
4140 touched = false;
4141
4142- auto ev = mev::make_event(id, std::chrono::nanoseconds(0), 0, 0);
4143+ auto ev = mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{}, 0);
4144 mev::add_touch(*ev, 0, mir_touch_action_up,
4145 mir_touch_tooltype_finger, point1.x.as_int(), point1.y.as_int(),
4146 1.0, 1.0, 1.0, 1.0);
4147
4148=== modified file 'tests/unit-tests/input/test_validator.cpp'
4149--- tests/unit-tests/input/test_validator.cpp 2016-01-20 23:59:18 +0000
4150+++ tests/unit-tests/input/test_validator.cpp 2016-01-25 13:42:04 +0000
4151@@ -67,7 +67,7 @@
4152 mir::EventUPtr make_touch(MirTouchId id, MirTouchAction action)
4153 {
4154 auto ev = mev::make_event(MirInputDeviceId(0), std::chrono::nanoseconds(0),
4155- 0, mir_input_event_modifier_none);
4156+ std::vector<uint8_t>{}, mir_input_event_modifier_none);
4157 add_another_touch(ev, id, action);
4158 return ev;
4159 }
4160
4161=== modified file 'tests/unit-tests/input/test_x11_platform.cpp'
4162--- tests/unit-tests/input/test_x11_platform.cpp 2016-01-20 23:59:18 +0000
4163+++ tests/unit-tests/input/test_x11_platform.cpp 2016-01-25 13:42:04 +0000
4164@@ -32,7 +32,7 @@
4165 #include "mir/test/doubles/mock_x11.h"
4166 #include "mir/test/doubles/mock_x11.h"
4167 #include "mir/test/fake_shared.h"
4168-#include "mir/cookie_factory.h"
4169+#include "mir/cookie/authority.h"
4170 #include "mir/test/event_matchers.h"
4171
4172 namespace md = mir::dispatch;
4173@@ -51,7 +51,7 @@
4174 NiceMock<mtd::MockInputSink> mock_keyboard_sink;
4175 NiceMock<mtd::MockX11> mock_x11;
4176 NiceMock<mtd::MockInputDeviceRegistry> mock_registry;
4177- mir::input::DefaultEventBuilder builder{0, mir::cookie::CookieFactory::create_keeping_secret()};
4178+ mir::input::DefaultEventBuilder builder{0, mir::cookie::Authority::create()};
4179
4180 mir::input::X::XInputPlatform x11_platform{
4181 mt::fake_shared(mock_registry),
4182
4183=== modified file 'tests/unit-tests/scene/test_abstract_shell.cpp'
4184--- tests/unit-tests/scene/test_abstract_shell.cpp 2016-01-20 23:59:18 +0000
4185+++ tests/unit-tests/scene/test_abstract_shell.cpp 2016-01-25 13:42:04 +0000
4186@@ -144,7 +144,7 @@
4187 }
4188
4189 std::chrono::nanoseconds const event_timestamp = std::chrono::nanoseconds(0);
4190- uint64_t const mac = 0;
4191+ std::vector<uint8_t> const cookie;
4192 };
4193 }
4194
4195@@ -286,7 +286,7 @@
4196 auto const event = mir::events::make_event(
4197 mir_input_event_type_key,
4198 event_timestamp,
4199- mac,
4200+ cookie,
4201 action,
4202 key_code,
4203 scan_code,
4204@@ -307,7 +307,7 @@
4205 auto const event = mir::events::make_event(
4206 mir_input_event_type_touch,
4207 event_timestamp,
4208- mac,
4209+ cookie,
4210 modifiers);
4211
4212 EXPECT_CALL(*wm, handle_touch_event(_))
4213@@ -333,7 +333,7 @@
4214 auto const event = mir::events::make_event(
4215 mir_input_event_type_pointer,
4216 event_timestamp,
4217- mac,
4218+ cookie,
4219 modifiers,
4220 action,
4221 buttons_pressed,
4222
4223=== modified file 'tests/unit-tests/scene/test_surface.cpp'
4224--- tests/unit-tests/scene/test_surface.cpp 2016-01-20 23:59:18 +0000
4225+++ tests/unit-tests/scene/test_surface.cpp 2016-01-25 13:42:04 +0000
4226@@ -407,9 +407,9 @@
4227 std::shared_ptr<mg::CursorImage>(),
4228 report);
4229
4230- auto key_event = mev::make_event(MirInputDeviceId(0), std::chrono::nanoseconds(0), 0,
4231+ auto key_event = mev::make_event(MirInputDeviceId(0), std::chrono::nanoseconds(0), std::vector<uint8_t>{},
4232 mir_keyboard_action_down, 0, 0, mir_input_event_modifier_none);
4233- auto touch_event = mev::make_event(MirInputDeviceId(0), std::chrono::nanoseconds(0), 0,
4234+ auto touch_event = mev::make_event(MirInputDeviceId(0), std::chrono::nanoseconds(0), std::vector<uint8_t>{},
4235 mir_input_event_modifier_none);
4236 mev::add_touch(*touch_event, 0, mir_touch_action_down, mir_touch_tooltype_finger, 0, 0,
4237 0, 0, 0, 0);
4238
4239=== modified file 'tests/unit-tests/test_mir_cookie.cpp'
4240--- tests/unit-tests/test_mir_cookie.cpp 2016-01-20 23:59:18 +0000
4241+++ tests/unit-tests/test_mir_cookie.cpp 2016-01-25 13:42:04 +0000
4242@@ -16,94 +16,102 @@
4243 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
4244 */
4245
4246-#include "mir/cookie_factory.h"
4247+#include "mir/cookie/authority.h"
4248+#include "mir/cookie/cookie.h"
4249
4250 #include <gtest/gtest.h>
4251 #include <gmock/gmock.h>
4252
4253-TEST(MirCookieFactory, attests_real_timestamp)
4254+TEST(MirCookieAuthority, attests_real_timestamp)
4255 {
4256 std::vector<uint8_t> secret{ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xde, 0x01 };
4257- auto factory = mir::cookie::CookieFactory::create_from_secret(secret);
4258+ auto authority = mir::cookie::Authority::create_from(secret);
4259
4260 uint64_t mock_timestamp{0x322322322332};
4261
4262- auto cookie = factory->timestamp_to_cookie(mock_timestamp);
4263-
4264- EXPECT_TRUE(factory->attest_timestamp(cookie));
4265+ auto cookie = authority->make_cookie(mock_timestamp);
4266+ EXPECT_NO_THROW({
4267+ authority->make_cookie(cookie->serialize());
4268+ });
4269 }
4270
4271-TEST(MirCookieFactory, doesnt_attest_faked_timestamp)
4272+TEST(MirCookieAuthority, doesnt_attest_faked_mac)
4273 {
4274 std::vector<uint8_t> secret{ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xde, 0x01 };
4275- auto factory = mir::cookie::CookieFactory::create_from_secret(secret);
4276-
4277- MirCookie bad_client_no_biscuit{ 0x33221100, 0x33221100 };
4278-
4279- EXPECT_FALSE(factory->attest_timestamp(bad_client_no_biscuit));
4280+ auto authority = mir::cookie::Authority::create_from(secret);
4281+
4282+ std::vector<uint8_t> cookie{ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xde, 0x01 };
4283+
4284+ EXPECT_THROW({
4285+ authority->make_cookie(cookie);
4286+ }, mir::cookie::SecurityCheckError);
4287 }
4288
4289-TEST(MirCookieFactory, timestamp_trusted_with_different_secret_doesnt_attest)
4290+TEST(MirCookieAuthority, timestamp_trusted_with_different_secret_doesnt_attest)
4291 {
4292 std::vector<uint8_t> alice{ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xde, 0x01 };
4293 std::vector<uint8_t> bob{ 0x01, 0x02, 0x44, 0xd8, 0xee, 0x0f, 0xde, 0x01 };
4294
4295- auto alices_factory = mir::cookie::CookieFactory::create_from_secret(alice);
4296- auto bobs_factory = mir::cookie::CookieFactory::create_from_secret(bob);
4297+ auto alices_authority = mir::cookie::Authority::create_from(alice);
4298+ auto bobs_authority = mir::cookie::Authority::create_from(bob);
4299
4300 uint64_t mock_timestamp{0x01020304};
4301
4302- auto alices_cookie = alices_factory->timestamp_to_cookie(mock_timestamp);
4303- auto bobs_cookie = bobs_factory->timestamp_to_cookie(mock_timestamp);
4304+ EXPECT_THROW({
4305+ auto alices_cookie = alices_authority->make_cookie(mock_timestamp);
4306+ auto bobs_cookie = bobs_authority->make_cookie(mock_timestamp);
4307
4308- EXPECT_FALSE(alices_factory->attest_timestamp(bobs_cookie));
4309- EXPECT_FALSE(bobs_factory->attest_timestamp(alices_cookie));
4310+ alices_authority->make_cookie(bobs_cookie->serialize());
4311+ bobs_authority->make_cookie(alices_cookie->serialize());
4312+ }, mir::cookie::SecurityCheckError);
4313 }
4314
4315-TEST(MirCookieFactory, throw_when_secret_size_to_small)
4316+TEST(MirCookieAuthority, throw_when_secret_size_to_small)
4317 {
4318- std::vector<uint8_t> bob(mir::cookie::CookieFactory::minimum_secret_size - 1);
4319+ std::vector<uint8_t> bob(mir::cookie::Authority::minimum_secret_size - 1);
4320 EXPECT_THROW({
4321- auto factory = mir::cookie::CookieFactory::create_from_secret(bob);
4322+ auto authority = mir::cookie::Authority::create_from(bob);
4323 }, std::logic_error);
4324 }
4325
4326-TEST(MirCookieFactory, saves_a_secret)
4327+TEST(MirCookieAuthority, saves_a_secret)
4328 {
4329 using namespace testing;
4330 std::vector<uint8_t> secret;
4331
4332- mir::cookie::CookieFactory::create_saving_secret(secret);
4333+ mir::cookie::Authority::create_saving(secret);
4334
4335- EXPECT_THAT(secret.size(), Ge(mir::cookie::CookieFactory::minimum_secret_size));
4336+ EXPECT_THAT(secret.size(), Ge(mir::cookie::Authority::minimum_secret_size));
4337 }
4338
4339-TEST(MirCookieFactory, timestamp_trusted_with_saved_secret_does_attest)
4340+TEST(MirCookieAuthority, timestamp_trusted_with_saved_secret_does_attest)
4341 {
4342 uint64_t timestamp = 23;
4343 std::vector<uint8_t> secret;
4344
4345- auto source_factory = mir::cookie::CookieFactory::create_saving_secret(secret);
4346- auto sink_factory = mir::cookie::CookieFactory::create_from_secret(secret);
4347- auto cookie = source_factory->timestamp_to_cookie(timestamp);
4348+ auto source_authority = mir::cookie::Authority::create_saving(secret);
4349+ auto sink_authority = mir::cookie::Authority::create_from(secret);
4350+ auto cookie = source_authority->make_cookie(timestamp);
4351
4352- EXPECT_TRUE(sink_factory->attest_timestamp(cookie));
4353+ EXPECT_NO_THROW({
4354+ sink_authority->make_cookie(cookie->serialize());
4355+ });
4356 }
4357
4358-TEST(MirCookieFactory, internally_generated_secret_has_optimum_size)
4359+TEST(MirCookieAuthority, internally_generated_secret_has_optimum_size)
4360 {
4361 using namespace testing;
4362 std::vector<uint8_t> secret;
4363
4364- mir::cookie::CookieFactory::create_saving_secret(secret);
4365+ mir::cookie::Authority::create_saving(secret);
4366
4367- EXPECT_THAT(secret.size(), Eq(mir::cookie::CookieFactory::optimal_secret_size()));
4368+ EXPECT_THAT(secret.size(), Eq(mir::cookie::Authority::optimal_secret_size()));
4369 }
4370
4371-TEST(MirCookieFactory, optimal_secret_size_is_larger_than_minimum_size)
4372+TEST(MirCookieAuthority, optimal_secret_size_is_larger_than_minimum_size)
4373 {
4374 using namespace testing;
4375
4376- EXPECT_THAT(mir::cookie::CookieFactory::optimal_secret_size(),
4377- Ge(mir::cookie::CookieFactory::minimum_secret_size));
4378+ EXPECT_THAT(mir::cookie::Authority::optimal_secret_size(),
4379+ Ge(mir::cookie::Authority::minimum_secret_size));
4380 }

Subscribers

People subscribed via source and target branches