.\" $NetBSD: sun8icrypto.4,v 1.2 2021/04/28 16:57:05 bad Exp $
.\"
.\" Copyright (c) 2021 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd April 28, 2021
.Dt SUN8ICRYPTO 4
.Os
.Sh NAME
.Nm sun8icrypto
.Nd driver for Allwinner Crypto Engine
.Sh SYNOPSIS
.Cd "sun8icrypto* at fdt?"
.Sh DESCRIPTION
The
.Nm
driver provides support for the cryptographic processors on Allwinner
A64, H3 and H5 systems-on-a-chip.
The Allwinner Crypto Engine is the successor to the earlier
Allwinner Security System.
.Pp
The hardware includes a True Random Number Generator (TRNG) that is
used as an entropy source for the
.Xr rnd 4
system, and implementations of various cryptographic algorithms
that can be used with
.Xr ipsec 4
and
.Xr crypto 4 .
.Pp
The following
.Xr opencrypto 9
algorithms are supported:
.Pp
.Bl -bullet -compact -offset indent
.It
.Dv CRYPTO_AES_CBC
.It
.Dv CRYPTO_AES_CTR
.It
.Dv CRYPTO_AES_ECB
.It
.Dv CRYPTO_AES_XTS
.It
.Dv CRYPTO_DES_CBC
.It
.Dv CRYPTO_DES_ECB
.It
.Dv CRYPTO_3DES_CBC
.It
.Dv CRYPTO_3DES_ECB
.It
.Dv CRYPTO_MD5
.It
.Dv CRYPTO_SHA1
.It
.Dv CRYPTO_SHA224
.It
.Dv CRYPTO_SHA256
.It
.Dv CRYPTO_SHA1_HMAC
.It
.Dv CRYPTO_SHA2_256_HMAC
.El
.Sh SEE ALSO
.Xr crypto 4 ,
.Xr ipsec 4 ,
.Xr rnd 4 ,
.Xr entropy 7 ,
.Xr opencrypto 9
.Sh HISTORY
The
.Nm
device driver first appeared in
.Nx 9.1 .
.Sh CAVEATS
The
.Nm
TRNG's underlying source of randomness is not documented by Allwinner,
so is not trusted as a reliable source of entropy.
Initial tests using NIST's SP800-90B tools showed highly biased
runs of output, suggesting any potential physical source is not
subject to whitening.
.Pp
Cryptographic operations using
.Nm
are generally slower than using the CPU on supported devices, but provide
an advantage in terms of hardware offloading if the CPU is busy.