Path: blob/master/lib/crypto/riscv/aes-riscv64-zvkned.S
121811 views
/* SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause */1//2// This file is dual-licensed, meaning that you can use it under your3// choice of either of the following two licenses:4//5// Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.6//7// Licensed under the Apache License 2.0 (the "License"). You can obtain8// a copy in the file LICENSE in the source distribution or at9// https://www.openssl.org/source/license.html10//11// or12//13// Copyright (c) 2023, Christoph Müllner <christoph.muellner@vrull.eu>14// Copyright (c) 2023, Phoebe Chen <phoebe.chen@sifive.com>15// Copyright (c) 2023, Jerry Shih <jerry.shih@sifive.com>16// Copyright 2024 Google LLC17// All rights reserved.18//19// Redistribution and use in source and binary forms, with or without20// modification, are permitted provided that the following conditions21// are met:22// 1. Redistributions of source code must retain the above copyright23// notice, this list of conditions and the following disclaimer.24// 2. Redistributions in binary form must reproduce the above copyright25// notice, this list of conditions and the following disclaimer in the26// documentation and/or other materials provided with the distribution.27//28// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS29// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT30// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR31// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT32// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,33// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT34// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,35// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY36// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT37// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE38// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.3940// The generated code of this file depends on the following RISC-V extensions:41// - RV64I42// - RISC-V Vector ('V') with VLEN >= 12843// - RISC-V Vector AES block cipher extension ('Zvkned')4445#include <linux/linkage.h>4647.text48.option arch, +zvkned4950#include "../../arch/riscv/crypto/aes-macros.S"5152#define RNDKEYS a053#define KEY_LEN a154#define OUTP a255#define INP a35657.macro __aes_crypt_zvkned enc, keybits58vle32.v v16, (INP)59aes_crypt v16, \enc, \keybits60vse32.v v16, (OUTP)61ret62.endm6364.macro aes_crypt_zvkned enc65aes_begin RNDKEYS, 128f, 192f, KEY_LEN66__aes_crypt_zvkned \enc, 25667128:68__aes_crypt_zvkned \enc, 12869192:70__aes_crypt_zvkned \enc, 19271.endm7273// void aes_encrypt_zvkned(const u32 rndkeys[], int key_len,74// u8 out[AES_BLOCK_SIZE], const u8 in[AES_BLOCK_SIZE]);75SYM_FUNC_START(aes_encrypt_zvkned)76aes_crypt_zvkned 177SYM_FUNC_END(aes_encrypt_zvkned)7879// void aes_decrypt_zvkned(const u32 rndkeys[], int key_len,80// u8 out[AES_BLOCK_SIZE], const u8 in[AES_BLOCK_SIZE]);81SYM_FUNC_START(aes_decrypt_zvkned)82aes_crypt_zvkned 083SYM_FUNC_END(aes_decrypt_zvkned)848586