New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EndSession support #1227
EndSession support #1227
Conversation
there is a behavior change on legacy: previously, calling e.g. |
Randomness has changed again in the TT PIN tests. I originally thought this is because we now call |
The only breaking change for hosts is that we currently require We have to test extensively. |
Please, what is the original bug? |
Btw is this going to work with HWI? Because they had some problems with our sessions didn't they? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approve for Core.
@mmilata it might be early but would you like to have a look on a first PR as a reviewer? :)
It's only breaking on T1. On TT since 2.3.0 doing anything without other than that, yes. well-behaved clients will see no changes, and it is not necessary to use
i meant the original issue, it's not a bug :) #912
i believe so, but we should do some tests anyway |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not very familiar with the session handling but for the untrained eye the change is looking good 👍
@@ -128,6 +161,15 @@ def call_Initialize(**kwargs): | |||
call_Initialize(session_id=session_id) | |||
self.assertEqual(cache.get(KEY), "hello") | |||
|
|||
def test_EndSession(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this work without @mock_storage
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mock_storage is only required for Initialize
, which calls apps.base.get_features
, which looks into storage fields
4aa1b8c
to
950983f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw maybe also consider documenting EndSession
message in docs/common/communication/sessions.md
?
this PR introduces an implementation of the
EndSession
message and fixes #912the new behavior is as follows:
Initialize
message is received, any attempt to use cached data is rejected with aProcessError("Invalid session")
Initialize
, a session is allocatedEndSession
destroys data of that session, and resets to the "invalid session" state. Subsequent uses of cache will again raise aProcessError
This allows us to reuse session cache slots: a session ended with
EndSession
is cleared away, so we can have 9 "long-lived" sessions and reuse the 10th slots for things like requesting passphrase again. Suite should start using it ASAP.trezorctl
is also updated to make use of this: every command ends the session after itself, unless the session was resumed bytrezorctl -s <session_id>
open questions:
InvalidSession
, as suggested in the original bug? ISTM there is low possibility of breakage, as previously the call would end in a FirmwareError anyway.