29 const BOOLEAN isPostTransaction )
37 if( isServer && sessionInfoPtr->iCertRequest !=
CRYPT_ERROR )
47 if( ( isServer || !isPostTransaction ) && \
60 int initSessionNetConnectInfo(
const SESSION_INFO *sessionInfoPtr,
102 if( serverNamePtr != NULL )
104 connectInfo->interface = serverNamePtr->value;
105 connectInfo->interfaceLength = serverNamePtr->
valueLength;
112 connectInfo->name = serverNamePtr->value;
113 connectInfo->nameLength = serverNamePtr->
valueLength;
114 if( clientNamePtr != NULL )
116 connectInfo->interface = clientNamePtr->value;
117 connectInfo->interfaceLength = clientNamePtr->
valueLength;
123 if( ( portInfoPtr = \
126 connectInfo->port = portInfoPtr->
intValue;
150 #define CHECK_ATTR_NONE 0x00
151 #define CHECK_ATTR_REQUEST 0x01
152 #define CHECK_ATTR_PRIVKEY 0x02
153 #define CHECK_ATTR_PRIVKEYSET 0x04
154 #define CHECK_ATTR_CACERT 0x08
155 #define CHECK_ATTR_FINGERPRINT 0x10
161 static const MAP_TABLE excludedAttrTbl[] = {
163 CHECK_ATTR_REQUEST | CHECK_ATTR_PRIVKEY | CHECK_ATTR_PRIVKEYSET },
165 CHECK_ATTR_PRIVKEY | CHECK_ATTR_PRIVKEYSET },
167 CHECK_ATTR_CACERT | CHECK_ATTR_FINGERPRINT },
169 CHECK_ATTR_FINGERPRINT | CHECK_ATTR_CACERT },
182 status = mapValue( attribute, &flags, excludedAttrTbl,
187 if( ( flags & CHECK_ATTR_REQUEST ) && \
194 if( ( flags & CHECK_ATTR_PRIVKEYSET ) && \
201 if( ( flags & CHECK_ATTR_CACERT ) && \
208 if( ( flags & CHECK_ATTR_FINGERPRINT ) && \
298 if( sessionInfoPtr->transportSession ==
CRYPT_ERROR && \
316 if( !( sessionInfoPtr->clientReqAttrFlags & \
326 if( !( sessionInfoPtr->clientReqAttrFlags & \
353 if( !( sessionInfoPtr->serverReqAttrFlags & \
377 errorAttribute =
isServer( sessionInfoPtr ) ? \
378 checkServerParameters( sessionInfoPtr ) : \
379 checkClientParameters( sessionInfoPtr );
392 sessionInfoPtr->protocolInfo->port > 0 );
398 if( sessionInfoPtr->sendBuffer == NULL )
406 if( ( sessionInfoPtr->receiveBuffer = \
407 clAlloc(
"activateConnection", \
408 sessionInfoPtr->receiveBufSize + 8 ) ) == NULL )
415 if( ( sessionInfoPtr->sendBuffer = \
416 clAlloc(
"activateConnection", \
417 sessionInfoPtr->receiveBufSize + 8 ) ) == NULL )
419 clFree(
"activateConnection", sessionInfoPtr->receiveBuffer );
420 sessionInfoPtr->receiveBuffer = NULL;
423 sessionInfoPtr->sendBufSize = sessionInfoPtr->receiveBufSize;
426 ENSURES( sessionInfoPtr->receiveBuffer != NULL && \
430 sessionInfoPtr->sendBuffer != NULL );
436 if( sessionInfoPtr->connectTimeout ==
CRYPT_ERROR )
444 sessionInfoPtr->connectTimeout = timeout;
447 DEBUG_DIAG((
"Couldn't get connect timeout config value" ));
449 sessionInfoPtr->connectTimeout = 30;
460 sessionInfoPtr->readTimeout = timeout;
463 DEBUG_DIAG((
"Couldn't get read timeout config value" ));
465 sessionInfoPtr->readTimeout = 30;
476 sessionInfoPtr->writeTimeout = timeout;
479 DEBUG_DIAG((
"Couldn't get write timeout config value" ));
481 sessionInfoPtr->writeTimeout = 30;
499 status = sessionInfoPtr->connectFunction( sessionInfoPtr );
512 status = sessionInfoPtr->transactFunction( sessionInfoPtr );
538 &sessionInfoPtr->iCryptInContext,
542 sessionInfoPtr->receiveBufPos = sessionInfoPtr->receiveBufEnd = 0;
543 sessionInfoPtr->sendBufPos = sessionInfoPtr->sendBufStartOfs;
575 status = activateConnection( sessionInfoPtr );
589 if( sessionInfoPtr->attributeList != NULL )
590 lockEphemeralAttributes( sessionInfoPtr->attributeList );
595 if( !sessionInfoPtr->protocolInfo->isReqResp )
603 cleanupReqResp( sessionInfoPtr,
FALSE );
604 status = sessionInfoPtr->transactFunction( sessionInfoPtr );
605 cleanupReqResp( sessionInfoPtr,
TRUE );
613 &streamState,
sizeof(
int ) );
617 sessionInfoPtr->shutdownFunction( sessionInfoPtr );
644 assert( ( data == NULL && length == 0 ) || \
647 REQUIRES( ( data == NULL && length == 0 ) || \
678 status = sioctlGet( &sessionInfoPtr->stream,
694 status = swrite( &sessionInfoPtr->stream, data, length );
733 status = initSessionNetConnectInfo( sessionInfoPtr, &connectInfo );
738 &connectInfo, &sessionInfoPtr->errorInfo );
741 #ifdef USE_CMP_TRANSPORT
750 if( connectInfo.
port == 80 )
751 connectInfo.
port = altProtocolInfoPtr->
port;
752 status = sNetConnect( &sessionInfoPtr->stream,
753 altProtocolInfoPtr->
type,
754 &connectInfo, &sessionInfoPtr->errorInfo );
759 status = sNetConnect( &sessionInfoPtr->stream,
761 &connectInfo, &sessionInfoPtr->errorInfo );
776 status = initSessionNetConnectInfo( sessionInfoPtr, &connectInfo );
781 &connectInfo, &sessionInfoPtr->errorInfo );
784 #ifdef USE_CMP_TRANSPORT
793 if( connectInfo.
port == 80 )
794 connectInfo.
port = altProtocolInfoPtr->
port;
795 status = sNetListen( &sessionInfoPtr->stream,
796 altProtocolInfoPtr->
type,
797 &connectInfo, &sessionInfoPtr->errorInfo );
802 status = sNetListen( &sessionInfoPtr->stream,
804 &connectInfo, &sessionInfoPtr->errorInfo );
812 status = sioctlGet( &sessionInfoPtr->stream,
814 &nameLen,
sizeof(
int ) );
817 status = sioctlGet( &sessionInfoPtr->stream,
819 sessionInfoPtr->receiveBuffer,
827 status = addSessionInfoS( &sessionInfoPtr->attributeList,
829 sessionInfoPtr->receiveBuffer, nameLen );
833 &port,
sizeof(
int ) );
839 return( addSessionInfo( &sessionInfoPtr->attributeList,
848 sNetDisconnect( &sessionInfoPtr->stream );
878 *responsePtr = sessionInfoPtr->iCertResponse;
879 sessionInfoPtr->iCertResponse = sessionInfoPtr->iAuthInContext;
888 *responsePtr = sessionInfoPtr->iCertResponse;
897 const PROTOCOL_INFO *protocolInfoPtr = sessionInfoPtr->protocolInfo;
902 if( sessionInfoPtr->shutdownFunction == NULL )
903 sessionInfoPtr->shutdownFunction = defaultShutdownFunction;
904 if( sessionInfoPtr->connectFunction == NULL )
905 sessionInfoPtr->connectFunction =
isServer( sessionInfoPtr ) ?
906 defaultServerStartupFunction : defaultClientStartupFunction;
908 sessionInfoPtr->getAttributeFunction == NULL )
909 sessionInfoPtr->getAttributeFunction = defaultGetAttributeFunction;