xref: /openssl/crypto/sm3/sm3_riscv.c (revision 1c25bc2e)
1 /*
2  * Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9 
10 #include <stdlib.h>
11 #include <string.h>
12 
13 #include <openssl/opensslconf.h>
14 #include "internal/sm3.h"
15 #include "crypto/riscv_arch.h"
16 #include <stdio.h>
17 
18 void ossl_hwsm3_block_data_order_zvksh(SM3_CTX *c, const void *p, size_t num);
19 void ossl_sm3_block_data_order(SM3_CTX *c, const void *p, size_t num);
20 void ossl_hwsm3_block_data_order(SM3_CTX *c, const void *p, size_t num);
21 
ossl_hwsm3_block_data_order(SM3_CTX * c,const void * p,size_t num)22 void ossl_hwsm3_block_data_order(SM3_CTX *c, const void *p, size_t num)
23 {
24     if (RISCV_HAS_ZVKB_AND_ZVKSH() && riscv_vlen() >= 128) {
25         ossl_hwsm3_block_data_order_zvksh(c, p, num);
26     } else {
27         ossl_sm3_block_data_order(c, p, num);
28     }
29 }
30