static ossl_inline void packet_forward(PACKET *pkt, size_t len)
{
    pkt->curr += len;
    pkt->remaining -= len;
}
["STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,\n                                               PACKET *cipher_suites,\n                                               STACK_OF(SSL_CIPHER) **skp,\n                                               int sslv2format, int *al)\n{\n    const SSL_CIPHER *c;\n    STACK_OF(SSL_CIPHER) *sk;\n    int n;\n    unsigned char cipher[SSLV2_CIPHER_LEN];\n    s->s3->send_connection_binding = 0;\n    n = sslv2format ? SSLV2_CIPHER_LEN : TLS_CIPHER_LEN;\n    if (PACKET_remaining(cipher_suites) == 0) {\n        SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, SSL_R_NO_CIPHERS_SPECIFIED);\n        *al = SSL_AD_ILLEGAL_PARAMETER;\n        return NULL;\n    }\n    if (PACKET_remaining(cipher_suites) % n != 0) {\n        SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST,\n               SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST);\n        *al = SSL_AD_DECODE_ERROR;\n        return NULL;\n    }\n    sk = sk_SSL_CIPHER_new_null();\n    if (sk == NULL) {\n        SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, ERR_R_MALLOC_FAILURE);\n        *al = SSL_AD_INTERNAL_ERROR;\n        return NULL;\n    }\n    if (sslv2format) {\n        size_t numciphers = PACKET_remaining(cipher_suites) / n;\n        PACKET sslv2ciphers = *cipher_suites;\n        unsigned int leadbyte;\n        unsigned char *raw;\n        raw = OPENSSL_malloc(numciphers * TLS_CIPHER_LEN);\n        s->s3->tmp.ciphers_raw = raw;\n        if (raw == NULL) {\n            *al = SSL_AD_INTERNAL_ERROR;\n            goto err;\n        }\n        for (s->s3->tmp.ciphers_rawlen = 0;\n             PACKET_remaining(&sslv2ciphers) > 0;\n             raw += TLS_CIPHER_LEN) {\n            if (!PACKET_get_1(&sslv2ciphers, &leadbyte)\n                    || (leadbyte == 0\n                        && !PACKET_copy_bytes(&sslv2ciphers, raw,\n                                              TLS_CIPHER_LEN))\n                    || (leadbyte != 0\n                        && !PACKET_forward(&sslv2ciphers, TLS_CIPHER_LEN))) {\n                *al = SSL_AD_INTERNAL_ERROR;\n                OPENSSL_free(raw);\n                s->s3->tmp.ciphers_raw = NULL;\n                s->s3->tmp.ciphers_rawlen = 0;\n                goto err;\n            }\n            if (leadbyte == 0)\n                s->s3->tmp.ciphers_rawlen += TLS_CIPHER_LEN;\n        }\n    } else if (!PACKET_memdup(cipher_suites, &s->s3->tmp.ciphers_raw,\n                           &s->s3->tmp.ciphers_rawlen)) {\n        *al = SSL_AD_INTERNAL_ERROR;\n        goto err;\n    }\n    while (PACKET_copy_bytes(cipher_suites, cipher, n)) {\n        if (sslv2format && cipher[0] != '\\0')\n            continue;\n        if ((cipher[n - 2] == ((SSL3_CK_SCSV >> 8) & 0xff)) &&\n            (cipher[n - 1] == (SSL3_CK_SCSV & 0xff))) {\n            if (s->renegotiate) {\n                SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST,\n                       SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING);\n                *al = SSL_AD_HANDSHAKE_FAILURE;\n                goto err;\n            }\n            s->s3->send_connection_binding = 1;\n            continue;\n        }\n        if ((cipher[n - 2] == ((SSL3_CK_FALLBACK_SCSV >> 8) & 0xff)) &&\n            (cipher[n - 1] == (SSL3_CK_FALLBACK_SCSV & 0xff))) {\n            if (!ssl_check_version_downgrade(s)) {\n                SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST,\n                       SSL_R_INAPPROPRIATE_FALLBACK);\n                *al = SSL_AD_INAPPROPRIATE_FALLBACK;\n                goto err;\n            }\n            continue;\n        }\n        c = ssl_get_cipher_by_char(s, sslv2format ? &cipher[1] : cipher);\n        if (c != NULL) {\n            if (!sk_SSL_CIPHER_push(sk, c)) {\n                SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, ERR_R_MALLOC_FAILURE);\n                *al = SSL_AD_INTERNAL_ERROR;\n                goto err;\n            }\n        }\n    }\n    if (PACKET_remaining(cipher_suites) > 0) {\n        *al = SSL_AD_INTERNAL_ERROR;\n        SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n    *skp = sk;\n    return sk;\n err:\n    sk_SSL_CIPHER_free(sk);\n    return NULL;\n}", 'static ossl_inline int PACKET_get_1(PACKET *pkt, unsigned int *data)\n{\n    if (!PACKET_peek_1(pkt, data))\n        return 0;\n    packet_forward(pkt, 1);\n    return 1;\n}', 'static ossl_inline int PACKET_peek_1(const PACKET *pkt,\n                                            unsigned int *data)\n{\n    if (!PACKET_remaining(pkt))\n        return 0;\n    *data = *pkt->curr;\n    return 1;\n}', 'static ossl_inline int PACKET_copy_bytes(PACKET *pkt,\n                                                unsigned char *data, size_t len)\n{\n    if (!PACKET_peek_copy_bytes(pkt, data, len))\n        return 0;\n    packet_forward(pkt, len);\n    return 1;\n}', 'static ossl_inline void packet_forward(PACKET *pkt, size_t len)\n{\n    pkt->curr += len;\n    pkt->remaining -= len;\n}']