[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/22] crypto: add crypto tests for single block DES-ECB and DES-C
From: |
Daniel P . Berrangé |
Subject: |
[PULL 08/22] crypto: add crypto tests for single block DES-ECB and DES-CBC |
Date: |
Mon, 12 Jul 2021 14:02:09 +0100 |
The GNUTLS crypto provider doesn't support DES-ECB, only DES-CBC.
We can use the latter to simulate the former, if we encrypt only
1 block (8 bytes) of data at a time, using an all-zeros IV. This
is a very inefficient way to use the QCryptoCipher APIs, but
since the VNC authentication challenge is only 16 bytes, this
is acceptable. No other part of QEMU should be using DES. This
test case demonstrates the equivalence of ECB and CBC for the
single-block case.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
tests/unit/test-crypto-cipher.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/tests/unit/test-crypto-cipher.c b/tests/unit/test-crypto-cipher.c
index fd0a8de34c..7dca7b26e4 100644
--- a/tests/unit/test-crypto-cipher.c
+++ b/tests/unit/test-crypto-cipher.c
@@ -149,6 +149,29 @@ static QCryptoCipherTestData test_data[] = {
"39f23369a9d9bacfa530e26304231461"
"b2eb05e2c39be9fcda6c19078c6a9d1b",
},
+ {
+ /*
+ * Testing 'password' as plaintext fits
+ * in single AES block, and gives identical
+ * ciphertext in ECB and CBC modes
+ */
+ .path = "/crypto/cipher/des-rfb-ecb-56-one-block",
+ .alg = QCRYPTO_CIPHER_ALG_DES_RFB,
+ .mode = QCRYPTO_CIPHER_MODE_ECB,
+ .key = "0123456789abcdef",
+ .plaintext = "70617373776f7264",
+ .ciphertext = "73fa80b66134e403",
+ },
+ {
+ /* See previous comment */
+ .path = "/crypto/cipher/des-rfb-cbc-56-one-block",
+ .alg = QCRYPTO_CIPHER_ALG_DES_RFB,
+ .mode = QCRYPTO_CIPHER_MODE_CBC,
+ .key = "0123456789abcdef",
+ .iv = "0000000000000000",
+ .plaintext = "70617373776f7264",
+ .ciphertext = "73fa80b66134e403",
+ },
{
.path = "/crypto/cipher/des-rfb-ecb-56",
.alg = QCRYPTO_CIPHER_ALG_DES_RFB,
--
2.31.1
- [PULL 00/22] Crypto and more patches, Daniel P . Berrangé, 2021/07/12
- [PULL 01/22] crypto: remove conditional around 3DES crypto test cases, Daniel P . Berrangé, 2021/07/12
- [PULL 02/22] crypto: remove obsolete crypto test condition, Daniel P . Berrangé, 2021/07/12
- [PULL 03/22] crypto: skip essiv ivgen tests if AES+ECB isn't available, Daniel P . Berrangé, 2021/07/12
- [PULL 04/22] crypto: use &error_fatal in crypto tests, Daniel P . Berrangé, 2021/07/12
- [PULL 05/22] crypto: fix gcrypt min version 1.8 regression, Daniel P . Berrangé, 2021/07/12
- [PULL 06/22] crypto: drop gcrypt thread initialization code, Daniel P . Berrangé, 2021/07/12
- [PULL 07/22] crypto: drop custom XTS support in gcrypt driver, Daniel P . Berrangé, 2021/07/12
- [PULL 08/22] crypto: add crypto tests for single block DES-ECB and DES-CBC,
Daniel P . Berrangé <=
- [PULL 09/22] crypto: delete built-in DES implementation, Daniel P . Berrangé, 2021/07/12
- [PULL 10/22] crypto: delete built-in XTS cipher mode support, Daniel P . Berrangé, 2021/07/12
- [PULL 11/22] crypto: replace 'des-rfb' cipher with 'des', Daniel P . Berrangé, 2021/07/12
- [PULL 12/22] crypto: flip priority of backends to prefer gcrypt, Daniel P . Berrangé, 2021/07/12
- [PULL 13/22] crypto: introduce build system for gnutls crypto backend, Daniel P . Berrangé, 2021/07/12
- [PULL 14/22] crypto: add gnutls cipher provider, Daniel P . Berrangé, 2021/07/12
- [PULL 15/22] crypto: add gnutls hash provider, Daniel P . Berrangé, 2021/07/12
- [PULL 16/22] crypto: add gnutls hmac provider, Daniel P . Berrangé, 2021/07/12
- [PULL 17/22] crypto: add gnutls pbkdf provider, Daniel P . Berrangé, 2021/07/12
- [PULL 18/22] crypto: prefer gnutls as the crypto backend if new enough, Daniel P . Berrangé, 2021/07/12