Lines Matching full:pos

45 	u8 *pos, *rhdr, *hs_start, *hs_length, *ext_start;  in tls_write_server_hello()  local
49 pos = *msgpos; in tls_write_server_hello()
52 rhdr = pos; in tls_write_server_hello()
53 pos += TLS_RECORD_HEADER_LEN; in tls_write_server_hello()
80 hs_start = pos; in tls_write_server_hello()
82 *pos++ = TLS_HANDSHAKE_TYPE_SERVER_HELLO; in tls_write_server_hello()
84 hs_length = pos; in tls_write_server_hello()
85 pos += 3; in tls_write_server_hello()
88 WPA_PUT_BE16(pos, conn->rl.tls_version); in tls_write_server_hello()
89 pos += 2; in tls_write_server_hello()
91 os_memcpy(pos, conn->server_random, TLS_RANDOM_LEN); in tls_write_server_hello()
92 pos += TLS_RANDOM_LEN; in tls_write_server_hello()
94 *pos++ = conn->session_id_len; in tls_write_server_hello()
95 os_memcpy(pos, conn->session_id, conn->session_id_len); in tls_write_server_hello()
96 pos += conn->session_id_len; in tls_write_server_hello()
98 WPA_PUT_BE16(pos, conn->cipher_suite); in tls_write_server_hello()
99 pos += 2; in tls_write_server_hello()
101 *pos++ = TLS_COMPRESSION_NULL; in tls_write_server_hello()
104 ext_start = pos; in tls_write_server_hello()
105 pos += 2; in tls_write_server_hello()
110 WPA_PUT_BE16(pos, TLS_EXT_STATUS_REQUEST); in tls_write_server_hello()
111 pos += 2; in tls_write_server_hello()
113 WPA_PUT_BE16(pos, 0); in tls_write_server_hello()
114 pos += 2; in tls_write_server_hello()
122 WPA_PUT_BE16(pos, TLS_EXT_STATUS_REQUEST_V2); in tls_write_server_hello()
123 pos += 2; in tls_write_server_hello()
125 WPA_PUT_BE16(pos, 0); in tls_write_server_hello()
126 pos += 2; in tls_write_server_hello()
165 if (pos == ext_start + 2) in tls_write_server_hello()
166 pos -= 2; /* no extensions */ in tls_write_server_hello()
168 WPA_PUT_BE16(ext_start, pos - ext_start - 2); in tls_write_server_hello()
170 WPA_PUT_BE24(hs_length, pos - hs_length - 3); in tls_write_server_hello()
171 tls_verify_hash_add(&conn->verify, hs_start, pos - hs_start); in tls_write_server_hello()
174 rhdr, end - rhdr, hs_start, pos - hs_start, in tls_write_server_hello()
181 pos = rhdr + rlen; in tls_write_server_hello()
183 *msgpos = pos; in tls_write_server_hello()
192 u8 *pos, *rhdr, *hs_start, *hs_length, *cert_start; in tls_write_server_certificate() local
204 pos = *msgpos; in tls_write_server_certificate()
205 if (TLS_RECORD_HEADER_LEN + 1 + 3 + 3 > end - pos) { in tls_write_server_certificate()
212 rhdr = pos; in tls_write_server_certificate()
213 pos += TLS_RECORD_HEADER_LEN; in tls_write_server_certificate()
218 hs_start = pos; in tls_write_server_certificate()
220 *pos++ = TLS_HANDSHAKE_TYPE_CERTIFICATE; in tls_write_server_certificate()
222 hs_length = pos; in tls_write_server_certificate()
223 pos += 3; in tls_write_server_certificate()
226 cert_start = pos; in tls_write_server_certificate()
227 pos += 3; in tls_write_server_certificate()
230 if (3 + cert->cert_len > (size_t) (end - pos)) { in tls_write_server_certificate()
234 (unsigned long) (end - pos)); in tls_write_server_certificate()
239 WPA_PUT_BE24(pos, cert->cert_len); in tls_write_server_certificate()
240 pos += 3; in tls_write_server_certificate()
241 os_memcpy(pos, cert->cert_start, cert->cert_len); in tls_write_server_certificate()
242 pos += cert->cert_len; in tls_write_server_certificate()
259 WPA_PUT_BE24(cert_start, pos - cert_start - 3); in tls_write_server_certificate()
261 WPA_PUT_BE24(hs_length, pos - hs_length - 3); in tls_write_server_certificate()
264 rhdr, end - rhdr, hs_start, pos - hs_start, in tls_write_server_certificate()
271 pos = rhdr + rlen; in tls_write_server_certificate()
273 tls_verify_hash_add(&conn->verify, hs_start, pos - hs_start); in tls_write_server_certificate()
275 *msgpos = pos; in tls_write_server_certificate()
287 u8 *pos, *rhdr, *hs_start, *hs_length; in tls_write_server_certificate_status() local
298 pos = *msgpos; in tls_write_server_certificate_status()
300 (unsigned int) (end - pos)) { in tls_write_server_certificate_status()
307 rhdr = pos; in tls_write_server_certificate_status()
308 pos += TLS_RECORD_HEADER_LEN; in tls_write_server_certificate_status()
313 hs_start = pos; in tls_write_server_certificate_status()
315 *pos++ = TLS_HANDSHAKE_TYPE_CERTIFICATE_STATUS; in tls_write_server_certificate_status()
317 hs_length = pos; in tls_write_server_certificate_status()
318 pos += 3; in tls_write_server_certificate_status()
339 *pos++ = 2; /* ocsp_multi(2) */ in tls_write_server_certificate_status()
341 *pos++ = 1; /* ocsp(1) */ in tls_write_server_certificate_status()
343 WPA_PUT_BE24(pos, ocsp_resp_len); in tls_write_server_certificate_status()
344 pos += 3; in tls_write_server_certificate_status()
345 os_memcpy(pos, ocsp_resp, ocsp_resp_len); in tls_write_server_certificate_status()
346 pos += ocsp_resp_len; in tls_write_server_certificate_status()
348 WPA_PUT_BE24(hs_length, pos - hs_length - 3); in tls_write_server_certificate_status()
351 rhdr, end - rhdr, hs_start, pos - hs_start, in tls_write_server_certificate_status()
358 pos = rhdr + rlen; in tls_write_server_certificate_status()
360 tls_verify_hash_add(&conn->verify, hs_start, pos - hs_start); in tls_write_server_certificate_status()
362 *msgpos = pos; in tls_write_server_certificate_status()
373 u8 *pos, *rhdr, *hs_start, *hs_length, *server_params; in tls_write_server_key_exchange() local
429 pos = conn->dh_secret; in tls_write_server_key_exchange()
430 while (pos + 1 < conn->dh_secret + conn->dh_secret_len && *pos == 0) in tls_write_server_key_exchange()
431 pos++; in tls_write_server_key_exchange()
432 if (pos != conn->dh_secret) { in tls_write_server_key_exchange()
433 os_memmove(conn->dh_secret, pos, in tls_write_server_key_exchange()
434 conn->dh_secret_len - (pos - conn->dh_secret)); in tls_write_server_key_exchange()
435 conn->dh_secret_len -= pos - conn->dh_secret; in tls_write_server_key_exchange()
481 pos = *msgpos; in tls_write_server_key_exchange()
484 rhdr = pos; in tls_write_server_key_exchange()
485 pos += TLS_RECORD_HEADER_LEN; in tls_write_server_key_exchange()
490 hs_start = pos; in tls_write_server_key_exchange()
492 *pos++ = TLS_HANDSHAKE_TYPE_SERVER_KEY_EXCHANGE; in tls_write_server_key_exchange()
494 hs_length = pos; in tls_write_server_key_exchange()
495 pos += 3; in tls_write_server_key_exchange()
498 server_params = pos; in tls_write_server_key_exchange()
500 if (2 + dh_p_len > (size_t) (end - pos)) { in tls_write_server_key_exchange()
508 WPA_PUT_BE16(pos, dh_p_len); in tls_write_server_key_exchange()
509 pos += 2; in tls_write_server_key_exchange()
510 os_memcpy(pos, dh_p, dh_p_len); in tls_write_server_key_exchange()
511 pos += dh_p_len; in tls_write_server_key_exchange()
514 if (2 + conn->cred->dh_g_len > (size_t) (end - pos)) { in tls_write_server_key_exchange()
522 WPA_PUT_BE16(pos, conn->cred->dh_g_len); in tls_write_server_key_exchange()
523 pos += 2; in tls_write_server_key_exchange()
524 os_memcpy(pos, conn->cred->dh_g, conn->cred->dh_g_len); in tls_write_server_key_exchange()
525 pos += conn->cred->dh_g_len; in tls_write_server_key_exchange()
528 if (2 + dh_ys_len > (size_t) (end - pos)) { in tls_write_server_key_exchange()
536 WPA_PUT_BE16(pos, dh_ys_len); in tls_write_server_key_exchange()
537 pos += 2; in tls_write_server_key_exchange()
538 os_memcpy(pos, dh_ys, dh_ys_len); in tls_write_server_key_exchange()
539 pos += dh_ys_len; in tls_write_server_key_exchange()
575 pos - server_params, hash + 19); in tls_write_server_key_exchange()
587 if (hlen < 0 || end - pos < 2) { in tls_write_server_key_exchange()
592 *pos++ = TLS_HASH_ALG_SHA256; in tls_write_server_key_exchange()
593 *pos++ = TLS_SIGN_ALG_RSA; in tls_write_server_key_exchange()
623 pos - server_params, hash, sizeof(hash)); in tls_write_server_key_exchange()
653 signed_start = pos; /* length to be filled */ in tls_write_server_key_exchange()
654 pos += 2; in tls_write_server_key_exchange()
655 clen = end - pos; in tls_write_server_key_exchange()
658 pos, &clen) < 0) { in tls_write_server_key_exchange()
668 pos[clen - 1] ^= 0x80; in tls_write_server_key_exchange()
672 pos += clen; in tls_write_server_key_exchange()
675 WPA_PUT_BE24(hs_length, pos - hs_length - 3); in tls_write_server_key_exchange()
678 rhdr, end - rhdr, hs_start, pos - hs_start, in tls_write_server_key_exchange()
685 pos = rhdr + rlen; in tls_write_server_key_exchange()
687 tls_verify_hash_add(&conn->verify, hs_start, pos - hs_start); in tls_write_server_key_exchange()
689 *msgpos = pos; in tls_write_server_key_exchange()
698 u8 *pos, *rhdr, *hs_start, *hs_length; in tls_write_server_certificate_request() local
706 pos = *msgpos; in tls_write_server_certificate_request()
709 rhdr = pos; in tls_write_server_certificate_request()
710 pos += TLS_RECORD_HEADER_LEN; in tls_write_server_certificate_request()
715 hs_start = pos; in tls_write_server_certificate_request()
717 *pos++ = TLS_HANDSHAKE_TYPE_CERTIFICATE_REQUEST; in tls_write_server_certificate_request()
719 hs_length = pos; in tls_write_server_certificate_request()
720 pos += 3; in tls_write_server_certificate_request()
730 *pos++ = 1; in tls_write_server_certificate_request()
731 *pos++ = 1; /* rsa_sign */ in tls_write_server_certificate_request()
738 WPA_PUT_BE16(pos, 0); in tls_write_server_certificate_request()
739 pos += 2; in tls_write_server_certificate_request()
741 WPA_PUT_BE24(hs_length, pos - hs_length - 3); in tls_write_server_certificate_request()
744 rhdr, end - rhdr, hs_start, pos - hs_start, in tls_write_server_certificate_request()
751 pos = rhdr + rlen; in tls_write_server_certificate_request()
753 tls_verify_hash_add(&conn->verify, hs_start, pos - hs_start); in tls_write_server_certificate_request()
755 *msgpos = pos; in tls_write_server_certificate_request()
764 u8 *pos; in tls_write_server_hello_done() local
773 pos = payload; in tls_write_server_hello_done()
775 *pos++ = TLS_HANDSHAKE_TYPE_SERVER_HELLO_DONE; in tls_write_server_hello_done()
777 WPA_PUT_BE24(pos, 0); in tls_write_server_hello_done()
778 pos += 3; in tls_write_server_hello_done()
782 *msgpos, end - *msgpos, payload, pos - payload, in tls_write_server_hello_done()
790 tls_verify_hash_add(&conn->verify, payload, pos - payload); in tls_write_server_hello_done()
834 u8 *pos, *hs_start; in tls_write_server_finished() local
839 pos = *msgpos; in tls_write_server_finished()
906 pos = hs_start = verify_data; in tls_write_server_finished()
908 *pos++ = TLS_HANDSHAKE_TYPE_FINISHED; in tls_write_server_finished()
910 WPA_PUT_BE24(pos, TLS_VERIFY_DATA_LEN); in tls_write_server_finished()
911 pos += 3; in tls_write_server_finished()
912 pos += TLS_VERIFY_DATA_LEN; in tls_write_server_finished()
913 tls_verify_hash_add(&conn->verify, hs_start, pos - hs_start); in tls_write_server_finished()
916 *msgpos, end - *msgpos, hs_start, pos - hs_start, in tls_write_server_finished()
932 u8 *msg, *end, *pos; in tls_send_server_hello() local
962 pos = msg; in tls_send_server_hello()
965 if (tls_write_server_hello(conn, &pos, end) < 0) { in tls_send_server_hello()
975 if (tls_write_server_change_cipher_spec(conn, &pos, end) < 0 || in tls_send_server_hello()
976 tls_write_server_finished(conn, &pos, end) < 0) { in tls_send_server_hello()
981 *out_len = pos - msg; in tls_send_server_hello()
989 if (tls_write_server_certificate(conn, &pos, end) < 0 || in tls_send_server_hello()
990 tls_write_server_certificate_status(conn, &pos, end, ocsp_multi, in tls_send_server_hello()
992 tls_write_server_key_exchange(conn, &pos, end) < 0 || in tls_send_server_hello()
993 tls_write_server_certificate_request(conn, &pos, end) < 0 || in tls_send_server_hello()
994 tls_write_server_hello_done(conn, &pos, end) < 0) { in tls_send_server_hello()
1001 *out_len = pos - msg; in tls_send_server_hello()
1012 u8 *msg, *end, *pos; in tls_send_change_cipher_spec() local
1020 pos = msg; in tls_send_change_cipher_spec()
1023 if (tls_write_server_change_cipher_spec(conn, &pos, end) < 0 || in tls_send_change_cipher_spec()
1024 tls_write_server_finished(conn, &pos, end) < 0) { in tls_send_change_cipher_spec()
1029 *out_len = pos - msg; in tls_send_change_cipher_spec()
1060 u8 *alert, *pos, *length; in tlsv1_server_send_alert() local
1069 pos = alert; in tlsv1_server_send_alert()
1073 *pos++ = TLS_CONTENT_TYPE_ALERT; in tlsv1_server_send_alert()
1075 WPA_PUT_BE16(pos, conn->rl.tls_version ? conn->rl.tls_version : in tlsv1_server_send_alert()
1077 pos += 2; in tlsv1_server_send_alert()
1079 length = pos; in tlsv1_server_send_alert()
1080 pos += 2; in tlsv1_server_send_alert()
1085 *pos++ = level; in tlsv1_server_send_alert()
1087 *pos++ = description; in tlsv1_server_send_alert()
1089 WPA_PUT_BE16(length, pos - length - 2); in tlsv1_server_send_alert()
1090 *out_len = pos - alert; in tlsv1_server_send_alert()