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.\" 25edb78df0SKonstantin Belousov.\" $FreeBSD$ 26edb78df0SKonstantin Belousov.\" 27*fe182ba1SConrad Meyer.Dd September 26, 2017 28edb78df0SKonstantin Belousov.Dt AESNI 4 29edb78df0SKonstantin Belousov.Os 30edb78df0SKonstantin Belousov.Sh NAME 31edb78df0SKonstantin Belousov.Nm aesni 32*fe182ba1SConrad Meyer.Nd "driver for the AES and SHA accelerator on x86 CPUs" 33edb78df0SKonstantin Belousov.Sh SYNOPSIS 34edb78df0SKonstantin BelousovTo compile this driver into the kernel, 35edb78df0SKonstantin Belousovplace the following lines in your 36edb78df0SKonstantin Belousovkernel configuration file: 37edb78df0SKonstantin Belousov.Bd -ragged -offset indent 38edb78df0SKonstantin Belousov.Cd "device crypto" 39695be8b9SKevin Lo.Cd "device cryptodev" 40edb78df0SKonstantin Belousov.Cd "device aesni" 41edb78df0SKonstantin Belousov.Ed 42edb78df0SKonstantin Belousov.Pp 43edb78df0SKonstantin BelousovAlternatively, to load the driver as a 44edb78df0SKonstantin Belousovmodule at boot time, place the following line in 45edb78df0SKonstantin Belousov.Xr loader.conf 5 : 46edb78df0SKonstantin Belousov.Bd -literal -offset indent 47edb78df0SKonstantin Belousovaesni_load="YES" 48edb78df0SKonstantin Belousov.Ed 49edb78df0SKonstantin Belousov.Sh DESCRIPTION 50*fe182ba1SConrad MeyerStarting with Intel Westmere and AMD Bulldozer, some x86 processors implement a 51*fe182ba1SConrad Meyernew set of instructions called AESNI. 52edb78df0SKonstantin BelousovThe set of six instructions accelerates the calculation of the key 53edb78df0SKonstantin Belousovschedule for key lengths of 128, 192, and 256 of the Advanced 546728a0dfSChristian BruefferEncryption Standard (AES) symmetric cipher, and provides a hardware 55edb78df0SKonstantin Belousovimplementation of the regular and the last encryption and decryption 56edb78df0SKonstantin Belousovrounds. 57edb78df0SKonstantin Belousov.Pp 58f5447a30SKonstantin BelousovThe processor capability is reported as AESNI in the Features2 line at boot. 59*fe182ba1SConrad Meyer.Pp 60*fe182ba1SConrad MeyerStarting with the Intel Goldmont and AMD Ryzen microarchitectures, some x86 61*fe182ba1SConrad Meyerprocessors implement a new set of SHA instructions. 62*fe182ba1SConrad MeyerThe set of seven instructions accelerates the calculation of SHA1 and SHA256 63*fe182ba1SConrad Meyerhashes. 64*fe182ba1SConrad Meyer.Pp 65*fe182ba1SConrad MeyerThe processor capability is reported as SHA in the Structured Extended Features 66*fe182ba1SConrad Meyerline at boot. 67edb78df0SKonstantin Belousov.Pp 68edb78df0SKonstantin BelousovThe 69edb78df0SKonstantin Belousov.Nm 70*fe182ba1SConrad Meyerdriver does not attach on systems that lack both CPU capabilities. 71*fe182ba1SConrad MeyerOn systems that support only one of AESNI or SHA extensions, the driver will 72*fe182ba1SConrad Meyerattach and support that one function. 73*fe182ba1SConrad Meyer.Pp 74*fe182ba1SConrad MeyerThe 75*fe182ba1SConrad Meyer.Nm 76*fe182ba1SConrad Meyerdriver registers itself to accelerate AES and SHA operations for 77edb78df0SKonstantin Belousov.Xr crypto 4 . 786728a0dfSChristian BruefferBesides speed, the advantage of using the 796728a0dfSChristian Brueffer.Nm 806728a0dfSChristian Bruefferdriver is that the AESNI operation 81f5447a30SKonstantin Belousovis data-independent, thus eliminating some attack vectors based on 826728a0dfSChristian Brueffermeasuring cache use and timings typically present in table-driven 83edb78df0SKonstantin Belousovimplementations. 84edb78df0SKonstantin Belousov.Sh SEE ALSO 85edb78df0SKonstantin Belousov.Xr crypt 3 , 86edb78df0SKonstantin Belousov.Xr crypto 4 , 87edb78df0SKonstantin Belousov.Xr intro 4 , 88edb78df0SKonstantin Belousov.Xr ipsec 4 , 89edb78df0SKonstantin Belousov.Xr padlock 4 , 90edb78df0SKonstantin Belousov.Xr random 4 , 91edb78df0SKonstantin Belousov.Xr crypto 9 92edb78df0SKonstantin Belousov.Sh HISTORY 93edb78df0SKonstantin BelousovThe 94edb78df0SKonstantin Belousov.Nm 95edb78df0SKonstantin Belousovdriver first appeared in 96edb78df0SKonstantin Belousov.Fx 9.0 . 97*fe182ba1SConrad MeyerSHA support was added in 98*fe182ba1SConrad Meyer.Fx 12.0 . 99edb78df0SKonstantin Belousov.Sh AUTHORS 100edb78df0SKonstantin Belousov.An -nosplit 101edb78df0SKonstantin BelousovThe 102edb78df0SKonstantin Belousov.Nm 103edb78df0SKonstantin Belousovdriver was written by 104*fe182ba1SConrad Meyer.An Konstantin Belousov Aq Mt kib@FreeBSD.org 105*fe182ba1SConrad Meyerand 106*fe182ba1SConrad Meyer.An Conrad Meyer Aq Mt cem@FreeBSD.org . 107edb78df0SKonstantin BelousovThe key schedule calculation code was adopted from the sample provided 108edb78df0SKonstantin Belousovby Intel and used in the analogous 109edb78df0SKonstantin Belousov.Ox 110edb78df0SKonstantin Belousovdriver. 111*fe182ba1SConrad MeyerThe hash step intrinsics implementations were supplied by Intel. 112