On Thu, Apr 21, 2022 at 01:38:00PM +0100, Peter Maydell wrote: > On Sun, 10 Apr 2022 at 20:12, Corentin Labbe <cla...@baylibre.com> wrote: > > > > From: Corentin LABBE <cla...@baylibre.com> > > > > The Allwinner A10 has a cryptographic offloader device which > > could be easily emulated. > > The emulated device is tested with Linux only as any of BSD does not > > support it. > > > > Signed-off-by: Corentin LABBE <cla...@baylibre.com> >
> > +The ``sun4i-ss`` emulates the Allwinner cryptographic offloader > > +present on early Allwinner SoCs (A10, A10s, A13, A20, A33) > > +In qemu only A10 via the cubieboard machine is supported. > > + > > +The emulated hardware is capable of handling the following algorithms: > > +- SHA1 and MD5 hash algorithms > > +- AES/DES/DES3 in CBC/ECB > > +- PRNG > > + > > +The emulated hardware does not handle yet: > > +- CTS for AES > > +- CTR for AES/DES/DES3 > > @@ -48,6 +50,10 @@ static void aw_a10_init(Object *obj) > > > > object_initialize_child(obj, "emac", &s->emac, TYPE_AW_EMAC); > > > > +#if defined CONFIG_NETTLE > > + object_initialize_child(obj, "crypto", &s->crypto, TYPE_AW_SUN4I_SS); > > +#endif > > Don't put this kind of ifdef into device/SoC code, please. > The device emulation needs to work regardless of what > the specific crypto backends that got compiled into QEMU are. > > > +#include <nettle/aes.h> > > +#include <nettle/cbc.h> > > +#include <nettle/des.h> > > +#include <nettle/md5.h> > > +#include <nettle/sha1.h> > > Similarly, don't directly include nettle headers. The device needs > to use the backend-agnostic headers from include/crypto. To the > extent that they aren't sufficient to implement this device we > can look at enhancing them. The include/crypto/{cipher,hash}.h files should provide APIs that cover these uses cases from what I see in this patch. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|