⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stasc.c

📁 SecuDe是一个由安全应用程序接口组成,对验证机制、证件处理、PEM、X.400报文处理和密钥管理提供支持。SecuDe提供DES、 RSA杂凑函数、密钥生成以及数字签名的生成和核实等多种密码机制。
💻 C
📖 第 1 页 / 共 5 页
字号:
}/*-------------------------------------------------------------*//* E N D   O F	 P R O C E D U R E	sca_register	       *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//*						         | GMD *//*						         +-----*//* PROC  sca_select_file          VERSION   1.0	    	       *//*				     DATE   Januar 1992	       *//*			      	       BY   Levona Eckstein    *//*							       *//* DESCRIPTION						       *//*  Select file on the smartcard.         	               *//*  Sca_select_file will be used to select the file (MF,DF or  *//*  SF) on the smartcard and to set the smartcard in the       *//*  context of this file.				       *//*							       *//*							       *//* IN			     DESCRIPTION		       *//*   sct_id		       SCT identifier		       *//*                                                             *//*   file_cat                  File category (MF,DF,SF         *//*							       *//*   file_name                 File name                       *//*			                         	       *//*   sel_control_par           Unused in the current version   *//*			                 		       *//*   file_info_req             File information requested      *//*			       (NONE or SHORT)		       */ /* sec_mess		       security modes                  *//* *//* OUT							       *//*							       *//*   file_info                 Returned file information       *//*							       *//*							       *//* RETURN		     DESCRIPTION	      	       *//*   0	         	       o.k			       *//*  -1			       error			       *//*				 M_EOUTDAT		       *//*                               M_EMEMORY                     *//* CALLED FUNCTIONS					       *//*  check_sct_sc               ERROR-Codes		       *//*			         ENOCARD		       *//*			         ESIDUNK		       *//*			 	 ENOSHELL		       *//*                               EOPERR                        *//*			         EEMPTY                        *//*                               EMEMAVAIL                     *//*                               ECLERR                        *//*                               ERDERR                        *//*                               EINVARG		       *//*                               ETOOLONG		       *//*                               sw1/sw2 from SCT response     *//*                               T1 - ERROR                    *//*							       *//*  cr_header         	       ERROR-Codes    		       *//*                               M_ESECMESS		       *//*							       *//*  create_trans   	       ERROR-Codes	               *//*                               EINVARG		       *//*                               ETOOLONG		       *//*                               EMEMAVAIL		       *//*                               ESIDUNK                       *//*                               EPARMISSED                    *//*			         EPARINC		       *//*                               INVPAR                        *//*                               EINVINS                       *//*                               sw1/sw2 from SCT response     *//*                               T1 - ERROR                    *//*                               sw1/sw2 from SC  response     *//*							       *//*-------------------------------------------------------------*/intsca_select_file(sct_id, file_cat, file_name, sel_control_par, file_info_req,		file_info, sec_mess)	int             sct_id;	FileCat         file_cat;	char           *file_name;	char            sel_control_par;	FileInfoReq     file_info_req;	FileInfo       *file_info;	SecMess        *sec_mess;{	/*----------------------------------------------------------*/	/* Definitions					       */	/*----------------------------------------------------------*/	int             i;	/*----------------------------------------------------------*/	/* Statements					       */	/*----------------------------------------------------------*/#ifdef TEST	fprintf(stdout, "\n***** STAMOD-Routine sca_select_file *****\n\n");	fprintf(stdout, "TRACE of the input parameters : \n");	fprintf(stdout, "sct_id                  : %d\n", sct_id);	print_filecat(file_cat);	fprintf(stdout, "file_name               : %s\n", file_name);	fprintf(stdout, "sel_control_par         : unused in this version\n");	print_inforeq(file_info_req);	print_secmess(sec_mess);#endif	/*-------------------------------------*/	/* call check_sct_sc                  */	/*-------------------------------------*/	if (check_sct_sc(sct_id, TRUE))		return (-1);	/*-------------------------------------*/	/* set parameter, which are unused in */	/* this version                       */	/*-------------------------------------*/	sel_control_par = 0x00;	/*-------------------------------------*/	/* create SC command SELECT           */	/*-------------------------------------*/	/* create header                       */	if (cr_header(SC_SELECT, sec_mess))		return (-1);	/* set parameters			  */	SCSELECT.id = file_cat;	SCSELECT.fi = file_info_req;	SCSELECT.scp = sel_control_par & 0xFF;	SCSELECT.fn = file_name;	/* call create_trans			  */	if (create_trans(sct_id, TRUE))		return (-1);	/* if file_info_req == SHORT_INFO => get file information */	if (file_info_req == SHORT_INFO) {		if (response.nbytes != 5) {	/* addinfo = 4 + 1 byte FSTAT */			sca_errno = M_EOUTDAT;			set_errmsg();			sta_aux_bytestr_free(&response);			return (-1);		} else {			/* create file_info->file_status */			file_info->file_status.install_status = get_bits((unsigned) response.bytes[4], 2, 1);			file_info->file_status.file_memory = get_bits((unsigned) response.bytes[4], 1, 6);			file_info->file_status.file_access = get_bits((unsigned) response.bytes[4], 1, 7);			/* create file_info->addinfo      */			file_info->addinfo.noctets = response.nbytes - 1;			if ((file_info->addinfo.octets = (char *) malloc(file_info->addinfo.noctets)) == NULL) {				sca_errno = M_EMEMORY;				set_errmsg();				sta_aux_bytestr_free(&response);				return (-1);			} else {				for (i = 0; i < file_info->addinfo.noctets; i++)					file_info->addinfo.octets[i] = response.bytes[i];			}		}	}	/*----------------------------------------------*/	/* normal end => release response storage       */	/*----------------------------------------------*/	sta_aux_bytestr_free(&response);#ifdef TEST	fprintf(stdout, "TRACE of the output parameters : \n");	if (file_info_req != NONE_INFO) {		fprintf(stdout, "file_status             : %d\n", sct_id);		switch (file_info->file_status.install_status) {		case REGISTERED:			fprintf(stdout, "    install_status      : REGISTERED\n");			break;		case DELETED:			fprintf(stdout, "    install_status      : DELETED\n");			break;		case DEL_PENDING:			fprintf(stdout, "    install_status      : DEL_PENDING\n");			break;		case INSTALLED:			fprintf(stdout, "    install_status      : INSTALLED\n");			break;		default:			fprintf(stdout, "    install_status      : undefined\n");			break;		}		switch (file_info->file_status.file_memory) {		case MEM_CONSISTENT:			fprintf(stdout, "    file_memory         : MEM_CONSISTENT\n");			break;		case MEM_INCONSISTENT:			fprintf(stdout, "    file_memory         : MEM_INCONSISTENT\n");			break;		default:			fprintf(stdout, "    file_memory         : undefined\n");			break;		}		switch (file_info->file_status.file_access) {		case FILE_UNLOCKED:			fprintf(stdout, "    file_access         : FILE_UNLOCKED\n");			break;		case FILE_LOCKED:			fprintf(stdout, "    file_access         : FILE_LOCKED\n");			break;		default:			fprintf(stdout, "    file_access         : undefined\n");			break;		}		fprintf(stdout, "addinfo                 : ");		for (i = 0; i < file_info->addinfo.noctets; i++)			fprintf(stdout, "%c", file_info->addinfo.octets[i]);		fprintf(stdout, "\n");	} else		fprintf(stdout, "file_info_req           : no output data \n");	fprintf(stdout, "\n***** Normal end of   sca_select_file *****\n\n");#endif	return (0);}/*-------------------------------------------------------------*//* E N D   O F	 P R O C E D U R E	sca_select_file	       *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//*						         | GMD *//*						         +-----*//* PROC  sca_close_file           VERSION   1.0	    	       *//*				     DATE   Januar 1992	       *//*			      	       BY   Levona Eckstein    *//*							       *//* DESCRIPTION						       *//*  Close file on the smartcard.         	               *//*  Sca_close_file closes the specified file and also all files*//*  belonging to the related file.			       *//*							       *//*							       *//* IN			     DESCRIPTION		       *//*   sct_id		       SCT identifier		       *//*                                                             *//*   file_cat                  File category (MF,DF,SF         *//*							       *//*   file_sel                  File name / File identifier     *//*			                         	       *//*   file_close_context        Close context                   *//*			       (CLOSE_CREATE or CLOSE_SELECT)  */ /* sec_mess		       security modes                  *//* *//* OUT							       *//*							       *//*							       *//* RETURN		     DESCRIPTION	      	       *//*   0	         	       o.k			       *//*  -1			       error			       *//* CALLED FUNCTIONS					       *//*  check_sct_sc               ERROR-Codes		       *//*			         ENOCARD		       *//*			         ESIDUNK		       *//*			 	 ENOSHELL		       *//*                               EOPERR                        *//*			         EEMPTY                        *//*                               EMEMAVAIL                     *//*                               ECLERR                        *//*                               ERDERR                        *//*                               EINVARG		       *//*                               ETOOLONG		       *//*                               sw1/sw2 from SCT response     *//*                               T1 - ERROR                    *//*							       *//*  cr_header         	       ERROR-Codes    		       *//*                               M_ESECMESS		       *//*							       *//*							       *//*  create_trans   	       ERROR-Codes	               *//*                               EINVARG		       *//*                               ETOOLONG		       *//*                               EMEMAVAIL		       *//*                               ESIDUNK                       *//*                               EPARMISSED                    *//*			         EPARINC		       *//*                               INVPAR                        *//*                               EINVINS                       *//*                               sw1/sw2 from SCT response     *//*                               T1 - ERROR                    *//*                               sw1/sw2 from SC  response     *//*							       *//*-------------------------------------------------------------*/intsca_close_file(sct_id, file_cat, file_sel, file_close_context,	       sec_mess)	int             sct_id;	FileCat         file_cat;	FileSel        *file_sel;	FileCloseContext file_close_context;	SecMess        *sec_mess;{	/*----------------------------------------------------------*/	/* Definitions					       */	/*----------------------------------------------------------*/	/*----------------------------------------------------------*/	/* Statements					       */	/*----------------------------------------------------------*/#ifdef TEST	fprintf(stdout, "\n***** STAMOD-Routine sca_close_file *****\n\n");	fprintf(stdout, "TRACE of the input parameters : \n");	fprintf(stdout, "sct_id		        : %d\n", sct_id);	print_filecat(file_cat);	print_filesel(file_cat, file_sel);	print_closecontext(file_close_context);	print_secmess(sec_mess);#endif	/*-------------------------------------*/	/* call check_sct_sc                  */	/*-------------------------------------*/	if (check_sct_sc(sct_id, TRUE))		return (-1);	/*-------------------------------------*/	/* create SC command CLOSE            */	/*-------------------------------------*/	/* create header                       */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -