diff options
Diffstat (limited to 'src/daemon/https/tls/gnutls_session_pack.c')
-rw-r--r-- | src/daemon/https/tls/gnutls_session_pack.c | 91 |
1 files changed, 50 insertions, 41 deletions
diff --git a/src/daemon/https/tls/gnutls_session_pack.c b/src/daemon/https/tls/gnutls_session_pack.c index 258cd9c2..ab359f6c 100644 --- a/src/daemon/https/tls/gnutls_session_pack.c +++ b/src/daemon/https/tls/gnutls_session_pack.c | |||
@@ -50,7 +50,8 @@ static int unpack_certificate_auth_info (MHD_gtls_session_t, | |||
50 | packed_session); | 50 | packed_session); |
51 | 51 | ||
52 | static int unpack_security_parameters (MHD_gtls_session_t session, | 52 | static int unpack_security_parameters (MHD_gtls_session_t session, |
53 | const MHD_gnutls_datum_t * packed_session); | 53 | const MHD_gnutls_datum_t * |
54 | packed_session); | ||
54 | static int pack_security_parameters (MHD_gtls_session_t session, | 55 | static int pack_security_parameters (MHD_gtls_session_t session, |
55 | MHD_gnutls_datum_t * packed_session); | 56 | MHD_gnutls_datum_t * packed_session); |
56 | 57 | ||
@@ -180,7 +181,8 @@ unpack_anon_auth_info (MHD_gtls_session_t session, | |||
180 | 181 | ||
181 | size = MHD_gtls_read_uint32 (&packed_session->data[pos]); | 182 | size = MHD_gtls_read_uint32 (&packed_session->data[pos]); |
182 | pos += 4; | 183 | pos += 4; |
183 | ret = MHD__gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size); | 184 | ret = |
185 | MHD__gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size); | ||
184 | if (ret < 0) | 186 | if (ret < 0) |
185 | { | 187 | { |
186 | MHD_gnutls_assert (); | 188 | MHD_gnutls_assert (); |
@@ -191,7 +193,8 @@ unpack_anon_auth_info (MHD_gtls_session_t session, | |||
191 | size = MHD_gtls_read_uint32 (&packed_session->data[pos]); | 193 | size = MHD_gtls_read_uint32 (&packed_session->data[pos]); |
192 | pos += 4; | 194 | pos += 4; |
193 | ret = | 195 | ret = |
194 | MHD__gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size); | 196 | MHD__gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], |
197 | size); | ||
195 | if (ret < 0) | 198 | if (ret < 0) |
196 | { | 199 | { |
197 | MHD_gnutls_assert (); | 200 | MHD_gnutls_assert (); |
@@ -203,7 +206,7 @@ unpack_anon_auth_info (MHD_gtls_session_t session, | |||
203 | pos += 4; | 206 | pos += 4; |
204 | ret = | 207 | ret = |
205 | MHD__gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos], | 208 | MHD__gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos], |
206 | size); | 209 | size); |
207 | if (ret < 0) | 210 | if (ret < 0) |
208 | { | 211 | { |
209 | MHD_gnutls_assert (); | 212 | MHD_gnutls_assert (); |
@@ -534,7 +537,8 @@ unpack_certificate_auth_info (MHD_gtls_session_t session, | |||
534 | 537 | ||
535 | size = MHD_gtls_read_uint32 (&packed_session->data[pos]); | 538 | size = MHD_gtls_read_uint32 (&packed_session->data[pos]); |
536 | pos += 4; | 539 | pos += 4; |
537 | ret = MHD__gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size); | 540 | ret = |
541 | MHD__gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size); | ||
538 | if (ret < 0) | 542 | if (ret < 0) |
539 | { | 543 | { |
540 | MHD_gnutls_assert (); | 544 | MHD_gnutls_assert (); |
@@ -545,7 +549,8 @@ unpack_certificate_auth_info (MHD_gtls_session_t session, | |||
545 | size = MHD_gtls_read_uint32 (&packed_session->data[pos]); | 549 | size = MHD_gtls_read_uint32 (&packed_session->data[pos]); |
546 | pos += 4; | 550 | pos += 4; |
547 | ret = | 551 | ret = |
548 | MHD__gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size); | 552 | MHD__gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], |
553 | size); | ||
549 | if (ret < 0) | 554 | if (ret < 0) |
550 | { | 555 | { |
551 | MHD_gnutls_assert (); | 556 | MHD_gnutls_assert (); |
@@ -557,7 +562,7 @@ unpack_certificate_auth_info (MHD_gtls_session_t session, | |||
557 | pos += 4; | 562 | pos += 4; |
558 | ret = | 563 | ret = |
559 | MHD__gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos], | 564 | MHD__gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos], |
560 | size); | 565 | size); |
561 | if (ret < 0) | 566 | if (ret < 0) |
562 | { | 567 | { |
563 | MHD_gnutls_assert (); | 568 | MHD_gnutls_assert (); |
@@ -569,7 +574,7 @@ unpack_certificate_auth_info (MHD_gtls_session_t session, | |||
569 | pos += 4; | 574 | pos += 4; |
570 | ret = | 575 | ret = |
571 | MHD__gnutls_set_datum (&info->rsa_export.modulus, | 576 | MHD__gnutls_set_datum (&info->rsa_export.modulus, |
572 | &packed_session->data[pos], size); | 577 | &packed_session->data[pos], size); |
573 | if (ret < 0) | 578 | if (ret < 0) |
574 | { | 579 | { |
575 | MHD_gnutls_assert (); | 580 | MHD_gnutls_assert (); |
@@ -581,7 +586,7 @@ unpack_certificate_auth_info (MHD_gtls_session_t session, | |||
581 | pos += 4; | 586 | pos += 4; |
582 | ret = | 587 | ret = |
583 | MHD__gnutls_set_datum (&info->rsa_export.exponent, | 588 | MHD__gnutls_set_datum (&info->rsa_export.exponent, |
584 | &packed_session->data[pos], size); | 589 | &packed_session->data[pos], size); |
585 | if (ret < 0) | 590 | if (ret < 0) |
586 | { | 591 | { |
587 | MHD_gnutls_assert (); | 592 | MHD_gnutls_assert (); |
@@ -611,7 +616,7 @@ unpack_certificate_auth_info (MHD_gtls_session_t session, | |||
611 | 616 | ||
612 | ret = | 617 | ret = |
613 | MHD__gnutls_set_datum (&info->raw_certificate_list[i], | 618 | MHD__gnutls_set_datum (&info->raw_certificate_list[i], |
614 | &packed_session->data[pos], size); | 619 | &packed_session->data[pos], size); |
615 | pos += size; | 620 | pos += size; |
616 | 621 | ||
617 | if (ret < 0) | 622 | if (ret < 0) |
@@ -881,7 +886,8 @@ unpack_psk_auth_info (MHD_gtls_session_t session, | |||
881 | 886 | ||
882 | size = MHD_gtls_read_uint32 (&packed_session->data[pos]); | 887 | size = MHD_gtls_read_uint32 (&packed_session->data[pos]); |
883 | pos += 4; | 888 | pos += 4; |
884 | ret = MHD__gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size); | 889 | ret = |
890 | MHD__gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size); | ||
885 | if (ret < 0) | 891 | if (ret < 0) |
886 | { | 892 | { |
887 | MHD_gnutls_assert (); | 893 | MHD_gnutls_assert (); |
@@ -892,7 +898,8 @@ unpack_psk_auth_info (MHD_gtls_session_t session, | |||
892 | size = MHD_gtls_read_uint32 (&packed_session->data[pos]); | 898 | size = MHD_gtls_read_uint32 (&packed_session->data[pos]); |
893 | pos += 4; | 899 | pos += 4; |
894 | ret = | 900 | ret = |
895 | MHD__gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size); | 901 | MHD__gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], |
902 | size); | ||
896 | if (ret < 0) | 903 | if (ret < 0) |
897 | { | 904 | { |
898 | MHD_gnutls_assert (); | 905 | MHD_gnutls_assert (); |
@@ -904,7 +911,7 @@ unpack_psk_auth_info (MHD_gtls_session_t session, | |||
904 | pos += 4; | 911 | pos += 4; |
905 | ret = | 912 | ret = |
906 | MHD__gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos], | 913 | MHD__gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos], |
907 | size); | 914 | size); |
908 | if (ret < 0) | 915 | if (ret < 0) |
909 | { | 916 | { |
910 | MHD_gnutls_assert (); | 917 | MHD_gnutls_assert (); |
@@ -1045,8 +1052,9 @@ pack_security_parameters (MHD_gtls_session_t session, | |||
1045 | session->security_parameters.extensions.srp_username, len); | 1052 | session->security_parameters.extensions.srp_username, len); |
1046 | pos += len; | 1053 | pos += len; |
1047 | 1054 | ||
1048 | MHD_gtls_write_uint16 (session->security_parameters.extensions. | 1055 | MHD_gtls_write_uint16 (session->security_parameters. |
1049 | server_names_size, &packed_session->data[pos]); | 1056 | extensions.server_names_size, |
1057 | &packed_session->data[pos]); | ||
1050 | pos += 2; | 1058 | pos += 2; |
1051 | 1059 | ||
1052 | for (i = 0; i < session->security_parameters.extensions.server_names_size; | 1060 | for (i = 0; i < session->security_parameters.extensions.server_names_size; |
@@ -1054,15 +1062,15 @@ pack_security_parameters (MHD_gtls_session_t session, | |||
1054 | { | 1062 | { |
1055 | packed_session->data[pos++] = | 1063 | packed_session->data[pos++] = |
1056 | session->security_parameters.extensions.server_names[i].type; | 1064 | session->security_parameters.extensions.server_names[i].type; |
1057 | MHD_gtls_write_uint16 (session->security_parameters.extensions. | 1065 | MHD_gtls_write_uint16 (session->security_parameters. |
1058 | server_names[i].name_length, | 1066 | extensions.server_names[i].name_length, |
1059 | &packed_session->data[pos]); | 1067 | &packed_session->data[pos]); |
1060 | pos += 2; | 1068 | pos += 2; |
1061 | 1069 | ||
1062 | memcpy (&packed_session->data[pos], | 1070 | memcpy (&packed_session->data[pos], |
1063 | session->security_parameters.extensions.server_names[i].name, | 1071 | session->security_parameters.extensions.server_names[i].name, |
1064 | session->security_parameters.extensions.server_names[i]. | 1072 | session->security_parameters.extensions. |
1065 | name_length); | 1073 | server_names[i].name_length); |
1066 | pos += | 1074 | pos += |
1067 | session->security_parameters.extensions.server_names[i].name_length; | 1075 | session->security_parameters.extensions.server_names[i].name_length; |
1068 | } | 1076 | } |
@@ -1121,10 +1129,10 @@ unpack_security_parameters (MHD_gtls_session_t session, | |||
1121 | packed_session->data[pos++]; | 1129 | packed_session->data[pos++]; |
1122 | session->internals.resumed_security_parameters.write_compression_algorithm = | 1130 | session->internals.resumed_security_parameters.write_compression_algorithm = |
1123 | packed_session->data[pos++]; | 1131 | packed_session->data[pos++]; |
1124 | session->internals.resumed_security_parameters.current_cipher_suite. | 1132 | session->internals.resumed_security_parameters. |
1125 | suite[0] = packed_session->data[pos++]; | 1133 | current_cipher_suite.suite[0] = packed_session->data[pos++]; |
1126 | session->internals.resumed_security_parameters.current_cipher_suite. | 1134 | session->internals.resumed_security_parameters. |
1127 | suite[1] = packed_session->data[pos++]; | 1135 | current_cipher_suite.suite[1] = packed_session->data[pos++]; |
1128 | 1136 | ||
1129 | session->internals.resumed_security_parameters.cert_type = | 1137 | session->internals.resumed_security_parameters.cert_type = |
1130 | packed_session->data[pos++]; | 1138 | packed_session->data[pos++]; |
@@ -1173,34 +1181,35 @@ unpack_security_parameters (MHD_gtls_session_t session, | |||
1173 | 1181 | ||
1174 | /* SRP */ | 1182 | /* SRP */ |
1175 | len = packed_session->data[pos++]; /* srp username length */ | 1183 | len = packed_session->data[pos++]; /* srp username length */ |
1176 | memcpy (session->internals.resumed_security_parameters.extensions. | 1184 | memcpy (session->internals.resumed_security_parameters. |
1177 | srp_username, &packed_session->data[pos], len); | 1185 | extensions.srp_username, &packed_session->data[pos], len); |
1178 | session->internals.resumed_security_parameters.extensions. | 1186 | session->internals.resumed_security_parameters. |
1179 | srp_username[len] = 0; | 1187 | extensions.srp_username[len] = 0; |
1180 | pos += len; | 1188 | pos += len; |
1181 | 1189 | ||
1182 | session->internals.resumed_security_parameters.extensions. | 1190 | session->internals.resumed_security_parameters. |
1183 | server_names_size = MHD_gtls_read_uint16 (&packed_session->data[pos]); | 1191 | extensions.server_names_size = |
1192 | MHD_gtls_read_uint16 (&packed_session->data[pos]); | ||
1184 | pos += 2; | 1193 | pos += 2; |
1185 | for (i = 0; | 1194 | for (i = 0; |
1186 | i < | 1195 | i < |
1187 | session->internals.resumed_security_parameters.extensions. | 1196 | session->internals.resumed_security_parameters. |
1188 | server_names_size; i++) | 1197 | extensions.server_names_size; i++) |
1189 | { | 1198 | { |
1190 | session->internals.resumed_security_parameters.extensions. | 1199 | session->internals.resumed_security_parameters. |
1191 | server_names[i].type = packed_session->data[pos++]; | 1200 | extensions.server_names[i].type = packed_session->data[pos++]; |
1192 | session->internals.resumed_security_parameters.extensions. | 1201 | session->internals.resumed_security_parameters. |
1193 | server_names[i].name_length = | 1202 | extensions.server_names[i].name_length = |
1194 | MHD_gtls_read_uint16 (&packed_session->data[pos]); | 1203 | MHD_gtls_read_uint16 (&packed_session->data[pos]); |
1195 | pos += 2; | 1204 | pos += 2; |
1196 | 1205 | ||
1197 | memcpy (session->internals.resumed_security_parameters.extensions. | 1206 | memcpy (session->internals.resumed_security_parameters. |
1198 | server_names[i].name, &packed_session->data[pos], | 1207 | extensions.server_names[i].name, &packed_session->data[pos], |
1199 | session->internals.resumed_security_parameters.extensions. | 1208 | session->internals.resumed_security_parameters. |
1200 | server_names[i].name_length); | 1209 | extensions.server_names[i].name_length); |
1201 | pos += | 1210 | pos += |
1202 | session->internals.resumed_security_parameters.extensions. | 1211 | session->internals.resumed_security_parameters. |
1203 | server_names[i].name_length; | 1212 | extensions.server_names[i].name_length; |
1204 | } | 1213 | } |
1205 | return 0; | 1214 | return 0; |
1206 | } | 1215 | } |