mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
Merge tag 'v6.15-p1' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto updates from Herbert Xu: "API: - Remove legacy compression interface - Improve scatterwalk API - Add request chaining to ahash and acomp - Add virtual address support to ahash and acomp - Add folio support to acomp - Remove NULL dst support from acomp Algorithms: - Library options are fuly hidden (selected by kernel users only) - Add Kerberos5 algorithms - Add VAES-based ctr(aes) on x86 - Ensure LZO respects output buffer length on compression - Remove obsolete SIMD fallback code path from arm/ghash-ce Drivers: - Add support for PCI device 0x1134 in ccp - Add support for rk3588's standalone TRNG in rockchip - Add Inside Secure SafeXcel EIP-93 crypto engine support in eip93 - Fix bugs in tegra uncovered by multi-threaded self-test - Fix corner cases in hisilicon/sec2 Others: - Add SG_MITER_LOCAL to sg miter - Convert ubifs, hibernate and xfrm_ipcomp from legacy API to acomp" * tag 'v6.15-p1' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (187 commits) crypto: testmgr - Add multibuffer acomp testing crypto: acomp - Fix synchronous acomp chaining fallback crypto: testmgr - Add multibuffer hash testing crypto: hash - Fix synchronous ahash chaining fallback crypto: arm/ghash-ce - Remove SIMD fallback code path crypto: essiv - Replace memcpy() + NUL-termination with strscpy() crypto: api - Call crypto_alg_put in crypto_unregister_alg crypto: scompress - Fix incorrect stream freeing crypto: lib/chacha - remove unused arch-specific init support crypto: remove obsolete 'comp' compression API crypto: compress_null - drop obsolete 'comp' implementation crypto: cavium/zip - drop obsolete 'comp' implementation crypto: zstd - drop obsolete 'comp' implementation crypto: lzo - drop obsolete 'comp' implementation crypto: lzo-rle - drop obsolete 'comp' implementation crypto: lz4hc - drop obsolete 'comp' implementation crypto: lz4 - drop obsolete 'comp' implementation crypto: deflate - drop obsolete 'comp' implementation crypto: 842 - drop obsolete 'comp' implementation crypto: nx - Migrate to scomp API ...
This commit is contained in:
@@ -196,8 +196,6 @@ the aforementioned cipher types:
|
||||
|
||||
- CRYPTO_ALG_TYPE_CIPHER Single block cipher
|
||||
|
||||
- CRYPTO_ALG_TYPE_COMPRESS Compression
|
||||
|
||||
- CRYPTO_ALG_TYPE_AEAD Authenticated Encryption with Associated Data
|
||||
(MAC)
|
||||
|
||||
|
||||
@@ -26,3 +26,4 @@ for cryptographic use cases, as well as programming examples.
|
||||
api-samples
|
||||
descore-readme
|
||||
device_drivers/index
|
||||
krb5
|
||||
|
||||
@@ -0,0 +1,262 @@
|
||||
.. SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
===========================
|
||||
Kerberos V Cryptography API
|
||||
===========================
|
||||
|
||||
.. Contents:
|
||||
|
||||
- Overview.
|
||||
- Small Buffer.
|
||||
- Encoding Type.
|
||||
- Key Derivation.
|
||||
- PRF+ Calculation.
|
||||
- Kc, Ke And Ki Derivation.
|
||||
- Crypto Functions.
|
||||
- Preparation Functions.
|
||||
- Encryption Mode.
|
||||
- Checksum Mode.
|
||||
- The krb5enc AEAD algorithm
|
||||
|
||||
Overview
|
||||
========
|
||||
|
||||
This API provides Kerberos 5-style cryptography for key derivation, encryption
|
||||
and checksumming for use in network filesystems and can be used to implement
|
||||
the low-level crypto that's needed for GSSAPI.
|
||||
|
||||
The following crypto types are supported::
|
||||
|
||||
KRB5_ENCTYPE_AES128_CTS_HMAC_SHA1_96
|
||||
KRB5_ENCTYPE_AES256_CTS_HMAC_SHA1_96
|
||||
KRB5_ENCTYPE_AES128_CTS_HMAC_SHA256_128
|
||||
KRB5_ENCTYPE_AES256_CTS_HMAC_SHA384_192
|
||||
KRB5_ENCTYPE_CAMELLIA128_CTS_CMAC
|
||||
KRB5_ENCTYPE_CAMELLIA256_CTS_CMAC
|
||||
|
||||
KRB5_CKSUMTYPE_HMAC_SHA1_96_AES128
|
||||
KRB5_CKSUMTYPE_HMAC_SHA1_96_AES256
|
||||
KRB5_CKSUMTYPE_CMAC_CAMELLIA128
|
||||
KRB5_CKSUMTYPE_CMAC_CAMELLIA256
|
||||
KRB5_CKSUMTYPE_HMAC_SHA256_128_AES128
|
||||
KRB5_CKSUMTYPE_HMAC_SHA384_192_AES256
|
||||
|
||||
The API can be included by::
|
||||
|
||||
#include <crypto/krb5.h>
|
||||
|
||||
Small Buffer
|
||||
------------
|
||||
|
||||
To pass small pieces of data about, such as keys, a buffer structure is
|
||||
defined, giving a pointer to the data and the size of that data::
|
||||
|
||||
struct krb5_buffer {
|
||||
unsigned int len;
|
||||
void *data;
|
||||
};
|
||||
|
||||
Encoding Type
|
||||
=============
|
||||
|
||||
The encoding type is defined by the following structure::
|
||||
|
||||
struct krb5_enctype {
|
||||
int etype;
|
||||
int ctype;
|
||||
const char *name;
|
||||
u16 key_bytes;
|
||||
u16 key_len;
|
||||
u16 Kc_len;
|
||||
u16 Ke_len;
|
||||
u16 Ki_len;
|
||||
u16 prf_len;
|
||||
u16 block_len;
|
||||
u16 conf_len;
|
||||
u16 cksum_len;
|
||||
...
|
||||
};
|
||||
|
||||
The fields of interest to the user of the API are as follows:
|
||||
|
||||
* ``etype`` and ``ctype`` indicate the protocol number for this encoding
|
||||
type for encryption and checksumming respectively. They hold
|
||||
``KRB5_ENCTYPE_*`` and ``KRB5_CKSUMTYPE_*`` constants.
|
||||
|
||||
* ``name`` is the formal name of the encoding.
|
||||
|
||||
* ``key_len`` and ``key_bytes`` are the input key length and the derived key
|
||||
length. (I think they only differ for DES, which isn't supported here).
|
||||
|
||||
* ``Kc_len``, ``Ke_len`` and ``Ki_len`` are the sizes of the derived Kc, Ke
|
||||
and Ki keys. Kc is used for in checksum mode; Ke and Ki are used in
|
||||
encryption mode.
|
||||
|
||||
* ``prf_len`` is the size of the result from the PRF+ function calculation.
|
||||
|
||||
* ``block_len``, ``conf_len`` and ``cksum_len`` are the encryption block
|
||||
length, confounder length and checksum length respectively. All three are
|
||||
used in encryption mode, but only the checksum length is used in checksum
|
||||
mode.
|
||||
|
||||
The encoding type is looked up by number using the following function::
|
||||
|
||||
const struct krb5_enctype *crypto_krb5_find_enctype(u32 enctype);
|
||||
|
||||
Key Derivation
|
||||
==============
|
||||
|
||||
Once the application has selected an encryption type, the keys that will be
|
||||
used to do the actual crypto can be derived from the transport key.
|
||||
|
||||
PRF+ Calculation
|
||||
----------------
|
||||
|
||||
To aid in key derivation, a function to calculate the Kerberos GSSAPI
|
||||
mechanism's PRF+ is provided::
|
||||
|
||||
int crypto_krb5_calc_PRFplus(const struct krb5_enctype *krb5,
|
||||
const struct krb5_buffer *K,
|
||||
unsigned int L,
|
||||
const struct krb5_buffer *S,
|
||||
struct krb5_buffer *result,
|
||||
gfp_t gfp);
|
||||
|
||||
This can be used to derive the transport key from a source key plus additional
|
||||
data to limit its use.
|
||||
|
||||
Crypto Functions
|
||||
================
|
||||
|
||||
Once the keys have been derived, crypto can be performed on the data. The
|
||||
caller must leave gaps in the buffer for the storage of the confounder (if
|
||||
needed) and the checksum when preparing a message for transmission. An enum
|
||||
and a pair of functions are provided to aid in this::
|
||||
|
||||
enum krb5_crypto_mode {
|
||||
KRB5_CHECKSUM_MODE,
|
||||
KRB5_ENCRYPT_MODE,
|
||||
};
|
||||
|
||||
size_t crypto_krb5_how_much_buffer(const struct krb5_enctype *krb5,
|
||||
enum krb5_crypto_mode mode,
|
||||
size_t data_size, size_t *_offset);
|
||||
|
||||
size_t crypto_krb5_how_much_data(const struct krb5_enctype *krb5,
|
||||
enum krb5_crypto_mode mode,
|
||||
size_t *_buffer_size, size_t *_offset);
|
||||
|
||||
All these functions take the encoding type and an indication the mode of crypto
|
||||
(checksum-only or full encryption).
|
||||
|
||||
The first function returns how big the buffer will need to be to house a given
|
||||
amount of data; the second function returns how much data will fit in a buffer
|
||||
of a particular size, and adjusts down the size of the required buffer
|
||||
accordingly. In both cases, the offset of the data within the buffer is also
|
||||
returned.
|
||||
|
||||
When a message has been received, the location and size of the data with the
|
||||
message can be determined by calling::
|
||||
|
||||
void crypto_krb5_where_is_the_data(const struct krb5_enctype *krb5,
|
||||
enum krb5_crypto_mode mode,
|
||||
size_t *_offset, size_t *_len);
|
||||
|
||||
The caller provides the offset and length of the message to the function, which
|
||||
then alters those values to indicate the region containing the data (plus any
|
||||
padding). It is up to the caller to determine how much padding there is.
|
||||
|
||||
Preparation Functions
|
||||
---------------------
|
||||
|
||||
Two functions are provided to allocated and prepare a crypto object for use by
|
||||
the action functions::
|
||||
|
||||
struct crypto_aead *
|
||||
crypto_krb5_prepare_encryption(const struct krb5_enctype *krb5,
|
||||
const struct krb5_buffer *TK,
|
||||
u32 usage, gfp_t gfp);
|
||||
struct crypto_shash *
|
||||
crypto_krb5_prepare_checksum(const struct krb5_enctype *krb5,
|
||||
const struct krb5_buffer *TK,
|
||||
u32 usage, gfp_t gfp);
|
||||
|
||||
Both of these functions take the encoding type, the transport key and the usage
|
||||
value used to derive the appropriate subkey(s). They create an appropriate
|
||||
crypto object, an AEAD template for encryption and a synchronous hash for
|
||||
checksumming, set the key(s) on it and configure it. The caller is expected to
|
||||
pass these handles to the action functions below.
|
||||
|
||||
Encryption Mode
|
||||
---------------
|
||||
|
||||
A pair of functions are provided to encrypt and decrypt a message::
|
||||
|
||||
ssize_t crypto_krb5_encrypt(const struct krb5_enctype *krb5,
|
||||
struct crypto_aead *aead,
|
||||
struct scatterlist *sg, unsigned int nr_sg,
|
||||
size_t sg_len,
|
||||
size_t data_offset, size_t data_len,
|
||||
bool preconfounded);
|
||||
int crypto_krb5_decrypt(const struct krb5_enctype *krb5,
|
||||
struct crypto_aead *aead,
|
||||
struct scatterlist *sg, unsigned int nr_sg,
|
||||
size_t *_offset, size_t *_len);
|
||||
|
||||
In both cases, the input and output buffers are indicated by the same
|
||||
scatterlist.
|
||||
|
||||
For the encryption function, the output buffer may be larger than is needed
|
||||
(the amount of output generated is returned) and the location and size of the
|
||||
data are indicated (which must match the encoding). If no confounder is set,
|
||||
the function will insert one.
|
||||
|
||||
For the decryption function, the offset and length of the message in buffer are
|
||||
supplied and these are shrunk to fit the data. The decryption function will
|
||||
verify any checksums within the message and give an error if they don't match.
|
||||
|
||||
Checksum Mode
|
||||
-------------
|
||||
|
||||
A pair of function are provided to generate the checksum on a message and to
|
||||
verify that checksum::
|
||||
|
||||
ssize_t crypto_krb5_get_mic(const struct krb5_enctype *krb5,
|
||||
struct crypto_shash *shash,
|
||||
const struct krb5_buffer *metadata,
|
||||
struct scatterlist *sg, unsigned int nr_sg,
|
||||
size_t sg_len,
|
||||
size_t data_offset, size_t data_len);
|
||||
int crypto_krb5_verify_mic(const struct krb5_enctype *krb5,
|
||||
struct crypto_shash *shash,
|
||||
const struct krb5_buffer *metadata,
|
||||
struct scatterlist *sg, unsigned int nr_sg,
|
||||
size_t *_offset, size_t *_len);
|
||||
|
||||
In both cases, the input and output buffers are indicated by the same
|
||||
scatterlist. Additional metadata can be passed in which will get added to the
|
||||
hash before the data.
|
||||
|
||||
For the get_mic function, the output buffer may be larger than is needed (the
|
||||
amount of output generated is returned) and the location and size of the data
|
||||
are indicated (which must match the encoding).
|
||||
|
||||
For the verification function, the offset and length of the message in buffer
|
||||
are supplied and these are shrunk to fit the data. An error will be returned
|
||||
if the checksums don't match.
|
||||
|
||||
The krb5enc AEAD algorithm
|
||||
==========================
|
||||
|
||||
A template AEAD crypto algorithm, called "krb5enc", is provided that hashes the
|
||||
plaintext before encrypting it (the reverse of authenc). The handle returned
|
||||
by ``crypto_krb5_prepare_encryption()`` may be one of these, but there's no
|
||||
requirement for the user of this API to interact with it directly.
|
||||
|
||||
For reference, its key format begins with a BE32 of the format number. Only
|
||||
format 1 is provided and that continues with a BE32 of the Ke key length
|
||||
followed by a BE32 of the Ki key length, followed by the bytes from the Ke key
|
||||
and then the Ki key.
|
||||
|
||||
Using specifically ordered words means that the static test data doesn't
|
||||
require byteswapping.
|
||||
@@ -0,0 +1,144 @@
|
||||
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
|
||||
%YAML 1.2
|
||||
---
|
||||
$id: http://devicetree.org/schemas/crypto/fsl,sec2.0.yaml#
|
||||
$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
|
||||
title: Freescale SoC SEC Security Engines versions 1.x-2.x-3.x
|
||||
|
||||
maintainers:
|
||||
- J. Neuschäfer <j.ne@posteo.net>
|
||||
|
||||
properties:
|
||||
compatible:
|
||||
description:
|
||||
Should contain entries for this and backward compatible SEC versions,
|
||||
high to low. Warning - SEC1 and SEC2 are mutually exclusive.
|
||||
oneOf:
|
||||
- items:
|
||||
- const: fsl,sec3.3
|
||||
- const: fsl,sec3.1
|
||||
- const: fsl,sec3.0
|
||||
- const: fsl,sec2.4
|
||||
- const: fsl,sec2.2
|
||||
- const: fsl,sec2.1
|
||||
- const: fsl,sec2.0
|
||||
- items:
|
||||
- const: fsl,sec3.1
|
||||
- const: fsl,sec3.0
|
||||
- const: fsl,sec2.4
|
||||
- const: fsl,sec2.2
|
||||
- const: fsl,sec2.1
|
||||
- const: fsl,sec2.0
|
||||
- items:
|
||||
- const: fsl,sec3.0
|
||||
- const: fsl,sec2.4
|
||||
- const: fsl,sec2.2
|
||||
- const: fsl,sec2.1
|
||||
- const: fsl,sec2.0
|
||||
- items:
|
||||
- const: fsl,sec2.4
|
||||
- const: fsl,sec2.2
|
||||
- const: fsl,sec2.1
|
||||
- const: fsl,sec2.0
|
||||
- items:
|
||||
- const: fsl,sec2.2
|
||||
- const: fsl,sec2.1
|
||||
- const: fsl,sec2.0
|
||||
- items:
|
||||
- const: fsl,sec2.1
|
||||
- const: fsl,sec2.0
|
||||
- items:
|
||||
- const: fsl,sec2.0
|
||||
- items:
|
||||
- const: fsl,sec1.2
|
||||
- const: fsl,sec1.0
|
||||
- items:
|
||||
- const: fsl,sec1.0
|
||||
|
||||
reg:
|
||||
maxItems: 1
|
||||
|
||||
interrupts:
|
||||
maxItems: 1
|
||||
|
||||
fsl,num-channels:
|
||||
$ref: /schemas/types.yaml#/definitions/uint32
|
||||
enum: [ 1, 4 ]
|
||||
description: An integer representing the number of channels available.
|
||||
|
||||
fsl,channel-fifo-len:
|
||||
$ref: /schemas/types.yaml#/definitions/uint32
|
||||
maximum: 100
|
||||
description:
|
||||
An integer representing the number of descriptor pointers each channel
|
||||
fetch fifo can hold.
|
||||
|
||||
fsl,exec-units-mask:
|
||||
$ref: /schemas/types.yaml#/definitions/uint32
|
||||
maximum: 0xfff
|
||||
description: |
|
||||
The bitmask representing what execution units (EUs) are available.
|
||||
EU information should be encoded following the SEC's Descriptor Header
|
||||
Dword EU_SEL0 field documentation, i.e. as follows:
|
||||
|
||||
bit 0 = reserved - should be 0
|
||||
bit 1 = set if SEC has the ARC4 EU (AFEU)
|
||||
bit 2 = set if SEC has the DES/3DES EU (DEU)
|
||||
bit 3 = set if SEC has the message digest EU (MDEU/MDEU-A)
|
||||
bit 4 = set if SEC has the random number generator EU (RNG)
|
||||
bit 5 = set if SEC has the public key EU (PKEU)
|
||||
bit 6 = set if SEC has the AES EU (AESU)
|
||||
bit 7 = set if SEC has the Kasumi EU (KEU)
|
||||
bit 8 = set if SEC has the CRC EU (CRCU)
|
||||
bit 11 = set if SEC has the message digest EU extended alg set (MDEU-B)
|
||||
|
||||
remaining bits are reserved for future SEC EUs.
|
||||
|
||||
fsl,descriptor-types-mask:
|
||||
$ref: /schemas/types.yaml#/definitions/uint32
|
||||
description: |
|
||||
The bitmask representing what descriptors are available. Descriptor type
|
||||
information should be encoded following the SEC's Descriptor Header Dword
|
||||
DESC_TYPE field documentation, i.e. as follows:
|
||||
|
||||
bit 0 = SEC supports descriptor type aesu_ctr_nonsnoop
|
||||
bit 1 = SEC supports descriptor type ipsec_esp
|
||||
bit 2 = SEC supports descriptor type common_nonsnoop
|
||||
bit 3 = SEC supports descriptor type 802.11i AES ccmp
|
||||
bit 4 = SEC supports descriptor type hmac_snoop_no_afeu
|
||||
bit 5 = SEC supports descriptor type srtp
|
||||
bit 6 = SEC supports descriptor type non_hmac_snoop_no_afeu
|
||||
bit 7 = SEC supports descriptor type pkeu_assemble
|
||||
bit 8 = SEC supports descriptor type aesu_key_expand_output
|
||||
bit 9 = SEC supports descriptor type pkeu_ptmul
|
||||
bit 10 = SEC supports descriptor type common_nonsnoop_afeu
|
||||
bit 11 = SEC supports descriptor type pkeu_ptadd_dbl
|
||||
|
||||
..and so on and so forth.
|
||||
|
||||
required:
|
||||
- compatible
|
||||
- reg
|
||||
- fsl,num-channels
|
||||
- fsl,channel-fifo-len
|
||||
- fsl,exec-units-mask
|
||||
- fsl,descriptor-types-mask
|
||||
|
||||
unevaluatedProperties: false
|
||||
|
||||
examples:
|
||||
- |
|
||||
/* MPC8548E */
|
||||
crypto@30000 {
|
||||
compatible = "fsl,sec2.1", "fsl,sec2.0";
|
||||
reg = <0x30000 0x10000>;
|
||||
interrupts = <29 2>;
|
||||
interrupt-parent = <&mpic>;
|
||||
fsl,num-channels = <4>;
|
||||
fsl,channel-fifo-len = <24>;
|
||||
fsl,exec-units-mask = <0xfe>;
|
||||
fsl,descriptor-types-mask = <0x12b0ebf>;
|
||||
};
|
||||
|
||||
...
|
||||
@@ -1,65 +0,0 @@
|
||||
Freescale SoC SEC Security Engines versions 1.x-2.x-3.x
|
||||
|
||||
Required properties:
|
||||
|
||||
- compatible : Should contain entries for this and backward compatible
|
||||
SEC versions, high to low, e.g., "fsl,sec2.1", "fsl,sec2.0" (SEC2/3)
|
||||
e.g., "fsl,sec1.2", "fsl,sec1.0" (SEC1)
|
||||
warning: SEC1 and SEC2 are mutually exclusive
|
||||
- reg : Offset and length of the register set for the device
|
||||
- interrupts : the SEC's interrupt number
|
||||
- fsl,num-channels : An integer representing the number of channels
|
||||
available.
|
||||
- fsl,channel-fifo-len : An integer representing the number of
|
||||
descriptor pointers each channel fetch fifo can hold.
|
||||
- fsl,exec-units-mask : The bitmask representing what execution units
|
||||
(EUs) are available. It's a single 32-bit cell. EU information
|
||||
should be encoded following the SEC's Descriptor Header Dword
|
||||
EU_SEL0 field documentation, i.e. as follows:
|
||||
|
||||
bit 0 = reserved - should be 0
|
||||
bit 1 = set if SEC has the ARC4 EU (AFEU)
|
||||
bit 2 = set if SEC has the DES/3DES EU (DEU)
|
||||
bit 3 = set if SEC has the message digest EU (MDEU/MDEU-A)
|
||||
bit 4 = set if SEC has the random number generator EU (RNG)
|
||||
bit 5 = set if SEC has the public key EU (PKEU)
|
||||
bit 6 = set if SEC has the AES EU (AESU)
|
||||
bit 7 = set if SEC has the Kasumi EU (KEU)
|
||||
bit 8 = set if SEC has the CRC EU (CRCU)
|
||||
bit 11 = set if SEC has the message digest EU extended alg set (MDEU-B)
|
||||
|
||||
remaining bits are reserved for future SEC EUs.
|
||||
|
||||
- fsl,descriptor-types-mask : The bitmask representing what descriptors
|
||||
are available. It's a single 32-bit cell. Descriptor type information
|
||||
should be encoded following the SEC's Descriptor Header Dword DESC_TYPE
|
||||
field documentation, i.e. as follows:
|
||||
|
||||
bit 0 = set if SEC supports the aesu_ctr_nonsnoop desc. type
|
||||
bit 1 = set if SEC supports the ipsec_esp descriptor type
|
||||
bit 2 = set if SEC supports the common_nonsnoop desc. type
|
||||
bit 3 = set if SEC supports the 802.11i AES ccmp desc. type
|
||||
bit 4 = set if SEC supports the hmac_snoop_no_afeu desc. type
|
||||
bit 5 = set if SEC supports the srtp descriptor type
|
||||
bit 6 = set if SEC supports the non_hmac_snoop_no_afeu desc.type
|
||||
bit 7 = set if SEC supports the pkeu_assemble descriptor type
|
||||
bit 8 = set if SEC supports the aesu_key_expand_output desc.type
|
||||
bit 9 = set if SEC supports the pkeu_ptmul descriptor type
|
||||
bit 10 = set if SEC supports the common_nonsnoop_afeu desc. type
|
||||
bit 11 = set if SEC supports the pkeu_ptadd_dbl descriptor type
|
||||
|
||||
..and so on and so forth.
|
||||
|
||||
Example:
|
||||
|
||||
/* MPC8548E */
|
||||
crypto@30000 {
|
||||
compatible = "fsl,sec2.1", "fsl,sec2.0";
|
||||
reg = <0x30000 0x10000>;
|
||||
interrupts = <29 2>;
|
||||
interrupt-parent = <&mpic>;
|
||||
fsl,num-channels = <4>;
|
||||
fsl,channel-fifo-len = <24>;
|
||||
fsl,exec-units-mask = <0xfe>;
|
||||
fsl,descriptor-types-mask = <0x12b0ebf>;
|
||||
};
|
||||
@@ -0,0 +1,67 @@
|
||||
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
|
||||
%YAML 1.2
|
||||
---
|
||||
$id: http://devicetree.org/schemas/crypto/inside-secure,safexcel-eip93.yaml#
|
||||
$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
|
||||
title: Inside Secure SafeXcel EIP-93 cryptographic engine
|
||||
|
||||
maintainers:
|
||||
- Christian Marangi <ansuelsmth@gmail.com>
|
||||
|
||||
description: |
|
||||
The Inside Secure SafeXcel EIP-93 is a cryptographic engine IP block
|
||||
integrated in varios devices with very different and generic name from
|
||||
PKTE to simply vendor+EIP93. The real IP under the hood is actually
|
||||
developed by Inside Secure and given to license to vendors.
|
||||
|
||||
The IP block is sold with different model based on what feature are
|
||||
needed and are identified with the final letter. Each letter correspond
|
||||
to a specific set of feature and multiple letter reflect the sum of the
|
||||
feature set.
|
||||
|
||||
EIP-93 models:
|
||||
- EIP-93i: (basic) DES/Triple DES, AES, PRNG, IPsec ESP, SRTP, SHA1
|
||||
- EIP-93ie: i + SHA224/256, AES-192/256
|
||||
- EIP-93is: i + SSL/DTLS/DTLS, MD5, ARC4
|
||||
- EIP-93ies: i + e + s
|
||||
- EIP-93iw: i + AES-XCB-MAC, AES-CCM
|
||||
|
||||
properties:
|
||||
compatible:
|
||||
oneOf:
|
||||
- items:
|
||||
- const: airoha,en7581-eip93
|
||||
- const: inside-secure,safexcel-eip93ies
|
||||
- items:
|
||||
- not: {}
|
||||
description: Need a SoC specific compatible
|
||||
- enum:
|
||||
- inside-secure,safexcel-eip93i
|
||||
- inside-secure,safexcel-eip93ie
|
||||
- inside-secure,safexcel-eip93is
|
||||
- inside-secure,safexcel-eip93iw
|
||||
|
||||
reg:
|
||||
maxItems: 1
|
||||
|
||||
interrupts:
|
||||
maxItems: 1
|
||||
|
||||
required:
|
||||
- compatible
|
||||
- reg
|
||||
- interrupts
|
||||
|
||||
additionalProperties: false
|
||||
|
||||
examples:
|
||||
- |
|
||||
#include <dt-bindings/interrupt-controller/arm-gic.h>
|
||||
|
||||
crypto@1e004000 {
|
||||
compatible = "airoha,en7581-eip93", "inside-secure,safexcel-eip93ies";
|
||||
reg = <0x1fb70000 0x1000>;
|
||||
|
||||
interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>;
|
||||
};
|
||||
@@ -47,6 +47,8 @@ properties:
|
||||
- const: core
|
||||
- const: reg
|
||||
|
||||
dma-coherent: true
|
||||
|
||||
required:
|
||||
- reg
|
||||
- interrupts
|
||||
|
||||
@@ -20,6 +20,7 @@ properties:
|
||||
- qcom,ipq5332-trng
|
||||
- qcom,ipq5424-trng
|
||||
- qcom,ipq9574-trng
|
||||
- qcom,qcs615-trng
|
||||
- qcom,qcs8300-trng
|
||||
- qcom,sa8255p-trng
|
||||
- qcom,sa8775p-trng
|
||||
|
||||
@@ -55,6 +55,7 @@ properties:
|
||||
- qcom,sm8550-qce
|
||||
- qcom,sm8650-qce
|
||||
- qcom,sm8750-qce
|
||||
- qcom,x1e80100-qce
|
||||
- const: qcom,sm8150-qce
|
||||
- const: qcom,qce
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
|
||||
%YAML 1.2
|
||||
---
|
||||
$id: http://devicetree.org/schemas/rng/rockchip,rk3588-rng.yaml#
|
||||
$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
|
||||
title: Rockchip RK3588 TRNG
|
||||
|
||||
description: True Random Number Generator on Rockchip RK3588 SoC
|
||||
|
||||
maintainers:
|
||||
- Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
|
||||
|
||||
properties:
|
||||
compatible:
|
||||
enum:
|
||||
- rockchip,rk3588-rng
|
||||
|
||||
reg:
|
||||
maxItems: 1
|
||||
|
||||
clocks:
|
||||
items:
|
||||
- description: TRNG AHB clock
|
||||
|
||||
interrupts:
|
||||
maxItems: 1
|
||||
|
||||
resets:
|
||||
maxItems: 1
|
||||
|
||||
required:
|
||||
- compatible
|
||||
- reg
|
||||
- clocks
|
||||
- interrupts
|
||||
|
||||
additionalProperties: false
|
||||
|
||||
examples:
|
||||
- |
|
||||
#include <dt-bindings/clock/rockchip,rk3588-cru.h>
|
||||
#include <dt-bindings/interrupt-controller/arm-gic.h>
|
||||
#include <dt-bindings/interrupt-controller/irq.h>
|
||||
#include <dt-bindings/reset/rockchip,rk3588-cru.h>
|
||||
bus {
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
|
||||
rng@fe378000 {
|
||||
compatible = "rockchip,rk3588-rng";
|
||||
reg = <0x0 0xfe378000 0x0 0x200>;
|
||||
interrupts = <GIC_SPI 400 IRQ_TYPE_LEVEL_HIGH 0>;
|
||||
clocks = <&scmi_clk SCMI_HCLK_SECURE_NS>;
|
||||
resets = <&scmi_reset SCMI_SRST_H_TRNG_NS>;
|
||||
};
|
||||
};
|
||||
|
||||
...
|
||||
+39
@@ -3610,14 +3610,42 @@ F: drivers/hwmon/asus_wmi_sensors.c
|
||||
|
||||
ASYMMETRIC KEYS
|
||||
M: David Howells <dhowells@redhat.com>
|
||||
M: Lukas Wunner <lukas@wunner.de>
|
||||
M: Ignat Korchagin <ignat@cloudflare.com>
|
||||
L: keyrings@vger.kernel.org
|
||||
L: linux-crypto@vger.kernel.org
|
||||
S: Maintained
|
||||
F: Documentation/crypto/asymmetric-keys.rst
|
||||
F: crypto/asymmetric_keys/
|
||||
F: include/crypto/pkcs7.h
|
||||
F: include/crypto/public_key.h
|
||||
F: include/keys/asymmetric-*.h
|
||||
F: include/linux/verification.h
|
||||
|
||||
ASYMMETRIC KEYS - ECDSA
|
||||
M: Lukas Wunner <lukas@wunner.de>
|
||||
M: Ignat Korchagin <ignat@cloudflare.com>
|
||||
R: Stefan Berger <stefanb@linux.ibm.com>
|
||||
L: linux-crypto@vger.kernel.org
|
||||
S: Maintained
|
||||
F: crypto/ecc*
|
||||
F: crypto/ecdsa*
|
||||
F: include/crypto/ecc*
|
||||
|
||||
ASYMMETRIC KEYS - GOST
|
||||
M: Lukas Wunner <lukas@wunner.de>
|
||||
M: Ignat Korchagin <ignat@cloudflare.com>
|
||||
L: linux-crypto@vger.kernel.org
|
||||
S: Odd fixes
|
||||
F: crypto/ecrdsa*
|
||||
|
||||
ASYMMETRIC KEYS - RSA
|
||||
M: Lukas Wunner <lukas@wunner.de>
|
||||
M: Ignat Korchagin <ignat@cloudflare.com>
|
||||
L: linux-crypto@vger.kernel.org
|
||||
S: Maintained
|
||||
F: crypto/rsa*
|
||||
|
||||
ASYNCHRONOUS TRANSFERS/TRANSFORMS (IOAT) API
|
||||
R: Dan Williams <dan.j.williams@intel.com>
|
||||
S: Odd fixes
|
||||
@@ -11599,6 +11627,13 @@ L: linux-crypto@vger.kernel.org
|
||||
S: Maintained
|
||||
F: drivers/crypto/inside-secure/
|
||||
|
||||
INSIDE SECURE EIP93 CRYPTO DRIVER
|
||||
M: Christian Marangi <ansuelsmth@gmail.com>
|
||||
L: linux-crypto@vger.kernel.org
|
||||
S: Maintained
|
||||
F: Documentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml
|
||||
F: drivers/crypto/inside-secure/eip93/
|
||||
|
||||
INTEGRITY MEASUREMENT ARCHITECTURE (IMA)
|
||||
M: Mimi Zohar <zohar@linux.ibm.com>
|
||||
M: Roberto Sassu <roberto.sassu@huawei.com>
|
||||
@@ -11802,6 +11837,7 @@ F: drivers/dma/ioat*
|
||||
|
||||
INTEL IAA CRYPTO DRIVER
|
||||
M: Kristen Accardi <kristen.c.accardi@intel.com>
|
||||
M: Vinicius Costa Gomes <vinicius.gomes@intel.com>
|
||||
L: linux-crypto@vger.kernel.org
|
||||
S: Supported
|
||||
F: Documentation/driver-api/crypto/iaa/iaa-crypto.rst
|
||||
@@ -20675,8 +20711,10 @@ F: include/uapi/linux/rkisp1-config.h
|
||||
ROCKCHIP RK3568 RANDOM NUMBER GENERATOR SUPPORT
|
||||
M: Daniel Golle <daniel@makrotopia.org>
|
||||
M: Aurelien Jarno <aurelien@aurel32.net>
|
||||
M: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
|
||||
S: Maintained
|
||||
F: Documentation/devicetree/bindings/rng/rockchip,rk3568-rng.yaml
|
||||
F: Documentation/devicetree/bindings/rng/rockchip,rk3588-rng.yaml
|
||||
F: drivers/char/hw_random/rockchip-rng.c
|
||||
|
||||
ROCKCHIP RASTER 2D GRAPHIC ACCELERATION UNIT DRIVER
|
||||
@@ -26493,6 +26531,7 @@ F: mm/zsmalloc.c
|
||||
|
||||
ZSTD
|
||||
M: Nick Terrell <terrelln@fb.com>
|
||||
M: David Sterba <dsterba@suse.com>
|
||||
S: Maintained
|
||||
B: https://github.com/facebook/zstd/issues
|
||||
T: git https://github.com/terrelln/linux.git
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
menu "Accelerated Cryptographic Algorithms for CPU (arm)"
|
||||
|
||||
config CRYPTO_CURVE25519_NEON
|
||||
tristate "Public key crypto: Curve25519 (NEON)"
|
||||
tristate
|
||||
depends on KERNEL_MODE_NEON
|
||||
select CRYPTO_KPP
|
||||
select CRYPTO_LIB_CURVE25519_GENERIC
|
||||
select CRYPTO_ARCH_HAVE_LIB_CURVE25519
|
||||
default CRYPTO_LIB_CURVE25519_INTERNAL
|
||||
help
|
||||
Curve25519 algorithm
|
||||
|
||||
@@ -45,9 +47,10 @@ config CRYPTO_NHPOLY1305_NEON
|
||||
- NEON (Advanced SIMD) extensions
|
||||
|
||||
config CRYPTO_POLY1305_ARM
|
||||
tristate "Hash functions: Poly1305 (NEON)"
|
||||
tristate
|
||||
select CRYPTO_HASH
|
||||
select CRYPTO_ARCH_HAVE_LIB_POLY1305
|
||||
default CRYPTO_LIB_POLY1305_INTERNAL
|
||||
help
|
||||
Poly1305 authenticator algorithm (RFC7539)
|
||||
|
||||
@@ -212,9 +215,10 @@ config CRYPTO_AES_ARM_CE
|
||||
- ARMv8 Crypto Extensions
|
||||
|
||||
config CRYPTO_CHACHA20_NEON
|
||||
tristate "Ciphers: ChaCha20, XChaCha20, XChaCha12 (NEON)"
|
||||
tristate
|
||||
select CRYPTO_SKCIPHER
|
||||
select CRYPTO_ARCH_HAVE_LIB_CHACHA
|
||||
default CRYPTO_LIB_CHACHA_INTERNAL
|
||||
help
|
||||
Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12
|
||||
stream cipher algorithms
|
||||
|
||||
@@ -399,9 +399,9 @@ static int ctr_encrypt(struct skcipher_request *req)
|
||||
}
|
||||
if (walk.nbytes) {
|
||||
u8 __aligned(8) tail[AES_BLOCK_SIZE];
|
||||
const u8 *tsrc = walk.src.virt.addr;
|
||||
unsigned int nbytes = walk.nbytes;
|
||||
u8 *tdst = walk.dst.virt.addr;
|
||||
u8 *tsrc = walk.src.virt.addr;
|
||||
|
||||
/*
|
||||
* Tell aes_ctr_encrypt() to process a tail block.
|
||||
|
||||
@@ -76,12 +76,6 @@ void hchacha_block_arch(const u32 *state, u32 *stream, int nrounds)
|
||||
}
|
||||
EXPORT_SYMBOL(hchacha_block_arch);
|
||||
|
||||
void chacha_init_arch(u32 *state, const u32 *key, const u8 *iv)
|
||||
{
|
||||
chacha_init_generic(state, key, iv);
|
||||
}
|
||||
EXPORT_SYMBOL(chacha_init_arch);
|
||||
|
||||
void chacha_crypt_arch(u32 *state, u8 *dst, const u8 *src, unsigned int bytes,
|
||||
int nrounds)
|
||||
{
|
||||
@@ -116,7 +110,7 @@ static int chacha_stream_xor(struct skcipher_request *req,
|
||||
|
||||
err = skcipher_walk_virt(&walk, req, false);
|
||||
|
||||
chacha_init_generic(state, ctx->key, iv);
|
||||
chacha_init(state, ctx->key, iv);
|
||||
|
||||
while (walk.nbytes > 0) {
|
||||
unsigned int nbytes = walk.nbytes;
|
||||
@@ -166,7 +160,7 @@ static int do_xchacha(struct skcipher_request *req, bool neon)
|
||||
u32 state[16];
|
||||
u8 real_iv[16];
|
||||
|
||||
chacha_init_generic(state, ctx->key, req->iv);
|
||||
chacha_init(state, ctx->key, req->iv);
|
||||
|
||||
if (!IS_ENABLED(CONFIG_KERNEL_MODE_NEON) || !neon) {
|
||||
hchacha_block_arm(state, subctx.key, ctx->nrounds);
|
||||
|
||||
+12
-201
@@ -55,10 +55,6 @@ struct ghash_desc_ctx {
|
||||
u32 count;
|
||||
};
|
||||
|
||||
struct ghash_async_ctx {
|
||||
struct cryptd_ahash *cryptd_tfm;
|
||||
};
|
||||
|
||||
asmlinkage void pmull_ghash_update_p64(int blocks, u64 dg[], const char *src,
|
||||
u64 const h[][2], const char *head);
|
||||
|
||||
@@ -78,34 +74,12 @@ static int ghash_init(struct shash_desc *desc)
|
||||
static void ghash_do_update(int blocks, u64 dg[], const char *src,
|
||||
struct ghash_key *key, const char *head)
|
||||
{
|
||||
if (likely(crypto_simd_usable())) {
|
||||
kernel_neon_begin();
|
||||
if (static_branch_likely(&use_p64))
|
||||
pmull_ghash_update_p64(blocks, dg, src, key->h, head);
|
||||
else
|
||||
pmull_ghash_update_p8(blocks, dg, src, key->h, head);
|
||||
kernel_neon_end();
|
||||
} else {
|
||||
be128 dst = { cpu_to_be64(dg[1]), cpu_to_be64(dg[0]) };
|
||||
|
||||
do {
|
||||
const u8 *in = src;
|
||||
|
||||
if (head) {
|
||||
in = head;
|
||||
blocks++;
|
||||
head = NULL;
|
||||
} else {
|
||||
src += GHASH_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
crypto_xor((u8 *)&dst, in, GHASH_BLOCK_SIZE);
|
||||
gf128mul_lle(&dst, &key->k);
|
||||
} while (--blocks);
|
||||
|
||||
dg[0] = be64_to_cpu(dst.b);
|
||||
dg[1] = be64_to_cpu(dst.a);
|
||||
}
|
||||
kernel_neon_begin();
|
||||
if (static_branch_likely(&use_p64))
|
||||
pmull_ghash_update_p64(blocks, dg, src, key->h, head);
|
||||
else
|
||||
pmull_ghash_update_p8(blocks, dg, src, key->h, head);
|
||||
kernel_neon_end();
|
||||
}
|
||||
|
||||
static int ghash_update(struct shash_desc *desc, const u8 *src,
|
||||
@@ -206,162 +180,13 @@ static struct shash_alg ghash_alg = {
|
||||
.descsize = sizeof(struct ghash_desc_ctx),
|
||||
|
||||
.base.cra_name = "ghash",
|
||||
.base.cra_driver_name = "ghash-ce-sync",
|
||||
.base.cra_priority = 300 - 1,
|
||||
.base.cra_driver_name = "ghash-ce",
|
||||
.base.cra_priority = 300,
|
||||
.base.cra_blocksize = GHASH_BLOCK_SIZE,
|
||||
.base.cra_ctxsize = sizeof(struct ghash_key) + sizeof(u64[2]),
|
||||
.base.cra_module = THIS_MODULE,
|
||||
};
|
||||
|
||||
static int ghash_async_init(struct ahash_request *req)
|
||||
{
|
||||
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
|
||||
struct ghash_async_ctx *ctx = crypto_ahash_ctx(tfm);
|
||||
struct ahash_request *cryptd_req = ahash_request_ctx(req);
|
||||
struct cryptd_ahash *cryptd_tfm = ctx->cryptd_tfm;
|
||||
struct shash_desc *desc = cryptd_shash_desc(cryptd_req);
|
||||
struct crypto_shash *child = cryptd_ahash_child(cryptd_tfm);
|
||||
|
||||
desc->tfm = child;
|
||||
return crypto_shash_init(desc);
|
||||
}
|
||||
|
||||
static int ghash_async_update(struct ahash_request *req)
|
||||
{
|
||||
struct ahash_request *cryptd_req = ahash_request_ctx(req);
|
||||
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
|
||||
struct ghash_async_ctx *ctx = crypto_ahash_ctx(tfm);
|
||||
struct cryptd_ahash *cryptd_tfm = ctx->cryptd_tfm;
|
||||
|
||||
if (!crypto_simd_usable() ||
|
||||
(in_atomic() && cryptd_ahash_queued(cryptd_tfm))) {
|
||||
memcpy(cryptd_req, req, sizeof(*req));
|
||||
ahash_request_set_tfm(cryptd_req, &cryptd_tfm->base);
|
||||
return crypto_ahash_update(cryptd_req);
|
||||
} else {
|
||||
struct shash_desc *desc = cryptd_shash_desc(cryptd_req);
|
||||
return shash_ahash_update(req, desc);
|
||||
}
|
||||
}
|
||||
|
||||
static int ghash_async_final(struct ahash_request *req)
|
||||
{
|
||||
struct ahash_request *cryptd_req = ahash_request_ctx(req);
|
||||
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
|
||||
struct ghash_async_ctx *ctx = crypto_ahash_ctx(tfm);
|
||||
struct cryptd_ahash *cryptd_tfm = ctx->cryptd_tfm;
|
||||
|
||||
if (!crypto_simd_usable() ||
|
||||
(in_atomic() && cryptd_ahash_queued(cryptd_tfm))) {
|
||||
memcpy(cryptd_req, req, sizeof(*req));
|
||||
ahash_request_set_tfm(cryptd_req, &cryptd_tfm->base);
|
||||
return crypto_ahash_final(cryptd_req);
|
||||
} else {
|
||||
struct shash_desc *desc = cryptd_shash_desc(cryptd_req);
|
||||
return crypto_shash_final(desc, req->result);
|
||||
}
|
||||
}
|
||||
|
||||
static int ghash_async_digest(struct ahash_request *req)
|
||||
{
|
||||
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
|
||||
struct ghash_async_ctx *ctx = crypto_ahash_ctx(tfm);
|
||||
struct ahash_request *cryptd_req = ahash_request_ctx(req);
|
||||
struct cryptd_ahash *cryptd_tfm = ctx->cryptd_tfm;
|
||||
|
||||
if (!crypto_simd_usable() ||
|
||||
(in_atomic() && cryptd_ahash_queued(cryptd_tfm))) {
|
||||
memcpy(cryptd_req, req, sizeof(*req));
|
||||
ahash_request_set_tfm(cryptd_req, &cryptd_tfm->base);
|
||||
return crypto_ahash_digest(cryptd_req);
|
||||
} else {
|
||||
struct shash_desc *desc = cryptd_shash_desc(cryptd_req);
|
||||
struct crypto_shash *child = cryptd_ahash_child(cryptd_tfm);
|
||||
|
||||
desc->tfm = child;
|
||||
return shash_ahash_digest(req, desc);
|
||||
}
|
||||
}
|
||||
|
||||
static int ghash_async_import(struct ahash_request *req, const void *in)
|
||||
{
|
||||
struct ahash_request *cryptd_req = ahash_request_ctx(req);
|
||||
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
|
||||
struct ghash_async_ctx *ctx = crypto_ahash_ctx(tfm);
|
||||
struct shash_desc *desc = cryptd_shash_desc(cryptd_req);
|
||||
|
||||
desc->tfm = cryptd_ahash_child(ctx->cryptd_tfm);
|
||||
|
||||
return crypto_shash_import(desc, in);
|
||||
}
|
||||
|
||||
static int ghash_async_export(struct ahash_request *req, void *out)
|
||||
{
|
||||
struct ahash_request *cryptd_req = ahash_request_ctx(req);
|
||||
struct shash_desc *desc = cryptd_shash_desc(cryptd_req);
|
||||
|
||||
return crypto_shash_export(desc, out);
|
||||
}
|
||||
|
||||
static int ghash_async_setkey(struct crypto_ahash *tfm, const u8 *key,
|
||||
unsigned int keylen)
|
||||
{
|
||||
struct ghash_async_ctx *ctx = crypto_ahash_ctx(tfm);
|
||||
struct crypto_ahash *child = &ctx->cryptd_tfm->base;
|
||||
|
||||
crypto_ahash_clear_flags(child, CRYPTO_TFM_REQ_MASK);
|
||||
crypto_ahash_set_flags(child, crypto_ahash_get_flags(tfm)
|
||||
& CRYPTO_TFM_REQ_MASK);
|
||||
return crypto_ahash_setkey(child, key, keylen);
|
||||
}
|
||||
|
||||
static int ghash_async_init_tfm(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct cryptd_ahash *cryptd_tfm;
|
||||
struct ghash_async_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||
|
||||
cryptd_tfm = cryptd_alloc_ahash("ghash-ce-sync", 0, 0);
|
||||
if (IS_ERR(cryptd_tfm))
|
||||
return PTR_ERR(cryptd_tfm);
|
||||
ctx->cryptd_tfm = cryptd_tfm;
|
||||
crypto_ahash_set_reqsize(__crypto_ahash_cast(tfm),
|
||||
sizeof(struct ahash_request) +
|
||||
crypto_ahash_reqsize(&cryptd_tfm->base));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ghash_async_exit_tfm(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct ghash_async_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||
|
||||
cryptd_free_ahash(ctx->cryptd_tfm);
|
||||
}
|
||||
|
||||
static struct ahash_alg ghash_async_alg = {
|
||||
.init = ghash_async_init,
|
||||
.update = ghash_async_update,
|
||||
.final = ghash_async_final,
|
||||
.setkey = ghash_async_setkey,
|
||||
.digest = ghash_async_digest,
|
||||
.import = ghash_async_import,
|
||||
.export = ghash_async_export,
|
||||
.halg.digestsize = GHASH_DIGEST_SIZE,
|
||||
.halg.statesize = sizeof(struct ghash_desc_ctx),
|
||||
.halg.base = {
|
||||
.cra_name = "ghash",
|
||||
.cra_driver_name = "ghash-ce",
|
||||
.cra_priority = 300,
|
||||
.cra_flags = CRYPTO_ALG_ASYNC,
|
||||
.cra_blocksize = GHASH_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct ghash_async_ctx),
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_init = ghash_async_init_tfm,
|
||||
.cra_exit = ghash_async_exit_tfm,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
void pmull_gcm_encrypt(int blocks, u64 dg[], const char *src,
|
||||
struct gcm_key const *k, char *dst,
|
||||
const char *iv, int rounds, u32 counter);
|
||||
@@ -459,17 +284,11 @@ static void gcm_calculate_auth_mac(struct aead_request *req, u64 dg[], u32 len)
|
||||
scatterwalk_start(&walk, req->src);
|
||||
|
||||
do {
|
||||
u32 n = scatterwalk_clamp(&walk, len);
|
||||
u8 *p;
|
||||
unsigned int n;
|
||||
|
||||
if (!n) {
|
||||
scatterwalk_start(&walk, sg_next(walk.sg));
|
||||
n = scatterwalk_clamp(&walk, len);
|
||||
}
|
||||
|
||||
p = scatterwalk_map(&walk);
|
||||
gcm_update_mac(dg, p, n, buf, &buf_count, ctx);
|
||||
scatterwalk_unmap(p);
|
||||
n = scatterwalk_next(&walk, len);
|
||||
gcm_update_mac(dg, walk.addr, n, buf, &buf_count, ctx);
|
||||
scatterwalk_done_src(&walk, n);
|
||||
|
||||
if (unlikely(len / SZ_4K > (len - n) / SZ_4K)) {
|
||||
kernel_neon_end();
|
||||
@@ -477,8 +296,6 @@ static void gcm_calculate_auth_mac(struct aead_request *req, u64 dg[], u32 len)
|
||||
}
|
||||
|
||||
len -= n;
|
||||
scatterwalk_advance(&walk, n);
|
||||
scatterwalk_done(&walk, 0, len);
|
||||
} while (len);
|
||||
|
||||
if (buf_count) {
|
||||
@@ -767,14 +584,9 @@ static int __init ghash_ce_mod_init(void)
|
||||
err = crypto_register_shash(&ghash_alg);
|
||||
if (err)
|
||||
goto err_aead;
|
||||
err = crypto_register_ahash(&ghash_async_alg);
|
||||
if (err)
|
||||
goto err_shash;
|
||||
|
||||
return 0;
|
||||
|
||||
err_shash:
|
||||
crypto_unregister_shash(&ghash_alg);
|
||||
err_aead:
|
||||
if (elf_hwcap2 & HWCAP2_PMULL)
|
||||
crypto_unregister_aeads(gcm_aes_algs,
|
||||
@@ -784,7 +596,6 @@ err_aead:
|
||||
|
||||
static void __exit ghash_ce_mod_exit(void)
|
||||
{
|
||||
crypto_unregister_ahash(&ghash_async_alg);
|
||||
crypto_unregister_shash(&ghash_alg);
|
||||
if (elf_hwcap2 & HWCAP2_PMULL)
|
||||
crypto_unregister_aeads(gcm_aes_algs,
|
||||
|
||||
@@ -26,10 +26,11 @@ config CRYPTO_NHPOLY1305_NEON
|
||||
- NEON (Advanced SIMD) extensions
|
||||
|
||||
config CRYPTO_POLY1305_NEON
|
||||
tristate "Hash functions: Poly1305 (NEON)"
|
||||
tristate
|
||||
depends on KERNEL_MODE_NEON
|
||||
select CRYPTO_HASH
|
||||
select CRYPTO_ARCH_HAVE_LIB_POLY1305
|
||||
default CRYPTO_LIB_POLY1305_INTERNAL
|
||||
help
|
||||
Poly1305 authenticator algorithm (RFC7539)
|
||||
|
||||
@@ -186,11 +187,12 @@ config CRYPTO_AES_ARM64_NEON_BLK
|
||||
- NEON (Advanced SIMD) extensions
|
||||
|
||||
config CRYPTO_CHACHA20_NEON
|
||||
tristate "Ciphers: ChaCha (NEON)"
|
||||
tristate
|
||||
depends on KERNEL_MODE_NEON
|
||||
select CRYPTO_SKCIPHER
|
||||
select CRYPTO_LIB_CHACHA_GENERIC
|
||||
select CRYPTO_ARCH_HAVE_LIB_CHACHA
|
||||
default CRYPTO_LIB_CHACHA_INTERNAL
|
||||
help
|
||||
Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12
|
||||
stream cipher algorithms
|
||||
|
||||
@@ -156,23 +156,13 @@ static void ccm_calculate_auth_mac(struct aead_request *req, u8 mac[])
|
||||
scatterwalk_start(&walk, req->src);
|
||||
|
||||
do {
|
||||
u32 n = scatterwalk_clamp(&walk, len);
|
||||
u8 *p;
|
||||
|
||||
if (!n) {
|
||||
scatterwalk_start(&walk, sg_next(walk.sg));
|
||||
n = scatterwalk_clamp(&walk, len);
|
||||
}
|
||||
p = scatterwalk_map(&walk);
|
||||
|
||||
macp = ce_aes_ccm_auth_data(mac, p, n, macp, ctx->key_enc,
|
||||
num_rounds(ctx));
|
||||
unsigned int n;
|
||||
|
||||
n = scatterwalk_next(&walk, len);
|
||||
macp = ce_aes_ccm_auth_data(mac, walk.addr, n, macp,
|
||||
ctx->key_enc, num_rounds(ctx));
|
||||
scatterwalk_done_src(&walk, n);
|
||||
len -= n;
|
||||
|
||||
scatterwalk_unmap(p);
|
||||
scatterwalk_advance(&walk, n);
|
||||
scatterwalk_done(&walk, 0, len);
|
||||
} while (len);
|
||||
}
|
||||
|
||||
|
||||
@@ -287,7 +287,8 @@ static int __xts_crypt(struct skcipher_request *req, bool encrypt,
|
||||
struct skcipher_walk walk;
|
||||
int nbytes, err;
|
||||
int first = 1;
|
||||
u8 *out, *in;
|
||||
const u8 *in;
|
||||
u8 *out;
|
||||
|
||||
if (req->cryptlen < AES_BLOCK_SIZE)
|
||||
return -EINVAL;
|
||||
|
||||
@@ -74,12 +74,6 @@ void hchacha_block_arch(const u32 *state, u32 *stream, int nrounds)
|
||||
}
|
||||
EXPORT_SYMBOL(hchacha_block_arch);
|
||||
|
||||
void chacha_init_arch(u32 *state, const u32 *key, const u8 *iv)
|
||||
{
|
||||
chacha_init_generic(state, key, iv);
|
||||
}
|
||||
EXPORT_SYMBOL(chacha_init_arch);
|
||||
|
||||
void chacha_crypt_arch(u32 *state, u8 *dst, const u8 *src, unsigned int bytes,
|
||||
int nrounds)
|
||||
{
|
||||
@@ -110,7 +104,7 @@ static int chacha_neon_stream_xor(struct skcipher_request *req,
|
||||
|
||||
err = skcipher_walk_virt(&walk, req, false);
|
||||
|
||||
chacha_init_generic(state, ctx->key, iv);
|
||||
chacha_init(state, ctx->key, iv);
|
||||
|
||||
while (walk.nbytes > 0) {
|
||||
unsigned int nbytes = walk.nbytes;
|
||||
@@ -151,7 +145,7 @@ static int xchacha_neon(struct skcipher_request *req)
|
||||
u32 state[16];
|
||||
u8 real_iv[16];
|
||||
|
||||
chacha_init_generic(state, ctx->key, req->iv);
|
||||
chacha_init(state, ctx->key, req->iv);
|
||||
hchacha_block_arch(state, subctx.key, ctx->nrounds);
|
||||
subctx.nrounds = ctx->nrounds;
|
||||
|
||||
|
||||
@@ -308,21 +308,12 @@ static void gcm_calculate_auth_mac(struct aead_request *req, u64 dg[], u32 len)
|
||||
scatterwalk_start(&walk, req->src);
|
||||
|
||||
do {
|
||||
u32 n = scatterwalk_clamp(&walk, len);
|
||||
u8 *p;
|
||||
unsigned int n;
|
||||
|
||||
if (!n) {
|
||||
scatterwalk_start(&walk, sg_next(walk.sg));
|
||||
n = scatterwalk_clamp(&walk, len);
|
||||
}
|
||||
p = scatterwalk_map(&walk);
|
||||
|
||||
gcm_update_mac(dg, p, n, buf, &buf_count, ctx);
|
||||
n = scatterwalk_next(&walk, len);
|
||||
gcm_update_mac(dg, walk.addr, n, buf, &buf_count, ctx);
|
||||
scatterwalk_done_src(&walk, n);
|
||||
len -= n;
|
||||
|
||||
scatterwalk_unmap(p);
|
||||
scatterwalk_advance(&walk, n);
|
||||
scatterwalk_done(&walk, 0, len);
|
||||
} while (len);
|
||||
|
||||
if (buf_count) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user