1edb78df0SKonstantin Belousov.\" Copyright (c) 2010 Konstantin Belousov <kib@FreeBSD.org> 2edb78df0SKonstantin Belousov.\" All rights reserved. 3edb78df0SKonstantin Belousov.\" 4edb78df0SKonstantin Belousov.\" Redistribution and use in source and binary forms, with or without 5edb78df0SKonstantin Belousov.\" modification, are permitted provided that the following conditions 6edb78df0SKonstantin Belousov.\" are met: 7edb78df0SKonstantin Belousov.\" 1. Redistributions of source code must retain the above copyright 8edb78df0SKonstantin Belousov.\" notice, this list of conditions and the following disclaimer. 9edb78df0SKonstantin Belousov.\" 2. Redistributions in binary form must reproduce the above copyright 10edb78df0SKonstantin Belousov.\" notice, this list of conditions and the following disclaimer in the 11edb78df0SKonstantin Belousov.\" documentation and/or other materials provided with the distribution. 12edb78df0SKonstantin Belousov.\" 13edb78df0SKonstantin Belousov.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14edb78df0SKonstantin Belousov.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15edb78df0SKonstantin Belousov.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16edb78df0SKonstantin Belousov.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17edb78df0SKonstantin Belousov.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18edb78df0SKonstantin Belousov.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19edb78df0SKonstantin Belousov.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20edb78df0SKonstantin Belousov.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21edb78df0SKonstantin Belousov.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22edb78df0SKonstantin Belousov.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23edb78df0SKonstantin Belousov.\" SUCH DAMAGE. 24edb78df0SKonstantin Belousov.\" 25*40326c17SJohn-Mark Gurney.Dd July 29, 2020 26edb78df0SKonstantin Belousov.Dt AESNI 4 27edb78df0SKonstantin Belousov.Os 28edb78df0SKonstantin Belousov.Sh NAME 29edb78df0SKonstantin Belousov.Nm aesni 30fe182ba1SConrad Meyer.Nd "driver for the AES and SHA accelerator on x86 CPUs" 31edb78df0SKonstantin Belousov.Sh SYNOPSIS 32edb78df0SKonstantin BelousovTo compile this driver into the kernel, 33edb78df0SKonstantin Belousovplace the following lines in your 34edb78df0SKonstantin Belousovkernel configuration file: 35edb78df0SKonstantin Belousov.Bd -ragged -offset indent 36edb78df0SKonstantin Belousov.Cd "device crypto" 37695be8b9SKevin Lo.Cd "device cryptodev" 38edb78df0SKonstantin Belousov.Cd "device aesni" 39edb78df0SKonstantin Belousov.Ed 40edb78df0SKonstantin Belousov.Pp 41edb78df0SKonstantin BelousovAlternatively, to load the driver as a 42edb78df0SKonstantin Belousovmodule at boot time, place the following line in 43edb78df0SKonstantin Belousov.Xr loader.conf 5 : 44edb78df0SKonstantin Belousov.Bd -literal -offset indent 45edb78df0SKonstantin Belousovaesni_load="YES" 46edb78df0SKonstantin Belousov.Ed 47edb78df0SKonstantin Belousov.Sh DESCRIPTION 48fe182ba1SConrad MeyerStarting with Intel Westmere and AMD Bulldozer, some x86 processors implement a 49fe182ba1SConrad Meyernew set of instructions called AESNI. 50edb78df0SKonstantin BelousovThe set of six instructions accelerates the calculation of the key 51edb78df0SKonstantin Belousovschedule for key lengths of 128, 192, and 256 of the Advanced 526728a0dfSChristian BruefferEncryption Standard (AES) symmetric cipher, and provides a hardware 53edb78df0SKonstantin Belousovimplementation of the regular and the last encryption and decryption 54edb78df0SKonstantin Belousovrounds. 55edb78df0SKonstantin Belousov.Pp 56f5447a30SKonstantin BelousovThe processor capability is reported as AESNI in the Features2 line at boot. 57fe182ba1SConrad Meyer.Pp 58fe182ba1SConrad MeyerStarting with the Intel Goldmont and AMD Ryzen microarchitectures, some x86 59fe182ba1SConrad Meyerprocessors implement a new set of SHA instructions. 60fe182ba1SConrad MeyerThe set of seven instructions accelerates the calculation of SHA1 and SHA256 61fe182ba1SConrad Meyerhashes. 62fe182ba1SConrad Meyer.Pp 63fe182ba1SConrad MeyerThe processor capability is reported as SHA in the Structured Extended Features 64fe182ba1SConrad Meyerline at boot. 65edb78df0SKonstantin Belousov.Pp 66edb78df0SKonstantin BelousovThe 67edb78df0SKonstantin Belousov.Nm 68fe182ba1SConrad Meyerdriver does not attach on systems that lack both CPU capabilities. 69fe182ba1SConrad MeyerOn systems that support only one of AESNI or SHA extensions, the driver will 70fe182ba1SConrad Meyerattach and support that one function. 71fe182ba1SConrad Meyer.Pp 72fe182ba1SConrad MeyerThe 73fe182ba1SConrad Meyer.Nm 74fe182ba1SConrad Meyerdriver registers itself to accelerate AES and SHA operations for 75edb78df0SKonstantin Belousov.Xr crypto 4 . 766728a0dfSChristian BruefferBesides speed, the advantage of using the 776728a0dfSChristian Brueffer.Nm 786728a0dfSChristian Bruefferdriver is that the AESNI operation 79f5447a30SKonstantin Belousovis data-independent, thus eliminating some attack vectors based on 806728a0dfSChristian Brueffermeasuring cache use and timings typically present in table-driven 81edb78df0SKonstantin Belousovimplementations. 82edb78df0SKonstantin Belousov.Sh SEE ALSO 83edb78df0SKonstantin Belousov.Xr crypt 3 , 84edb78df0SKonstantin Belousov.Xr crypto 4 , 85edb78df0SKonstantin Belousov.Xr intro 4 , 86edb78df0SKonstantin Belousov.Xr ipsec 4 , 87edb78df0SKonstantin Belousov.Xr padlock 4 , 88edb78df0SKonstantin Belousov.Xr random 4 , 89*40326c17SJohn-Mark Gurney.Xr crypto 7 , 90edb78df0SKonstantin Belousov.Xr crypto 9 91edb78df0SKonstantin Belousov.Sh HISTORY 92edb78df0SKonstantin BelousovThe 93edb78df0SKonstantin Belousov.Nm 94edb78df0SKonstantin Belousovdriver first appeared in 95edb78df0SKonstantin Belousov.Fx 9.0 . 96fe182ba1SConrad MeyerSHA support was added in 97fe182ba1SConrad Meyer.Fx 12.0 . 98edb78df0SKonstantin Belousov.Sh AUTHORS 99edb78df0SKonstantin Belousov.An -nosplit 100edb78df0SKonstantin BelousovThe 101edb78df0SKonstantin Belousov.Nm 102edb78df0SKonstantin Belousovdriver was written by 103fe182ba1SConrad Meyer.An Konstantin Belousov Aq Mt kib@FreeBSD.org 104fe182ba1SConrad Meyerand 105fe182ba1SConrad Meyer.An Conrad Meyer Aq Mt cem@FreeBSD.org . 106edb78df0SKonstantin BelousovThe key schedule calculation code was adopted from the sample provided 107edb78df0SKonstantin Belousovby Intel and used in the analogous 108edb78df0SKonstantin Belousov.Ox 109edb78df0SKonstantin Belousovdriver. 110fe182ba1SConrad MeyerThe hash step intrinsics implementations were supplied by Intel. 111