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/*- 11 * RISC-V 64 ZVKSED support for SM4 GCM. 12 * This file is included by cipher_sm4_gcm_hw.c 13 */ 14 15static int rv64i_zvksed_sm4_xts_initkey(PROV_CIPHER_CTX *ctx, 16 const unsigned char *key, 17 size_t keylen) 18{ 19 PROV_SM4_XTS_CTX *xctx = (PROV_SM4_XTS_CTX *)ctx; 20 OSSL_xts_stream_fn stream_fn = NULL; 21 OSSL_xts_stream_fn stream_gb_fn = NULL; 22 23 XTS_SET_KEY_FN(rv64i_zvksed_sm4_set_encrypt_key, 24 rv64i_zvksed_sm4_set_decrypt_key, 25 rv64i_zvksed_sm4_encrypt, 26 rv64i_zvksed_sm4_decrypt, 27 stream_fn, stream_gb_fn); 28 return 1; 29} 30 31static const PROV_CIPHER_HW rv64i_zvksed_sm4_xts = { 32 rv64i_zvksed_sm4_xts_initkey, 33 NULL, 34 cipher_hw_sm4_xts_copyctx 35}; 36 37const PROV_CIPHER_HW *ossl_prov_cipher_hw_sm4_xts(size_t keybits) 38{ 39 if (RISCV_HAS_ZVKB_AND_ZVKSED() && riscv_vlen() >= 128) 40 return &rv64i_zvksed_sm4_xts; 41 else 42 return &sm4_generic_xts; 43} 44