Debian Codegraph @

lib/crypto/riscv/aes-riscv64-zvkned.S

raw
1 /* SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause */
2 //
3 // This file is dual-licensed, meaning that you can use it under your
4 // choice of either of the following two licenses:
5 //
6 // Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.
7 //
8 // Licensed under the Apache License 2.0 (the "License"). You can obtain
9 // a copy in the file LICENSE in the source distribution or at
10 // https://www.openssl.org/source/license.html
11 //
12 // or
13 //
14 // Copyright (c) 2023, Christoph Müllner <[email protected]>
15 // Copyright (c) 2023, Phoebe Chen <[email protected]>
16 // Copyright (c) 2023, Jerry Shih <[email protected]>
17 // Copyright 2024 Google LLC
18 // All rights reserved.
19 //
20 // Redistribution and use in source and binary forms, with or without
21 // modification, are permitted provided that the following conditions
22 // are met:
23 // 1. Redistributions of source code must retain the above copyright
24 // notice, this list of conditions and the following disclaimer.
25 // 2. Redistributions in binary form must reproduce the above copyright
26 // notice, this list of conditions and the following disclaimer in the
27 // documentation and/or other materials provided with the distribution.
28 //
29 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40
41 // The generated code of this file depends on the following RISC-V extensions:
42 // - RV64I
43 // - RISC-V Vector ('V') with VLEN >= 128
44 // - RISC-V Vector AES block cipher extension ('Zvkned')
45
46 #include <linux/linkage.h>
47
48 .text
49 .option arch, +zvkned
50
51 #include "../../arch/riscv/crypto/aes-macros.S"
52
53 #define RNDKEYS a0
54 #define KEY_LEN a1
55 #define OUTP a2
56 #define INP a3
57
58 .macro __aes_crypt_zvkned enc, keybits
59 vle32.v v16, (INP)
60 aes_crypt v16, \enc, \keybits
61 vse32.v v16, (OUTP)
62 ret
63 .endm
64
65 .macro aes_crypt_zvkned enc
66 aes_begin RNDKEYS, 128f, 192f, KEY_LEN
67 __aes_crypt_zvkned \enc, 256
68 128:
69 __aes_crypt_zvkned \enc, 128
70 192:
71 __aes_crypt_zvkned \enc, 192
72 .endm
73
74 // void aes_encrypt_zvkned(const u32 rndkeys[], int key_len,
75 // u8 out[AES_BLOCK_SIZE], const u8 in[AES_BLOCK_SIZE]);
76 SYM_FUNC_START(aes_encrypt_zvkned)
77 aes_crypt_zvkned 1
78 SYM_FUNC_END(aes_encrypt_zvkned)
79
80 // void aes_decrypt_zvkned(const u32 rndkeys[], int key_len,
81 // u8 out[AES_BLOCK_SIZE], const u8 in[AES_BLOCK_SIZE]);
82 SYM_FUNC_START(aes_decrypt_zvkned)
83 aes_crypt_zvkned 0
84 SYM_FUNC_END(aes_decrypt_zvkned)