/* Skip the CVE-2025-15468 fix in case the version being livepatched already have a fix for it.  */

#ifndef _DISABLE_CVE_2025_15468

#include <stdlib.h>
#include <stdint.h>

/** clang-extract: from include/openssl/ssl.h:239:1 */
typedef struct ssl_cipher_st SSL_CIPHER;

#define SSL_QUIC                0x00040000U
/** clang-extract: from ssl/quic/../ssl_local.h:382:1 */
struct ssl_cipher_st {
    uint32_t valid;
    const char *name;           /* text name */
    const char *stdname;        /* RFC name */
    uint32_t id;                /* id, 4 bytes, first is version */
    /*
     * changed in 1.0.0: these four used to be portions of a single value
     * 'algorithms'
     */
    uint32_t algorithm_mkey;    /* key exchange algorithm */
    uint32_t algorithm_auth;    /* server authentication */
    uint32_t algorithm_enc;     /* symmetric encryption */
    uint32_t algorithm_mac;     /* symmetric authentication */
    int min_tls;                /* minimum SSL/TLS protocol version */
    int max_tls;                /* maximum SSL/TLS protocol version */
    int min_dtls;               /* minimum DTLS protocol version */
    int max_dtls;               /* maximum DTLS protocol version */
    uint32_t algo_strength;     /* strength and export flags */
    uint32_t algorithm2;        /* Extra flags */
    int32_t strength_bits;      /* Number of bits really used */
    uint32_t alg_bits;          /* Number of bits for algorithm */
};

/** clang-extract: from ssl/quic/../ssl_local.h:2647:8 */
const SSL_CIPHER *(*klpe_ssl3_get_cipher_by_char)(const unsigned char *);

/** clang-extract: from ssl/quic/quic_impl.c:5013:1 */
__attribute__((visibility("default")))
const SSL_CIPHER *ossl_quic_get_cipher_by_char(const unsigned char *p)
{
    const SSL_CIPHER *ciph = (*klpe_ssl3_get_cipher_by_char)(p);

    if (ciph == NULL)
        return NULL;

    if ((ciph->algorithm2 & SSL_QUIC) == 0)
        return NULL;

    return ciph;
}

#endif
