| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Glue code for the SHA256 Secure Hash Algorithm assembly implementation |
|---|
| 3 | 4 | * using NEON instructions. |
|---|
| .. | .. |
|---|
| 6 | 7 | * |
|---|
| 7 | 8 | * This file is based on sha512_neon_glue.c: |
|---|
| 8 | 9 | * Copyright © 2014 Jussi Kivilinna <jussi.kivilinna@iki.fi> |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 11 | | - * under the terms of the GNU General Public License as published by the Free |
|---|
| 12 | | - * Software Foundation; either version 2 of the License, or (at your option) |
|---|
| 13 | | - * any later version. |
|---|
| 14 | | - * |
|---|
| 15 | 10 | */ |
|---|
| 16 | 11 | |
|---|
| 17 | 12 | #include <crypto/internal/hash.h> |
|---|
| 18 | | -#include <linux/cryptohash.h> |
|---|
| 13 | +#include <crypto/internal/simd.h> |
|---|
| 19 | 14 | #include <linux/types.h> |
|---|
| 20 | 15 | #include <linux/string.h> |
|---|
| 21 | 16 | #include <crypto/sha.h> |
|---|
| .. | .. |
|---|
| 29 | 24 | asmlinkage void sha256_block_data_order_neon(u32 *digest, const void *data, |
|---|
| 30 | 25 | unsigned int num_blks); |
|---|
| 31 | 26 | |
|---|
| 32 | | -static int sha256_update(struct shash_desc *desc, const u8 *data, |
|---|
| 33 | | - unsigned int len) |
|---|
| 27 | +static int crypto_sha256_neon_update(struct shash_desc *desc, const u8 *data, |
|---|
| 28 | + unsigned int len) |
|---|
| 34 | 29 | { |
|---|
| 35 | 30 | struct sha256_state *sctx = shash_desc_ctx(desc); |
|---|
| 36 | 31 | |
|---|
| 37 | | - if (!may_use_simd() || |
|---|
| 32 | + if (!crypto_simd_usable() || |
|---|
| 38 | 33 | (sctx->count % SHA256_BLOCK_SIZE) + len < SHA256_BLOCK_SIZE) |
|---|
| 39 | 34 | return crypto_sha256_arm_update(desc, data, len); |
|---|
| 40 | 35 | |
|---|
| .. | .. |
|---|
| 46 | 41 | return 0; |
|---|
| 47 | 42 | } |
|---|
| 48 | 43 | |
|---|
| 49 | | -static int sha256_finup(struct shash_desc *desc, const u8 *data, |
|---|
| 50 | | - unsigned int len, u8 *out) |
|---|
| 44 | +static int crypto_sha256_neon_finup(struct shash_desc *desc, const u8 *data, |
|---|
| 45 | + unsigned int len, u8 *out) |
|---|
| 51 | 46 | { |
|---|
| 52 | | - if (!may_use_simd()) |
|---|
| 47 | + if (!crypto_simd_usable()) |
|---|
| 53 | 48 | return crypto_sha256_arm_finup(desc, data, len, out); |
|---|
| 54 | 49 | |
|---|
| 55 | 50 | kernel_neon_begin(); |
|---|
| .. | .. |
|---|
| 63 | 58 | return sha256_base_finish(desc, out); |
|---|
| 64 | 59 | } |
|---|
| 65 | 60 | |
|---|
| 66 | | -static int sha256_final(struct shash_desc *desc, u8 *out) |
|---|
| 61 | +static int crypto_sha256_neon_final(struct shash_desc *desc, u8 *out) |
|---|
| 67 | 62 | { |
|---|
| 68 | | - return sha256_finup(desc, NULL, 0, out); |
|---|
| 63 | + return crypto_sha256_neon_finup(desc, NULL, 0, out); |
|---|
| 69 | 64 | } |
|---|
| 70 | 65 | |
|---|
| 71 | 66 | struct shash_alg sha256_neon_algs[] = { { |
|---|
| 72 | 67 | .digestsize = SHA256_DIGEST_SIZE, |
|---|
| 73 | 68 | .init = sha256_base_init, |
|---|
| 74 | | - .update = sha256_update, |
|---|
| 75 | | - .final = sha256_final, |
|---|
| 76 | | - .finup = sha256_finup, |
|---|
| 69 | + .update = crypto_sha256_neon_update, |
|---|
| 70 | + .final = crypto_sha256_neon_final, |
|---|
| 71 | + .finup = crypto_sha256_neon_finup, |
|---|
| 77 | 72 | .descsize = sizeof(struct sha256_state), |
|---|
| 78 | 73 | .base = { |
|---|
| 79 | 74 | .cra_name = "sha256", |
|---|
| .. | .. |
|---|
| 85 | 80 | }, { |
|---|
| 86 | 81 | .digestsize = SHA224_DIGEST_SIZE, |
|---|
| 87 | 82 | .init = sha224_base_init, |
|---|
| 88 | | - .update = sha256_update, |
|---|
| 89 | | - .final = sha256_final, |
|---|
| 90 | | - .finup = sha256_finup, |
|---|
| 83 | + .update = crypto_sha256_neon_update, |
|---|
| 84 | + .final = crypto_sha256_neon_final, |
|---|
| 85 | + .finup = crypto_sha256_neon_finup, |
|---|
| 91 | 86 | .descsize = sizeof(struct sha256_state), |
|---|
| 92 | 87 | .base = { |
|---|
| 93 | 88 | .cra_name = "sha224", |
|---|