Hello
Almost an entire year ago, as part of a student research project, a
fellow student and I implemented a small security token prototype based
on Tock. In light of the recent OpenSK announcement by Google [1], I've
dug up this project and was wondering whether some of the developments
could improve the TockOS project.
--
Around a purely safe Rust AES-128/256 implementation, we have thought of
an in-kernel AES abstraction layer. We are aware of the
symmetric_encryption HIL, but found it to be focused on hardware
implementations, and less flexible than desired.
Our efforts can be found here: [2]. These are in no way finished, but
should help explain the concepts.
The basic idea is to have a flexible layer, which can accomodate any
combination of supported AES key sizes and modes by the hardware, and
even support software implementations where the hardware does not
support the desired mode / key size.
This works by creating a strongly typed interface for AES keys, to be
used by the rest of the infrastructure.
Following that, two types of traits are used:
- "key traits" /^AES[0-9]*Engine$/
These traits provide methods for expanding the AES key, which is
required prior to any encryption or decryption operation. If a
hardware only supports a certain key length, the implementer may
choose to only implement for instance the "AES128Engine" trait. For
supporting all key sizes, it is sufficient to implement the
"AESEngine" trait.
- "block cipher mode traits" /^AES[A-Z]*Mode$/
If a hardware directly supports a given AES mode, the proper trait
can be directly implemented, providing methods for setting all
required parameters, such as initialisation vectors etc. However,
implementing the basic building block called "AESBlockEngine", all
other mode traits are implemented automatically.
For any given AES hardware or software implementation, it should be
sufficient to provide any combination of both key- and mode traits. This
implicitly describes the implementations' capabilities and can be used
to derive other possible modes.
This architecture appears to be fitting, as key expansion is AFAIK
generally independent of the chosen block cipher mode. Also, every mode
has different parameters and constraints, hence an individual trait per
mode. The abstraction should not incur a significant runtime cost,
although this is to be investigated.
A rudimentary usage of this infrastructure can be seen in [3], where a
(probably insecure and exclusively for research purposes) software
implementation of AES implements the basic "AESBlockEngine" and
"AESEngine".
Future improvements include terminology (trait names), more traits for
complex AES modes (currently only ECB is supported), a userspace driver
for each mode, support of existing HW implementations, and other changes
(i.e. make set_client() take an Option<>, etc.).
--
The primary advantage over the existing HIL is that _using_ this
architecture requires only the two well-defined key- and mode traits
respectively. It is not inspired by any hardware, but focuses on the
algorithms and their requirements/constraints instead.
I would love to hear feedback. If the general concepts make sense and
such an interface is appropriate for the Tock kernel, I'd be willing to
invest more time improving and mainlining this.
Thanks!
- Leon Schürmann
[1]:
https://security.googleblog.com/2020/01/say-hello-to-opensk-fully-open-source.html
[2]:
https://github.com/lschuermann/hsm-tock/blob/softaes/capsules/src/aes.rs
[3]:
https://github.com/lschuermann/hsm-tock/blob/softaes/capsules/src/softaes/mod.rs
--
This email was composed and sent using free software.
emacs, notmuch, msmtp, qmail, linux, nixos, gnupg, ...
Proudly brought to you without php, outlook, and win32.