mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
crypto: replace 'des-rfb' cipher with 'des'
Currently the crypto layer exposes support for a 'des-rfb' algorithm which is just normal single-DES, with the bits in each key byte reversed. This special key munging is required by the RFB protocol password authentication mechanism. Since the crypto layer is generic shared code, it makes more sense to do the key byte munging in the VNC server code, and expose normal single-DES support. Replacing cipher 'des-rfb' by 'des' looks like an incompatible interface change, but it doesn't matter. While the QMP schema allows any QCryptoCipherAlgorithm for the 'cipher-alg' field in QCryptoBlockCreateOptionsLUKS, the code restricts what can be used at runtime. Thus the only effect is a change in error message. Original behaviour: $ qemu-img create -f luks --object secret,id=sec0,data=123 -o cipher-alg=des-rfb,key-secret=sec0 demo.luks 1G Formatting 'demo.luks', fmt=luks size=1073741824 key-secret=sec0 cipher-alg=des-rfb qemu-img: demo.luks: Algorithm 'des-rfb' not supported New behaviour: $ qemu-img create -f luks --object secret,id=sec0,data=123 -o cipher-alg=des-rfb,key-secret=sec0 demo.luks 1G Formatting 'demo.luks', fmt=luks size=1073741824 key-secret=sec0 cipher-alg=des-fish qemu-img: demo.luks: Invalid parameter 'des-rfb' Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
6801404429
commit
83bee4b51f
6 changed files with 47 additions and 65 deletions
20
ui/vnc.c
20
ui/vnc.c
|
@ -2733,6 +2733,19 @@ static void authentication_failed(VncState *vs)
|
|||
vnc_client_error(vs);
|
||||
}
|
||||
|
||||
static void
|
||||
vnc_munge_des_rfb_key(unsigned char *key, size_t nkey)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < nkey; i++) {
|
||||
uint8_t r = key[i];
|
||||
r = (r & 0xf0) >> 4 | (r & 0x0f) << 4;
|
||||
r = (r & 0xcc) >> 2 | (r & 0x33) << 2;
|
||||
r = (r & 0xaa) >> 1 | (r & 0x55) << 1;
|
||||
key[i] = r;
|
||||
}
|
||||
}
|
||||
|
||||
static int protocol_client_auth_vnc(VncState *vs, uint8_t *data, size_t len)
|
||||
{
|
||||
unsigned char response[VNC_AUTH_CHALLENGE_SIZE];
|
||||
|
@ -2757,9 +2770,10 @@ static int protocol_client_auth_vnc(VncState *vs, uint8_t *data, size_t len)
|
|||
pwlen = strlen(vs->vd->password);
|
||||
for (i=0; i<sizeof(key); i++)
|
||||
key[i] = i<pwlen ? vs->vd->password[i] : 0;
|
||||
vnc_munge_des_rfb_key(key, sizeof(key));
|
||||
|
||||
cipher = qcrypto_cipher_new(
|
||||
QCRYPTO_CIPHER_ALG_DES_RFB,
|
||||
QCRYPTO_CIPHER_ALG_DES,
|
||||
QCRYPTO_CIPHER_MODE_ECB,
|
||||
key, G_N_ELEMENTS(key),
|
||||
&err);
|
||||
|
@ -4045,9 +4059,9 @@ void vnc_display_open(const char *id, Error **errp)
|
|||
goto fail;
|
||||
}
|
||||
if (!qcrypto_cipher_supports(
|
||||
QCRYPTO_CIPHER_ALG_DES_RFB, QCRYPTO_CIPHER_MODE_ECB)) {
|
||||
QCRYPTO_CIPHER_ALG_DES, QCRYPTO_CIPHER_MODE_ECB)) {
|
||||
error_setg(errp,
|
||||
"Cipher backend does not support DES RFB algorithm");
|
||||
"Cipher backend does not support DES algorithm");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue