Loading ssl/packet.c +45 −45 Original line number Diff line number Diff line Loading @@ -10,10 +10,10 @@ #include "packet_locl.h" /* * Allocate bytes in the PACKETW_BUF for the output. This reserves the bytes * Allocate bytes in the WPACKET_BUF for the output. This reserves the bytes * and count them as "written", but doesn't actually do the writing. */ static unsigned char *PACKETW_BUF_allocate(PACKETW_BUF *wbuf, size_t len) static unsigned char *WPACKET_BUF_allocate(WPACKET_BUF *wbuf, size_t len) { unsigned char *ret = wbuf->curr; Loading @@ -40,19 +40,19 @@ static unsigned char *PACKETW_BUF_allocate(PACKETW_BUF *wbuf, size_t len) } /* * Initialise a PACKETW with the buffer in |buf|. The buffer must exist * for the whole time that the PACKETW is being used. Additionally |lenbytes| of * Initialise a WPACKET with the buffer in |buf|. The buffer must exist * for the whole time that the WPACKET is being used. Additionally |lenbytes| of * data is preallocated at the start of the buffer to store the length of the * PACKETW once we know it. * WPACKET once we know it. */ int PACKETW_init_len(PACKETW *pkt, BUF_MEM *buf, size_t lenbytes) int WPACKET_init_len(WPACKET *pkt, BUF_MEM *buf, size_t lenbytes) { PACKETW_BUF *wbuf; WPACKET_BUF *wbuf; /* Sanity check */ if (buf == NULL) return 0; wbuf = OPENSSL_zalloc(sizeof(PACKETW_BUF)); wbuf = OPENSSL_zalloc(sizeof(WPACKET_BUF)); if (wbuf == NULL) { pkt->isclosed = 1; return 0; Loading @@ -75,7 +75,7 @@ int PACKETW_init_len(PACKETW *pkt, BUF_MEM *buf, size_t lenbytes) return 1; } pkt->packet_len = PACKETW_BUF_allocate(wbuf, lenbytes); pkt->packet_len = WPACKET_BUF_allocate(wbuf, lenbytes); if (pkt->packet_len == NULL) { OPENSSL_free(wbuf); pkt->wbuf = NULL; Loading @@ -87,23 +87,23 @@ int PACKETW_init_len(PACKETW *pkt, BUF_MEM *buf, size_t lenbytes) } /* * Same as PACKETW_init_len except there is no preallocation of the PACKETW * Same as WPACKET_init_len except there is no preallocation of the WPACKET * length. */ int PACKETW_init(PACKETW *pkt, BUF_MEM *buf) int WPACKET_init(WPACKET *pkt, BUF_MEM *buf) { return PACKETW_init_len(pkt, buf, 0); return WPACKET_init_len(pkt, buf, 0); } /* * Set the PACKETW length, and the location for where we should write that * length. Normally this will be at the start of the PACKETW, and therefore * the PACKETW would have been initialised via PACKETW_init_len(). However there * Set the WPACKET length, and the location for where we should write that * length. Normally this will be at the start of the WPACKET, and therefore * the WPACKET would have been initialised via WPACKET_init_len(). However there * is the possibility that the length needs to be written to some other location * other than the start of the PACKETW. In that case init via PACKETW_init() and * other than the start of the WPACKET. In that case init via WPACKET_init() and * then set the location for the length using this function. */ int PACKETW_set_packet_len(PACKETW *pkt, unsigned char *packet_len, int WPACKET_set_packet_len(WPACKET *pkt, unsigned char *packet_len, size_t lenbytes) { /* We only allow this to be set once */ Loading @@ -116,7 +116,7 @@ int PACKETW_set_packet_len(PACKETW *pkt, unsigned char *packet_len, return 1; } int PACKETW_set_flags(PACKETW *pkt, unsigned int flags) int WPACKET_set_flags(WPACKET *pkt, unsigned int flags) { pkt->flags = flags; Loading @@ -124,12 +124,12 @@ int PACKETW_set_flags(PACKETW *pkt, unsigned int flags) } /* * Closes the PACKETW and marks it as invalid for future writes. It also writes * Closes the WPACKET and marks it as invalid for future writes. It also writes * out the length of the packet to the required location (normally the start * of the PACKETW) if appropriate. A PACKETW cannot be closed if it has an * of the WPACKET) if appropriate. A WPACKET cannot be closed if it has an * active sub-packet. */ int PACKETW_close(PACKETW *pkt) int WPACKET_close(WPACKET *pkt) { size_t packlen; Loading @@ -137,12 +137,12 @@ int PACKETW_close(PACKETW *pkt) return 0; packlen = pkt->wbuf->written - pkt->pwritten; if (packlen == 0 && pkt->flags & OPENSSL_PACKETW_FLAGS_NON_ZERO_LENGTH) if (packlen == 0 && pkt->flags & OPENSSL_WPACKET_FLAGS_NON_ZERO_LENGTH) return 0; if (packlen == 0 && pkt->flags & OPENSSL_PACKETW_FLAGS_ABANDON_ON_ZERO_LENGTH) { /* Deallocate any bytes allocated for the length of the PACKETW */ && pkt->flags & OPENSSL_WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH) { /* Deallocate any bytes allocated for the length of the WPACKET */ if ((pkt->wbuf->curr - pkt->lenbytes) == pkt->packet_len) { pkt->wbuf->written -= pkt->lenbytes; pkt->wbuf->curr -= pkt->lenbytes; Loading @@ -152,7 +152,7 @@ int PACKETW_close(PACKETW *pkt) pkt->packet_len = NULL; } /* Write out the PACKETW length if needed */ /* Write out the WPACKET length if needed */ if (pkt->packet_len != NULL) { size_t lenbytes; Loading Loading @@ -189,7 +189,7 @@ int PACKETW_close(PACKETW *pkt) * Additionally |lenbytes| of data is preallocated at the start of the * sub-packet to store its length once we know it. */ int PACKETW_get_sub_packet_len(PACKETW *pkt, PACKETW *subpkt, size_t lenbytes) int WPACKET_get_sub_packet_len(WPACKET *pkt, WPACKET *subpkt, size_t lenbytes) { if (pkt->isclosed || pkt->haschild || subpkt == NULL) return 0; Loading @@ -207,7 +207,7 @@ int PACKETW_get_sub_packet_len(PACKETW *pkt, PACKETW *subpkt, size_t lenbytes) return 1; } subpkt->packet_len = PACKETW_BUF_allocate(pkt->wbuf, lenbytes); subpkt->packet_len = WPACKET_BUF_allocate(pkt->wbuf, lenbytes); if (subpkt->packet_len == NULL) { subpkt->isclosed = 1; return 0; Loading @@ -219,20 +219,20 @@ int PACKETW_get_sub_packet_len(PACKETW *pkt, PACKETW *subpkt, size_t lenbytes) } /* * Same as PACKETW_get_sub_packet_len() except no bytes are pre-allocated for * Same as WPACKET_get_sub_packet_len() except no bytes are pre-allocated for * the sub-packet length. */ int PACKETW_get_sub_packet(PACKETW *pkt, PACKETW *subpkt) int WPACKET_get_sub_packet(WPACKET *pkt, WPACKET *subpkt) { return PACKETW_get_sub_packet_len(pkt, subpkt, 0); return WPACKET_get_sub_packet_len(pkt, subpkt, 0); } /* * Allocate some bytes in the PACKETW for writing. That number of bytes is * Allocate some bytes in the WPACKET for writing. That number of bytes is * marked as having been written, and a pointer to their location is stored in * |*allocbytes|. */ int PACKETW_allocate_bytes(PACKETW *pkt, size_t bytes, int WPACKET_allocate_bytes(WPACKET *pkt, size_t bytes, unsigned char **allocbytes) { unsigned char *data; Loading @@ -240,7 +240,7 @@ int PACKETW_allocate_bytes(PACKETW *pkt, size_t bytes, if (pkt->isclosed || pkt->haschild || bytes == 0) return 0; data = PACKETW_BUF_allocate(pkt->wbuf, bytes); data = WPACKET_BUF_allocate(pkt->wbuf, bytes); if (data == NULL) return 0; Loading @@ -250,17 +250,17 @@ int PACKETW_allocate_bytes(PACKETW *pkt, size_t bytes, } /* * Write the value stored in |val| into the PACKETW. The value will consome * Write the value stored in |val| into the WPACKET. The value will consome * |bytes| amount of storage. An error will occur if |val| cannot be accommdated * in |bytes| storage, e.g. attempting to write the value 256 into 1 byte will * fail. */ int PACKETW_put_bytes(PACKETW *pkt, unsigned int val, size_t bytes) int WPACKET_put_bytes(WPACKET *pkt, unsigned int val, size_t bytes) { unsigned char *data; if (bytes > sizeof(unsigned int) || !PACKETW_allocate_bytes(pkt, bytes, &data)) || !WPACKET_allocate_bytes(pkt, bytes, &data)) return 0; data += bytes - 1; Loading @@ -278,10 +278,10 @@ int PACKETW_put_bytes(PACKETW *pkt, unsigned int val, size_t bytes) } /* * Set a maximum size that we will not allow the PACKETW to grow beyond. If not * Set a maximum size that we will not allow the WPACKET to grow beyond. If not * set then there is no maximum. */ int PACKETW_set_max_size(PACKETW *pkt, size_t maxsize) int WPACKET_set_max_size(WPACKET *pkt, size_t maxsize) { pkt->wbuf->maxsize = maxsize; Loading @@ -289,16 +289,16 @@ int PACKETW_set_max_size(PACKETW *pkt, size_t maxsize) } /* * Copy |len| bytes of data from |*src| into the PACKETW. * Copy |len| bytes of data from |*src| into the WPACKET. */ int PACKETW_memcpy(PACKETW *pkt, const void *src, size_t len) int WPACKET_memcpy(WPACKET *pkt, const void *src, size_t len) { unsigned char *dest; if (len == 0) return 1; if (!PACKETW_allocate_bytes(pkt, len, &dest)) if (!WPACKET_allocate_bytes(pkt, len, &dest)) return 0; memcpy(dest, src, len); Loading @@ -308,9 +308,9 @@ int PACKETW_memcpy(PACKETW *pkt, const void *src, size_t len) /* * Return the total number of bytes written so far to the underlying buffer. * This might includes bytes written by a parent PACKETW. * This might includes bytes written by a parent WPACKET. */ int PACKETW_get_total_written(PACKETW *pkt, size_t *written) int WPACKET_get_total_written(WPACKET *pkt, size_t *written) { if (pkt->isclosed || written == NULL) return 0; Loading @@ -321,10 +321,10 @@ int PACKETW_get_total_written(PACKETW *pkt, size_t *written) } /* * Returns the length of this PACKETW so far. This excludes any bytes allocated * Returns the length of this WPACKET so far. This excludes any bytes allocated * for the length itself. */ int PACKETW_get_length(PACKETW *pkt, size_t *len) int WPACKET_get_length(WPACKET *pkt, size_t *len) { if (pkt->isclosed || len == NULL) return 0; Loading ssl/packet_locl.h +27 −27 Original line number Diff line number Diff line Loading @@ -562,25 +562,25 @@ typedef struct packetw_buf { size_t written; /* * Maximum number of bytes we will allow to be written to this PACKETW. Zero * Maximum number of bytes we will allow to be written to this WPACKET. Zero * if no maximum */ size_t maxsize; } PACKETW_BUF; } WPACKET_BUF; typedef struct packetw_st PACKETW; typedef struct packetw_st WPACKET; struct packetw_st { /* The parent PACKETW if we have one or NULL otherwise */ PACKETW *parent; /* The parent WPACKET if we have one or NULL otherwise */ WPACKET *parent; /* The actual buffer - shared with sub-packets */ PACKETW_BUF *wbuf; WPACKET_BUF *wbuf; /* Flags for this PACKETW */ /* Flags for this WPACKET */ unsigned int flags; /* * Pointer to where the length of this PACKETW goes (or NULL if we don't * Pointer to where the length of this WPACKET goes (or NULL if we don't * write the length) */ unsigned char *packet_len; Loading @@ -594,35 +594,35 @@ struct packetw_st { /* True if we have an active sub-packet or false otherwise */ int haschild; /* True if PACKETW_close() has been called on this PACKETW */ /* True if WPACKET_close() has been called on this WPACKET */ int isclosed; }; /* Flags */ #define OPENSSL_PACKETW_FLAGS_NONE 0 /* Error on PACKETW_close() if no data written to the PACKETW */ #define OPENSSL_PACKETW_FLAGS_NON_ZERO_LENGTH 1 #define OPENSSL_WPACKET_FLAGS_NONE 0 /* Error on WPACKET_close() if no data written to the WPACKET */ #define OPENSSL_WPACKET_FLAGS_NON_ZERO_LENGTH 1 /* * Abandon all changes on PACKETW_close() if no data written to the PACKETW, * Abandon all changes on WPACKET_close() if no data written to the WPACKET, * i.e. this does not write out a zero packet length */ #define OPENSSL_PACKETW_FLAGS_ABANDON_ON_ZERO_LENGTH 2 #define OPENSSL_WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH 2 int PACKETW_init_len(PACKETW *pkt, BUF_MEM *buf, size_t lenbytes); int PACKETW_init(PACKETW *pkt, BUF_MEM *buf); int PACKETW_set_flags(PACKETW *pkt, unsigned int flags); int PACKETW_set_packet_len(PACKETW *pkt, unsigned char *packet_len, int WPACKET_init_len(WPACKET *pkt, BUF_MEM *buf, size_t lenbytes); int WPACKET_init(WPACKET *pkt, BUF_MEM *buf); int WPACKET_set_flags(WPACKET *pkt, unsigned int flags); int WPACKET_set_packet_len(WPACKET *pkt, unsigned char *packet_len, size_t lenbytes); int PACKETW_close(PACKETW *pkt); int PACKETW_get_sub_packet_len(PACKETW *pkt, PACKETW *subpkt, size_t lenbytes); int PACKETW_get_sub_packet(PACKETW *pkt, PACKETW *subpkt); int PACKETW_allocate_bytes(PACKETW *pkt, size_t bytes, int WPACKET_close(WPACKET *pkt); int WPACKET_get_sub_packet_len(WPACKET *pkt, WPACKET *subpkt, size_t lenbytes); int WPACKET_get_sub_packet(WPACKET *pkt, WPACKET *subpkt); int WPACKET_allocate_bytes(WPACKET *pkt, size_t bytes, unsigned char **allocbytes); int PACKETW_put_bytes(PACKETW *pkt, unsigned int val, size_t bytes); int PACKETW_set_max_size(PACKETW *pkt, size_t maxsize); int PACKETW_memcpy(PACKETW *pkt, const void *src, size_t len); int PACKETW_get_total_written(PACKETW *pkt, size_t *written); int PACKETW_get_length(PACKETW *pkt, size_t *len); int WPACKET_put_bytes(WPACKET *pkt, unsigned int val, size_t bytes); int WPACKET_set_max_size(WPACKET *pkt, size_t maxsize); int WPACKET_memcpy(WPACKET *pkt, const void *src, size_t len); int WPACKET_get_total_written(WPACKET *pkt, size_t *written); int WPACKET_get_length(WPACKET *pkt, size_t *len); # ifdef __cplusplus } Loading ssl/s3_lib.c +7 −7 Original line number Diff line number Diff line Loading @@ -2790,16 +2790,16 @@ int ssl3_set_handshake_header(SSL *s, int htype, unsigned long len) } /* * Temporary name. To be renamed ssl3_set_handshake_header() once all PACKETW * Temporary name. To be renamed ssl3_set_handshake_header() once all WPACKET * conversion is complete. The old ssl3_set_handshake_heder() can be deleted * at that point. * TODO - RENAME ME */ int ssl3_set_handshake_header2(SSL *s, PACKETW *pkt, PACKETW *body, int htype) int ssl3_set_handshake_header2(SSL *s, WPACKET *pkt, WPACKET *body, int htype) { /* Set the content type and 3 bytes for the message len */ if (!PACKETW_put_bytes(pkt, htype, 1) || !PACKETW_get_sub_packet_len(pkt, body, 3)) if (!WPACKET_put_bytes(pkt, htype, 1) || !WPACKET_get_sub_packet_len(pkt, body, 3)) return 0; return 1; Loading Loading @@ -3573,7 +3573,7 @@ const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p) /* * Old version of the ssl3_put_cipher_by_char function used by code that has not * yet been converted to PACKETW yet. It will be deleted once PACKETW conversion * yet been converted to WPACKET yet. It will be deleted once WPACKET conversion * is complete. * TODO - DELETE ME */ Loading @@ -3591,14 +3591,14 @@ int ssl3_put_cipher_by_char_old(const SSL_CIPHER *c, unsigned char *p) return (2); } int ssl3_put_cipher_by_char(const SSL_CIPHER *c, PACKETW *pkt, size_t *len) int ssl3_put_cipher_by_char(const SSL_CIPHER *c, WPACKET *pkt, size_t *len) { if ((c->id & 0xff000000) != 0x03000000) { *len = 0; return 1; } if (!PACKETW_put_bytes(pkt, c->id & 0xffff, 2)) if (!WPACKET_put_bytes(pkt, c->id & 0xffff, 2)) return 0; *len = 2; Loading ssl/ssl_locl.h +11 −11 Original line number Diff line number Diff line Loading @@ -457,7 +457,7 @@ struct ssl_method_st { long (*ssl_ctrl) (SSL *s, int cmd, long larg, void *parg); long (*ssl_ctx_ctrl) (SSL_CTX *ctx, int cmd, long larg, void *parg); const SSL_CIPHER *(*get_cipher_by_char) (const unsigned char *ptr); int (*put_cipher_by_char) (const SSL_CIPHER *cipher, PACKETW *pkt, int (*put_cipher_by_char) (const SSL_CIPHER *cipher, WPACKET *pkt, size_t *len); int (*ssl_pending) (const SSL *s); int (*num_ciphers) (void); Loading Loading @@ -1586,10 +1586,10 @@ typedef struct ssl3_enc_method { /* Set the handshake header */ int (*set_handshake_header) (SSL *s, int type, unsigned long len); /* Set the handshake header */ int (*set_handshake_header2) (SSL *s, PACKETW *pkt, PACKETW *body, int (*set_handshake_header2) (SSL *s, WPACKET *pkt, WPACKET *body, int type); /* Close construction of the handshake message */ int (*close_construct_packet) (SSL *s, PACKETW *pkt); int (*close_construct_packet) (SSL *s, WPACKET *pkt); /* Write out handshake message */ int (*do_write) (SSL *s); } SSL3_ENC_METHOD; Loading Loading @@ -1865,7 +1865,7 @@ __owur EVP_PKEY *ssl_dh_to_pkey(DH *dh); __owur const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p); __owur int ssl3_put_cipher_by_char_old(const SSL_CIPHER *c, unsigned char *p); __owur int ssl3_put_cipher_by_char(const SSL_CIPHER *c, PACKETW *pkt, __owur int ssl3_put_cipher_by_char(const SSL_CIPHER *c, WPACKET *pkt, size_t *len); int ssl3_init_finished_mac(SSL *s); __owur int ssl3_setup_key_block(SSL *s); Loading Loading @@ -1906,12 +1906,12 @@ __owur int ssl3_do_change_cipher_spec(SSL *ssl); __owur long ssl3_default_timeout(void); __owur int ssl3_set_handshake_header(SSL *s, int htype, unsigned long len); __owur int ssl3_set_handshake_header2(SSL *s, PACKETW *pkt, PACKETW *body, __owur int ssl3_set_handshake_header2(SSL *s, WPACKET *pkt, WPACKET *body, int htype); __owur int tls_close_construct_packet(SSL *s, PACKETW *pkt); __owur int dtls1_set_handshake_header2(SSL *s, PACKETW *pkt, PACKETW *body, __owur int tls_close_construct_packet(SSL *s, WPACKET *pkt); __owur int dtls1_set_handshake_header2(SSL *s, WPACKET *pkt, WPACKET *body, int htype); __owur int dtls1_close_construct_packet(SSL *s, PACKETW *pkt); __owur int dtls1_close_construct_packet(SSL *s, WPACKET *pkt); __owur int ssl3_handshake_write(SSL *s); __owur int ssl_allow_compression(SSL *s); Loading Loading @@ -2020,7 +2020,7 @@ __owur EVP_PKEY *ssl_generate_pkey_curve(int id); __owur int tls1_shared_list(SSL *s, const unsigned char *l1, size_t l1len, const unsigned char *l2, size_t l2len, int nmatch); __owur int ssl_add_clienthello_tlsext(SSL *s, PACKETW *pkt, int *al); __owur int ssl_add_clienthello_tlsext(SSL *s, WPACKET *pkt, int *al); __owur unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, unsigned char *limit, int *al); __owur int ssl_parse_clienthello_tlsext(SSL *s, PACKET *pkt); Loading Loading @@ -2075,7 +2075,7 @@ __owur int ssl_parse_clienthello_renegotiate_ext(SSL *s, PACKET *pkt, int *al); __owur long ssl_get_algorithm2(SSL *s); __owur size_t tls12_copy_sigalgs_old(SSL *s, unsigned char *out, const unsigned char *psig, size_t psiglen); __owur int tls12_copy_sigalgs(SSL *s, PACKETW *pkt, __owur int tls12_copy_sigalgs(SSL *s, WPACKET *pkt, const unsigned char *psig, size_t psiglen); __owur int tls1_save_sigalgs(SSL *s, const unsigned char *data, int dsize); __owur int tls1_process_sigalgs(SSL *s); Loading Loading @@ -2125,7 +2125,7 @@ __owur int custom_ext_parse(SSL *s, int server, int *al); __owur int custom_ext_add_old(SSL *s, int server, unsigned char **pret, unsigned char *limit, int *al); __owur int custom_ext_add(SSL *s, int server, PACKETW *pkt, int *al); __owur int custom_ext_add(SSL *s, int server, WPACKET *pkt, int *al); __owur int custom_exts_copy(custom_ext_methods *dst, const custom_ext_methods *src); Loading ssl/statem/statem_clnt.c +23 −23 Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ static ossl_inline int cert_req_allowed(SSL *s); static int key_exchange_expected(SSL *s); static int ca_dn_cmp(const X509_NAME *const *a, const X509_NAME *const *b); static int ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *sk, PACKETW *pkt); WPACKET *pkt); /* * Is a CertificateRequest message allowed at the moment or not? Loading Loading @@ -697,10 +697,10 @@ int tls_construct_client_hello(SSL *s) SSL_COMP *comp; #endif SSL_SESSION *sess = s->session; PACKETW pkt, body, spkt; WPACKET pkt, body, spkt; if (!PACKETW_init(&pkt, s->init_buf) || !PACKETW_set_max_size(&pkt, SSL3_RT_MAX_PLAIN_LENGTH)) { if (!WPACKET_init(&pkt, s->init_buf) || !WPACKET_set_max_size(&pkt, SSL3_RT_MAX_PLAIN_LENGTH)) { /* Should not happen */ SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; Loading Loading @@ -782,8 +782,8 @@ int tls_construct_client_hello(SSL *s) * client_version in client hello and not resetting it to * the negotiated version. */ if (!PACKETW_put_bytes(&body, s->client_version, 2) || !PACKETW_memcpy(&body, s->s3->client_random, SSL3_RANDOM_SIZE)) { if (!WPACKET_put_bytes(&body, s->client_version, 2) || !WPACKET_memcpy(&body, s->s3->client_random, SSL3_RANDOM_SIZE)) { SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } Loading @@ -794,9 +794,9 @@ int tls_construct_client_hello(SSL *s) else i = s->session->session_id_length; if (i > (int)sizeof(s->session->session_id) || !PACKETW_get_sub_packet_len(&body, &spkt, 1) || (i != 0 && !PACKETW_memcpy(&spkt, s->session->session_id, i)) || !PACKETW_close(&spkt)) { || !WPACKET_get_sub_packet_len(&body, &spkt, 1) || (i != 0 && !WPACKET_memcpy(&spkt, s->session->session_id, i)) || !WPACKET_close(&spkt)) { SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } Loading @@ -804,29 +804,29 @@ int tls_construct_client_hello(SSL *s) /* cookie stuff for DTLS */ if (SSL_IS_DTLS(s)) { if (s->d1->cookie_len > sizeof(s->d1->cookie) || !PACKETW_get_sub_packet_len(&body, &spkt, 1) || !PACKETW_memcpy(&spkt, s->d1->cookie, s->d1->cookie_len) || !PACKETW_close(&spkt)) { || !WPACKET_get_sub_packet_len(&body, &spkt, 1) || !WPACKET_memcpy(&spkt, s->d1->cookie, s->d1->cookie_len) || !WPACKET_close(&spkt)) { SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } } /* Ciphers supported */ if (!PACKETW_get_sub_packet_len(&body, &spkt, 2)) { if (!WPACKET_get_sub_packet_len(&body, &spkt, 2)) { SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } /* ssl_cipher_list_to_bytes() raises SSLerr if appropriate */ if (!ssl_cipher_list_to_bytes(s, SSL_get_ciphers(s), &spkt)) goto err; if (!PACKETW_close(&spkt)) { if (!WPACKET_close(&spkt)) { SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } /* COMPRESSION */ if (!PACKETW_get_sub_packet_len(&body, &spkt, 1)) { if (!WPACKET_get_sub_packet_len(&body, &spkt, 1)) { SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } Loading @@ -835,7 +835,7 @@ int tls_construct_client_hello(SSL *s) int compnum = sk_SSL_COMP_num(s->ctx->comp_methods); for (i = 0; i < compnum; i++) { comp = sk_SSL_COMP_value(s->ctx->comp_methods, i); if (!PACKETW_put_bytes(&spkt, comp->id, 1)) { if (!WPACKET_put_bytes(&spkt, comp->id, 1)) { SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } Loading @@ -843,7 +843,7 @@ int tls_construct_client_hello(SSL *s) } #endif /* Add the NULL method */ if (!PACKETW_put_bytes(&spkt, 0, 1) || !PACKETW_close(&spkt)) { if (!WPACKET_put_bytes(&spkt, 0, 1) || !WPACKET_close(&spkt)) { SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } Loading @@ -853,21 +853,21 @@ int tls_construct_client_hello(SSL *s) SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT); goto err; } if (!PACKETW_get_sub_packet_len(&body, &spkt, 2) if (!WPACKET_get_sub_packet_len(&body, &spkt, 2) /* * If extensions are of zero length then we don't even add the * extensions length bytes */ || !PACKETW_set_flags(&spkt, OPENSSL_PACKETW_FLAGS_ABANDON_ON_ZERO_LENGTH) || !WPACKET_set_flags(&spkt, OPENSSL_WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH) || !ssl_add_clienthello_tlsext(s, &spkt, &al) || !PACKETW_close(&spkt)) { || !WPACKET_close(&spkt)) { ssl3_send_alert(s, SSL3_AL_FATAL, al); SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } if (!PACKETW_close(&body) || !ssl_close_construct_packet(s, &pkt)) { if (!WPACKET_close(&body) || !ssl_close_construct_packet(s, &pkt)) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; Loading Loading @@ -2917,7 +2917,7 @@ int ssl_do_client_cert_cb(SSL *s, X509 **px509, EVP_PKEY **ppkey) return i; } int ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *sk, PACKETW *pkt) int ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *sk, WPACKET *pkt) { int i; size_t totlen = 0, len, maxlen; Loading Loading
ssl/packet.c +45 −45 Original line number Diff line number Diff line Loading @@ -10,10 +10,10 @@ #include "packet_locl.h" /* * Allocate bytes in the PACKETW_BUF for the output. This reserves the bytes * Allocate bytes in the WPACKET_BUF for the output. This reserves the bytes * and count them as "written", but doesn't actually do the writing. */ static unsigned char *PACKETW_BUF_allocate(PACKETW_BUF *wbuf, size_t len) static unsigned char *WPACKET_BUF_allocate(WPACKET_BUF *wbuf, size_t len) { unsigned char *ret = wbuf->curr; Loading @@ -40,19 +40,19 @@ static unsigned char *PACKETW_BUF_allocate(PACKETW_BUF *wbuf, size_t len) } /* * Initialise a PACKETW with the buffer in |buf|. The buffer must exist * for the whole time that the PACKETW is being used. Additionally |lenbytes| of * Initialise a WPACKET with the buffer in |buf|. The buffer must exist * for the whole time that the WPACKET is being used. Additionally |lenbytes| of * data is preallocated at the start of the buffer to store the length of the * PACKETW once we know it. * WPACKET once we know it. */ int PACKETW_init_len(PACKETW *pkt, BUF_MEM *buf, size_t lenbytes) int WPACKET_init_len(WPACKET *pkt, BUF_MEM *buf, size_t lenbytes) { PACKETW_BUF *wbuf; WPACKET_BUF *wbuf; /* Sanity check */ if (buf == NULL) return 0; wbuf = OPENSSL_zalloc(sizeof(PACKETW_BUF)); wbuf = OPENSSL_zalloc(sizeof(WPACKET_BUF)); if (wbuf == NULL) { pkt->isclosed = 1; return 0; Loading @@ -75,7 +75,7 @@ int PACKETW_init_len(PACKETW *pkt, BUF_MEM *buf, size_t lenbytes) return 1; } pkt->packet_len = PACKETW_BUF_allocate(wbuf, lenbytes); pkt->packet_len = WPACKET_BUF_allocate(wbuf, lenbytes); if (pkt->packet_len == NULL) { OPENSSL_free(wbuf); pkt->wbuf = NULL; Loading @@ -87,23 +87,23 @@ int PACKETW_init_len(PACKETW *pkt, BUF_MEM *buf, size_t lenbytes) } /* * Same as PACKETW_init_len except there is no preallocation of the PACKETW * Same as WPACKET_init_len except there is no preallocation of the WPACKET * length. */ int PACKETW_init(PACKETW *pkt, BUF_MEM *buf) int WPACKET_init(WPACKET *pkt, BUF_MEM *buf) { return PACKETW_init_len(pkt, buf, 0); return WPACKET_init_len(pkt, buf, 0); } /* * Set the PACKETW length, and the location for where we should write that * length. Normally this will be at the start of the PACKETW, and therefore * the PACKETW would have been initialised via PACKETW_init_len(). However there * Set the WPACKET length, and the location for where we should write that * length. Normally this will be at the start of the WPACKET, and therefore * the WPACKET would have been initialised via WPACKET_init_len(). However there * is the possibility that the length needs to be written to some other location * other than the start of the PACKETW. In that case init via PACKETW_init() and * other than the start of the WPACKET. In that case init via WPACKET_init() and * then set the location for the length using this function. */ int PACKETW_set_packet_len(PACKETW *pkt, unsigned char *packet_len, int WPACKET_set_packet_len(WPACKET *pkt, unsigned char *packet_len, size_t lenbytes) { /* We only allow this to be set once */ Loading @@ -116,7 +116,7 @@ int PACKETW_set_packet_len(PACKETW *pkt, unsigned char *packet_len, return 1; } int PACKETW_set_flags(PACKETW *pkt, unsigned int flags) int WPACKET_set_flags(WPACKET *pkt, unsigned int flags) { pkt->flags = flags; Loading @@ -124,12 +124,12 @@ int PACKETW_set_flags(PACKETW *pkt, unsigned int flags) } /* * Closes the PACKETW and marks it as invalid for future writes. It also writes * Closes the WPACKET and marks it as invalid for future writes. It also writes * out the length of the packet to the required location (normally the start * of the PACKETW) if appropriate. A PACKETW cannot be closed if it has an * of the WPACKET) if appropriate. A WPACKET cannot be closed if it has an * active sub-packet. */ int PACKETW_close(PACKETW *pkt) int WPACKET_close(WPACKET *pkt) { size_t packlen; Loading @@ -137,12 +137,12 @@ int PACKETW_close(PACKETW *pkt) return 0; packlen = pkt->wbuf->written - pkt->pwritten; if (packlen == 0 && pkt->flags & OPENSSL_PACKETW_FLAGS_NON_ZERO_LENGTH) if (packlen == 0 && pkt->flags & OPENSSL_WPACKET_FLAGS_NON_ZERO_LENGTH) return 0; if (packlen == 0 && pkt->flags & OPENSSL_PACKETW_FLAGS_ABANDON_ON_ZERO_LENGTH) { /* Deallocate any bytes allocated for the length of the PACKETW */ && pkt->flags & OPENSSL_WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH) { /* Deallocate any bytes allocated for the length of the WPACKET */ if ((pkt->wbuf->curr - pkt->lenbytes) == pkt->packet_len) { pkt->wbuf->written -= pkt->lenbytes; pkt->wbuf->curr -= pkt->lenbytes; Loading @@ -152,7 +152,7 @@ int PACKETW_close(PACKETW *pkt) pkt->packet_len = NULL; } /* Write out the PACKETW length if needed */ /* Write out the WPACKET length if needed */ if (pkt->packet_len != NULL) { size_t lenbytes; Loading Loading @@ -189,7 +189,7 @@ int PACKETW_close(PACKETW *pkt) * Additionally |lenbytes| of data is preallocated at the start of the * sub-packet to store its length once we know it. */ int PACKETW_get_sub_packet_len(PACKETW *pkt, PACKETW *subpkt, size_t lenbytes) int WPACKET_get_sub_packet_len(WPACKET *pkt, WPACKET *subpkt, size_t lenbytes) { if (pkt->isclosed || pkt->haschild || subpkt == NULL) return 0; Loading @@ -207,7 +207,7 @@ int PACKETW_get_sub_packet_len(PACKETW *pkt, PACKETW *subpkt, size_t lenbytes) return 1; } subpkt->packet_len = PACKETW_BUF_allocate(pkt->wbuf, lenbytes); subpkt->packet_len = WPACKET_BUF_allocate(pkt->wbuf, lenbytes); if (subpkt->packet_len == NULL) { subpkt->isclosed = 1; return 0; Loading @@ -219,20 +219,20 @@ int PACKETW_get_sub_packet_len(PACKETW *pkt, PACKETW *subpkt, size_t lenbytes) } /* * Same as PACKETW_get_sub_packet_len() except no bytes are pre-allocated for * Same as WPACKET_get_sub_packet_len() except no bytes are pre-allocated for * the sub-packet length. */ int PACKETW_get_sub_packet(PACKETW *pkt, PACKETW *subpkt) int WPACKET_get_sub_packet(WPACKET *pkt, WPACKET *subpkt) { return PACKETW_get_sub_packet_len(pkt, subpkt, 0); return WPACKET_get_sub_packet_len(pkt, subpkt, 0); } /* * Allocate some bytes in the PACKETW for writing. That number of bytes is * Allocate some bytes in the WPACKET for writing. That number of bytes is * marked as having been written, and a pointer to their location is stored in * |*allocbytes|. */ int PACKETW_allocate_bytes(PACKETW *pkt, size_t bytes, int WPACKET_allocate_bytes(WPACKET *pkt, size_t bytes, unsigned char **allocbytes) { unsigned char *data; Loading @@ -240,7 +240,7 @@ int PACKETW_allocate_bytes(PACKETW *pkt, size_t bytes, if (pkt->isclosed || pkt->haschild || bytes == 0) return 0; data = PACKETW_BUF_allocate(pkt->wbuf, bytes); data = WPACKET_BUF_allocate(pkt->wbuf, bytes); if (data == NULL) return 0; Loading @@ -250,17 +250,17 @@ int PACKETW_allocate_bytes(PACKETW *pkt, size_t bytes, } /* * Write the value stored in |val| into the PACKETW. The value will consome * Write the value stored in |val| into the WPACKET. The value will consome * |bytes| amount of storage. An error will occur if |val| cannot be accommdated * in |bytes| storage, e.g. attempting to write the value 256 into 1 byte will * fail. */ int PACKETW_put_bytes(PACKETW *pkt, unsigned int val, size_t bytes) int WPACKET_put_bytes(WPACKET *pkt, unsigned int val, size_t bytes) { unsigned char *data; if (bytes > sizeof(unsigned int) || !PACKETW_allocate_bytes(pkt, bytes, &data)) || !WPACKET_allocate_bytes(pkt, bytes, &data)) return 0; data += bytes - 1; Loading @@ -278,10 +278,10 @@ int PACKETW_put_bytes(PACKETW *pkt, unsigned int val, size_t bytes) } /* * Set a maximum size that we will not allow the PACKETW to grow beyond. If not * Set a maximum size that we will not allow the WPACKET to grow beyond. If not * set then there is no maximum. */ int PACKETW_set_max_size(PACKETW *pkt, size_t maxsize) int WPACKET_set_max_size(WPACKET *pkt, size_t maxsize) { pkt->wbuf->maxsize = maxsize; Loading @@ -289,16 +289,16 @@ int PACKETW_set_max_size(PACKETW *pkt, size_t maxsize) } /* * Copy |len| bytes of data from |*src| into the PACKETW. * Copy |len| bytes of data from |*src| into the WPACKET. */ int PACKETW_memcpy(PACKETW *pkt, const void *src, size_t len) int WPACKET_memcpy(WPACKET *pkt, const void *src, size_t len) { unsigned char *dest; if (len == 0) return 1; if (!PACKETW_allocate_bytes(pkt, len, &dest)) if (!WPACKET_allocate_bytes(pkt, len, &dest)) return 0; memcpy(dest, src, len); Loading @@ -308,9 +308,9 @@ int PACKETW_memcpy(PACKETW *pkt, const void *src, size_t len) /* * Return the total number of bytes written so far to the underlying buffer. * This might includes bytes written by a parent PACKETW. * This might includes bytes written by a parent WPACKET. */ int PACKETW_get_total_written(PACKETW *pkt, size_t *written) int WPACKET_get_total_written(WPACKET *pkt, size_t *written) { if (pkt->isclosed || written == NULL) return 0; Loading @@ -321,10 +321,10 @@ int PACKETW_get_total_written(PACKETW *pkt, size_t *written) } /* * Returns the length of this PACKETW so far. This excludes any bytes allocated * Returns the length of this WPACKET so far. This excludes any bytes allocated * for the length itself. */ int PACKETW_get_length(PACKETW *pkt, size_t *len) int WPACKET_get_length(WPACKET *pkt, size_t *len) { if (pkt->isclosed || len == NULL) return 0; Loading
ssl/packet_locl.h +27 −27 Original line number Diff line number Diff line Loading @@ -562,25 +562,25 @@ typedef struct packetw_buf { size_t written; /* * Maximum number of bytes we will allow to be written to this PACKETW. Zero * Maximum number of bytes we will allow to be written to this WPACKET. Zero * if no maximum */ size_t maxsize; } PACKETW_BUF; } WPACKET_BUF; typedef struct packetw_st PACKETW; typedef struct packetw_st WPACKET; struct packetw_st { /* The parent PACKETW if we have one or NULL otherwise */ PACKETW *parent; /* The parent WPACKET if we have one or NULL otherwise */ WPACKET *parent; /* The actual buffer - shared with sub-packets */ PACKETW_BUF *wbuf; WPACKET_BUF *wbuf; /* Flags for this PACKETW */ /* Flags for this WPACKET */ unsigned int flags; /* * Pointer to where the length of this PACKETW goes (or NULL if we don't * Pointer to where the length of this WPACKET goes (or NULL if we don't * write the length) */ unsigned char *packet_len; Loading @@ -594,35 +594,35 @@ struct packetw_st { /* True if we have an active sub-packet or false otherwise */ int haschild; /* True if PACKETW_close() has been called on this PACKETW */ /* True if WPACKET_close() has been called on this WPACKET */ int isclosed; }; /* Flags */ #define OPENSSL_PACKETW_FLAGS_NONE 0 /* Error on PACKETW_close() if no data written to the PACKETW */ #define OPENSSL_PACKETW_FLAGS_NON_ZERO_LENGTH 1 #define OPENSSL_WPACKET_FLAGS_NONE 0 /* Error on WPACKET_close() if no data written to the WPACKET */ #define OPENSSL_WPACKET_FLAGS_NON_ZERO_LENGTH 1 /* * Abandon all changes on PACKETW_close() if no data written to the PACKETW, * Abandon all changes on WPACKET_close() if no data written to the WPACKET, * i.e. this does not write out a zero packet length */ #define OPENSSL_PACKETW_FLAGS_ABANDON_ON_ZERO_LENGTH 2 #define OPENSSL_WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH 2 int PACKETW_init_len(PACKETW *pkt, BUF_MEM *buf, size_t lenbytes); int PACKETW_init(PACKETW *pkt, BUF_MEM *buf); int PACKETW_set_flags(PACKETW *pkt, unsigned int flags); int PACKETW_set_packet_len(PACKETW *pkt, unsigned char *packet_len, int WPACKET_init_len(WPACKET *pkt, BUF_MEM *buf, size_t lenbytes); int WPACKET_init(WPACKET *pkt, BUF_MEM *buf); int WPACKET_set_flags(WPACKET *pkt, unsigned int flags); int WPACKET_set_packet_len(WPACKET *pkt, unsigned char *packet_len, size_t lenbytes); int PACKETW_close(PACKETW *pkt); int PACKETW_get_sub_packet_len(PACKETW *pkt, PACKETW *subpkt, size_t lenbytes); int PACKETW_get_sub_packet(PACKETW *pkt, PACKETW *subpkt); int PACKETW_allocate_bytes(PACKETW *pkt, size_t bytes, int WPACKET_close(WPACKET *pkt); int WPACKET_get_sub_packet_len(WPACKET *pkt, WPACKET *subpkt, size_t lenbytes); int WPACKET_get_sub_packet(WPACKET *pkt, WPACKET *subpkt); int WPACKET_allocate_bytes(WPACKET *pkt, size_t bytes, unsigned char **allocbytes); int PACKETW_put_bytes(PACKETW *pkt, unsigned int val, size_t bytes); int PACKETW_set_max_size(PACKETW *pkt, size_t maxsize); int PACKETW_memcpy(PACKETW *pkt, const void *src, size_t len); int PACKETW_get_total_written(PACKETW *pkt, size_t *written); int PACKETW_get_length(PACKETW *pkt, size_t *len); int WPACKET_put_bytes(WPACKET *pkt, unsigned int val, size_t bytes); int WPACKET_set_max_size(WPACKET *pkt, size_t maxsize); int WPACKET_memcpy(WPACKET *pkt, const void *src, size_t len); int WPACKET_get_total_written(WPACKET *pkt, size_t *written); int WPACKET_get_length(WPACKET *pkt, size_t *len); # ifdef __cplusplus } Loading
ssl/s3_lib.c +7 −7 Original line number Diff line number Diff line Loading @@ -2790,16 +2790,16 @@ int ssl3_set_handshake_header(SSL *s, int htype, unsigned long len) } /* * Temporary name. To be renamed ssl3_set_handshake_header() once all PACKETW * Temporary name. To be renamed ssl3_set_handshake_header() once all WPACKET * conversion is complete. The old ssl3_set_handshake_heder() can be deleted * at that point. * TODO - RENAME ME */ int ssl3_set_handshake_header2(SSL *s, PACKETW *pkt, PACKETW *body, int htype) int ssl3_set_handshake_header2(SSL *s, WPACKET *pkt, WPACKET *body, int htype) { /* Set the content type and 3 bytes for the message len */ if (!PACKETW_put_bytes(pkt, htype, 1) || !PACKETW_get_sub_packet_len(pkt, body, 3)) if (!WPACKET_put_bytes(pkt, htype, 1) || !WPACKET_get_sub_packet_len(pkt, body, 3)) return 0; return 1; Loading Loading @@ -3573,7 +3573,7 @@ const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p) /* * Old version of the ssl3_put_cipher_by_char function used by code that has not * yet been converted to PACKETW yet. It will be deleted once PACKETW conversion * yet been converted to WPACKET yet. It will be deleted once WPACKET conversion * is complete. * TODO - DELETE ME */ Loading @@ -3591,14 +3591,14 @@ int ssl3_put_cipher_by_char_old(const SSL_CIPHER *c, unsigned char *p) return (2); } int ssl3_put_cipher_by_char(const SSL_CIPHER *c, PACKETW *pkt, size_t *len) int ssl3_put_cipher_by_char(const SSL_CIPHER *c, WPACKET *pkt, size_t *len) { if ((c->id & 0xff000000) != 0x03000000) { *len = 0; return 1; } if (!PACKETW_put_bytes(pkt, c->id & 0xffff, 2)) if (!WPACKET_put_bytes(pkt, c->id & 0xffff, 2)) return 0; *len = 2; Loading
ssl/ssl_locl.h +11 −11 Original line number Diff line number Diff line Loading @@ -457,7 +457,7 @@ struct ssl_method_st { long (*ssl_ctrl) (SSL *s, int cmd, long larg, void *parg); long (*ssl_ctx_ctrl) (SSL_CTX *ctx, int cmd, long larg, void *parg); const SSL_CIPHER *(*get_cipher_by_char) (const unsigned char *ptr); int (*put_cipher_by_char) (const SSL_CIPHER *cipher, PACKETW *pkt, int (*put_cipher_by_char) (const SSL_CIPHER *cipher, WPACKET *pkt, size_t *len); int (*ssl_pending) (const SSL *s); int (*num_ciphers) (void); Loading Loading @@ -1586,10 +1586,10 @@ typedef struct ssl3_enc_method { /* Set the handshake header */ int (*set_handshake_header) (SSL *s, int type, unsigned long len); /* Set the handshake header */ int (*set_handshake_header2) (SSL *s, PACKETW *pkt, PACKETW *body, int (*set_handshake_header2) (SSL *s, WPACKET *pkt, WPACKET *body, int type); /* Close construction of the handshake message */ int (*close_construct_packet) (SSL *s, PACKETW *pkt); int (*close_construct_packet) (SSL *s, WPACKET *pkt); /* Write out handshake message */ int (*do_write) (SSL *s); } SSL3_ENC_METHOD; Loading Loading @@ -1865,7 +1865,7 @@ __owur EVP_PKEY *ssl_dh_to_pkey(DH *dh); __owur const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p); __owur int ssl3_put_cipher_by_char_old(const SSL_CIPHER *c, unsigned char *p); __owur int ssl3_put_cipher_by_char(const SSL_CIPHER *c, PACKETW *pkt, __owur int ssl3_put_cipher_by_char(const SSL_CIPHER *c, WPACKET *pkt, size_t *len); int ssl3_init_finished_mac(SSL *s); __owur int ssl3_setup_key_block(SSL *s); Loading Loading @@ -1906,12 +1906,12 @@ __owur int ssl3_do_change_cipher_spec(SSL *ssl); __owur long ssl3_default_timeout(void); __owur int ssl3_set_handshake_header(SSL *s, int htype, unsigned long len); __owur int ssl3_set_handshake_header2(SSL *s, PACKETW *pkt, PACKETW *body, __owur int ssl3_set_handshake_header2(SSL *s, WPACKET *pkt, WPACKET *body, int htype); __owur int tls_close_construct_packet(SSL *s, PACKETW *pkt); __owur int dtls1_set_handshake_header2(SSL *s, PACKETW *pkt, PACKETW *body, __owur int tls_close_construct_packet(SSL *s, WPACKET *pkt); __owur int dtls1_set_handshake_header2(SSL *s, WPACKET *pkt, WPACKET *body, int htype); __owur int dtls1_close_construct_packet(SSL *s, PACKETW *pkt); __owur int dtls1_close_construct_packet(SSL *s, WPACKET *pkt); __owur int ssl3_handshake_write(SSL *s); __owur int ssl_allow_compression(SSL *s); Loading Loading @@ -2020,7 +2020,7 @@ __owur EVP_PKEY *ssl_generate_pkey_curve(int id); __owur int tls1_shared_list(SSL *s, const unsigned char *l1, size_t l1len, const unsigned char *l2, size_t l2len, int nmatch); __owur int ssl_add_clienthello_tlsext(SSL *s, PACKETW *pkt, int *al); __owur int ssl_add_clienthello_tlsext(SSL *s, WPACKET *pkt, int *al); __owur unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, unsigned char *limit, int *al); __owur int ssl_parse_clienthello_tlsext(SSL *s, PACKET *pkt); Loading Loading @@ -2075,7 +2075,7 @@ __owur int ssl_parse_clienthello_renegotiate_ext(SSL *s, PACKET *pkt, int *al); __owur long ssl_get_algorithm2(SSL *s); __owur size_t tls12_copy_sigalgs_old(SSL *s, unsigned char *out, const unsigned char *psig, size_t psiglen); __owur int tls12_copy_sigalgs(SSL *s, PACKETW *pkt, __owur int tls12_copy_sigalgs(SSL *s, WPACKET *pkt, const unsigned char *psig, size_t psiglen); __owur int tls1_save_sigalgs(SSL *s, const unsigned char *data, int dsize); __owur int tls1_process_sigalgs(SSL *s); Loading Loading @@ -2125,7 +2125,7 @@ __owur int custom_ext_parse(SSL *s, int server, int *al); __owur int custom_ext_add_old(SSL *s, int server, unsigned char **pret, unsigned char *limit, int *al); __owur int custom_ext_add(SSL *s, int server, PACKETW *pkt, int *al); __owur int custom_ext_add(SSL *s, int server, WPACKET *pkt, int *al); __owur int custom_exts_copy(custom_ext_methods *dst, const custom_ext_methods *src); Loading
ssl/statem/statem_clnt.c +23 −23 Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ static ossl_inline int cert_req_allowed(SSL *s); static int key_exchange_expected(SSL *s); static int ca_dn_cmp(const X509_NAME *const *a, const X509_NAME *const *b); static int ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *sk, PACKETW *pkt); WPACKET *pkt); /* * Is a CertificateRequest message allowed at the moment or not? Loading Loading @@ -697,10 +697,10 @@ int tls_construct_client_hello(SSL *s) SSL_COMP *comp; #endif SSL_SESSION *sess = s->session; PACKETW pkt, body, spkt; WPACKET pkt, body, spkt; if (!PACKETW_init(&pkt, s->init_buf) || !PACKETW_set_max_size(&pkt, SSL3_RT_MAX_PLAIN_LENGTH)) { if (!WPACKET_init(&pkt, s->init_buf) || !WPACKET_set_max_size(&pkt, SSL3_RT_MAX_PLAIN_LENGTH)) { /* Should not happen */ SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; Loading Loading @@ -782,8 +782,8 @@ int tls_construct_client_hello(SSL *s) * client_version in client hello and not resetting it to * the negotiated version. */ if (!PACKETW_put_bytes(&body, s->client_version, 2) || !PACKETW_memcpy(&body, s->s3->client_random, SSL3_RANDOM_SIZE)) { if (!WPACKET_put_bytes(&body, s->client_version, 2) || !WPACKET_memcpy(&body, s->s3->client_random, SSL3_RANDOM_SIZE)) { SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } Loading @@ -794,9 +794,9 @@ int tls_construct_client_hello(SSL *s) else i = s->session->session_id_length; if (i > (int)sizeof(s->session->session_id) || !PACKETW_get_sub_packet_len(&body, &spkt, 1) || (i != 0 && !PACKETW_memcpy(&spkt, s->session->session_id, i)) || !PACKETW_close(&spkt)) { || !WPACKET_get_sub_packet_len(&body, &spkt, 1) || (i != 0 && !WPACKET_memcpy(&spkt, s->session->session_id, i)) || !WPACKET_close(&spkt)) { SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } Loading @@ -804,29 +804,29 @@ int tls_construct_client_hello(SSL *s) /* cookie stuff for DTLS */ if (SSL_IS_DTLS(s)) { if (s->d1->cookie_len > sizeof(s->d1->cookie) || !PACKETW_get_sub_packet_len(&body, &spkt, 1) || !PACKETW_memcpy(&spkt, s->d1->cookie, s->d1->cookie_len) || !PACKETW_close(&spkt)) { || !WPACKET_get_sub_packet_len(&body, &spkt, 1) || !WPACKET_memcpy(&spkt, s->d1->cookie, s->d1->cookie_len) || !WPACKET_close(&spkt)) { SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } } /* Ciphers supported */ if (!PACKETW_get_sub_packet_len(&body, &spkt, 2)) { if (!WPACKET_get_sub_packet_len(&body, &spkt, 2)) { SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } /* ssl_cipher_list_to_bytes() raises SSLerr if appropriate */ if (!ssl_cipher_list_to_bytes(s, SSL_get_ciphers(s), &spkt)) goto err; if (!PACKETW_close(&spkt)) { if (!WPACKET_close(&spkt)) { SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } /* COMPRESSION */ if (!PACKETW_get_sub_packet_len(&body, &spkt, 1)) { if (!WPACKET_get_sub_packet_len(&body, &spkt, 1)) { SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } Loading @@ -835,7 +835,7 @@ int tls_construct_client_hello(SSL *s) int compnum = sk_SSL_COMP_num(s->ctx->comp_methods); for (i = 0; i < compnum; i++) { comp = sk_SSL_COMP_value(s->ctx->comp_methods, i); if (!PACKETW_put_bytes(&spkt, comp->id, 1)) { if (!WPACKET_put_bytes(&spkt, comp->id, 1)) { SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } Loading @@ -843,7 +843,7 @@ int tls_construct_client_hello(SSL *s) } #endif /* Add the NULL method */ if (!PACKETW_put_bytes(&spkt, 0, 1) || !PACKETW_close(&spkt)) { if (!WPACKET_put_bytes(&spkt, 0, 1) || !WPACKET_close(&spkt)) { SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } Loading @@ -853,21 +853,21 @@ int tls_construct_client_hello(SSL *s) SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT); goto err; } if (!PACKETW_get_sub_packet_len(&body, &spkt, 2) if (!WPACKET_get_sub_packet_len(&body, &spkt, 2) /* * If extensions are of zero length then we don't even add the * extensions length bytes */ || !PACKETW_set_flags(&spkt, OPENSSL_PACKETW_FLAGS_ABANDON_ON_ZERO_LENGTH) || !WPACKET_set_flags(&spkt, OPENSSL_WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH) || !ssl_add_clienthello_tlsext(s, &spkt, &al) || !PACKETW_close(&spkt)) { || !WPACKET_close(&spkt)) { ssl3_send_alert(s, SSL3_AL_FATAL, al); SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } if (!PACKETW_close(&body) || !ssl_close_construct_packet(s, &pkt)) { if (!WPACKET_close(&body) || !ssl_close_construct_packet(s, &pkt)) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; Loading Loading @@ -2917,7 +2917,7 @@ int ssl_do_client_cert_cb(SSL *s, X509 **px509, EVP_PKEY **ppkey) return i; } int ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *sk, PACKETW *pkt) int ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *sk, WPACKET *pkt) { int i; size_t totlen = 0, len, maxlen; Loading