mirror of
https://github.com/OpenVPN/openvpn.git
synced 2026-05-28 04:03:29 -04:00
dco_win: In dco_new_key, document size assumptions for the integer casts
And make all casts explicit so that compiler doesn't complain. Change-Id: I612bf3b1c56d70a89fc04fad6fe36fd9fadfd258 Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com> Acked-by: MaxF <max@max-fillinger.net> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1221 Message-Id: <20250926165151.1502-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg33229.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
This commit is contained in:
parent
2682fb541e
commit
e77c34370d
1 changed files with 5 additions and 12 deletions
|
|
@ -525,11 +525,6 @@ dco_set_peer(dco_context_t *dco, unsigned int peerid, int keepalive_interval, in
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__GNUC__) || defined(__clang__)
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
int
|
||||||
dco_new_key(dco_context_t *dco, unsigned int peerid, int keyid, dco_key_slot_t slot,
|
dco_new_key(dco_context_t *dco, unsigned int peerid, int keyid, dco_key_slot_t slot,
|
||||||
const uint8_t *encrypt_key, const uint8_t *encrypt_iv, const uint8_t *decrypt_key,
|
const uint8_t *encrypt_key, const uint8_t *encrypt_iv, const uint8_t *decrypt_key,
|
||||||
|
|
@ -540,21 +535,23 @@ dco_new_key(dco_context_t *dco, unsigned int peerid, int keyid, dco_key_slot_t s
|
||||||
|
|
||||||
const int nonce_len = 8;
|
const int nonce_len = 8;
|
||||||
size_t key_len = cipher_kt_key_size(ciphername);
|
size_t key_len = cipher_kt_key_size(ciphername);
|
||||||
|
ASSERT(key_len <= 32);
|
||||||
|
|
||||||
OVPN_CRYPTO_DATA crypto_data;
|
OVPN_CRYPTO_DATA crypto_data;
|
||||||
ZeroMemory(&crypto_data, sizeof(crypto_data));
|
ZeroMemory(&crypto_data, sizeof(crypto_data));
|
||||||
|
|
||||||
crypto_data.CipherAlg = dco_get_cipher(ciphername);
|
crypto_data.CipherAlg = dco_get_cipher(ciphername);
|
||||||
crypto_data.KeyId = keyid;
|
ASSERT(keyid > 0 && keyid <= UCHAR_MAX);
|
||||||
|
crypto_data.KeyId = (unsigned char)keyid;
|
||||||
crypto_data.PeerId = peerid;
|
crypto_data.PeerId = peerid;
|
||||||
crypto_data.KeySlot = slot;
|
crypto_data.KeySlot = slot;
|
||||||
|
|
||||||
CopyMemory(crypto_data.Encrypt.Key, encrypt_key, key_len);
|
CopyMemory(crypto_data.Encrypt.Key, encrypt_key, key_len);
|
||||||
crypto_data.Encrypt.KeyLen = (char)key_len;
|
crypto_data.Encrypt.KeyLen = (unsigned char)key_len;
|
||||||
CopyMemory(crypto_data.Encrypt.NonceTail, encrypt_iv, nonce_len);
|
CopyMemory(crypto_data.Encrypt.NonceTail, encrypt_iv, nonce_len);
|
||||||
|
|
||||||
CopyMemory(crypto_data.Decrypt.Key, decrypt_key, key_len);
|
CopyMemory(crypto_data.Decrypt.Key, decrypt_key, key_len);
|
||||||
crypto_data.Decrypt.KeyLen = (char)key_len;
|
crypto_data.Decrypt.KeyLen = (unsigned char)key_len;
|
||||||
CopyMemory(crypto_data.Decrypt.NonceTail, decrypt_iv, nonce_len);
|
CopyMemory(crypto_data.Decrypt.NonceTail, decrypt_iv, nonce_len);
|
||||||
|
|
||||||
ASSERT(crypto_data.CipherAlg > 0);
|
ASSERT(crypto_data.CipherAlg > 0);
|
||||||
|
|
@ -570,10 +567,6 @@ dco_new_key(dco_context_t *dco, unsigned int peerid, int keyid, dco_key_slot_t s
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__GNUC__) || defined(__clang__)
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
int
|
||||||
dco_del_key(dco_context_t *dco, unsigned int peerid, dco_key_slot_t slot)
|
dco_del_key(dco_context_t *dco, unsigned int peerid, dco_key_slot_t slot)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue