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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? lib_keyx.c

?? 提供了很多種加密算法和CA認(rèn)證及相關(guān)服務(wù)如CMP、OCSP等的開發(fā)
?? C
?? 第 1 頁 / 共 3 頁
字號:
/****************************************************************************
*																			*
*						  cryptlib Key Exchange Routines					*
*						Copyright Peter Gutmann 1993-2001					*
*																			*
****************************************************************************/

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

/****************************************************************************
*																			*
*							Low-level Key Export Functions					*
*																			*
****************************************************************************/

/* Export a conventionally encrypted session key */

static int exportConventionalKey( void *encryptedKey, int *encryptedKeyLength,
								  const CRYPT_CONTEXT iSessionKeyContext,
								  const CRYPT_CONTEXT iExportContext )
	{
	MECHANISM_WRAP_INFO mechanismInfo;
	BYTE buffer[ CRYPT_MAX_KEYSIZE + 16 ];
	int keySize, ivSize, status;

	krnlSendMessage( iSessionKeyContext, RESOURCE_IMESSAGE_GETATTRIBUTE, 
					 &keySize, CRYPT_CTXINFO_KEYSIZE );
	if( cryptStatusError( krnlSendMessage( iExportContext, 
								RESOURCE_IMESSAGE_GETATTRIBUTE, &ivSize, 
								CRYPT_CTXINFO_IVSIZE ) ) )
		ivSize = 0;

	/* If we're just doing a length check, write the data to a null stream
	   and return its length */
	if( encryptedKey == NULL )
		{
		STREAM nullStream;
		int dummyDataSize;

		/* Calculate the eventual encrypted key size */
		setMechanismWrapInfo( &mechanismInfo, NULL, 0,
							  NULL, 0, iSessionKeyContext, iExportContext,
							  CRYPT_UNUSED );
		status = krnlSendMessage( SYSTEM_OBJECT_HANDLE, 
								  RESOURCE_IMESSAGE_DEV_EXPORT, &mechanismInfo, 
								  MECHANISM_CMS );
		dummyDataSize = mechanismInfo.wrappedDataLength;
		clearMechanismInfo( &mechanismInfo );
		if( cryptStatusError( status ) )
			return( status );

		/* Generate an IV to allow the KEK write to succeed - see the comment
		   below about this */
		if( ivSize )
			krnlSendNotifier( iExportContext, RESOURCE_IMESSAGE_CTX_GENIV );

		/* Write the data to a null stream to determine its size.  The 
		   buffer doesn't contain anything useful since it's only used for a 
		   size check */
		sMemOpen( &nullStream, NULL, 0 );
		status = writeKEKInfo( &nullStream, iExportContext, buffer,
							   dummyDataSize );
		*encryptedKeyLength = stell( &nullStream );
		sMemClose( &nullStream );

		return( status );
		}

	/* Load an IV into the exporting context.  This is somewhat nasty in that
	   a side-effect of exporting a key is to load an IV into the exporting
	   context which isn't really part of the function's job description.  
	   The alternative is to require the user to explicitly load an IV before
	   exporting the key, which is equally nasty (they'll never remember).  
	   The lesser of the two evils is to load the IV here and assume that 
	   anyone loading the IV themselves will read the docs which warn about 
	   the side-effects of exporting a key.

	   Note that we always load a new IV when we export a key because the
	   caller may be using the context to exchange multiple keys.  Since each
	   exported key requires its own IV, we perform an unconditional reload.
	   In addition because we don't want another thread coming along and
	   changing the IV while we're in the process of encrypting with it, we
	   lock the exporting key object until the encryption has completed and 
	   the IV is written to the output */
	krnlSendNotifier( iExportContext, RESOURCE_IMESSAGE_LOCK );
	if( ivSize )
		krnlSendNotifier( iExportContext, RESOURCE_IMESSAGE_CTX_GENIV );

	/* Encrypt the session key and write the result to the output stream */
	setMechanismWrapInfo( &mechanismInfo, buffer, CRYPT_MAX_KEYSIZE + 16,
						  NULL, 0, iSessionKeyContext, iExportContext,
						  CRYPT_UNUSED );
	status = krnlSendMessage( SYSTEM_OBJECT_HANDLE, 
							  RESOURCE_IMESSAGE_DEV_EXPORT, &mechanismInfo, 
							  MECHANISM_CMS );
	if( cryptStatusOK( status ) )
		{
		STREAM stream;

		sMemOpen( &stream, encryptedKey, STREAMSIZE_UNKNOWN );
		status = writeKEKInfo( &stream, iExportContext, 
							   mechanismInfo.wrappedData, 
							   mechanismInfo.wrappedDataLength );
		*encryptedKeyLength = stell( &stream );
		sMemDisconnect( &stream );
		}
	clearMechanismInfo( &mechanismInfo );
	zeroise( buffer, CRYPT_MAX_KEYSIZE + 16 );
	krnlSendNotifier( iExportContext, RESOURCE_IMESSAGE_UNLOCK );

	return( status );
	}

/* Export a public-key encrypted session key */

static int exportPublicKey( void *encryptedKey, int *encryptedKeyLength,
							const CRYPT_CONTEXT iSessionKeyContext,
							const CRYPT_CONTEXT iExportContext,
							const void *auxInfo, const int auxInfoLength,
							const RECIPIENT_TYPE recipientType )
	{
	MECHANISM_WRAP_INFO mechanismInfo;
	BYTE buffer[ CRYPT_MAX_PKCSIZE ];
	int keySize, status;

	krnlSendMessage( iSessionKeyContext, RESOURCE_IMESSAGE_GETATTRIBUTE, 
					 &keySize, CRYPT_CTXINFO_KEYSIZE );

	/* If we're just doing a length check, write the data to a null stream
	   and return its length */
	if( encryptedKey == NULL )
		{
		STREAM nullStream;
		int dummyDataSize;

		/* Calculate the eventual encrypted key size */
		setMechanismWrapInfo( &mechanismInfo, NULL, 0, NULL, 0, 
							  iSessionKeyContext, iExportContext,
							  CRYPT_UNUSED );
		status = krnlSendMessage( iExportContext, RESOURCE_IMESSAGE_DEV_EXPORT, 
								  &mechanismInfo, MECHANISM_PKCS1 );
		dummyDataSize = mechanismInfo.wrappedDataLength;
		clearMechanismInfo( &mechanismInfo );
		if( cryptStatusError( status ) )
			return( status );

		/* Write the data to a null stream to determine its size.  The 
		   buffer doesn't contain anything useful since it's only used for a 
		   size check */
		sMemOpen( &nullStream, NULL, 0 );
		status = writeKeyTransInfo( &nullStream, iExportContext, buffer,
						dummyDataSize, auxInfo, auxInfoLength, recipientType );
		if( cryptStatusOK( status ) )
			*encryptedKeyLength = stell( &nullStream );
		sMemClose( &nullStream );

		return( status );
		}

	/* Encrypt the session key and write the result to the output stream */
	setMechanismWrapInfo( &mechanismInfo, buffer, CRYPT_MAX_PKCSIZE, NULL, 0, 
						  iSessionKeyContext, iExportContext, CRYPT_UNUSED );
	status = krnlSendMessage( iExportContext, RESOURCE_IMESSAGE_DEV_EXPORT, 
							  &mechanismInfo, MECHANISM_PKCS1 );
	if( cryptStatusOK( status ) )
		{
		STREAM stream;

		sMemOpen( &stream, encryptedKey, STREAMSIZE_UNKNOWN );
		status = writeKeyTransInfo( &stream, iExportContext, 
									mechanismInfo.wrappedData, 
									mechanismInfo.wrappedDataLength, 
									auxInfo, auxInfoLength, recipientType );
		if( cryptStatusOK( status ) )
			*encryptedKeyLength = stell( &stream );
		sMemDisconnect( &stream );
		}
	clearMechanismInfo( &mechanismInfo );

	/* Clean up */
	return( status );
	}

/* Export a key agreement key */

static int exportKeyAgreeKey( void *encryptedKey, int *encryptedKeyLength,
							  const CRYPT_CONTEXT iSessionKeyContext,
							  const CRYPT_CONTEXT iExportContext,
							  const CRYPT_CONTEXT iAuxContext,
							  const void *auxInfo, const int auxInfoLength )
	{
	CRYPT_ALGO keyAgreeAlgo;
	MECHANISM_WRAP_INFO mechanismInfo;
	BYTE buffer[ CRYPT_MAX_PKCSIZE ];
	int wrappedKeyLen, ukmLen, status;

	/* Extract general information */
	status = krnlSendMessage( iExportContext, RESOURCE_IMESSAGE_GETATTRIBUTE,
							  &keyAgreeAlgo, CRYPT_CTXINFO_ALGO );
	if( cryptStatusOK( status ) && keyAgreeAlgo == CRYPT_ALGO_DH )
		status = CRYPT_ERROR_PARAM4;
	if( cryptStatusError( status ) )
		return( status );

	/* If we're just doing a length check, write the data to a null stream
	   and return its length */
	if( encryptedKey == NULL )
		{
		STREAM nullStream;

		/* Calculate the eventual encrypted key size */
		setMechanismWrapInfo( &mechanismInfo, NULL, 0,
							  NULL, 0, iSessionKeyContext, iExportContext,
							  iAuxContext );
		status = krnlSendMessage( iExportContext, RESOURCE_IMESSAGE_DEV_EXPORT, 
								  &mechanismInfo, MECHANISM_KEA );
		wrappedKeyLen = mechanismInfo.wrappedDataLength >> 8;
		ukmLen = mechanismInfo.wrappedDataLength & 0xFF;
		clearMechanismInfo( &mechanismInfo );
		if( cryptStatusError( status ) )
			return( status );

		/* Write the data to a null stream to determine its size.  The 
		   buffer doesn't contain anything useful since it's only used for a 
		   size check */
		sMemOpen( &nullStream, NULL, 0 );
		status = writeKeyAgreeInfo( &nullStream, iExportContext, 
									buffer, wrappedKeyLen, buffer, 
									ukmLen, auxInfo, auxInfoLength );
		if( cryptStatusOK( status ) )
			*encryptedKeyLength = stell( &nullStream );
		sMemClose( &nullStream );

		return( status );
		}

	/* Export the session key and write the result to the output stream */
	setMechanismWrapInfo( &mechanismInfo, buffer, CRYPT_MAX_PKCSIZE,
						  NULL, 0, iSessionKeyContext, iExportContext,
						  iAuxContext );
	status = krnlSendMessage( iExportContext, RESOURCE_IMESSAGE_DEV_EXPORT, 
							  &mechanismInfo, MECHANISM_KEA );
	if( cryptStatusOK( status ) )
		{
		STREAM stream;

		/* Extract the length information */
		wrappedKeyLen = mechanismInfo.wrappedDataLength >> 8;
		ukmLen = mechanismInfo.wrappedDataLength & 0xFF;

		sMemOpen( &stream, encryptedKey, STREAMSIZE_UNKNOWN );
		status = writeKeyAgreeInfo( &stream, iExportContext, buffer, 
									wrappedKeyLen, buffer, ukmLen, auxInfo, 
									auxInfoLength );
		if( cryptStatusOK( status ) )
			*encryptedKeyLength = stell( &stream );
		sMemDisconnect( &stream );
		}
	clearMechanismInfo( &mechanismInfo );

	/* Clean up */
	zeroise( buffer, CRYPT_MAX_PKCSIZE );
	return( status );
	}

/****************************************************************************
*																			*
*							Low-level Key Import Functions					*
*																			*
****************************************************************************/

/* Import a conventionally encrypted session key */

static int importConventionalKey( const void *encryptedKey,
								  const int encryptedKeyLength,
								  const CRYPT_CONTEXT iSessionKeyContext,
								  const CRYPT_CONTEXT iImportContext )
	{
	CRYPT_ALGO cryptAlgo;
	CRYPT_MODE cryptMode;
	MECHANISM_WRAP_INFO mechanismInfo;
	QUERY_INFO queryInfo;
	RESOURCE_DATA msgData;
	STREAM stream;
	int status;

	/* Get information on the importing key */
	krnlSendMessage( iImportContext, RESOURCE_IMESSAGE_GETATTRIBUTE, 
					 &cryptAlgo, CRYPT_CTXINFO_ALGO );
	status = krnlSendMessage( iImportContext, RESOURCE_IMESSAGE_GETATTRIBUTE, 
							  &cryptMode, CRYPT_CTXINFO_MODE );
	if( cryptStatusError( status ) )
		return( status );

	/* Read the encrypted key record up to the start of the encrypted key and
	   make sure we'll be using the correct type of encryption context to
	   decrypt it */
	sMemConnect( &stream, encryptedKey, encryptedKeyLength );
	status = readKEKInfo( &stream, &queryInfo );
	sMemDisconnect( &stream );
	if( cryptStatusError( status ) )
		return( status );
	if( cryptAlgo != queryInfo.cryptAlgo || cryptMode != queryInfo.cryptMode )
		return( CRYPT_ARGERROR_NUM1 );

	/* Extract the encrypted key from the buffer and decrypt it.  Since we 
	   don't want another thread changing the IV while we're using the import

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人精品电影在线观看| 91精品国产品国语在线不卡| 精品久久久久久亚洲综合网| 视频在线观看一区二区三区| 在线观看国产一区二区| 一区二区三区国产豹纹内裤在线 | aa级大片欧美| 亚洲三级在线看| 91日韩一区二区三区| 国产精品色哟哟| 99精品偷自拍| 亚洲精品五月天| 欧美性xxxxxxxx| 丝袜亚洲精品中文字幕一区| 成人福利视频网站| 欧美xxxxx裸体时装秀| 免费在线观看一区二区三区| 欧美α欧美αv大片| 国产一区二区调教| 日本一区二区三区国色天香 | 91精品国产一区二区三区香蕉| 亚洲欧洲国产日韩| 国产成人精品综合在线观看| 日本一区二区三区在线观看| 91网址在线看| 天天做天天摸天天爽国产一区 | 日韩一区二区高清| 激情综合色播激情啊| 中文字幕第一区| 色婷婷久久综合| 亚洲高清视频中文字幕| 欧美r级在线观看| 成人h动漫精品一区二区| 国产精品欧美极品| 色88888久久久久久影院按摩| 亚洲成av人片在线观看| 精品三级在线看| 99精品视频一区| 欧美日韩国产123区| 国产一二精品视频| 亚洲图片欧美色图| 中文字幕一区二区三区乱码在线| 日韩免费电影一区| 日本精品视频一区二区| 国产传媒久久文化传媒| 日韩福利电影在线| 亚洲激情男女视频| 国产精品美女久久久久久久久| 91精品国模一区二区三区| 色激情天天射综合网| 盗摄精品av一区二区三区| 久久精品国产精品亚洲红杏| 亚洲va韩国va欧美va精品| 成人欧美一区二区三区视频网页| 精品欧美乱码久久久久久1区2区| 欧美日韩美少妇| 色久综合一二码| 99re亚洲国产精品| av成人免费在线观看| 韩国精品久久久| 久久99国产精品免费| 蜜臀精品久久久久久蜜臀| 香蕉乱码成人久久天堂爱免费| ...中文天堂在线一区| 国产欧美日韩三级| 国产亚洲午夜高清国产拍精品| 欧美刺激午夜性久久久久久久| 欧美一区二区视频在线观看2022| 欧美日韩一区二区三区不卡 | 午夜视频久久久久久| 一区二区三区在线观看视频| 亚洲日本在线天堂| 18成人在线观看| 亚洲婷婷综合色高清在线| 自拍偷拍亚洲激情| 亚洲色图制服丝袜| 亚洲男人的天堂av| 一区二区三区中文字幕精品精品| 中文字幕一区二区不卡| 亚洲欧美日本在线| 一卡二卡三卡日韩欧美| 亚洲国产成人高清精品| 日韩电影免费在线| 黄色资源网久久资源365| 国产在线看一区| 成人久久18免费网站麻豆| 成人黄动漫网站免费app| 99久久综合99久久综合网站| 日本韩国一区二区三区| 欧美日韩激情在线| 欧美videos中文字幕| 国产日韩欧美高清在线| 亚洲三级在线免费观看| 亚洲国产乱码最新视频 | 亚洲视频电影在线| 亚洲第一在线综合网站| 秋霞电影网一区二区| 精品一区二区精品| 成人av网址在线观看| 欧美曰成人黄网| 欧美mv日韩mv国产网站app| 中文在线一区二区| 一区二区三区在线免费播放| 热久久免费视频| 国产1区2区3区精品美女| 色中色一区二区| 日韩精品一区国产麻豆| 欧美激情一二三区| 午夜天堂影视香蕉久久| 国产东北露脸精品视频| 在线免费观看成人短视频| 欧美成人一区二区三区在线观看 | 国产成人av福利| 欧美色精品天天在线观看视频| 日韩一级高清毛片| 国产精品乱人伦| 日韩福利电影在线| 99久久久精品| 精品国产乱码久久久久久久| 亚洲欧美一区二区三区久本道91| 日韩电影在线看| 9人人澡人人爽人人精品| 日韩欧美在线1卡| 亚洲蜜臀av乱码久久精品| 精品午夜一区二区三区在线观看| 91色porny在线视频| 久久综合九色综合97_久久久| 亚洲精品videosex极品| 国产乱码精品1区2区3区| 欧美精三区欧美精三区| 国产精品视频第一区| 久久精品国产77777蜜臀| 色999日韩国产欧美一区二区| 久久免费精品国产久精品久久久久 | 亚洲高清视频中文字幕| 丰满岳乱妇一区二区三区| 日韩欧美一卡二卡| 午夜视频在线观看一区二区 | 欧美一区二区私人影院日本| 亚洲免费观看在线视频| 国产成人免费9x9x人网站视频| 欧美一区二区不卡视频| 亚洲综合丁香婷婷六月香| 豆国产96在线|亚洲| 精品播放一区二区| 免费人成网站在线观看欧美高清| 在线一区二区视频| 亚洲精品亚洲人成人网 | 欧美性猛片aaaaaaa做受| 国产精品三级视频| 国产剧情一区二区| 久久久亚洲高清| 激情六月婷婷久久| 欧美tk丨vk视频| 精品一区二区三区在线视频| 日韩欧美一级精品久久| 美女www一区二区| 日韩精品一区二区三区四区| 日韩精彩视频在线观看| 91精品蜜臀在线一区尤物| 亚洲主播在线观看| 欧美色涩在线第一页| 亚洲国产精品视频| 欧美精品成人一区二区三区四区| 亚洲成人免费视| 欧美日韩国产123区| 日日夜夜精品视频免费| 91精品国产综合久久精品麻豆| 香蕉久久夜色精品国产使用方法| 欧美三级电影精品| 五月综合激情网| 538在线一区二区精品国产| 日本美女一区二区| 精品国产电影一区二区| 国产成人一级电影| 一区在线观看视频| 在线免费观看日本欧美| 日韩精品成人一区二区三区| 欧美成人aa大片| 国产白丝网站精品污在线入口| 国产精品视频线看| 欧洲亚洲国产日韩| 麻豆国产精品视频| 国产日韩欧美综合一区| 91麻豆视频网站| 国产成人夜色高潮福利影视| 中文字幕一区免费在线观看| 欧美四级电影在线观看| 麻豆国产欧美日韩综合精品二区| 久久久不卡网国产精品二区| 成人久久视频在线观看| 亚洲主播在线播放| 日韩三级高清在线| 99久久婷婷国产综合精品电影| 一区二区三区日韩精品视频| 日韩一区二区麻豆国产| 成人免费不卡视频| 亚洲成人av免费| 国产日韩高清在线| 欧美日韩国产高清一区二区|