| 338 | |
| 339 | |
| 340 | int SSL_accept(SSL* ssl) |
| 341 | { |
| 342 | if (ssl->GetError() == YasslError(SSL_ERROR_WANT_READ)) |
| 343 | ssl->SetError(no_error); |
| 344 | |
| 345 | if (ssl->GetError() == YasslError(SSL_ERROR_WANT_WRITE)) { |
| 346 | |
| 347 | ssl->SetError(no_error); |
| 348 | ssl->SendWriteBuffered(); |
| 349 | if (!ssl->GetError()) |
| 350 | ssl->useStates().UseAccept() = |
| 351 | AcceptState(ssl->getStates().GetAccept() + 1); |
| 352 | } |
| 353 | |
| 354 | switch (ssl->getStates().GetAccept()) { |
| 355 | |
| 356 | case ACCEPT_BEGIN : |
| 357 | processReply(*ssl); |
| 358 | if (!ssl->GetError()) |
| 359 | ssl->useStates().UseAccept() = ACCEPT_FIRST_REPLY_DONE; |
| 360 | |
| 361 | case ACCEPT_FIRST_REPLY_DONE : |
| 362 | sendServerHello(*ssl); |
| 363 | |
| 364 | if (!ssl->getSecurity().get_resuming()) { |
| 365 | sendCertificate(*ssl); |
| 366 | |
| 367 | if (ssl->getSecurity().get_connection().send_server_key_) |
| 368 | sendServerKeyExchange(*ssl); |
| 369 | |
| 370 | if(ssl->getCrypto().get_certManager().verifyPeer()) |
| 371 | sendCertificateRequest(*ssl); |
| 372 | |
| 373 | sendServerHelloDone(*ssl); |
| 374 | ssl->flushBuffer(); |
| 375 | } |
| 376 | |
| 377 | if (!ssl->GetError()) |
| 378 | ssl->useStates().UseAccept() = SERVER_HELLO_DONE; |
| 379 | |
| 380 | case SERVER_HELLO_DONE : |
| 381 | if (!ssl->getSecurity().get_resuming()) { |
| 382 | while (ssl->getStates().getServer() < clientFinishedComplete) { |
| 383 | if (ssl->GetError()) break; |
| 384 | processReply(*ssl); |
| 385 | } |
| 386 | } |
| 387 | if (!ssl->GetError()) |
| 388 | ssl->useStates().UseAccept() = ACCEPT_SECOND_REPLY_DONE; |
| 389 | |
| 390 | case ACCEPT_SECOND_REPLY_DONE : |
| 391 | sendChangeCipher(*ssl); |
| 392 | sendFinished(*ssl, server_end); |
| 393 | ssl->flushBuffer(); |
| 394 | |
| 395 | if (!ssl->GetError()) |
| 396 | ssl->useStates().UseAccept() = ACCEPT_FINISHED_DONE; |
| 397 |
no test coverage detected