• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/Security-57031.1.35/Security/libsecurity_ssl/security_ssl/

Lines Matching refs:ctx

45     SSLContext *ctx,
52 ctx, op, req, moved, (int)stat);
55 #define sslIoTrace(ctx, op, req, moved, stat)
60 static OSStatus SSLProcessProtocolMessage(SSLRecord *rec, SSLContext *ctx);
61 static OSStatus SSLHandshakeProceed(SSLContext *ctx);
62 //static OSStatus SSLInitConnection(SSLContext *ctx);
66 SSLContext *ctx,
75 sslLogRecordIo("[%p] SSLWrite top", ctx);
76 if((ctx == NULL) || (bytesWritten == NULL)) {
83 switch(ctx->state) {
94 sslIoTrace(ctx, "SSLWrite(1)", dataLength, 0, errSecBadReq);
104 while (!(ctx->writeCipher_ready))
105 { if ((err = SSLHandshakeProceed(ctx)) != 0)
110 if ((err = SSLServiceWriteQueue(ctx)) != 0)
118 rec.protocolVersion = ctx->negProtocolVersion;
121 if ((err = SSLWriteRecord(rec, ctx)) != 0)
128 if ((err = SSLServiceWriteQueue(ctx)) == 0) {
143 SSLChangeHdskState(ctx, SSL_HdskStateErrorClose);
147 sslIoTrace(ctx, "SSLWrite(2)", dataLength, *bytesWritten, err);
153 SSLContext *ctx,
163 sslLogRecordIo("[%p] SSLRead top (dataLength=%ld)", ctx, dataLength);
164 if((ctx == NULL) || (data == NULL) || (processed == NULL)) {
172 switch(ctx->state) {
189 while (ctx->readCipher_ready == 0) {
190 if ((err = SSLHandshakeProceed(ctx)) != 0) {
196 if ((err = SSLServiceWriteQueue(ctx)) != 0) {
205 if (ctx->receivedDataBuffer.data)
206 { count = ctx->receivedDataBuffer.length - ctx->receivedDataPos;
209 memcpy(data, ctx->receivedDataBuffer.data + ctx->receivedDataPos, count);
213 ctx->receivedDataPos += count;
216 assert(ctx->receivedDataPos <= ctx->receivedDataBuffer.length);
220 if (ctx->receivedDataBuffer.data != 0 &&
221 ctx->receivedDataPos >= ctx->receivedDataBuffer.length)
222 { SSLFreeBuffer(&ctx->receivedDataBuffer);
223 ctx->receivedDataBuffer.data = 0;
224 ctx->receivedDataPos = 0;
229 while (remaining > 0 && ctx->state != SSL_HdskStateGracefulClose)
234 if (remaining > 0 && ctx->state != SSL_HdskStateGracefulClose)
235 { assert(ctx->receivedDataBuffer.data == 0);
236 if ((err = SSLReadRecord(&rec, ctx)) != 0) {
247 if ((err = SSLFreeRecord(rec, ctx))) {
256 ctx->receivedDataBuffer = rec.contents;
257 ctx->receivedDataPos = remaining;
262 if ((err = SSLProcessProtocolMessage(&rec, ctx)) != 0) {
267 err = SSLClose(ctx);
272 if ((err = SSLFreeRecord(rec, ctx))) {
299 SSLChangeHdskState(ctx, SSL_HdskStateErrorClose);
303 sslIoTrace(ctx, "SSLRead returns", dataLength, *processed, err);
312 SSLHandshake(SSLContext *ctx)
316 if(ctx == NULL) {
319 if (ctx->state == SSL_HdskStateGracefulClose)
321 if (ctx->state == SSL_HdskStateErrorClose)
324 if(ctx->validCipherSuites == NULL) {
326 err = sslBuildCipherSuiteArray(ctx);
334 if(ctx->isDTLS && ctx->timeout_deadline) {
337 if (ctx->timeout_deadline<current) {
338 sslDebugLog("%p, retransmition deadline expired\n", ctx);
339 err = tls_handshake_retransmit_timer_expired(ctx->hdsk);
346 while (ctx->readCipher_ready == 0 || ctx->writeCipher_ready == 0)
348 err = SSLHandshakeProceed(ctx);
354 if ((err = SSLServiceWriteQueue(ctx)) != 0) {
363 SSLHandshakeProceed(SSLContext *ctx)
368 if(ctx->state==SSL_HdskStateUninit) {
370 if(ctx->protocolSide == kSSLClientSide) {
371 err = tls_handshake_negotiate(ctx->hdsk, &ctx->peerID);
375 SSLChangeHdskState(ctx, SSL_HdskStatePending);
378 if ((err = tls_handshake_continue(ctx->hdsk)) != 0)
381 if ((err = SSLServiceWriteQueue(ctx)) != 0)
386 err = SSLReadRecord(&rec, ctx);
389 sslDebugLog("%p going to process a record (rec.len=%zd, ct=%d)\n", ctx, rec.contents.length, rec.contentType);
390 err = tls_handshake_process(ctx->hdsk, rec.contents, rec.contentType);
391 sslDebugLog("%p processed a record (rec.len=%zd, ct=%d, err=%d)\n", ctx, rec.contents.length, rec.contentType, (int)err);
392 SSLFreeRecord(rec, ctx);
394 sslDebugLog("%p Read error err=%d\n\n", ctx, (int)err);
401 SSLProcessProtocolMessage(SSLRecord *rec, SSLContext *ctx)
403 return tls_handshake_process(ctx->hdsk, rec->contents, rec->contentType);
407 SSLClose(SSLContext *ctx)
412 if(ctx == NULL) {
416 err = tls_handshake_close(ctx->hdsk);
419 err = SSLServiceWriteQueue(ctx);
421 SSLChangeHdskState(ctx, SSL_HdskStateGracefulClose);
436 SSLGetBufferedReadSize(SSLContextRef ctx,
439 if(ctx == NULL) {
442 if(ctx->receivedDataBuffer.data == NULL) {
446 assert(ctx->receivedDataBuffer.length >= ctx->receivedDataPos);
447 *bufSize = ctx->receivedDataBuffer.length - ctx->receivedDataPos;