Changeset 5406
- Timestamp:
- 03/15/08 09:31:25 (4 months ago)
- Files:
-
- libwired/trunk/config.m4 (modified) (1 diff)
- libwired/trunk/configure (modified) (2 diffs)
- libwired/trunk/configure.in (modified) (1 diff)
- libwired/trunk/libwired/p7/wi-p7-socket.c (modified) (18 diffs)
- libwired/trunk/libwired/p7/wi-p7-socket.h (modified) (3 diffs)
- libwired/trunk/libwired/p7/wi-p7-spec.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libwired/trunk/config.m4
r5030 r5406 97 97 AC_DEFUN([WI_INCLUDE_P7_LIBRARIES], [ 98 98 WI_INCLUDE_CRYPTO_LIBRARY 99 WI_INCLUDE_SSL_LIBRARY 99 100 WI_INCLUDE_LIBXML2_LIBRARY 100 101 WI_INCLUDE_ZLIB_LIBRARY libwired/trunk/configure
r5338 r5406 3706 3706 3707 3707 if test -n "$enable_p7"; then 3708 CPPFLAGS="$CPPFLAGS -DWI_P7 -DWI_LIBXML2 -DWI_CRYPTO -DWI_ ZLIB"3708 CPPFLAGS="$CPPFLAGS -DWI_P7 -DWI_LIBXML2 -DWI_CRYPTO -DWI_SSL -DWI_ZLIB" 3709 3709 fi 3710 3710 … … 7254 7254 7255 7255 LIBS="$LIBS -lcrypto" 7256 7257 else 7258 7259 7260 { { echo "$as_me:$LINENO: error: could not locate OpenSSL 7261 7262 If you installed OpenSSL into a non-standard directory, please run: 7263 7264 env CPPFLAGS=\"-I/path/to/include\" LDFLAGS=\"-L/path/to/lib\" ./configure" >&5 7265 echo "$as_me: error: could not locate OpenSSL 7266 7267 If you installed OpenSSL into a non-standard directory, please run: 7268 7269 env CPPFLAGS=\"-I/path/to/include\" LDFLAGS=\"-L/path/to/lib\" ./configure" >&2;} 7270 { (exit 1); exit 1; }; } 7271 7272 7273 fi 7274 7275 7276 else 7277 7278 7279 { { echo "$as_me:$LINENO: error: could not locate OpenSSL 7280 7281 If you installed OpenSSL into a non-standard directory, please run: 7282 7283 env CPPFLAGS=\"-I/path/to/include\" LDFLAGS=\"-L/path/to/lib\" ./configure" >&5 7284 echo "$as_me: error: could not locate OpenSSL 7285 7286 If you installed OpenSSL into a non-standard directory, please run: 7287 7288 env CPPFLAGS=\"-I/path/to/include\" LDFLAGS=\"-L/path/to/lib\" ./configure" >&2;} 7289 { (exit 1); exit 1; }; } 7290 7291 7292 fi 7293 7294 done 7295 7296 7297 7298 7299 if test "$_wi_ssl_paths_added" != yes ; then 7300 if test -d /usr/local/ssl/include; then 7301 CPPFLAGS="$CPPFLAGS -I/usr/local/ssl/include" 7302 fi 7303 7304 if test -d /usr/kerberos/include; then 7305 CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include" 7306 fi 7307 7308 if test -d /usr/local/ssl/lib; then 7309 LDFLAGS="$LDFLAGS -L/usr/local/ssl/lib" 7310 fi 7311 fi 7312 7313 _wi_ssl_paths_added=yes 7314 7315 7316 7317 for ac_header in openssl/ssl.h 7318 do 7319 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` 7320 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then 7321 { echo "$as_me:$LINENO: checking for $ac_header" >&5 7322 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } 7323 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then 7324 echo $ECHO_N "(cached) $ECHO_C" >&6 7325 fi 7326 ac_res=`eval echo '${'$as_ac_Header'}'` 7327 { echo "$as_me:$LINENO: result: $ac_res" >&5 7328 echo "${ECHO_T}$ac_res" >&6; } 7329 else 7330 # Is the header compilable? 7331 { echo "$as_me:$LINENO: checking $ac_header usability" >&5 7332 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } 7333 cat >conftest.$ac_ext <<_ACEOF 7334 /* confdefs.h. */ 7335 _ACEOF 7336 cat confdefs.h >>conftest.$ac_ext 7337 cat >>conftest.$ac_ext <<_ACEOF 7338 /* end confdefs.h. */ 7339 $ac_includes_default 7340 #include <$ac_header> 7341 _ACEOF 7342 rm -f conftest.$ac_objext 7343 if { (ac_try="$ac_compile" 7344 case "(($ac_try" in 7345 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 7346 *) ac_try_echo=$ac_try;; 7347 esac 7348 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 7349 (eval "$ac_compile") 2>conftest.er1 7350 ac_status=$? 7351 grep -v '^ *+' conftest.er1 >conftest.err 7352 rm -f conftest.er1 7353 cat conftest.err >&5 7354 echo "$as_me:$LINENO: \$? = $ac_status" >&5 7355 (exit $ac_status); } && { 7356 test -z "$ac_c_werror_flag" || 7357 test ! -s conftest.err 7358 } && test -s conftest.$ac_objext; then 7359 ac_header_compiler=yes 7360 else 7361 echo "$as_me: failed program was:" >&5 7362 sed 's/^/| /' conftest.$ac_ext >&5 7363 7364 ac_header_compiler=no 7365 fi 7366 7367 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 7368 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 7369 echo "${ECHO_T}$ac_header_compiler" >&6; } 7370 7371 # Is the header present? 7372 { echo "$as_me:$LINENO: checking $ac_header presence" >&5 7373 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } 7374 cat >conftest.$ac_ext <<_ACEOF 7375 /* confdefs.h. */ 7376 _ACEOF 7377 cat confdefs.h >>conftest.$ac_ext 7378 cat >>conftest.$ac_ext <<_ACEOF 7379 /* end confdefs.h. */ 7380 #include <$ac_header> 7381 _ACEOF 7382 if { (ac_try="$ac_cpp conftest.$ac_ext" 7383 case "(($ac_try" in 7384 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 7385 *) ac_try_echo=$ac_try;; 7386 esac 7387 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 7388 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 7389 ac_status=$? 7390 grep -v '^ *+' conftest.er1 >conftest.err 7391 rm -f conftest.er1 7392 cat conftest.err >&5 7393 echo "$as_me:$LINENO: \$? = $ac_status" >&5 7394 (exit $ac_status); } >/dev/null && { 7395 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || 7396 test ! -s conftest.err 7397 }; then 7398 ac_header_preproc=yes 7399 else 7400 echo "$as_me: failed program was:" >&5 7401 sed 's/^/| /' conftest.$ac_ext >&5 7402 7403 ac_header_preproc=no 7404 fi 7405 7406 rm -f conftest.err conftest.$ac_ext 7407 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 7408 echo "${ECHO_T}$ac_header_preproc" >&6; } 7409 7410 # So? What about this header? 7411 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in 7412 yes:no: ) 7413 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 7414 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} 7415 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 7416 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} 7417 ac_header_preproc=yes 7418 ;; 7419 no:yes:* ) 7420 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 7421 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} 7422 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 7423 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} 7424 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 7425 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} 7426 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 7427 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} 7428 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 7429 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} 7430 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 7431 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} 7432 ( cat <<\_ASBOX 7433 ## ------------------------------------- ## 7434 ## Report this to axel@zankasoftware.com ## 7435 ## ------------------------------------- ## 7436 _ASBOX 7437 ) | sed "s/^/$as_me: WARNING: /" >&2 7438 ;; 7439 esac 7440 { echo "$as_me:$LINENO: checking for $ac_header" >&5 7441 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } 7442 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then 7443 echo $ECHO_N "(cached) $ECHO_C" >&6 7444 else 7445 eval "$as_ac_Header=\$ac_header_preproc" 7446 fi 7447 ac_res=`eval echo '${'$as_ac_Header'}'` 7448 { echo "$as_me:$LINENO: result: $ac_res" >&5 7449 echo "${ECHO_T}$ac_res" >&6; } 7450 7451 fi 7452 if test `eval echo '${'$as_ac_Header'}'` = yes; then 7453 cat >>confdefs.h <<_ACEOF 7454 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 7455 _ACEOF 7456 7457 { echo "$as_me:$LINENO: checking for SSL_library_init in -lssl" >&5 7458 echo $ECHO_N "checking for SSL_library_init in -lssl... $ECHO_C" >&6; } 7459 if test "${ac_cv_lib_ssl_SSL_library_init+set}" = set; then 7460 echo $ECHO_N "(cached) $ECHO_C" >&6 7461 else 7462 ac_check_lib_save_LIBS=$LIBS 7463 LIBS="-lssl $LIBS" 7464 cat >conftest.$ac_ext <<_ACEOF 7465 /* confdefs.h. */ 7466 _ACEOF 7467 cat confdefs.h >>conftest.$ac_ext 7468 cat >>conftest.$ac_ext <<_ACEOF 7469 /* end confdefs.h. */ 7470 7471 /* Override any GCC internal prototype to avoid an error. 7472 Use char because int might match the return type of a GCC 7473 builtin and then its argument prototype would still apply. */ 7474 #ifdef __cplusplus 7475 extern "C" 7476 #endif 7477 char SSL_library_init (); 7478 int 7479 main () 7480 { 7481 return SSL_library_init (); 7482 ; 7483 return 0; 7484 } 7485 _ACEOF 7486 rm -f conftest.$ac_objext conftest$ac_exeext 7487 if { (ac_try="$ac_link" 7488 case "(($ac_try" in 7489 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 7490 *) ac_try_echo=$ac_try;; 7491 esac 7492 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 7493 (eval "$ac_link") 2>conftest.er1 7494 ac_status=$? 7495 grep -v '^ *+' conftest.er1 >conftest.err 7496 rm -f conftest.er1 7497 cat conftest.err >&5 7498 echo "$as_me:$LINENO: \$? = $ac_status" >&5 7499 (exit $ac_status); } && { 7500 test -z "$ac_c_werror_flag" || 7501 test ! -s conftest.err 7502 } && test -s conftest$ac_exeext && 7503 $as_test_x conftest$ac_exeext; then 7504 ac_cv_lib_ssl_SSL_library_init=yes 7505 else 7506 echo "$as_me: failed program was:" >&5 7507 sed 's/^/| /' conftest.$ac_ext >&5 7508 7509 ac_cv_lib_ssl_SSL_library_init=no 7510 fi 7511 7512 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ 7513 conftest$ac_exeext conftest.$ac_ext 7514 LIBS=$ac_check_lib_save_LIBS 7515 fi 7516 { echo "$as_me:$LINENO: result: $ac_cv_lib_ssl_SSL_library_init" >&5 7517 echo "${ECHO_T}$ac_cv_lib_ssl_SSL_library_init" >&6; } 7518 if test $ac_cv_lib_ssl_SSL_library_init = yes; then 7519 7520 LIBS="$LIBS -lssl" 7256 7521 7257 7522 else libwired/trunk/configure.in
r5338 r5406 89 89 90 90 if test -n "$enable_p7"; then 91 CPPFLAGS="$CPPFLAGS -DWI_P7 -DWI_LIBXML2 -DWI_CRYPTO -DWI_ ZLIB"91 CPPFLAGS="$CPPFLAGS -DWI_P7 -DWI_LIBXML2 -DWI_CRYPTO -DWI_SSL -DWI_ZLIB" 92 92 fi 93 93 libwired/trunk/libwired/p7/wi-p7-socket.c
r5383 r5406 138 138 wi_p7_options_t options; 139 139 140 wi_boolean_t tls_enabled; 141 wi_socket_tls_t *tls; 142 140 143 wi_boolean_t encryption_enabled; 141 144 wi_rsa_t *rsa; … … 178 181 static wi_boolean_t _wi_p7_socket_connect_handshake(wi_p7_socket_t *, wi_time_interval_t, wi_p7_options_t); 179 182 static wi_boolean_t _wi_p7_socket_accept_handshake(wi_p7_socket_t *, wi_time_interval_t, wi_p7_options_t); 183 static wi_boolean_t _wi_p7_socket_connect_tls(wi_p7_socket_t *, wi_time_interval_t); 184 static wi_boolean_t _wi_p7_socket_accept_tls(wi_p7_socket_t *, wi_time_interval_t); 180 185 static wi_boolean_t _wi_p7_socket_connect_key_exchange(wi_p7_socket_t *, wi_time_interval_t, wi_string_t *, wi_string_t *); 181 186 static wi_boolean_t _wi_p7_socket_accept_key_exchange(wi_p7_socket_t *, wi_time_interval_t); … … 313 318 314 319 320 void wi_p7_socket_set_tls(wi_p7_socket_t *p7_socket, wi_socket_tls_t *tls) { 321 wi_retain(tls); 322 wi_release(p7_socket->tls); 323 324 p7_socket->tls = tls; 325 } 326 327 328 329 wi_socket_tls_t * wi_p7_socket_tls(wi_p7_socket_t *p7_socket) { 330 return p7_socket->tls; 331 } 332 333 334 315 335 #pragma mark - 316 336 … … 357 377 wi_string_t *version; 358 378 wi_p7_message_t *p7_message; 359 wi_p7_enum_t flag; 379 wi_p7_enum_t eflag; 380 wi_p7_boolean_t bflag; 360 381 361 382 p7_message = wi_p7_message_with_name(WI_STR("p7.handshake.client_handshake"), wi_p7_socket_spec(p7_socket)); … … 367 388 return false; 368 389 369 if(!wi_p7_message_set_string_for_name(p7_message, wi_p7_spec_name(p7_socket->spec), WI_STR("p7.handshake.protocol _name")))370 return false; 371 372 if(!wi_p7_message_set_string_for_name(p7_message, wi_p7_spec_version(p7_socket->spec), WI_STR("p7.handshake.protocol _version")))390 if(!wi_p7_message_set_string_for_name(p7_message, wi_p7_spec_name(p7_socket->spec), WI_STR("p7.handshake.protocol.name"))) 391 return false; 392 393 if(!wi_p7_message_set_string_for_name(p7_message, wi_p7_spec_version(p7_socket->spec), WI_STR("p7.handshake.protocol.version"))) 373 394 return false; 374 395 375 396 if(p7_socket->serialization == WI_P7_BINARY) { 397 if(WI_P7_TLS_ENABLED(options)) { 398 if(!wi_p7_message_set_bool_for_name(p7_message, true, WI_STR("p7.handshake.tls"))) 399 return false; 400 } 401 376 402 if(WI_P7_COMPRESSION_ENABLED(options)) { 377 403 if(!wi_p7_message_set_enum_for_name(p7_message, … … 432 458 } 433 459 434 p7_socket->name = wi_retain(wi_p7_message_string_for_name(p7_message, WI_STR("p7.handshake.protocol _name")));460 p7_socket->name = wi_retain(wi_p7_message_string_for_name(p7_message, WI_STR("p7.handshake.protocol.name"))); 435 461 436 462 if(!p7_socket->name) { 437 463 wi_error_set_libwired_p7_error(WI_ERROR_P7_HANDSHAKEFAILED, 438 WI_STR("Message has no \"p7.handshake.protocol _name\" field"));439 440 return false; 441 } 442 443 p7_socket->version = wi_retain(wi_p7_message_string_for_name(p7_message, WI_STR("p7.handshake.protocol _version")));464 WI_STR("Message has no \"p7.handshake.protocol.name\" field")); 465 466 return false; 467 } 468 469 p7_socket->version = wi_retain(wi_p7_message_string_for_name(p7_message, WI_STR("p7.handshake.protocol.version"))); 444 470 445 471 if(!p7_socket->version) { 446 472 wi_error_set_libwired_p7_error(WI_ERROR_P7_HANDSHAKEFAILED, 447 WI_STR("Message has no \"p7.handshake.protocol _version\" field"));473 WI_STR("Message has no \"p7.handshake.protocol.version\" field")); 448 474 449 475 return false; … … 453 479 454 480 if(p7_socket->serialization == WI_P7_BINARY) { 455 if(wi_p7_message_get_enum_for_name(p7_message, &flag, WI_STR("p7.handshake.compression"))) 456 p7_socket->options |= _WI_P7_COMPRESSION_ENUM_TO_OPTIONS(flag); 457 458 if(wi_p7_message_get_enum_for_name(p7_message, &flag, WI_STR("p7.handshake.encryption"))) 459 p7_socket->options |= _WI_P7_ENCRYPTION_ENUM_TO_OPTIONS(flag); 460 461 if(wi_p7_message_get_enum_for_name(p7_message, &flag, WI_STR("p7.handshake.checksum"))) 462 p7_socket->options |= _WI_P7_CHECKSUM_ENUM_TO_OPTIONS(flag); 481 if(wi_p7_message_get_bool_for_name(p7_message, &bflag, WI_STR("p7.handshake.tls")) && bflag) 482 p7_socket->options |= WI_P7_TLS; 483 484 if(wi_p7_message_get_enum_for_name(p7_message, &eflag, WI_STR("p7.handshake.compression"))) 485 p7_socket->options |= _WI_P7_COMPRESSION_ENUM_TO_OPTIONS(eflag); 486 487 if(wi_p7_message_get_enum_for_name(p7_message, &eflag, WI_STR("p7.handshake.encryption"))) 488 p7_socket->options |= _WI_P7_ENCRYPTION_ENUM_TO_OPTIONS(eflag); 489 490 if(wi_p7_message_get_enum_for_name(p7_message, &eflag, WI_STR("p7.handshake.checksum"))) 491 p7_socket->options |= _WI_P7_CHECKSUM_ENUM_TO_OPTIONS(eflag); 463 492 } 464 493 … … 487 516 wi_string_t *version; 488 517 wi_p7_message_t *p7_message; 489 wi_p7_enum_t flag; 518 wi_p7_enum_t eflag; 519 wi_p7_boolean_t bflag; 490 520 wi_p7_options_t client_options; 491 521 … … 520 550 } 521 551 522 p7_socket->name = wi_retain(wi_p7_message_string_for_name(p7_message, WI_STR("p7.handshake.protocol _name")));552 p7_socket->name = wi_retain(wi_p7_message_string_for_name(p7_message, WI_STR("p7.handshake.protocol.name"))); 523 553 524 554 if(!p7_socket->name) { 525 555 wi_error_set_libwired_p7_error(WI_ERROR_P7_HANDSHAKEFAILED, 526 WI_STR("Message has no \"p7.handshake.protocol _name\" field"));527 528 return false; 529 } 530 531 p7_socket->version = wi_retain(wi_p7_message_string_for_name(p7_message, WI_STR("p7.handshake.protocol _version")));556 WI_STR("Message has no \"p7.handshake.protocol.name\" field")); 557 558 return false; 559 } 560 561 p7_socket->version = wi_retain(wi_p7_message_string_for_name(p7_message, WI_STR("p7.handshake.protocol.version"))); 532 562 533 563 if(!p7_socket->version) { 534 564 wi_error_set_libwired_p7_error(WI_ERROR_P7_HANDSHAKEFAILED, 535 WI_STR("Message has no \"p7.handshake.protocol _version\" field"));565 WI_STR("Message has no \"p7.handshake.protocol.version\" field")); 536 566 537 567 return false; … … 541 571 542 572 if(p7_socket->serialization == WI_P7_BINARY) { 543 if(wi_p7_message_get_ enum_for_name(p7_message, &flag, WI_STR("p7.handshake.compression"))) {544 client_options = _WI_P7_COMPRESSION_ENUM_TO_OPTIONS(flag);573 if(wi_p7_message_get_bool_for_name(p7_message, &bflag, WI_STR("p7.handshake.tls")) && bflag) { 574 client_options = WI_P7_TLS; 545 575 546 576 if(options & client_options) … … 548 578 } 549 579 550 if(wi_p7_message_get_enum_for_name(p7_message, & flag, WI_STR("p7.handshake.encryption"))) {551 client_options = _WI_P7_ ENCRYPTION_ENUM_TO_OPTIONS(flag);552 580 if(wi_p7_message_get_enum_for_name(p7_message, &eflag, WI_STR("p7.handshake.compression"))) { 581 client_options = _WI_P7_COMPRESSION_ENUM_TO_OPTIONS(eflag); 582 553 583 if(options & client_options) 554 584 p7_socket->options |= client_options; 555 585 } 556 586 557 if(wi_p7_message_get_enum_for_name(p7_message, & flag, WI_STR("p7.handshake.checksum"))) {558 client_options = _WI_P7_ CHECKSUM_ENUM_TO_OPTIONS(flag);587 if(wi_p7_message_get_enum_for_name(p7_message, &eflag, WI_STR("p7.handshake.encryption"))) { 588 client_options = _WI_P7_ENCRYPTION_ENUM_TO_OPTIONS(eflag); 559 589 560 590 if(options & client_options) 561 591 p7_socket->options |= client_options; 562 592 } 593 594 if(wi_p7_message_get_enum_for_name(p7_message, &eflag, WI_STR("p7.handshake.checksum"))) { 595 client_options = _WI_P7_CHECKSUM_ENUM_TO_OPTIONS(eflag); 596 597 if(options & client_options) 598 p7_socket->options |= client_options; 599 } 563 600 } 564 601 … … 571 608 return false; 572 609 573 if(!wi_p7_message_set_string_for_name(p7_message, wi_p7_spec_name(p7_socket->spec), WI_STR("p7.handshake.protocol _name")))574 return false; 575 576 if(!wi_p7_message_set_string_for_name(p7_message, wi_p7_spec_version(p7_socket->spec), WI_STR("p7.handshake.protocol _version")))610 if(!wi_p7_message_set_string_for_name(p7_message, wi_p7_spec_name(p7_socket->spec), WI_STR("p7.handshake.protocol.name"))) 611 return false; 612 613 if(!wi_p7_message_set_string_for_name(p7_message, wi_p7_spec_version(p7_socket->spec), WI_STR("p7.handshake.protocol.version"))) 577 614 return false; 578 615 579 616 if(p7_socket->serialization == WI_P7_BINARY) { 617 if(WI_P7_TLS_ENABLED(p7_socket->options)) { 618 if(!wi_p7_message_set_bool_for_name(p7_message, true, WI_STR("p7.handshake.tls"))) 619 return false; 620 } 621 580 622 if(WI_P7_COMPRESSION_ENABLED(p7_socket->options)) { 581 623 if(!wi_p7_message_set_enum_for_name(p7_message, … … 632 674 633 675 676 static wi_boolean_t _wi_p7_socket_connect_tls(wi_p7_socket_t *p7_socket, wi_time_interval_t timeout) { 677 return wi_socket_connect_tls(p7_socket->socket, p7_socket->tls, timeout); 678 } 679 680 681 682 static wi_boolean_t _wi_p7_socket_accept_tls(wi_p7_socket_t *p7_socket, wi_time_interval_t timeout) { 683 return wi_socket_accept_tls(p7_socket->socket, p7_socket->tls, timeout); 684 } 685 686 687 634 688 static wi_boolean_t _wi_p7_socket_connect_key_exchange(wi_p7_socket_t *p7_socket, wi_time_interval_t timeout, wi_string_t *username, wi_string_t *password) { 635 689 wi_p7_message_t *p7_message; … … 676 730 data = wi_rsa_encrypt(p7_socket->rsa, wi_cipher_key(p7_socket->cipher)); 677 731 678 if(!wi_p7_message_set_data_for_name(p7_message, data, WI_STR("p7.encryption.cipher _key")))732 if(!wi_p7_message_set_data_for_name(p7_message, data, WI_STR("p7.encryption.cipher.key"))) 679 733 return false; 680 734 … … 684 738 data = wi_rsa_encrypt(p7_socket->rsa, data); 685 739 686 if(!wi_p7_message_set_data_for_name(p7_message, data, WI_STR("p7.encryption.cipher _iv")))740 if(!wi_p7_message_set_data_for_name(p7_message, data, WI_STR("p7.encryption.cipher.iv"))) 687 741 return false; 688 742 } … … 802 856 } 803 857 804 key = wi_p7_message_data_for_name(p7_message, WI_STR("p7.encryption.cipher _key"));805 iv = wi_p7_message_data_for_name(p7_message, WI_STR("p7.encryption.cipher _iv"));858 key = wi_p7_message_data_for_name(p7_message, WI_STR("p7.encryption.cipher.key")); 859 iv = wi_p7_message_data_for_name(p7_message, WI_STR("p7.encryption.cipher.iv")); 806 860 807 861 if(!key) { 808 862 wi_error_set_libwired_p7_error(WI_ERROR_P7_HANDSHAKEFAILED, 809 WI_STR("Message has no \"p7.encryption.cipher _key\" field"));863 WI_STR("Message has no \"p7.encryption.cipher.key\" field")); 810 864 811 865 return false; … … 1395 1449 _wi_p7_socket_configure_checksum(p7_socket); 1396 1450 1451 if(WI_P7_TLS_ENABLED(p7_socket->options)) { 1452 if(!_wi_p7_socket_connect_tls(p7_socket, timeout)) 1453 return false; 1454 } 1455 1397 1456 if(WI_P7_ENCRYPTION_ENABLED(p7_socket->options)) { 1398 1457 if(!_wi_p7_socket_connect_key_exchange(p7_socket, timeout, username, password)) … … 1426 1485 if(WI_P7_CHECKSUM_ENABLED(p7_socket->options)) 1427 1486 _wi_p7_socket_configure_checksum(p7_socket); 1487 1488 if(WI_P7_TLS_ENABLED(p7_socket->options)) { 1489 if(!_wi_p7_socket_accept_tls(p7_socket, timeout)) 1490 return false; 1491 } 1428 1492 1429 1493 if(WI_P7_ENCRYPTION_ENABLED(p7_socket->options)) { libwired/trunk/libwired/p7/wi-p7-socket.h
r5295 r5406 35 35 #include <wired/wi-socket.h> 36 36 37 #define WI_P7_TLS_ENABLED(options) \ 38 (((options) & WI_P7_TLS)) 39 37 40 #define WI_P7_COMPRESSION_ENABLED(options) \ 38 41 (((options) & WI_P7_COMPRESSION_DEFLATE)) … … 50 53 51 54 enum _wi_p7_options { 52 WI_P7_COMPRESSION_DEFLATE = (1 << 0), 53 WI_P7_ENCRYPTION_RSA_AES128_SHA1 = (1 << 1), 54 WI_P7_ENCRYPTION_RSA_AES192_SHA1 = (1 << 2), 55 WI_P7_ENCRYPTION_RSA_AES256_SHA1 = (1 << 3), 56 WI_P7_ENCRYPTION_RSA_BF128_SHA1 = (1 << 4), 57 WI_P7_ENCRYPTION_RSA_3DES192_SHA1 = (1 << 5), 58 WI_P7_CHECKSUM_SHA1 = (1 << 6), 59 WI_P7_ALL = (WI_P7_COMPRESSION_DEFLATE | 55 WI_P7_TLS = (1 << 0), 56 WI_P7_COMPRESSION_DEFLATE = (1 << 1), 57 WI_P7_ENCRYPTION_RSA_AES128_SHA1 = (1 << 2), 58 WI_P7_ENCRYPTION_RSA_AES192_SHA1 = (1 << 3), 59 WI_P7_ENCRYPTION_RSA_AES256_SHA1 = (1 << 4), 60 WI_P7_ENCRYPTION_RSA_BF128_SHA1 = (1 << 5), 61 WI_P7_ENCRYPTION_RSA_3DES192_SHA1 = (1 << 6), 62 WI_P7_CHECKSUM_SHA1 = (1 << 7), 63 WI_P7_ALL = (WI_P7_TLS | 64 WI_P7_COMPRESSION_DEFLATE | 60 65 WI_P7_ENCRYPTION_RSA_AES128_SHA1 | 61 66 WI_P7_ENCRYPTION_RSA_AES192_SHA1 | … … 79 84 WI_EXPORT void wi_p7_socket_set_private_rsa(wi_p7_socket_t *, wi_rsa_t *); 80 85 WI_EXPORT wi_rsa_t * wi_p7_socket_private_rsa(wi_p7_socket_t *); 86 WI_EXPORT void wi_p7_socket_set_tls(wi_p7_socket_t *, wi_socket_tls_t *); 87 WI_EXPORT wi_socket_tls_t * wi_p7_socket_tls(wi_p7_socket_t *); 81 88 82 89 WI_EXPORT wi_socket_t * wi_p7_socket_socket(wi_p7_socket_t *); libwired/trunk/libwired/p7/wi-p7-spec.c
r5381 r5406 368 368 " <p7:fields>" 369 369 " <p7:field name=\"p7.handshake.version\" type=\"string\" id=\"1\" />" 370 " <p7:field name=\"p7.handshake.protocol_name\" type=\"string\" id=\"2\" />" 371 " <p7:field name=\"p7.handshake.protocol_version\" type=\"string\" id=\"3\" />" 372 " <p7:field name=\"p7.handshake.compression\" type=\"enum\" id=\"4\">" 370 " <p7:field name=\"p7.handshake.protocol.name\" type=\"string\" id=\"2\" />" 371 " <p7:field name=\"p7.handshake.protocol.version\" type=\"string\" id=\"3\" />" 372 " <p7:field name=\"p7.handshake.tls\" type=\"bool\" id=\"4\" />" 373 " <p7:field name=\"p7.handshake.compression\" type=\"enum\" id=\"5\">" 373 374 " <p7:enum name=\"p7.handshake.compression.deflate\" value=\"0\" />" 374 375 " </p7:field>" 375 " <p7:field name=\"p7.handshake.encryption\" type=\"enum\" id=\" 5\">"376 " <p7:field name=\"p7.handshake.encryption\" type=\"enum\" id=\"6\">" 376 377 " <p7:enum name=\"p7.handshake.encryption.rsa_aes128_sha1\" value=\"0\" />" 377 378 " <p7:enum name=\"p7.handshake.encryption.rsa_aes192_sha1\" value=\"1\" />" … … 380 381 " <p7:enum name=\"p7.handshake.encryption.rsa_3des192_sha1\" value=\"4\" />" 381 382 " </p7:field>" 382 " <p7:field name=\"p7.handshake.checksum\" type=\"enum\" id=\" 6\">"383 " <p7:field name=\"p7.handshake.checksum\" type=\"enum\" id=\"7\">" 383 384 " <p7:enum name=\"p7.handshake.checksum.sha1\" value=\"0\" />" 384 385 " </p7:field>" 385 " <p7:field name=\"p7.handshake.compatibility_check\" type=\"bool\" id=\" 7\" />"386 " <p7:field name=\"p7.handshake.compatibility_check\" type=\"bool\" id=\"8\" />" 386 387 "" 387 " <p7:field name=\"p7.encryption.public_key\" id=\" 8\" type=\"data\" />"388 " <p7:field name=\"p7.encryption.cipher _key\" id=\"9\" type=\"data\" />"389 " <p7:field name=\"p7.encryption.cipher _iv\" id=\"10\" type=\"data\" />"390 " <p7:field name=\"p7.encryption.username\" id=\"1 1\" type=\"data\" />"391 " <p7:field name=\"p7.encryption.client_password\" id=\"1 2\" type=\"data\" />"392 " <p7:field name=\"p7.encryption.server_password\" id=\"1 3\" type=\"data\" />"388 " <p7:field name=\"p7.encryption.public_key\" id=\"9\" type=\"data\" />" 389 " <p7:field name=\"p7.encryption.cipher.key\" id=\"10\" type=\"data\" />" 390 " <p7:field name=\"p7.encryption.cipher.iv\" id=\"11\" type=\"data\" />" 391 " <p7:field name=\"p7.encryption.username\" id=\"12\" type=\"data\" />" 392 " <p7:field name=\"p7.encryption.client_password\" id=\"13\" type=\"data\" />" 393 " <p7:field name=\"p7.encryption.server_password\" id=\"14\" type=\"data\" />" 393 394 "" 394 " <p7:field name=\"p7.compatibility_check.specification\" id=\"1 4\" type=\"string\" />"395 " <p7:field name=\"p7.compatibility_check.status\" id=\"1 5\" type=\"bool\" />"395 " <p7:field name=\"p7.compatibility_check.specification\" id=\"15\" type=\"string\" />" 396 " <p7:field name=\"p7.compatibility_check.status\" id=\"16\" type=\"bool\" />" 396 397 " </p7:fields>" 397 398 "" … … 399 400 " <p7:message name=\"p7.handshake.client_handshake\" id=\"1\">" 400 401 " <p7:parameter field=\"p7.handshake.version\" use=\"required\" />" 401 " <p7:parameter field=\"p7.handshake.protocol_name\" use=\"required\" />" 402 " <p7:parameter field=\"p7.handshake.protocol_version\" use=\"required\" />" 402 " <p7:parameter field=\"p7.handshake.protocol.name\" use=\"required\" />" 403 " <p7:parameter field=\"p7.handshake.protocol.version\" use=\"required\" />" 404 " <p7:parameter field=\"p7.handshake.tls\" />" 403 405 " <p7:parameter field=\"p7.handshake.encryption\" />" 404 406 " <p7:parameter field=\"p7.handshake.compression\" />" … … 408 410 " <p7:message name=\"p7.handshake.server_handshake\" id=\"2\">" 409 411 " <p7:parameter field=\"p7.handshake.version\" use=\"required\" />" 410 " <p7:parameter field=\"p7.handshake.protocol_name\" use=\"required\" />" 411 " <p7:parameter field=\"p7.handshake.protocol_version\" use=\"required\" />" 412 " <p7:parameter field=\"p7.handshake.protocol.name\" use=\"required\" />" 413 " <p7:parameter field=\"p7.handshake.protocol.version\" use=\"required\" />" 414 " <p7:parameter field=\"p7.handshake.tls\" />" 412 415 " <p7:parameter field=\"p7.handshake.encryption\" />" 413 416 " <p7:parameter field=\"p7.handshake.compression\" />" … … 425 428 "" 426 429 " <p7:message name=\"p7.encryption.client_key\" id=\"5\">" 427 " <p7:parameter field=\"p7.encryption.cipher _key\" use=\"required\" />"428 " <p7:parameter field=\"p7.encryption.cipher _iv\" />"430 " <p7:parameter field=\"p7.encryption.cipher.key\" use=\"required\" />" 431 " <p7:parameter field=\"p7.encryption.cipher.iv\" />" 429 432 " <p7:parameter field=\"p7.encryption.username\" use=\"required\" />" 430 433 " <p7:parameter field=\"p7.encryption.client_password\" use=\"required\" />" … … 516 519 517 520 wi_p7_spec_t * wi_p7_spec_builtin_spec(void) { 518 if(!_wi_p7_spec_builtin_spec) 521 if(!_wi_p7_spec_builtin_spec) { 519 522 _wi_p7_spec_builtin_spec = _wi_p7_spec_init_builtin_spec(wi_p7_spec_alloc()); 523 524 if(!_wi_p7_spec_builtin_spec) 525 wi_log_info(WI_STR("Could not load builtin P7 spec: %m")); 526 } 520 527 521 528 return _wi_p7_spec_builtin_spec;
