Skip to content

crypto: Improve AEAD cipher detection logic in cipher_kt_mode_aead() #774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/openvpn/crypto_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,15 +821,16 @@ cipher_kt_mode_aead(const char *ciphername)
evp_cipher_type *cipher = cipher_get(ciphername);
if (cipher)
{
if (EVP_CIPHER_mode(cipher) == OPENVPN_MODE_GCM)
int flags = EVP_CIPHER_flags(cipher);
if (flags & EVP_CIPH_FLAG_AEAD_CIPHER)
{
isaead = true;
}

#ifdef NID_chacha20_poly1305
#if defined(NID_chacha20_poly1305) && OPENSSL_VERSION_NUMBER < 0x30000000L
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you tested that this doesn't break libreSSL?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, but I didn't check this with LibreSSL since I implemented it in a similar way to cipher_ctx_mode_aead:

bool
cipher_ctx_mode_aead(const cipher_ctx_t *ctx)
{
    if (ctx)
    {
        int flags = EVP_CIPHER_CTX_flags(ctx);
        if (flags & EVP_CIPH_FLAG_AEAD_CIPHER)
        {
            return true;
        }

#if defined(NID_chacha20_poly1305) && OPENSSL_VERSION_NUMBER < 0x30000000L
        if (EVP_CIPHER_CTX_nid(ctx) == NID_chacha20_poly1305)
        {
            return true;
        }
#endif
    }

    return false;
}

I hope that if it works with cipher_ctx_mode_aead then it will work here. I can check it, but a little later.

if (EVP_CIPHER_nid(cipher) == NID_chacha20_poly1305)
{
isaead = true;
isaead = true;
}
#endif
}
Expand Down
Loading