2 * Ceph - scalable distributed file system
4 * Copyright (C) 2016 Mirantis, Inc.
6 * Author: Adam Kupczyk <akupczyk@mirantis.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
15 #include "crypto/isa-l/isal_crypto_accel.h"
17 #include "crypto/isa-l/isa-l_crypto/include/aes_cbc.h"
19 bool ISALCryptoAccel::cbc_encrypt(unsigned char* out, const unsigned char* in, size_t size,
20 const unsigned char (&iv)[AES_256_IVSIZE],
21 const unsigned char (&key)[AES_256_KEYSIZE])
23 if ((size % AES_256_IVSIZE) != 0) {
26 alignas(16) struct cbc_key_data keys_blk;
27 aes_cbc_precomp(const_cast<unsigned char*>(&key[0]), AES_256_KEYSIZE, &keys_blk);
28 aes_cbc_enc_256(const_cast<unsigned char*>(in),
29 const_cast<unsigned char*>(&iv[0]), keys_blk.enc_keys, out, size);
32 bool ISALCryptoAccel::cbc_decrypt(unsigned char* out, const unsigned char* in, size_t size,
33 const unsigned char (&iv)[AES_256_IVSIZE],
34 const unsigned char (&key)[AES_256_KEYSIZE])
36 if ((size % AES_256_IVSIZE) != 0) {
39 alignas(16) struct cbc_key_data keys_blk;
40 aes_cbc_precomp(const_cast<unsigned char*>(&key[0]), AES_256_KEYSIZE, &keys_blk);
41 aes_cbc_dec_256(const_cast<unsigned char*>(in), const_cast<unsigned char*>(&iv[0]), keys_blk.dec_keys, out, size);