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

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

?? cryptusr.c

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

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

/* States for the user object */

typedef enum {
	USER_STATE_NONE,				/* No initialisation state */
	USER_STATE_SOINITED,			/* SSO inited, not usable */
	USER_STATE_USERINITED,			/* User inited, usable */
	USER_STATE_LOCKED,				/* Disabled, not usable */
	USER_STATE_LAST					/* Last possible state */
	} USER_STATE_TYPE;

/* The structure which stores the information on a user */

typedef struct UI {
	/* Control and status information */
	CRYPT_USER_TYPE type;			/* User type */
	USER_STATE_TYPE state;			/* User object state */
	BYTE userName[ CRYPT_MAX_TEXTSIZE + 1 ];
	int userNameLength;				/* User name */
	BYTE userID[ KEYID_SIZE ], creatorID[ KEYID_SIZE ];
									/* ID of user and creator of this user */
	int fileRef;					/* User info keyset reference */

	/* Configuration options for this user.  These aren't handled directly by
	   the user object code but are managed externally through the config 
	   code, so they're just treated as a dynamically-allocated blob within
	   the user object */
	void *configOptions;

	/* The user object contains an associated keyset which is used to store
	   user information to disk, in addition for SOs and CAs it also contains
	   an associated encryption context, either a private key (for an SO) or
	   a conventional key (for a CA) */
	CRYPT_KEYSET iKeyset;			/* Keyset */
	CRYPT_CONTEXT iCryptContext;	/* Private/secret key */

	/* Error information */
	CRYPT_ATTRIBUTE_TYPE errorLocus;/* Error locus */
	CRYPT_ERRTYPE_TYPE errorType;	/* Error type */

	/* When we clone an object, there are certain per-instance fields which
	   don't get cloned.  These fields are located after the following
	   member, and must be initialised by the cloning function */
	int _sharedEnd;					/* Dummy used for end of shared fields */

	/* The object's handle, used when sending messages to the object when
	   only the xxx_INFO is available */
	CRYPT_HANDLE objectHandle;

	/* In multithreaded environments we need to protect the information from
	   access by other threads while we use it.  The following macro declares
	   the actual variables required to handle the resource locking (the
	   actual values are defined in cryptos.h) */
	DECLARE_OBJECT_LOCKING_VARS
	} USER_INFO;

/* User information as read from the user info file */

typedef struct {
	CRYPT_USER_TYPE type;			/* User type */
	USER_STATE_TYPE state;			/* User state */
	BYTE userName[ CRYPT_MAX_TEXTSIZE + 1 ];
	int userNameLength;				/* User name */
	BYTE userID[ KEYID_SIZE ];		/* User ID */
	BYTE creatorID[ KEYID_SIZE ];	/* Creator ID */
	int fileRef;					/* User info file reference */
	} USER_FILE_INFO;

/* Default and primary SO user info */

static const USER_FILE_INFO defaultUserInfo = {
	CRYPT_USER_NONE,				/* Special-case SO+normal user */
	USER_STATE_USERINITED,			/* Initialised, ready for use */
	"Default cryptlib user", 21,	/* Pre-set user name */
	"<<<<DEFAULT_USER>>>>", "<<<<DEFAULT_USER>>>>", 
	CRYPT_UNUSED					/* No corresponding user file */
	};
static const USER_FILE_INFO 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

/* Prototypes for functions in cryptcfg.c */

int initOptions( void **configOptionsPtr );
void endOptions( void *configOptions );
int setOption( void *configOptions, const CRYPT_ATTRIBUTE_TYPE option, 
			   const int value );
int setOptionString( void *configOptions, const CRYPT_ATTRIBUTE_TYPE option, 
					 const char *value, const int valueLength );
int getOption( void *configOptions, const CRYPT_ATTRIBUTE_TYPE option );
char *getOptionString( void *configOptions, 
					   const CRYPT_ATTRIBUTE_TYPE option );
int readConfig( const CRYPT_USER cryptUser, const char *fileName );
int encodeConfigData( void *configOptions, const char *fileName, 
					  void **data, int *length );
int commitConfigData( const char *fileName, const void *data, 
					  const int length );

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

/* The maximum size of the index data for a user, ~128 bytes, and for the 
   fixed user information */

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

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

#define KEYSET_BUFFERSIZE	1024

/* The different types of userID which we can use for matching purposes */

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;

/* 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 */

static int findUser( const void *userIndexData, const int userIndexDataLength,
					 const USERID_TYPE idType, const void *userID, 
					 const int userIDlength )
	{
	STREAM stream;
	int fileReference = CRYPT_ERROR_NOTFOUND, status;

	/* Check each entry to make sure the user name or ID aren't already 
	   present */
	sMemConnect( &stream, userIndexData, userIndexDataLength );
	while( stell( &stream ) < userIndexDataLength )
		{
		BYTE userData[ 128 ];
		long newFileReference;
		int userDataLength;

		readSequence( &stream, NULL );
		if( idType == USERID_USERID )
			readOctetString( &stream, userData, &userDataLength, KEYID_SIZE );
		else
			readUniversal( &stream );
		if( idType == USERID_CREATORID )
			readOctetString( &stream, userData, &userDataLength, KEYID_SIZE );
		else
			readUniversal( &stream );
		if( idType == USERID_NAME )
			readOctetStringTag( &stream, userData, &userDataLength, 
								CRYPT_MAX_TEXTSIZE, BER_STRING_UTF8 );
		else
			readUniversal( &stream );
		status = readShortInteger( &stream, &newFileReference );
		if( cryptStatusError( status ) )
			break;
		if( userIDlength == userDataLength && \
			!memcmp( userData, userData, userDataLength ) )
			{
			fileReference = ( int ) newFileReference;
			break;
			}
		}
	sMemDisconnect( &stream );

	return( cryptStatusError( status ) ? status : fileReference );
	}

/* Open a user keyset */

static int openUserKeyset( CRYPT_KEYSET *iUserKeyset, const char *fileName,
						   const int options )
	{
	MESSAGE_CREATEOBJECT_INFO createInfo;
	char userFilePath[ MAX_PATH_LENGTH + 128 ];	/* Protection for Windows */
	int status;

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

	/* Open the given keyset */
	fileBuildCryptlibPath( userFilePath, fileName, 
						   ( options == CRYPT_KEYOPT_READONLY ) ? \
						   FALSE : TRUE );
	setMessageCreateObjectInfo( &createInfo, CRYPT_KEYSET_FILE );
	createInfo.arg2 = options;
	createInfo.strArg1 = userFilePath;
	createInfo.strArgLen1 = strlen( userFilePath );
	status = krnlSendMessage( SYSTEM_OBJECT_HANDLE,
							  RESOURCE_IMESSAGE_DEV_CREATEOBJECT,
							  &createInfo, OBJECT_TYPE_KEYSET );
	if( cryptStatusOK( status ) )
		*iUserKeyset = createInfo.cryptHandle;
	return( status );
	}

/* Read data from a user keyset.  This takes a pointer to a buffer and
   optionally allocates a larger buffer if required, with behaviour
   determined by the overallocSize parameter.  If it's less than zero
   then no attempt to allocate a larger buffer is made, if it's zero
   then a larger buffer is allocated, and if it's larger than zero then
   a buffer of the required size plus the overallocSize value is
   allocated */

static int readUserData( const CRYPT_KEYSET iUserKeyset, 
						 const CRYPT_ATTRIBUTE_TYPE dataType, 
						 void **data, int *dataLength, 
						 const int overallocSize )
	{
	RESOURCE_DATA msgData;
	void *dataPtr = *data;
	int status;

	/* Clear return value */
	*dataLength = 0;

	/* Read the requested data from the keyset, allocating a bigger
	   buffer if required.  When we allocate the buffer we add a caller-
	   specified over-allocation amount to handle any extra data the caller
	   wants to add to the buffer */
	setResourceData( &msgData, NULL, 0 );
	status = krnlSendMessage( iUserKeyset, RESOURCE_IMESSAGE_GETATTRIBUTE_S,
							  &msgData, dataType );
	if( cryptStatusError( status ) )
		return( status );
	if( msgData.length > KEYSET_BUFFERSIZE )
		{
		if( overallocSize == CRYPT_ERROR )
			/* Don't try to reallocate the buffer if it's too small, there
			   shouldn't be this much data present */
			return( CRYPT_ERROR_OVERFLOW );
		if( ( dataPtr = malloc( msgData.length + overallocSize ) ) == NULL )
			return( CRYPT_ERROR_MEMORY );
		}
	msgData.data = dataPtr;
	status = krnlSendMessage( iUserKeyset, RESOURCE_IMESSAGE_GETATTRIBUTE_S,
							  &msgData, dataType );
	if( cryptStatusError( status ) )
		{
		if( dataPtr != *data )
			free( dataPtr );
		}
	else
		{
		*data = dataPtr;
		*dataLength = msgData.length;
		}
	return( status );
	}

/* Find the file reference for a given user in the index keyset */

static int findUserFileRef( const USERID_TYPE idType, const BYTE *id, 
							const int idLength )
	{
	CRYPT_KEYSET iUserKeyset;
	BYTE buffer[ KEYSET_BUFFERSIZE ];
	void *bufPtr = buffer;
	int length, status;

	/* Open the index file and read the index entries from it */
	status = openUserKeyset( &iUserKeyset, "index", CRYPT_KEYOPT_READONLY );
	if( cryptStatusError( status ) )
		{
		/* If there's no index file present, we're in the zeroised state,
		   the only valid user is the (implicitly present) primary SO */
		if( status == CRYPT_ERROR_NOTFOUND && idType == USERID_NAME && \
			idLength == primarySOInfo.userNameLength && \
			!memcmp( id, primarySOInfo.userName, 
					 primarySOInfo.userNameLength ) )
			status = OK_SPECIAL;

		return( status );
		}
	status = readUserData( iUserKeyset, CRYPT_IATTRIBUTE_USERINDEX,
						   &bufPtr, &length, 0 );
	krnlSendNotifier( iUserKeyset, RESOURCE_IMESSAGE_DECREFCOUNT );
	if( cryptStatusError( status ) )
		{
		if( bufPtr != buffer )
			free( bufPtr );
		return( status );
		}

	/* Check whether this user is present in the index */
	status = findUser( bufPtr, length, idType, id, idLength );
	if( bufPtr != buffer )
		free( bufPtr );

	return( status );
	}

/* Insert a new entry into the index */

static int insertIndexEntry( const USER_INFO *userInfoPtr, 
							 BYTE *userIndexData, int *userIndexDataLength )
	{
	STREAM stream;
	BYTE userInfoBuffer[ MAX_USERINDEX_SIZE ];
	int userInfoLength, newReference = 0, lastPos = 0;

	/* If there's already index data present, find the appropriate place to
	   insert the new entry and the file reference to use */
	if( *userIndexDataLength )
		{
		sMemConnect( &stream, userIndexData, *userIndexDataLength );
		while( stell( &stream ) < *userIndexDataLength )
			{
			long fileReference;
			int status;

			/* Read an index entry and check whether the file reference
			   matches the expected file reference */
			readSequence( &stream, NULL );
			readUniversal( &stream );
			readUniversal( &stream );
			status = readShortInteger( &stream, &fileReference );
			if( cryptStatusError( status ) )
				{
				sMemDisconnect( &stream );
				return( status );
				}
			if( fileReference != newReference )
				break;
			lastPos = stell( &stream );
			newReference++;
			}
		sMemDisconnect( &stream );
		}

	/* We've found an unused reference, insert the user data at this point */
	sMemOpen( &stream, userInfoBuffer, MAX_USERINDEX_SIZE );

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美自拍偷拍| 亚洲不卡一区二区三区| 一区二区三区不卡视频在线观看 | 国产一区二区三区在线看麻豆| 国产精品1区二区.| 欧美日韩视频不卡| 中文字幕在线一区二区三区| 五月天亚洲婷婷| www.欧美日韩| 久久久久亚洲综合| 日韩在线卡一卡二| 色婷婷久久久亚洲一区二区三区 | 色婷婷亚洲综合| 久久精品无码一区二区三区| 亚洲mv在线观看| 91蜜桃网址入口| 国产精品午夜在线| 国产一区啦啦啦在线观看| 欧美日本在线播放| 亚洲最大色网站| 色综合久久天天| 国产精品美女久久久久久久久久久| 美美哒免费高清在线观看视频一区二区 | 欧美精选在线播放| 一区二区三区不卡在线观看| 成人午夜电影小说| 国产色综合久久| 国产精品一级片在线观看| 2024国产精品| 精品夜夜嗨av一区二区三区| 91麻豆精品国产自产在线观看一区 | 免费精品视频在线| 91精品国产免费| 日韩精品视频网| 91精品国产高清一区二区三区蜜臀| 亚洲一区二区三区四区五区中文| 一本久久a久久免费精品不卡| 亚洲色图视频免费播放| 色综合久久88色综合天天| 1024成人网| 欧洲视频一区二区| 亚洲一区欧美一区| 制服丝袜中文字幕一区| 日韩高清在线一区| 日韩一区二区三区av| 久久激情综合网| 久久先锋影音av鲁色资源网| 国产盗摄视频一区二区三区| 中文字幕一区二区三中文字幕| 播五月开心婷婷综合| 亚洲欧美一区二区不卡| 精品视频全国免费看| 日本视频中文字幕一区二区三区| www国产精品av| jizz一区二区| 天堂va蜜桃一区二区三区| 日韩午夜激情视频| 国产成+人+日韩+欧美+亚洲| 亚洲免费在线观看| 欧美欧美欧美欧美| 国产麻豆精品久久一二三| 国产精品久久久久久久久搜平片| 欧美怡红院视频| 久久99九九99精品| 日韩一区欧美小说| 91精品国产综合久久精品app| 精品一区二区国语对白| 亚洲精选免费视频| 欧美一级欧美三级在线观看| 国产99久久久国产精品免费看| 亚洲乱码国产乱码精品精98午夜 | 欧美日韩精品专区| 国产在线精品不卡| 亚洲人成亚洲人成在线观看图片 | 成人午夜电影网站| 午夜不卡av免费| 国产欧美精品一区aⅴ影院| 色狠狠桃花综合| 国内精品写真在线观看| 一区二区三区中文字幕电影 | 久久麻豆一区二区| 欧美日韩一区中文字幕| 国产成人精品1024| 蜜桃一区二区三区在线观看| 亚洲日穴在线视频| 国产亚洲精品aa午夜观看| 欧美性猛片aaaaaaa做受| 国产91精品一区二区麻豆网站| 亚洲成在人线在线播放| 国产精品私人自拍| 精品免费视频一区二区| 欧美午夜一区二区| 99久久亚洲一区二区三区青草| 国内精品视频一区二区三区八戒| 亚洲国产日韩综合久久精品| 欧美激情中文字幕| 精品女同一区二区| 91精品国产高清一区二区三区| 91丨九色丨尤物| 成人动漫在线一区| 国产精品一区二区你懂的| 久久国产视频网| 日日夜夜免费精品| 亚洲一区在线观看视频| 亚洲图片你懂的| 最新日韩av在线| 国产精品污污网站在线观看| 久久色.com| 久久女同精品一区二区| 精品国产电影一区二区| 91麻豆精品国产91| 91精品国产综合久久久久久久| 欧美午夜精品理论片a级按摩| 色综合天天综合网国产成人综合天 | 麻豆91精品91久久久的内涵| 天天色天天操综合| 亚洲一区二区三区四区五区中文| 亚洲欧美日韩国产另类专区| 亚洲欧美日韩国产综合在线| 亚洲三级在线免费观看| 亚洲精品ww久久久久久p站| 中文字幕欧美一| 亚洲欧美另类小说| 一区二区三区蜜桃| 天堂资源在线中文精品| 日韩av电影天堂| 久久99国产精品麻豆| 国产麻豆精品久久一二三| 国产电影一区二区三区| 不卡欧美aaaaa| 色呦呦网站一区| 欧美色倩网站大全免费| 3d动漫精品啪啪一区二区竹菊| 精品久久久久久久久久久久包黑料 | 欧美大白屁股肥臀xxxxxx| 日韩欧美精品在线视频| 久久久久久久久久久电影| 国产精品剧情在线亚洲| 一区二区视频免费在线观看| 日韩av中文字幕一区二区三区| 久久精品国产99久久6| 高清不卡一区二区| 91久久久免费一区二区| 欧美群妇大交群的观看方式| 欧美sm极限捆绑bd| 国产精品网曝门| 一区二区三区四区国产精品| 日本成人在线网站| 国产高清久久久久| 欧美在线观看视频在线| 51久久夜色精品国产麻豆| 国产欧美一区二区精品性色超碰 | 日本高清不卡视频| 欧美激情一区二区三区不卡| 中文字幕在线不卡一区二区三区| 亚洲图片欧美色图| 国产中文一区二区三区| 91久久人澡人人添人人爽欧美 | 欧美日韩成人综合| 久久蜜桃av一区二区天堂| 日韩毛片视频在线看| 精品亚洲porn| 在线观看欧美黄色| 欧美激情一区二区在线| 青青草国产精品97视觉盛宴| gogogo免费视频观看亚洲一| 日韩一区二区免费视频| 亚洲精选免费视频| 国产凹凸在线观看一区二区| 51精品国自产在线| 尤物在线观看一区| 国产suv一区二区三区88区| 91精品国产色综合久久不卡蜜臀 | 中文字幕综合网| 国产剧情一区二区| 在线观看91精品国产麻豆| 国产精品久久久久影院老司| 极品美女销魂一区二区三区| 欧洲一区二区三区在线| 中文字幕日本乱码精品影院| 国产在线精品不卡| 日韩欧美国产一二三区| 性做久久久久久免费观看欧美| 成人黄色在线看| 国产日韩欧美精品综合| 另类小说一区二区三区| 7777精品伊人久久久大香线蕉 | 视频一区二区中文字幕| 在线视频欧美区| 亚洲日本在线观看| gogogo免费视频观看亚洲一| 国产网红主播福利一区二区| 激情都市一区二区| 日韩欧美第一区| 看电视剧不卡顿的网站| 欧美一区二区二区| 蜜臀精品久久久久久蜜臀| 3d成人动漫网站| 日韩av在线免费观看不卡| 欧美日本国产一区|