open-source-firmware/go-tcg-storage

[Core Feature]: Simplify session handling

ChriMarMe opened this issue · 0 comments

At this moment session build up and handling is quite complex. We have ControlSession and Session with NewControlSession and NewSession functions in package core but also in package locking. The Initialize function of the locking package which builds a ControlSession and a NewSession function as a specific variation of Session for the purpose of the locking mechanism.

It is not easy to understand how to use sessions in a way to implement additional Opal/Enterprise features like TakeOwnership.

The specification describes two mechanisms for authentication in the context of sessions.

  1. Explicit - A session in existance can pass credentials to the device which then authorize the user. (This is implemented in the table package as ThisSP_Authenticate function. You can think of this as a rights elevation after session creation.
    TCG-Storage spec, p.188
  2. Implicit - The NewSession function gets additional parameters to create a session for the passed credentials and authenticates the user or admin in the process. TCG-Storage spec, p.132

While the spec describes ControlSessions and Sessions as seperate, I argue that we don't implement a session manager here and therefore we can wrap up ControlSession and Session build up to a single NewSession function which makes session handling easiers to understand and use. This would lead to the elimination of NewControlSession and NewSession in the locking package which means more seperation of concern. The locking mechanism shouldnt have anything to do with session handling. This should happen on an upper level of the library OR in the implementation of commands.