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

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

?? user.c

?? cryptlib安全工具包
?? C
?? 第 1 頁 / 共 4 頁
字號:
/****************************************************************************
*																			*
*							cryptlib User Routines							*
*						Copyright Peter Gutmann 1999-2007					*
*																			*
****************************************************************************/

#include <stdio.h>		/* For snprintf_s() */
#include "crypt.h"
#ifdef INC_ALL
  #include "trustmgr.h"
  #include "asn1.h"
  #include "asn1_ext.h"
  #include "user.h"
#else
  #include "cert/trustmgr.h"
  #include "misc/asn1.h"
  #include "misc/asn1_ext.h"
  #include "misc/user.h"
#endif /* Compiler-specific includes */

/* The different types of userID that we can use to look up users in the 
   index */

typedef enum {
	USERID_NONE,		/* No userID type */
	USERID_USERID,		/* User's userID */
	USERID_CREATORID,	/* Creating SO's userID */
	USERID_NAME,		/* User's name */
	USERID_LAST			/* Last possible userID type */
	} USERID_TYPE;

/* cryptlib can work with multiple users (although it's extremely unlikely 
   that there'll ever be more than one or two), we allow a maximum of 
   MAX_USER_OBJECTS in order to discourage them from being used as a
   substitute for OS user management.  A setting of 32 objects consumes 
   ~4K of memory (32 x ~128), so we choose that as the limit */

#ifdef CONFIG_CONSERVE_MEMORY
  #define MAX_USER_OBJECTS		4
#else
  #define MAX_USER_OBJECTS		32
#endif /* CONFIG_CONSERVE_MEMORY */

/* The size of the default buffer used to read data from a keyset.  If
   the data is larger than this, the buffer is allocated dynamically */

#define USERDATA_BUFFERSIZE		1024

/* The maximum size of the encoded index data */

#define MAX_USERINDEX_SIZE	( ( 16 + ( KEYID_SIZE * 2 ) + \
							  CRYPT_MAX_TEXTSIZE + 8 ) * MAX_USER_OBJECTS )

/* Primary SO user info */

static const USER_FILE_INFO FAR_BSS primarySOInfo = {
	CRYPT_USER_SO,					/* SO user */
	USER_STATE_SOINITED,			/* SO initialised, not ready for use */
	"Security officer", 16,			/* Pre-set user name */
	"<<<PRIMARYSO_USER>>>", "<<<TETRAGRAMMATON>>>",
	-1			/* No user file when starting from zeroised state */
	};

/* The primary SO password after zeroisation */

#define PRIMARYSO_PASSWORD		"zeroised"
#define PRIMARYSO_ALTPASSWORD	"zeroized"
#define PRIMARYSO_PASSWORD_LENGTH 8

/* The structure that stores the user index in the default user object */

typedef struct {
	USER_FILE_INFO userIndex[ MAX_USER_OBJECTS ];	/* User index */
	int lastEntry;					/* Last entry in user index */
	} USER_INDEX_INFO;

/****************************************************************************
*																			*
*								Utility Functions							*
*																			*
****************************************************************************/

/* Open a user or index keyset */

CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 2 ) ) \
static int openKeyset( OUT_HANDLE_OPT CRYPT_KEYSET *iKeyset, 
					   IN_BUFFER( fileNameLen ) const char *fileName, 
					   IN_LENGTH_SHORT const int fileNameLen, 
					   IN_ENUM_OPT( CRYPT_KEYOPT ) const int options )
	{
	MESSAGE_CREATEOBJECT_INFO createInfo;
	char userFilePath[ MAX_PATH_LENGTH + 8 ];
	int userFilePathLen, status;

	assert( isWritePtr( iKeyset, sizeof( CRYPT_KEYSET ) ) );
	assert( isReadPtr( fileName, fileNameLen ) );

	REQUIRES( fileNameLen > 0 && fileNameLen < MAX_INTLENGTH_SHORT );
	REQUIRES( options >= CRYPT_KEYOPT_NONE && options < CRYPT_KEYOPT_LAST );

	/* Clear return value */
	*iKeyset = CRYPT_ERROR;

	/* Open the given keyset */
	status = fileBuildCryptlibPath( userFilePath, MAX_PATH_LENGTH, 
									&userFilePathLen, fileName, fileNameLen, 
									( options == CRYPT_KEYOPT_READONLY ) ? \
									BUILDPATH_GETPATH : BUILDPATH_CREATEPATH );
	if( cryptStatusError( status ) )
		{
		/* Map the lower-level filesystem-specific error into a more 
		   meaningful generic error */
		return( CRYPT_ERROR_OPEN );
		}
	setMessageCreateObjectInfo( &createInfo, CRYPT_KEYSET_FILE );
	createInfo.arg2 = options;
	createInfo.strArg1 = userFilePath;
	createInfo.strArgLen1 = userFilePathLen;
	status = krnlSendMessage( SYSTEM_OBJECT_HANDLE,
							  IMESSAGE_DEV_CREATEOBJECT, &createInfo,
							  OBJECT_TYPE_KEYSET );
	if( cryptStatusOK( status ) )
		*iKeyset = createInfo.cryptHandle;
	return( status );
	}

CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
static int openUserKeyset( OUT_HANDLE_OPT CRYPT_KEYSET *iUserKeyset, 
						   IN_INT_SHORT_Z const int fileRef, 
						   IN_ENUM_OPT( CRYPT_KEYOPT ) const int options )
	{
	char userFileName[ 16 + 8 ];
	int userFileNameLen;

	assert( isWritePtr( iUserKeyset, sizeof( CRYPT_KEYSET ) ) );

	REQUIRES( fileRef >= 0 && fileRef < MAX_INTLENGTH_SHORT );
	REQUIRES( options >= CRYPT_KEYOPT_NONE && options < CRYPT_KEYOPT_LAST );

	userFileNameLen = sprintf_s( userFileName, 16, "u%06x", fileRef );
	return( openKeyset( iUserKeyset, userFileName, userFileNameLen, 
						options ) );
	}

CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
static int openIndexKeyset( OUT CRYPT_KEYSET *iIndexKeyset, 
							IN_ENUM_OPT( CRYPT_KEYOPT ) const int options )
	{
	assert( isWritePtr( iIndexKeyset, sizeof( CRYPT_KEYSET ) ) );

	REQUIRES( options >= CRYPT_KEYOPT_NONE && options < CRYPT_KEYOPT_LAST );

	return( openKeyset( iIndexKeyset, "index", 5, options ) );
	}

/* Add a user key to the keyset */

CHECK_RETVAL STDC_NONNULL_ARG( ( 3, 5 ) ) \
static int addKey( IN_HANDLE const CRYPT_KEYSET iUserKeyset, 
				   IN_HANDLE const CRYPT_CONTEXT iCryptContext,
				   IN_BUFFER( userIdLength ) const void *userID, 
				   IN_LENGTH_SHORT const int userIdLength,
				   IN_BUFFER( passwordLength ) const char *password, 
				   IN_LENGTH_SHORT const int passwordLength,
				   const BOOLEAN isPrivateKey )
	{
	MESSAGE_KEYMGMT_INFO setkeyInfo;
	MESSAGE_DATA msgData;
	int status;

	assert( isReadPtr( userID, userIdLength ) );
	assert( isReadPtr( password, passwordLength ) );

	REQUIRES( isHandleRangeValid( iUserKeyset ) );
	REQUIRES( isHandleRangeValid( iCryptContext ) );
	REQUIRES( userIdLength > 0 && userIdLength < MAX_INTLENGTH_SHORT );
	REQUIRES( passwordLength > 0 && passwordLength < MAX_INTLENGTH_SHORT );

	setMessageData( &msgData, ( void * ) userID, userIdLength );
	status = krnlSendMessage( iUserKeyset, IMESSAGE_SETATTRIBUTE_S,
							  &msgData, CRYPT_IATTRIBUTE_USERID );
	if( cryptStatusError( status ) )
		return( status );

	setMessageKeymgmtInfo( &setkeyInfo, CRYPT_KEYID_NONE, NULL, 0,
						   ( void * ) password, passwordLength,
						   KEYMGMT_FLAG_NONE );
	setkeyInfo.cryptHandle = iCryptContext;
	status = krnlSendMessage( iUserKeyset, IMESSAGE_KEY_SETKEY,
							  &setkeyInfo, isPrivateKey ? \
								KEYMGMT_ITEM_PRIVATEKEY : \
								KEYMGMT_ITEM_SECRETKEY );
	return( status );
	}

/****************************************************************************
*																			*
*								Manage User Index							*
*																			*
****************************************************************************/

/* Find a user in the user index.  Note that this search implements a flat
   namespace rather than allowing duplicate names created by different SOs
   because when we're looking up a user we don't know which SO they belong
   to until after we've looked them up */

CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 4 ) ) \
static const USER_FILE_INFO *findUser( IN_ARRAY( noUserIndexEntries ) \
										const USER_FILE_INFO *userIndex,
									   IN_RANGE( 1, MAX_USER_OBJECTS ) \
										const int noUserIndexEntries, 
									   IN_ENUM( USERID ) const USERID_TYPE idType, 
									   IN_BUFFER( idLength ) const BYTE *id, 
									   IN_LENGTH_SHORT const int idLength )
	{
	int i, iterationCount;

	assert( isReadPtr( userIndex, \
					   sizeof( USER_FILE_INFO ) * noUserIndexEntries ) );
	assert( isReadPtr( id, idLength ) );

	REQUIRES_N( noUserIndexEntries > 0 && \
				noUserIndexEntries <= MAX_USER_OBJECTS );
	REQUIRES_N( idType > USERID_NONE && idType < USERID_LAST );
	REQUIRES_N( idLength > 0 && idLength < MAX_INTLENGTH_SHORT );

	for( i = 0, iterationCount = 0; 
		 i < noUserIndexEntries && \
			iterationCount < FAILSAFE_ITERATIONS_LARGE; 
		 i++, iterationCount++ )
		{
		const USER_FILE_INFO *userIndexPtr = &userIndex[ i ];

		switch( idType )
			{
			case USERID_USERID:
				if( idLength == KEYID_SIZE && \
					!memcmp( userIndexPtr->userID, id, idLength ) )
					return( userIndexPtr );
				break;

			case USERID_CREATORID:
				if( idLength == KEYID_SIZE && \
					!memcmp( userIndexPtr->creatorID, id, idLength ) )
					return( userIndexPtr );
				break;

			case USERID_NAME:
				if( idLength == userIndexPtr->userNameLength && \
					!memcmp( userIndexPtr->userName, id, idLength ) )
					return( userIndexPtr );
				break;

			default:
				retIntError_Null();
			}
		}
	ENSURES_N( iterationCount < FAILSAFE_ITERATIONS_LARGE );

	return( NULL );
	}

/* Find a free user entry */

CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 3 ) ) \
static USER_FILE_INFO *findFreeEntry( IN_ARRAY( noUserIndexEntries ) \
										USER_FILE_INFO *userIndex,
									  IN_RANGE( 1, MAX_USER_OBJECTS ) \
										const int noUserIndexEntries,
									  OUT_INT_SHORT_Z int *fileRef )
	{
	USER_FILE_INFO *userIndexPtr;
	int newFileRef, i, iterationCount;

	assert( isWritePtr( userIndex, \
						sizeof( USER_FILE_INFO ) * noUserIndexEntries ) );
	assert( isWritePtr( fileRef, sizeof( int ) ) );

	REQUIRES_N( noUserIndexEntries > 0 && \
				noUserIndexEntries <= MAX_USER_OBJECTS );

	/* Look for an available free entry */
	for( i = 0, iterationCount  = 0; 
		 i < noUserIndexEntries && \
			iterationCount < FAILSAFE_ITERATIONS_LARGE; 
		 i++, iterationCount++ )
		{
		if( userIndex[ i ].state == USER_STATE_NONE )
			break;
		}
	ENSURES_N( iterationCount < FAILSAFE_ITERATIONS_LARGE );
	if( i >= noUserIndexEntries )
		{
		/* No more available entries */
		*fileRef = CRYPT_ERROR;
		return( NULL );
		}

	/* Remember where we found our match */
	userIndexPtr = &userIndex[ i ];

	/* We've found a free entry, now look for an unused fileRef.  There are 
	   two possible strategies for this, the first is to make it generational
	   and always allocate a new fileRef, the second is to use the smallest
	   available value, i.e. to re-use values.  The former has problems with
	   overflow (although it'd have to be a pretty funny situation to cause 
	   this), the latter has potential problems with user confusion when one
	   ref #3 user file is replaced by another ref #3 file that belongs to
	   a completely different user.  However, even the generational approach
	   has problems (unless we can make the last-used fileRef persistent)
	   because deleting the highest-numbered ref. and then creating a new one
	   will result in the fileRef being re-allocated to the newly-created
	   file.

	   Since this is all highly speculative (it's not certain under what 
	   conditions we could run into these problems because users aren't 
	   expected to be bypassing cryptlib to directly access the user files),
	   we take the simplest approach and use the lowest-value free fileRef.
	   This is somewhat ugly because it's potentially an O( n^2 ) operation,
	   but the actualy impact is insignificant because the number of users
	   is tiny and new user creation is extremely rare, so it's not worth
	   switching to the complexity of a more sophisticated algorithm */
	for( newFileRef = 0; newFileRef < MAX_USER_OBJECTS; newFileRef++ )
		{
		/* Check whether this fileRef is already in use.  If not, we're
		   done */
		for( i = 0; i < noUserIndexEntries; i++ )
			{
			if( userIndex[ i ].fileRef == newFileRef )

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久精品国产免大香伊| 亚洲综合免费观看高清完整版| 亚洲成av人**亚洲成av**| 91蜜桃网址入口| 亚洲三级电影网站| 欧美性欧美巨大黑白大战| 亚洲国产精品久久艾草纯爱| 欧美日韩精品一区二区三区蜜桃 | 欧美亚洲动漫精品| 亚洲成精国产精品女| 欧美另类一区二区三区| 人人爽香蕉精品| 国产亚洲精品超碰| 成人免费精品视频| 一区二区三区精品| 日韩午夜在线播放| 成人av在线资源网| 亚洲国产精品一区二区久久| 欧美一区二区啪啪| 国产精一品亚洲二区在线视频| 国产精品久久久久毛片软件| 欧美午夜精品理论片a级按摩| 免费在线观看一区| 欧美激情一区在线| 欧美色图免费看| 国内精品国产三级国产a久久| 一区精品在线播放| 日韩一区二区三区四区| 国产精品99久久久久久有的能看| 亚洲欧洲国产日韩| 欧美大片免费久久精品三p| 成人免费福利片| 日韩国产欧美视频| 国产精品久久久久影院| 欧美一区二区视频观看视频| 成人黄色在线视频| 奇米影视一区二区三区小说| 国产精品理伦片| 日韩欧美黄色影院| 色美美综合视频| 国产一区在线精品| 午夜欧美视频在线观看 | 亚洲欧美偷拍卡通变态| 日韩视频在线你懂得| va亚洲va日韩不卡在线观看| 免费成人小视频| 亚洲国产精品久久久久秋霞影院| 久久久99久久| 日韩欧美123| 在线观看免费亚洲| 97久久精品人人做人人爽50路| 免费三级欧美电影| 亚洲成人中文在线| 亚洲精品国产a| 日本一区二区免费在线| 欧美一级国产精品| 欧美午夜片在线观看| 粉嫩嫩av羞羞动漫久久久| 奇米精品一区二区三区在线观看| 一区视频在线播放| 国产亚洲一区二区在线观看| 欧美欧美午夜aⅴ在线观看| 99久久免费国产| 粉嫩av一区二区三区| 久久99精品久久久久久国产越南 | 五月激情综合网| 亚洲精选视频在线| 中文字幕在线观看不卡| 久久久激情视频| 久久嫩草精品久久久久| 日韩欧美的一区二区| 欧美日韩精品欧美日韩精品| 欧美在线综合视频| 欧美丝袜自拍制服另类| 色综合久久久久综合99| 99国产精品久久久久久久久久| 高清不卡一区二区| 国产乱码字幕精品高清av| 国产一区二区三区视频在线播放| 日韩国产一区二| 日本视频一区二区三区| 美女在线一区二区| 久久精品国产亚洲一区二区三区| 蜜臀av性久久久久av蜜臀妖精| 亚洲成av人片在www色猫咪| 午夜精品久久久久久久| 日韩国产欧美一区二区三区| 日韩电影网1区2区| av激情综合网| 热久久免费视频| 国产在线播放一区二区三区| 国产中文字幕精品| 丝袜诱惑亚洲看片| 欧美不卡一区二区| 91精品久久久久久蜜臀| 97久久人人超碰| 99re6这里只有精品视频在线观看| 亚洲视频一二三| 国产精品欧美一区二区三区| 高清不卡在线观看| 99久久国产综合精品女不卡| 在线观看国产日韩| 精品久久久久久综合日本欧美| 久久婷婷色综合| 国产精品网站在线观看| 欧美国产精品一区| 国产欧美一区二区精品仙草咪| 国产欧美日韩精品一区| 国产午夜精品理论片a级大结局| 欧美久久高跟鞋激| 日韩欧美在线网站| 国产精品久久久久久亚洲伦 | 一区二区三区中文在线观看| 亚洲素人一区二区| 久久中文娱乐网| 亚洲精品在线免费观看视频| 制服丝袜一区二区三区| 欧美电影免费观看高清完整版| 精品久久久久久最新网址| 日韩欧美一区中文| 欧美一级日韩不卡播放免费| 日韩三级.com| 蜜臀av性久久久久蜜臀aⅴ| 激情五月婷婷综合网| 精品系列免费在线观看| 欧亚一区二区三区| 日韩久久久精品| 国产精品美女久久久久久久| 偷窥国产亚洲免费视频| 欧美日韩一级黄| 精品久久久三级丝袜| 国产精品九色蝌蚪自拍| 日韩欧美你懂的| 国产精品一区二区免费不卡 | 国产乱一区二区| 色欧美88888久久久久久影院| 日韩一区二区三区在线观看 | 在线观看日韩精品| 久久久欧美精品sm网站| 日韩成人一区二区| 色综合久久中文综合久久牛| 久久蜜桃一区二区| 日韩精品电影在线| 欧美在线免费观看视频| 国产精品视频看| 成人av免费在线| www国产精品av| 日韩福利电影在线| 在线一区二区三区四区五区| 国产精品福利影院| 国产精品一区二区在线播放| 日韩亚洲电影在线| 天堂资源在线中文精品| 在线看不卡av| 亚洲欧美激情在线| 成人av网站在线| 中文字幕av资源一区| 国产精品一级在线| 久久无码av三级| 韩国av一区二区| www激情久久| 国产美女精品人人做人人爽| 日韩一区二区在线观看视频| 日韩成人一区二区| 欧美va亚洲va| 久久99国产乱子伦精品免费| 日韩情涩欧美日韩视频| 蜜桃视频一区二区| 日韩一级免费一区| 免费观看日韩电影| 精品国产一区二区三区四区四 | 久久99国产精品免费网站| 欧美日韩国产在线观看| 日韩电影在线免费| 欧美一区二区三区日韩| 免费av网站大全久久| 日韩免费在线观看| 国精产品一区一区三区mba视频| 欧美大片免费久久精品三p| 国内成+人亚洲+欧美+综合在线| 精品999在线播放| 成人av电影免费在线播放| 综合久久国产九一剧情麻豆| 色94色欧美sute亚洲线路一久| 亚洲小说春色综合另类电影| 欧美人与禽zozo性伦| 黑人精品欧美一区二区蜜桃| 久久精品一区二区三区不卡牛牛| 国产精品69毛片高清亚洲| 中文字幕综合网| 欧美日韩国产美| 国内偷窥港台综合视频在线播放| 久久亚洲影视婷婷| 99精品1区2区| 日韩精品视频网| 久久婷婷国产综合精品青草| 99久久婷婷国产综合精品电影| 亚洲第四色夜色| 久久精品夜色噜噜亚洲aⅴ| 色8久久精品久久久久久蜜|