2 * QEMU Crypto cipher algorithms
4 * Copyright (c) 2015 Red Hat, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 #include "crypto/cipher.h"
23 static size_t alg_key_len
[QCRYPTO_CIPHER_ALG_LAST
] = {
24 [QCRYPTO_CIPHER_ALG_AES_128
] = 16,
25 [QCRYPTO_CIPHER_ALG_AES_192
] = 24,
26 [QCRYPTO_CIPHER_ALG_AES_256
] = 32,
27 [QCRYPTO_CIPHER_ALG_DES_RFB
] = 8,
31 qcrypto_cipher_validate_key_length(QCryptoCipherAlgorithm alg
,
35 if ((unsigned)alg
>= QCRYPTO_CIPHER_ALG_LAST
) {
36 error_setg(errp
, "Cipher algorithm %d out of range",
41 if (alg_key_len
[alg
] != nkey
) {
42 error_setg(errp
, "Cipher key length %zu should be %zu",
43 alg_key_len
[alg
], nkey
);
49 #include "crypto/cipher-builtin.c"