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

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

?? ssh1.c

?? cryptlib安全工具包
?? C
?? 第 1 頁 / 共 5 頁
字號:

static int processKeyFingerprint( SESSION_INFO *sessionInfoPtr,
								  const void *n, const int nLength,
								  const void *e, int eLength )
	{
	HASHFUNCTION hashFunction;
	HASHINFO hashInfo;
	const ATTRIBUTE_LIST *attributeListPtr = \
				findSessionInfo( sessionInfoPtr->attributeList,
								 CRYPT_SESSINFO_SERVER_FINGERPRINT );
	BYTE fingerPrint[ CRYPT_MAX_HASHSIZE + 8 ];
	int hashSize;

	getHashParameters( CRYPT_ALGO_MD5, &hashFunction, &hashSize );
	hashFunction( hashInfo, NULL, n, nLength, HASH_START );
	hashFunction( hashInfo, fingerPrint, e, eLength, HASH_END );
	if( attributeListPtr == NULL )
		/* Remember the value for the caller */
		return( addSessionInfo( &sessionInfoPtr->attributeList,
								CRYPT_SESSINFO_SERVER_FINGERPRINT,
								fingerPrint, hashSize ) );

	/* There's an existing fingerprint value, make sure that it matches what
	   we just calculated */
	if( attributeListPtr->valueLength != hashSize || \
		memcmp( attributeListPtr->value, fingerPrint, hashSize ) )
		retExt( sessionInfoPtr, CRYPT_ERROR_WRONGKEY,
				"Server key fingerprint doesn't match requested "
				"fingerprint" );
	return( CRYPT_OK );
	}

/* Generate a response to an RSA authentication challenge */

static void generateChallengeResponse( BYTE *response,
									   const SSH_HANDSHAKE_INFO *handshakeInfo,
									   const BYTE *challenge )
	{
	HASHFUNCTION hashFunction;
	HASHINFO hashInfo;

	/* Hash the session ID and challenge:
		hash( sessionID || challenge ) */
	getHashParameters( CRYPT_ALGO_MD5, &hashFunction, NULL );
	hashFunction( hashInfo, NULL, ( BYTE * ) handshakeInfo->sessionID,
				  handshakeInfo->sessionIDlength, HASH_START );
	hashFunction( hashInfo, response, ( BYTE * ) challenge,
				  SSH1_CHALLENGE_SIZE, HASH_END );
	}

/* Process the public key data.  The preceding key length value isn't useful
   because it contains the nominal key size in bits rather than the size of
   the following data, so we have to dig into the data to find out how much
   there is.  In addition we need to take a copy of the key modulus since
   it's needed later for calculating the session ID */

static int processPublickeyData( SSH_HANDSHAKE_INFO *handshakeInfo,
								 const void *data, const int dataLength,
								 const BOOLEAN isServerKey,
								 SESSION_INFO *sessionInfoPtr )
	{
	BYTE *dataPtr = ( BYTE * ) data, *ePtr;
	int nominalLength, eLength, nLength;

	nominalLength = ( int ) mgetLong( dataPtr );
	nominalLength = bitsToBytes( nominalLength );
	if( nominalLength < bitsToBytes( MIN_PKCSIZE_BITS ) || \
		nominalLength > CRYPT_MAX_PKCSIZE )
		retExt( sessionInfoPtr, CRYPT_ERROR_BADDATA,
				"Invalid public key size %d", nominalLength );
	eLength = mgetWord( dataPtr );
	eLength = bitsToBytes( eLength );
	if( LENGTH_SIZE + SSH1_MPI_LENGTH_SIZE + eLength + \
					  SSH1_MPI_LENGTH_SIZE + nominalLength > dataLength )
		retExt( sessionInfoPtr, CRYPT_ERROR_BADDATA,
				"Invalid exponent size %d for key size %d", eLength,
				nominalLength );
	ePtr = dataPtr;
	dataPtr += eLength;
	nLength = mgetWord( dataPtr );
	nLength = bitsToBytes( nLength );
	if( nLength != nominalLength )
		retExt( sessionInfoPtr, CRYPT_ERROR_BADDATA,
				"Public key size %d doesn't match modulus size %d",
				nominalLength, nLength );
	if( isServerKey )
		{
		memcpy( handshakeInfo->serverModulus, dataPtr, nLength );
		handshakeInfo->serverModulusLength = nLength;
		}
	else
		{
		memcpy( handshakeInfo->hostModulus, dataPtr, nLength );
		handshakeInfo->hostModulusLength = nLength;
		}
	if( sessionInfoPtr != NULL )
		{
		int status;

		status = processKeyFingerprint( sessionInfoPtr, dataPtr, nLength,
										ePtr, eLength );
		if( cryptStatusError( status ) )
			return( status );
		}

	return( LENGTH_SIZE + SSH1_MPI_LENGTH_SIZE + eLength + \
						  SSH1_MPI_LENGTH_SIZE + nLength );
	}

/* Set up the security information required for the session */

static int initSecurityInfoSSH1( SESSION_INFO *sessionInfoPtr,
								 SSH_HANDSHAKE_INFO *handshakeInfo )
	{
	MESSAGE_DATA msgData;
	int keySize, ivSize, status;

	/* Create the security contexts required for the session */
	status = initSecurityContextsSSH( sessionInfoPtr );
	if( cryptStatusError( status ) )
		return( status );
	if( sessionInfoPtr->cryptAlgo == CRYPT_ALGO_BLOWFISH )
		/* For Blowfish the session key size doesn't match the default
		   Blowfish key size so we explicitly specify its length */
		keySize = SSH1_SECRET_SIZE;
	else
		krnlSendMessage( sessionInfoPtr->iCryptInContext,
						 IMESSAGE_GETATTRIBUTE, &keySize,
						 CRYPT_CTXINFO_KEYSIZE );
	if( krnlSendMessage( sessionInfoPtr->iCryptInContext,
						 IMESSAGE_GETATTRIBUTE, &ivSize,
						 CRYPT_CTXINFO_IVSIZE ) == CRYPT_ERROR_NOTAVAIL )
		/* It's a stream cipher */
		ivSize = 0;

	/* Load the keys.  For RC4, which is IV-less, the session key is split
	   into two parts, with the first part being the receive key and the
	   second part being the send key.  For other algorithms, the entire
	   session key is used for both send and receive contexts, leading to
	   a simple attack on the first data block since the initial IV is all
	   zeroes */
	setMessageData( &msgData, ( sessionInfoPtr->cryptAlgo == CRYPT_ALGO_RC4 ) ? \
					handshakeInfo->secretValue + 16 : handshakeInfo->secretValue,
					keySize );
	status = krnlSendMessage( sessionInfoPtr->iCryptOutContext,
							  IMESSAGE_SETATTRIBUTE_S, &msgData,
							  CRYPT_CTXINFO_KEY );
	if( cryptStatusOK( status ) )
		{
		setMessageData( &msgData, handshakeInfo->secretValue, keySize );
		status = krnlSendMessage( sessionInfoPtr->iCryptInContext,
								  IMESSAGE_SETATTRIBUTE_S, &msgData,
								  CRYPT_CTXINFO_KEY );
		}
	if( cryptStatusOK( status ) && ivSize > 0 )
		{
		static const char iv[ CRYPT_MAX_IVSIZE ] = { 0 };

		setMessageData( &msgData, ( void * ) iv, ivSize );
		krnlSendMessage( sessionInfoPtr->iCryptOutContext,
						 IMESSAGE_SETATTRIBUTE_S, &msgData, CRYPT_CTXINFO_IV );
		setMessageData( &msgData, ( void * ) iv, ivSize );
		krnlSendMessage( sessionInfoPtr->iCryptInContext,
						 IMESSAGE_SETATTRIBUTE_S, &msgData, CRYPT_CTXINFO_IV );
		}
	if( cryptStatusError( status ) )
		return( status );

	/* If we're talking to a cryptlib peer, set up the MAC context which is
	   used instead of a CRC32.  The key we use for this is taken from the
	   end of the SSH secret data, which isn't used for any cipher except
	   Blowfish */
	if( sessionInfoPtr->flags & SESSION_ISCRYPTLIB )
		{
		setMessageData( &msgData,
				handshakeInfo->secretValue + ( SSH1_SECRET_SIZE - 16 ), 16 );
		status = krnlSendMessage( sessionInfoPtr->iAuthInContext,
								  IMESSAGE_SETATTRIBUTE_S, &msgData,
								  CRYPT_CTXINFO_KEY );
		if( cryptStatusError( status ) )
			return( status );
		}

	/* We've set up the security info, from now on all data is encrypted */
	sessionInfoPtr->flags |= SESSION_ISSECURE_READ | SESSION_ISSECURE_WRITE;

	return( CRYPT_OK );
	}

/* Read an SSH packet */

static int decryptPayload( SESSION_INFO *sessionInfoPtr, BYTE *buffer,
						   const int length )
	{
	int status;

	/* Decrypt the payload, with handling for SSH's Blowfish endianness bug.
	   This may not be a true bug but more a problem in the spec, since the
	   original was rather vague about the endianness of the byte -> long
	   conversion */
	if( sessionInfoPtr->cryptAlgo == CRYPT_ALGO_BLOWFISH )
		longReverse( ( unsigned long * ) buffer, length );
	status = krnlSendMessage( sessionInfoPtr->iCryptInContext,
							  IMESSAGE_CTX_DECRYPT, buffer, length );
	if( sessionInfoPtr->cryptAlgo == CRYPT_ALGO_BLOWFISH )
		longReverse( ( unsigned long * ) buffer, length );
	return( status );
	}

static BOOLEAN checksumPayload( SESSION_INFO *sessionInfoPtr,
								const BYTE *buffer, const int length )
	{
	const int dataLength = length - SSH1_CRC_SIZE;	/* CRC isn't part of payload */
	BYTE *bufPtr = ( BYTE * ) buffer + dataLength;
	unsigned long crc32, storedCrc32;

	/* Calculate the checksum over the padding, type, and data and make sure
	   that it matches the transmitted value */
	if( ( sessionInfoPtr->flags & ( SESSION_ISCRYPTLIB | SESSION_ISSECURE_READ ) ) == \
								  ( SESSION_ISCRYPTLIB | SESSION_ISSECURE_READ ) )
		crc32 = calculateTruncatedMAC( sessionInfoPtr->iAuthInContext,
									   buffer, dataLength );
	else
		crc32 = calculateCRC( buffer, dataLength );
	storedCrc32 = mgetLong( bufPtr );
	return( ( crc32 == storedCrc32 ) ? TRUE : FALSE );
	}

static int getDisconnectInfoSSH1( SESSION_INFO *sessionInfoPtr, BYTE *bufPtr )
	{
	int length;

	/* Server is disconnecting, find out why */
	length = mgetLong( bufPtr );
	if( length > MAX_ERRMSG_SIZE - 32 )
		retExt( sessionInfoPtr, CRYPT_ERROR_OVERFLOW,
				"Invalid error information size %d", length );
	strlcpy_s( sessionInfoPtr->errorMessage, MAX_ERRMSG_SIZE,
			   "Received SSHv1 server message: " );
	memcpy( sessionInfoPtr->errorMessage + 31, bufPtr, length );
	sessionInfoPtr->errorMessage[ 31 + length ] = '\0';

	return( CRYPT_ERROR_READ );
	}

static int readPacketSSH1( SESSION_INFO *sessionInfoPtr, int expectedType )
	{
	BYTE *bufPtr = sessionInfoPtr->receiveBuffer;
	long length;
	int padLength, packetType, iterationCount = 0;

	/* Alongside the expected packets the server can also send us all sorts
	   of no-op messages, ranging from explicit no-ops (SSH_MSG_IGNORE)
	   through to general chattiness (SSH_MSG_DEBUG).  Because we can
	   receive any quantity of these at any time, we have to run the receive
	   code in a loop to strip them out */
	do
		{
		const BYTE *lengthPtr = bufPtr;
		int status;

		/* Read the SSHv1 packet header:

			uint32		length (excluding padding)
			byte[]		padding
			byte		type
			byte[]		data
			uint32		crc32

		  The padding length is implicitly calculated as
		  8 - ( length & 7 ) bytes, and the CRC is calculated over the
		  padding, type, and data */
		assert( sessionInfoPtr->receiveBufEnd == 0 );
		status = readFixedHeader( sessionInfoPtr, LENGTH_SIZE );
		if( cryptStatusError( status ) )
			return( status );
		assert( status == LENGTH_SIZE );
		length = mgetLong( lengthPtr );
		padLength = 8 - ( length & 7 );
		if( length < SSH1_HEADER_SIZE || \
			length + padLength >= sessionInfoPtr->receiveBufSize )
			retExt( sessionInfoPtr, CRYPT_ERROR_BADDATA,
					"Invalid packet length %d", length );
		status = sread( &sessionInfoPtr->stream,
						sessionInfoPtr->receiveBuffer, padLength + length );
		if( cryptStatusError( status ) )
			{
			sNetGetErrorInfo( &sessionInfoPtr->stream,
							  &sessionInfoPtr->errorInfo );
			return( status );
			}
		if( status != padLength + length )
			retExt( sessionInfoPtr, CRYPT_ERROR_TIMEOUT,
					"Timeout during packet remainder read, only got %d of "
					"%d bytes", status, padLength + length );
		if( sessionInfoPtr->flags & SESSION_ISSECURE_READ )
			{
			status = decryptPayload( sessionInfoPtr,
									 sessionInfoPtr->receiveBuffer,
									 padLength + length );
			if( cryptStatusError( status ) )
				return( status );
			}
		if( !checksumPayload( sessionInfoPtr, sessionInfoPtr->receiveBuffer,
							  padLength + length ) )
			/* If we're expecting a success packet after a key exchange or an
			   immediate post key-exchange packet and don't get it then it's
			   more likely that the problem is due to the wrong key being
			   used than data corruption, so we return a wrong key error
			   instead of bad data */
			retExt( sessionInfoPtr, ( expectedType == SSH1_SMSG_SUCCESS ) ? \
						CRYPT_ERROR_WRONGKEY : CRYPT_ERROR_BADDATA,
					"Bad message checksum" );
		packetType = sessionInfoPtr->receiveBuffer[ padLength ];
		}
	while( ( packetType == SSH1_MSG_IGNORE || \
			 packetType == SSH1_MSG_DEBUG ) && iterationCount++ < 1000 );
	if( iterationCount >= 1000 )
		retExt( sessionInfoPtr, CRYPT_ERROR_OVERFLOW,
				"Peer sent excessive number of no-op packets" );
	length -= ID_SIZE + UINT_SIZE;	/* Remove fixed fields */

	/* Make sure we either got what we asked for or one of the allowed
	   special-case packets */
	if( packetType == SSH1_MSG_DISCONNECT )
		return( getDisconnectInfoSSH1( sessionInfoPtr,
					sessionInfoPtr->receiveBuffer + padLength + ID_SIZE ) );
	if( expectedType == SSH1_MSG_SPECIAL_USEROPT )
		{
		/* Sending an SSH1_CMSG_USER can result in an SSH1_SMSG_FAILURE if the
		   user needs some form of authentiction to log on, so we have to
		   filter this and convert it into a CRYPT_OK/OK_SPECIAL value to
		   let the caller know whether they have to send a password or not */
		if( packetType == SSH1_SMSG_SUCCESS )
			return( CRYPT_OK );
		if( packetType == SSH1_SMSG_FAILURE )
			return( OK_SPECIAL );

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩伦理电影网| 国产一区二区三区在线观看精品| 精品一区二区免费| 色综合一个色综合亚洲| 久久午夜色播影院免费高清 | 欧美在线观看18| ww亚洲ww在线观看国产| 婷婷开心激情综合| 色天使色偷偷av一区二区| 国产视频一区二区在线观看| 婷婷国产在线综合| 91九色最新地址| 中文字幕精品三区| 国产丶欧美丶日本不卡视频| 欧美一区二区三区思思人| 一区二区高清视频在线观看| 国产风韵犹存在线视精品| 日韩女优毛片在线| 视频一区二区中文字幕| 欧美午夜精品免费| 亚洲欧美日韩成人高清在线一区| 国产裸体歌舞团一区二区| 欧美电影免费观看高清完整版在 | 国产成人在线视频免费播放| 日韩一二三区视频| 麻豆国产欧美一区二区三区| 欧美精品在线视频| 午夜精品福利一区二区蜜股av| 91免费观看视频在线| 日韩一区中文字幕| 色婷婷亚洲一区二区三区| 亚洲色大成网站www久久九九| 成人蜜臀av电影| 久久精品视频一区| 高清日韩电视剧大全免费| 欧美国产激情二区三区| 成人18视频在线播放| 中文字幕在线不卡一区| 99久久久久久99| 亚洲在线一区二区三区| 欧美日韩高清一区| 麻豆精品一区二区三区| 精品裸体舞一区二区三区| 国产电影一区二区三区| 亚洲欧美国产77777| 欧美日韩一区 二区 三区 久久精品| 亚洲成a人v欧美综合天堂下载 | 精品少妇一区二区三区 | 日韩福利电影在线| 精品国产在天天线2019| 成人久久18免费网站麻豆 | 免费成人美女在线观看.| 亚洲精品一区二区三区影院 | 欧美午夜精品免费| 蜜桃视频在线观看一区二区| 国产日韩精品视频一区| 91免费视频观看| 美女一区二区久久| 国产精品美女久久久久久久久 | 亚洲成精国产精品女| 日韩网站在线看片你懂的| 国产成人综合在线观看| 亚洲精品免费视频| 欧美岛国在线观看| 91精品办公室少妇高潮对白| 蜜臀av国产精品久久久久| **网站欧美大片在线观看| 7799精品视频| 97久久超碰国产精品电影| 蜜臀精品一区二区三区在线观看 | 欧美成人午夜电影| 91在线精品一区二区三区| 青青草精品视频| 国产精品色一区二区三区| 在线播放91灌醉迷j高跟美女 | 亚洲精品视频在线看| 欧美成人一区二区三区在线观看 | 成人精品电影在线观看| 日韩avvvv在线播放| 中文字幕一区二区在线观看| 日韩精品一区二| 在线观看91精品国产入口| 东方aⅴ免费观看久久av| 男女激情视频一区| 亚洲国产日韩一级| 中文字幕色av一区二区三区| 欧美变态口味重另类| 欧美日韩一区二区电影| 99re66热这里只有精品3直播| 精品一区二区三区的国产在线播放 | 国产精品久久99| 精品久久久久久久久久久院品网 | 91女人视频在线观看| 国模少妇一区二区三区| 免费观看日韩电影| 图片区小说区国产精品视频| 亚洲免费观看在线观看| 国产日韩在线不卡| 久久综合九色综合欧美亚洲| 欧美一区二区日韩一区二区| 欧美亚洲尤物久久| 欧美综合久久久| 色综合天天天天做夜夜夜夜做| 国产成人精品免费| 国产伦精品一区二区三区免费迷 | 有码一区二区三区| 中文字幕乱码亚洲精品一区| 久久亚洲一区二区三区四区| 精品精品欲导航| 精品国产伦一区二区三区观看方式 | 99re成人在线| 97精品视频在线观看自产线路二| 成人免费视频网站在线观看| 波多野洁衣一区| 成人精品一区二区三区四区| 成人爱爱电影网址| 91丨porny丨最新| 91丨九色丨黑人外教| 在线观看国产日韩| 欧美精品日日鲁夜夜添| 日韩三区在线观看| 久久色中文字幕| 国产精品国产三级国产普通话99| 国产精品国产精品国产专区不蜜 | 另类小说综合欧美亚洲| 久久精品av麻豆的观看方式| 国模冰冰炮一区二区| 国产成人自拍高清视频在线免费播放| 国产91精品欧美| 99视频精品在线| 欧美色综合影院| 欧美一区二区不卡视频| 国产色爱av资源综合区| 中文字幕佐山爱一区二区免费| 一二三四区精品视频| 天堂成人免费av电影一区| 久草热8精品视频在线观看| 国产aⅴ综合色| 欧美午夜电影在线播放| 精品免费国产一区二区三区四区| 欧美国产成人精品| 亚洲国产一区二区三区青草影视| 日韩精品一卡二卡三卡四卡无卡| 狠狠色丁香久久婷婷综合丁香| 成人午夜视频免费看| 欧美日韩精品免费观看视频| 26uuu成人网一区二区三区| 中文字幕一区三区| 免费观看一级欧美片| 成人91在线观看| 欧美一区二区三区色| 国产精品久久久久久久久免费丝袜 | 亚洲一二三区视频在线观看| 国产做a爰片久久毛片| 日本乱人伦aⅴ精品| 久久久久久久久久久99999| 亚洲夂夂婷婷色拍ww47| 国产精品资源在线| 欧美三级电影在线看| 国产欧美一区二区在线| 日韩一区精品字幕| 91影院在线观看| 久久中文娱乐网| 午夜一区二区三区视频| 99v久久综合狠狠综合久久| 精品国产91亚洲一区二区三区婷婷| 国产精品国产三级国产普通话三级| 青青草国产成人av片免费| 色综合一区二区| 欧美国产视频在线| 极品尤物av久久免费看| 欧美精品乱码久久久久久按摩| 国产精品理论片| 国产精品 欧美精品| 制服丝袜在线91| 一区二区三区91| 91网上在线视频| 日本一区二区视频在线| 精品一区二区免费视频| 日韩一区和二区| 首页欧美精品中文字幕| 欧美午夜精品理论片a级按摩| 中文字幕一区二区5566日韩| 国产伦精品一区二区三区免费迷| 91精品国产色综合久久ai换脸| 亚洲国产成人91porn| 在线观看亚洲成人| 一区二区三区日韩欧美精品| 99国产精品国产精品久久| 国产精品久久久久久久久免费相片| 国产一区二区看久久| 久久久亚洲高清| 国产乱人伦偷精品视频不卡| 精品成人一区二区| 国产在线一区二区| 久久夜色精品国产噜噜av | 久久精工是国产品牌吗| 日韩午夜av电影| 精品一区二区三区免费| 国产偷v国产偷v亚洲高清|