亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cryptses.c

?? 提供了很多種加密算法和CA認證及相關服務如CMP、OCSP等的開發
?? C
?? 第 1 頁 / 共 3 頁
字號:
/****************************************************************************
*																			*
*						cryptlib Secure Session Routines					*
*						Copyright Peter Gutmann 1998-2002					*
*																			*
****************************************************************************/

#include <stdlib.h>
#include <string.h>
#include "crypt.h"
#ifdef INC_ALL
  #include "stream.h"
  #include "session.h"
#else
  #include "keymgmt/stream.h"
  #include "session/session.h"
#endif /* Compiler-specific includes */

/* Some session types aren't supported on some platforms so we alias the 
   calls out */

#ifndef NET_TCP
  #define setAccessMethodSSL( x )		CRYPT_ARGERROR_NUM1
  #define setAccessMethodSSH( x )		CRYPT_ARGERROR_NUM1
  #define setAccessMethodCMP( x )		CRYPT_ARGERROR_NUM1
  #define setAccessMethodOCSP( x )		CRYPT_ARGERROR_NUM1
  #define setAccessMethodTSP( x )		CRYPT_ARGERROR_NUM1
#endif /* NET_TCP */

/****************************************************************************
*																			*
*								Get/Put Data Functions						*
*																			*
****************************************************************************/

/* Common code to read and write data over the secure connection.  This
   is called by the protocol-specific handlers, which supply three functions:

	readHeaderFunction()	- Reads the header for a packet and sets up
							  length information.
	processBodyFunction()	- Processes the body of a packet.
	writeDataFunction()		- Wraps and sends a packet.
   
   The read data code uses a help function which either reads everything 
   which is available or to the end of the current packet.  If it runs out 
   of data before reading the end of the packet it returns 0, otherwise it 
   returns a positive value to indicate that it's read a complete packet and 
   should be called again to try for further packets.
   
   Buffer management is handled as follows: The bPos index always points to
   the end of the decoded data (ie data which can be used by the user), if
   there's no partial packet present this index is the same as bEnd:

	----+------------------------
	////|
	----+------------------------
		^
		|
	  bEnd/bPos

   If there's a partial packet present, bEnd points to the end of the 
   received data, and is advanced as more data is read:

	----+-----+-------------+----
	////| hdr |/////////////|....
	----+-----+-------------+----
		^					^
		|					|
	  bPos				  bEnd

   Once the complete packet is read, it's decrypted and moved down to bPos, 
   and bPos and bEnd are adjusted to point to the end of the new data */

static int tryRead( SESSION_INFO *sessionInfoPtr )
	{
	int status;

	/* If there's no pending packet information present, try and read it */
	if( !sessionInfoPtr->pendingPacketLength )
		{
		status = sessionInfoPtr->readHeaderFunction( sessionInfoPtr );
		if( status <= 0 ) 
			{
			/* Some protocols treat the header information for a secured 
			   data packet as part of the data to be secured and some don't.  
			   When we read the header and don't want it to be processed as 
			   part of the packet, we indicate this by returning OK_SPECIAL */
			if( status != OK_SPECIAL )
				return( status );
			}
		else
			{
			sessionInfoPtr->receiveBufEnd += status;
			sessionInfoPtr->pendingPacketPartialLength = status;
			sessionInfoPtr->pendingPacketRemaining -= status;
			}
		}

	/* If there's not enough room in the receive buffer to read at least 1K 
	   of packet data, don't try anything until the user has emptied more 
	   data from the buffer */
	if( sessionInfoPtr->receiveBufSize - sessionInfoPtr->receiveBufEnd < \
		min( sessionInfoPtr->pendingPacketRemaining, 1024 ) )
		return( 0 );

	/* Try and read more of the packet */
	status = sread( &sessionInfoPtr->stream, 
					sessionInfoPtr->receiveBuffer + sessionInfoPtr->receiveBufEnd, 
					sessionInfoPtr->pendingPacketRemaining );
	if( cryptStatusError( status ) )
		{
		sNetGetErrorInfo( &sessionInfoPtr->stream, 
						  sessionInfoPtr->errorMessage,
						  &sessionInfoPtr->errorCode );
		return( status );
		}
	if( status == 0 )
		/* Nothing read, try again later */
		return( 0 );
	sessionInfoPtr->receiveBufEnd += status;
	sessionInfoPtr->pendingPacketRemaining -= status;
	if( sessionInfoPtr->pendingPacketRemaining > 0 )
		/* We got some but not all of the data, try again later */
		return( 0 );

	/* We've got a complete packet in the buffer, process it */
	return( sessionInfoPtr->processBodyFunction( sessionInfoPtr ) );
	}

/* Get data from the remote system */

static int getData( SESSION_INFO *sessionInfoPtr, void *data, 
					const int length )
	{
	int bytesToCopy = length, remainder, timeout, savedTimeout, status;

	/* If there's an error pending and we've exhausted what was still present
	   from earlier reads, set the current error state to the pending state
	   and return */
	if( cryptStatusError( sessionInfoPtr->pendingErrorState ) && \
		!sessionInfoPtr->receiveBufPos )
		return( sessionInfoPtr->pendingErrorState );

	/* Set the stream to the appropriate timeout value (usually zero so we 
	   can see whether there's anything there without blocking, but kul 
	   takhira fi'khira) and see if there's any more data available to 
	   return to the user.  We save the previous value around the access in 
	   case other administrative code needs to perform reads without being 
	   affected by a user-set timeout */
	sioctl( &sessionInfoPtr->stream, STREAM_IOCTL_GETTIMEOUT, 
			&savedTimeout, 0 );
	krnlSendMessage( sessionInfoPtr->ownerHandle, 
					 RESOURCE_IMESSAGE_GETATTRIBUTE, &timeout, 
					 CRYPT_OPTION_NET_TIMEOUT );
	sioctl( &sessionInfoPtr->stream, STREAM_IOCTL_TIMEOUT, NULL, timeout );

	do
		{
		status = tryRead( sessionInfoPtr );
		if( status > 0 )
			/* If we've got some data to return to the caller, reset the 
			   stream to be nonblocking.  This is necessary to avoid having
			   the stream always block for the set timeout value on the last
			   read */
			sioctl( &sessionInfoPtr->stream, STREAM_IOCTL_TIMEOUT, NULL, 0 );
		}
	while( status > 0 );
	sioctl( &sessionInfoPtr->stream, STREAM_IOCTL_TIMEOUT, NULL, 
			savedTimeout );
	if( cryptStatusError( status ) )
		{
		/* If there's an error reading data, only return an error status if
		   there's no further data in the buffer which can be returned, this
		   lets the caller drain out any remaining data from the session
		   buffer before they start getting error returns */
		sessionInfoPtr->pendingErrorState = status;
		if( sessionInfoPtr->receiveBufPos <= 0 )
			return( status );
		}

	/* Adjust the data to copy length by the amount we have available */
	if( bytesToCopy > sessionInfoPtr->receiveBufPos )
		bytesToCopy = sessionInfoPtr->receiveBufPos;

	/* Copy the data across and move any remaining data down to the start of 
	   the receive buffer */
	memcpy( data, sessionInfoPtr->receiveBuffer, bytesToCopy );
	remainder = sessionInfoPtr->receiveBufEnd - bytesToCopy;
	if( remainder )
		memmove( sessionInfoPtr->receiveBuffer, 
				 sessionInfoPtr->receiveBuffer + bytesToCopy, remainder );
	sessionInfoPtr->receiveBufPos -= bytesToCopy;
	sessionInfoPtr->receiveBufEnd = remainder;
	
	return( bytesToCopy );
	}

/* Send data to the remote system */

static int putData( SESSION_INFO *sessionInfoPtr, const void *data,
					const int length )
	{
	BYTE *dataPtr = ( BYTE * ) data;
	int dataLength = length;

	assert( sessionInfoPtr->sendBufPos >= 4 && \
			sessionInfoPtr->sendBufPos <= sessionInfoPtr->sendBufSize );

	/* If it's a flush, send the data through to the server */
	if( !dataLength )
		return( sessionInfoPtr->writeDataFunction( sessionInfoPtr ) );

	/* If there's too much data to fit in the buffer, send it through to the
	   host */
	while( dataLength >= sessionInfoPtr->sendBufSize - \
						 sessionInfoPtr->sendBufPos )
		{
		const int bytesToCopy = sessionInfoPtr->sendBufSize - \
								sessionInfoPtr->sendBufPos;
		int status;

		assert( bytesToCopy >= 0 && bytesToCopy <= dataLength );

		/* Copy in as much data as we have room for and send it through */
		memcpy( sessionInfoPtr->sendBuffer + sessionInfoPtr->sendBufPos,
				dataPtr, bytesToCopy );
		dataPtr += bytesToCopy;
		dataLength -= bytesToCopy;
		status = sessionInfoPtr->writeDataFunction( sessionInfoPtr );
		if( cryptStatusError( status ) )
			return( status );
		}

	/* If there's anything left, it'll fit in the buffer, just copy it in */
	if( dataLength > 0 )
		{
		assert( dataLength < sessionInfoPtr->sendBufSize - \
							 sessionInfoPtr->sendBufPos );

		memcpy( sessionInfoPtr->sendBuffer + sessionInfoPtr->sendBufPos, 
				dataPtr, dataLength );
		sessionInfoPtr->sendBufPos += dataLength;
		}

	return( length );
	}

/****************************************************************************
*																			*
*							General Session API Functions					*
*																			*
****************************************************************************/

/* Handle data sent to or read from a session object */

static int processGetAttribute( SESSION_INFO *sessionInfoPtr,
								void *messageDataPtr, const int messageValue )
	{
	int *valuePtr = ( int * ) messageDataPtr;

	/* Handle the various information types */
	switch( messageValue )
		{
		case CRYPT_ATTRIBUTE_ERRORTYPE:
			*valuePtr = sessionInfoPtr->errorType;
			return( CRYPT_OK );

		case CRYPT_ATTRIBUTE_ERRORLOCUS:
			*valuePtr = sessionInfoPtr->errorLocus;
			return( CRYPT_OK );

		case CRYPT_ATTRIBUTE_BUFFERSIZE:
			*valuePtr = sessionInfoPtr->receiveBufSize;
			return( CRYPT_OK );

		case CRYPT_ATTRIBUTE_INT_ERRORCODE:
			*valuePtr = sessionInfoPtr->errorCode;
			return( CRYPT_OK );

		case CRYPT_SESSINFO_ACTIVE:
			*valuePtr = sessionInfoPtr->sessionOpen;
			return( CRYPT_OK );

		case CRYPT_SESSINFO_SERVER_PORT:
			*valuePtr = sessionInfoPtr->serverPort;
			return( CRYPT_OK );

		case CRYPT_SESSINFO_CLIENT_PORT:
			if( !sessionInfoPtr->clientPort )
				return( CRYPT_ERROR_NOTINITED );
			*valuePtr = sessionInfoPtr->clientPort;
			return( CRYPT_OK );

		case CRYPT_SESSINFO_PROTOCOLVERSION:
			*valuePtr = sessionInfoPtr->version;
			return( CRYPT_OK );
		}

	assert( NOTREACHED );
	return( CRYPT_ERROR );	/* Get rid of compiler warning */
	}

static int processSetAttribute( SESSION_INFO *sessionInfoPtr,
								void *messageDataPtr, const int messageValue )
	{
	const int value = *( int * ) messageDataPtr;
	int status;

	/* Handle the various information types */
	switch( messageValue )
		{
		case CRYPT_ATTRIBUTE_BUFFERSIZE:
			assert( !sessionInfoPtr->sessionOpen );
			sessionInfoPtr->receiveBufSize = value;
			return( CRYPT_OK );

		case CRYPT_SESSINFO_ACTIVE:
			assert( !sessionInfoPtr->sessionOpen );
			if( value == FALSE )
				return( CRYPT_OK );	/* Noop */

			/* Make sure everything is set up ready to go */
			if( !sessionInfoPtr->serverPort )
				{
				setErrorInfo( sessionInfoPtr, CRYPT_SESSINFO_SERVER_PORT, 
							  CRYPT_ERRTYPE_ATTR_ABSENT );
				return( CRYPT_ERROR_NOTINITED );
				}
			if( sessionInfoPtr->flags & SESSION_ISSERVER )

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品一品二品| 日韩精品一区二区三区四区视频 | 91理论电影在线观看| 欧美色图激情小说| 中文字幕精品一区二区精品绿巨人| 粉嫩aⅴ一区二区三区四区五区| 波多野结衣精品在线| 99久久精品国产一区二区三区 | 国产成人福利片| 欧美午夜一区二区三区| 国产日韩欧美a| 免费看日韩精品| 欧美三级在线视频| 亚洲另类春色国产| 国产99精品视频| 精品免费国产一区二区三区四区| 欧美日本一区二区三区四区| 亚洲国产精品高清| 国产成a人无v码亚洲福利| 日韩精品中文字幕一区二区三区 | 人妖欧美一区二区| 欧美在线观看一区| 一区二区三区.www| 色久综合一二码| 中文字幕精品综合| 丁香亚洲综合激情啪啪综合| 久久这里只有精品6| 国产毛片精品视频| 久久综合九色综合欧美就去吻| 国产日产欧美精品一区二区三区| 日本一区二区三区在线不卡| 日韩电影免费在线观看网站| 欧美情侣在线播放| 爽好久久久欧美精品| 欧美久久久影院| 欧美a级一区二区| 欧美一级爆毛片| 老司机一区二区| 亚洲欧美另类小说视频| 色婷婷综合激情| 亚洲第四色夜色| 欧美一区二区三区在线视频| 日本美女视频一区二区| 日韩一卡二卡三卡国产欧美| 精久久久久久久久久久| 国产欧美一区二区三区沐欲| 成人av网站免费| 亚洲亚洲精品在线观看| 欧美一区二区三区在线| 国产麻豆精品一区二区| 亚洲欧洲日韩女同| 欧美剧情片在线观看| 久久99热99| 国产精品天美传媒| 欧美偷拍一区二区| 久久成人精品无人区| 国产欧美一区二区三区鸳鸯浴| 亚洲福利一区二区| 日韩一区二区三免费高清| 国产一区二区三区免费观看| 亚洲国产精品二十页| 精品视频一区二区三区免费| 免费人成黄页网站在线一区二区 | 国产超碰在线一区| 国产精品色哟哟网站| 欧美日韩精品一区二区三区四区| 亚洲欧洲av色图| 欧美日韩国产成人在线91| 精品一区二区三区久久| 国产精品不卡在线| 欧美一区二区三区公司| 不卡av免费在线观看| 丝袜a∨在线一区二区三区不卡| 99国产精品99久久久久久| 日日欢夜夜爽一区| 欧美国产综合一区二区| 欧美日韩五月天| 成人午夜av在线| 蜜桃传媒麻豆第一区在线观看| 欧美日韩一区二区三区在线| 国产999精品久久久久久| 午夜激情综合网| 国产精品国模大尺度视频| 欧美一级日韩一级| 欧洲精品一区二区| 成人国产一区二区三区精品| 免费xxxx性欧美18vr| 亚洲综合免费观看高清完整版 | 人妖欧美一区二区| 亚洲精品一二三区| 亚洲国产精品精华液ab| 精品99999| 欧美日韩一区高清| 欧洲另类一二三四区| www.亚洲人| 大陆成人av片| 国产大陆精品国产| 激情小说亚洲一区| 另类的小说在线视频另类成人小视频在线 | 午夜电影一区二区| 亚洲欧洲制服丝袜| 日韩一区欧美小说| 国产精品美女久久久久久久久| 国产成人综合精品三级| 精品制服美女丁香| 五月天亚洲婷婷| 亚洲成人精品一区二区| 亚洲一区二区三区美女| 亚洲综合激情另类小说区| 一区二区三区四区蜜桃| 亚洲乱码国产乱码精品精小说 | 风间由美中文字幕在线看视频国产欧美| 久久婷婷国产综合国色天香| 日韩一区二区免费电影| 欧美放荡的少妇| 欧美一区二区三区免费| 欧美日韩高清在线| 91精品在线免费| 日韩西西人体444www| 精品粉嫩超白一线天av| 精品日韩一区二区| 国产色婷婷亚洲99精品小说| 欧美国产一区二区在线观看| 国产精品日产欧美久久久久| 综合激情成人伊人| 亚洲宅男天堂在线观看无病毒| 日韩丝袜美女视频| 精品99久久久久久| 国产精品网站在线观看| 亚洲人成网站在线| 午夜天堂影视香蕉久久| 秋霞午夜av一区二区三区| 毛片av中文字幕一区二区| 国产一区二三区| 成人av电影在线| 欧美亚男人的天堂| 欧美不卡视频一区| 国产精品三级电影| 五月婷婷另类国产| 国产精品小仙女| 色哟哟一区二区三区| 欧美日韩高清一区二区三区| 欧美成人一区二区三区片免费| 欧美性xxxxxxxx| 欧美变态口味重另类| 日韩伦理电影网| 免费一级欧美片在线观看| 丰满亚洲少妇av| 91高清视频免费看| 久久―日本道色综合久久| 亚洲色图都市小说| 蜜桃av一区二区三区| 成人av在线播放网址| 4438成人网| 亚洲欧洲日产国码二区| 毛片一区二区三区| 91社区在线播放| 亚洲精品一区二区在线观看| 亚洲欧美另类图片小说| 极品美女销魂一区二区三区 | 亚洲人123区| 日韩av网站在线观看| av电影在线观看不卡| 日韩亚洲欧美在线| 亚洲精选一二三| 国产+成+人+亚洲欧洲自线| 欧美日本国产视频| 亚洲视频免费在线观看| 久久99精品国产麻豆不卡| 色94色欧美sute亚洲线路一久| 色94色欧美sute亚洲线路一ni| 99re这里只有精品首页| 91精品国产一区二区三区香蕉| 欧美日韩不卡视频| 亚洲欧美一区二区三区久本道91| 一区在线中文字幕| 美国十次了思思久久精品导航| 免费日韩伦理电影| 欧美日韩午夜在线| 亚洲精品成a人| 99视频一区二区| 国产免费成人在线视频| 黄一区二区三区| 56国语精品自产拍在线观看| 亚洲欧美日韩久久| a在线播放不卡| 欧美高清在线一区二区| 国产成人免费av在线| 亚洲精品一线二线三线| 久久9热精品视频| 日韩欧美在线网站| 麻豆精品蜜桃视频网站| 在线成人小视频| 日韩av在线播放中文字幕| 欧美精品日韩综合在线| 亚洲国产另类av| 在线不卡免费av| 日本人妖一区二区| 日韩一区二区视频| 久久99深爱久久99精品|