24 #define RTCS_CONTENT_TYPE_REQ "application/rtcs-request"
25 #define RTCS_CONTENT_TYPE_REQ_LEN 24
26 #define RTCS_CONTENT_TYPE_RESP "application/rtcs-response"
27 #define RTCS_CONTENT_TYPE_RESP_LEN 25
66 { NULL, 0 }, { NULL, 0 }
70 static
int checkRtcsHeader(
IN_BUFFER( rtcsDataLength )
const void *rtcsData,
77 assert(
isReadPtr( rtcsData, rtcsDataLength ) );
86 sMemConnect( &stream, rtcsData, rtcsDataLength );
87 status = readCMSheader( &stream, envelopeOIDinfo,
90 sMemDisconnect( &stream );
115 sessionInfoPtr->receiveBufSize );
118 CRYPT_ICERTFORMAT_DATA );
123 "Couldn't get RTCS request data from RTCS request "
126 status = envelopeWrap( sessionInfoPtr->receiveBuffer, msgData.
length,
127 sessionInfoPtr->receiveBuffer,
128 sessionInfoPtr->receiveBufSize,
129 &sessionInfoPtr->receiveBufEnd,
136 "Couldn't CMS-envelope RTCS request data" ) );
139 sessionInfoPtr->receiveBufEnd );
142 return( writePkiDatagram( sessionInfoPtr, RTCS_CONTENT_TYPE_REQ,
143 RTCS_CONTENT_TYPE_REQ_LEN ) );
161 status = readPkiDatagram( sessionInfoPtr );
165 sessionInfoPtr->receiveBufEnd );
166 status = checkRtcsHeader( sessionInfoPtr->receiveBuffer,
167 sessionInfoPtr->receiveBufEnd, &actionType );
172 "Invalid RTCS response header" ) );
178 "Unexpected RTCS encapsulation type %d", actionType ) );
182 status = envelopeSigCheck( sessionInfoPtr->receiveBuffer,
183 sessionInfoPtr->receiveBufEnd,
184 sessionInfoPtr->receiveBuffer,
185 sessionInfoPtr->receiveBufSize, &dataLength,
192 "Invalid CMS-enveloped RTCS response data" ) );
214 memcmp( msgData.data, responseMsgData.data, msgData.
length ) ) )
228 "RTCS response doesn't contain a nonce" : \
229 "RTCS response nonce doesn't match the one in the "
235 sessionInfoPtr->receiveBuffer, dataLength,
244 "Invalid RTCS response contents" ) );
246 sessionInfoPtr->iCertResponse = createInfo.
cryptHandle;
269 assert(
isWritePtr( protocolInfo,
sizeof( RTCS_PROTOCOL_INFO ) ) );
274 status = readPkiDatagram( sessionInfoPtr );
278 sessionInfoPtr->receiveBufEnd );
279 status = checkRtcsHeader( sessionInfoPtr->receiveBuffer,
280 sessionInfoPtr->receiveBufEnd, &actionType );
286 if( actionType != ACTION_UNWRAP )
290 "Unexpected RTCS encapsulation type %d", actionType ) );
292 status = envelopeUnwrap( sessionInfoPtr->receiveBuffer,
293 sessionInfoPtr->receiveBufEnd,
294 sessionInfoPtr->receiveBuffer,
295 sessionInfoPtr->receiveBufSize, &dataLength,
301 "Invalid CMS-enveloped RTCS request data" ) );
311 sessionInfoPtr->iCertResponse = createInfo.
cryptHandle;
315 sessionInfoPtr->receiveBuffer, dataLength,
327 protocolInfo->nonceSize = msgData.
length;
339 "Invalid RTCS request contents" ) );
346 CRYPT_IATTRIBUTE_RTCSREQUEST );
352 "Couldn't create RTCS response from request" ) );
361 INOUT RTCS_PROTOCOL_INFO *protocolInfo )
368 assert(
isWritePtr( protocolInfo,
sizeof( RTCS_PROTOCOL_INFO ) ) );
377 sessionInfoPtr->cryptKeyset );
382 "Couldn't check RTCS request against certificate "
387 if( protocolInfo->nonceSize > 0 )
400 protocolInfo->nonceSize );
413 sessionInfoPtr->receiveBufSize );
416 CRYPT_ICERTFORMAT_DATA );
419 status = envelopeSign( sessionInfoPtr->receiveBuffer, msgData.
length,
420 sessionInfoPtr->receiveBuffer,
421 sessionInfoPtr->receiveBufSize,
422 &sessionInfoPtr->receiveBufEnd,
424 sessionInfoPtr->privateKey, iCmsAttributes );
432 "Couldn't CMS-envelope RTCS response" ) );
435 sessionInfoPtr->receiveBufEnd );
436 return( writePkiDatagram( sessionInfoPtr, RTCS_CONTENT_TYPE_RESP,
437 RTCS_CONTENT_TYPE_RESP_LEN ) );
456 status = sendClientRequest( sessionInfoPtr );
458 status = readServerResponse( sessionInfoPtr );
471 memset( &protocolInfo, 0,
sizeof( RTCS_PROTOCOL_INFO ) );
472 status = readClientRequest( sessionInfoPtr, &protocolInfo );
474 status = sendServerResponse( sessionInfoPtr, &protocolInfo );
494 assert(
isReadPtr( data,
sizeof(
int ) ) );
505 CRYPT_ICERTFORMAT_DATA );
519 &msgData, CRYPT_IATTRIBUTE_RESPONDERURL );
528 sessionInfoPtr->iCertRequest = rtcsRequest;
552 SESSION_NEEDS_PRIVKEYCERT | \
553 SESSION_NEEDS_KEYSET,
564 sessionInfoPtr->transactFunction = serverTransact;
566 sessionInfoPtr->transactFunction = clientTransact;
567 sessionInfoPtr->setAttributeFunction = setAttributeFunction;