sha256-glue.c (3eb66e91a25497065c5322b1268cbc3953642227) sha256-glue.c (e52b7023cdad005756cd91d7c54fa90ef6b43d32)
1/*
2 * Linux/arm64 port of the OpenSSL SHA256 implementation for AArch64
3 *
4 * Copyright (c) 2016 Linaro Ltd. <ard.biesheuvel@linaro.org>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 */
12
13#include <asm/hwcap.h>
14#include <asm/neon.h>
15#include <asm/simd.h>
16#include <crypto/internal/hash.h>
1/*
2 * Linux/arm64 port of the OpenSSL SHA256 implementation for AArch64
3 *
4 * Copyright (c) 2016 Linaro Ltd. <ard.biesheuvel@linaro.org>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 */
12
13#include <asm/hwcap.h>
14#include <asm/neon.h>
15#include <asm/simd.h>
16#include <crypto/internal/hash.h>
17#include <crypto/internal/simd.h>
17#include <crypto/sha.h>
18#include <crypto/sha256_base.h>
19#include <linux/cryptohash.h>
20#include <linux/types.h>
21#include <linux/string.h>
22
23MODULE_DESCRIPTION("SHA-224/SHA-256 secure hash for arm64");
24MODULE_AUTHOR("Andy Polyakov <appro@openssl.org>");

--- 59 unchanged lines hidden (view full) ---

84 .base.cra_module = THIS_MODULE,
85} };
86
87static int sha256_update_neon(struct shash_desc *desc, const u8 *data,
88 unsigned int len)
89{
90 struct sha256_state *sctx = shash_desc_ctx(desc);
91
18#include <crypto/sha.h>
19#include <crypto/sha256_base.h>
20#include <linux/cryptohash.h>
21#include <linux/types.h>
22#include <linux/string.h>
23
24MODULE_DESCRIPTION("SHA-224/SHA-256 secure hash for arm64");
25MODULE_AUTHOR("Andy Polyakov <appro@openssl.org>");

--- 59 unchanged lines hidden (view full) ---

85 .base.cra_module = THIS_MODULE,
86} };
87
88static int sha256_update_neon(struct shash_desc *desc, const u8 *data,
89 unsigned int len)
90{
91 struct sha256_state *sctx = shash_desc_ctx(desc);
92
92 if (!may_use_simd())
93 if (!crypto_simd_usable())
93 return sha256_base_do_update(desc, data, len,
94 (sha256_block_fn *)sha256_block_data_order);
95
96 while (len > 0) {
97 unsigned int chunk = len;
98
99 /*
100 * Don't hog the CPU for the entire time it takes to process all

--- 13 unchanged lines hidden (view full) ---

114 len -= chunk;
115 }
116 return 0;
117}
118
119static int sha256_finup_neon(struct shash_desc *desc, const u8 *data,
120 unsigned int len, u8 *out)
121{
94 return sha256_base_do_update(desc, data, len,
95 (sha256_block_fn *)sha256_block_data_order);
96
97 while (len > 0) {
98 unsigned int chunk = len;
99
100 /*
101 * Don't hog the CPU for the entire time it takes to process all

--- 13 unchanged lines hidden (view full) ---

115 len -= chunk;
116 }
117 return 0;
118}
119
120static int sha256_finup_neon(struct shash_desc *desc, const u8 *data,
121 unsigned int len, u8 *out)
122{
122 if (!may_use_simd()) {
123 if (!crypto_simd_usable()) {
123 if (len)
124 sha256_base_do_update(desc, data, len,
125 (sha256_block_fn *)sha256_block_data_order);
126 sha256_base_do_finalize(desc,
127 (sha256_block_fn *)sha256_block_data_order);
128 } else {
129 if (len)
130 sha256_update_neon(desc, data, len);

--- 62 unchanged lines hidden ---
124 if (len)
125 sha256_base_do_update(desc, data, len,
126 (sha256_block_fn *)sha256_block_data_order);
127 sha256_base_do_finalize(desc,
128 (sha256_block_fn *)sha256_block_data_order);
129 } else {
130 if (len)
131 sha256_update_neon(desc, data, len);

--- 62 unchanged lines hidden ---