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

📄 stasc.c

📁 SecuDe是一个由安全应用程序接口组成,对验证机制、证件处理、PEM、X.400报文处理和密钥管理提供支持。SecuDe提供DES、 RSA杂凑函数、密钥生成以及数字签名的生成和核实等多种密码机制。
💻 C
📖 第 1 页 / 共 5 页
字号:
	/* call create_trans			  */	if (create_trans(sct_id, FALSE))		return (-1);	/*----------------------------------------------*/	/* normal end => transfer response message      */	/* from SC into sc_response       */	/*----------------------------------------------*/	sc_response->noctets = response.nbytes;	if ((sc_response->octets = (char *) malloc(sc_response->noctets)) == NULL) {		sca_errno = M_EMEMORY;		set_errmsg();		sta_aux_bytestr_free(&response);		return (-1);	}	for (i = 0; i < sc_response->noctets; i++)		sc_response->octets[i] = response.bytes[i];	sta_aux_bytestr_free(&response);#ifdef TEST	fprintf(stdout, "TRACE of the output parameters : \n");	fprintf(stdout, "sc_response             : \n");	fprintf(stdout, "    noctets             : %d\n", sc_response->noctets);	fprintf(stdout, "    octets              : \n");	aux_fxdump(stdout, sc_response->octets, sc_response->noctets, 0);	fprintf(stdout, "\n***** Normal end of   sca_trans *****\n\n");#endif	return (0);}/*-------------------------------------------------------------*//* E N D   O F	 P R O C E D U R E	sca_trans	       *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//*						         | GMD *//*						         +-----*//* PROC  sca_create_file          VERSION   1.0	    	       *//*				     DATE   Januar 1992	       *//*			      	       BY   Levona Eckstein    *//*							       *//* DESCRIPTION						       *//*  Create file on the smartcard.        	               *//*  Sca_create_file creates a new file (MF,DF,SF or EF) on     *//*  the smartcard. 					       *//*							       *//*							       *//* IN			     DESCRIPTION		       *//*   sct_id		       SCT identifier		       *//*                                                             *//*   file_cat                  File category(MF,DF,SF,EF)      *//*							       *//*   file_type		       Elementary file type            *//*			       (PEF,ACF,ISF,WEF)	       *//*   data_struc                Data structure of the EF        *//* 			       (LIN_FIX,LIN_VAR,CYCLIC,        *//*			        TRANSPAREN)		       *//*   file_control_info         File control information        *//*						  	       *//*   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_create_file(sct_id, file_cat, file_type, data_struc, file_control_info,		sec_mess)	int             sct_id;	FileCat         file_cat;	FileType        file_type;	DataStruc       data_struc;	FileControlInfo *file_control_info;	SecMess        *sec_mess;{	/*----------------------------------------------------------*/	/* Definitions					       */	/*----------------------------------------------------------*/	/*----------------------------------------------------------*/	/* Statements					       */	/*----------------------------------------------------------*/#ifdef TEST	fprintf(stdout, "\n***** STAMOD-Routine sca_create_file *****\n\n");	fprintf(stdout, "TRACE of the input parameters : \n");	fprintf(stdout, "sct_id		        : %d\n", sct_id);	print_filecat(file_cat);	print_filetype(file_type, NULL);	fprintf(stdout, "                          set to 0x00 in case of MF,DF or SF\n");	print_datastruc(data_struc);	fprintf(stdout, "                          set to 0x00 in case of MF,DF or SF\n");	print_filecontinfo(file_cat, file_control_info);	print_secmess(sec_mess);#endif	/*-------------------------------------*/	/* check / set parameter              */	/*-------------------------------------*/	if (file_cat < EF) {		file_type = 0x00;		data_struc = 0x00;		file_control_info->readwrite = 0x00;	}	if (((file_cat == EF) &&	     ((data_struc != LIN_FIX) && (data_struc != CYCLIC))) ||	    (file_cat <= SF))		file_control_info->recordsize = 0;	/*-------------------------------------*/	/* call check_sct_sc                  */	/*-------------------------------------*/	if (check_sct_sc(sct_id, TRUE))		return (-1);	/*-------------------------------------*/	/* create SC command CREATE           */	/*-------------------------------------*/	/* create header                       */	if (cr_header(SC_CREATE, sec_mess))		return (-1);	/* set parameters			  */	SCCREATE.filecat = file_cat;	SCCREATE.filetype = file_type;	SCCREATE.datastruc = data_struc;	SCCREATE.filecontrolinfo = file_control_info;	/* call create_trans			  */	if (create_trans(sct_id, TRUE))		return (-1);	/*----------------------------------------------*/	/* normal end => release response storage       */	/*----------------------------------------------*/	sta_aux_bytestr_free(&response);#ifdef TEST	fprintf(stdout, "\n***** Normal end of   sca_create_file *****\n\n");#endif	return (0);}/*-------------------------------------------------------------*//* E N D   O F	 P R O C E D U R E	sca_create_file	       *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//*						         | GMD *//*						         +-----*//* PROC  sca_register             VERSION   1.0	    	       *//*				     DATE   Januar 1992	       *//*			      	       BY   Levona Eckstein    *//*							       *//* DESCRIPTION						       *//*  Registering of applications.         	               *//*  With sca_register a DF which shall be created must be      *//*  registered on the smartcard.			       *//*							       *//*							       *//* IN			     DESCRIPTION		       *//*   sct_id		       SCT identifier		       *//*                                                             *//*   DF_name                   Name of the DF                  *//*							       *//*   memory_units	       Number of units required for    *//*			       this DF           	       *//*   auth_key_id               Unused in the current version   *//*			                 		       *//*   sec_status                Security status to protect the  *//*			       creation			       *//*   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_register(sct_id, DF_name, memory_units, auth_key_id, sec_status,	     sec_mess)	int             sct_id;	char           *DF_name;	int             memory_units;	KeyId          *auth_key_id;	char            sec_status;	SecMess        *sec_mess;{	/*----------------------------------------------------------*/	/* Definitions					       */	/*----------------------------------------------------------*/	/*----------------------------------------------------------*/	/* Statements					       */	/*----------------------------------------------------------*/#ifdef TEST	fprintf(stdout, "\n***** STAMOD-Routine sca_register *****\n\n");	fprintf(stdout, "TRACE of the input parameters : \n");	fprintf(stdout, "sct_id                  : %d\n", sct_id);	fprintf(stdout, "DF_name                 : %s\n", DF_name);	fprintf(stdout, "memory_units            : %d\n", memory_units);	fprintf(stdout, "auth_key_id             : unused in this version\n");	fprintf(stdout, "sec_status              : %x\n", sec_status);	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                       */	/*-------------------------------------*/	auth_key_id->key_level = 0;	auth_key_id->key_number = 0;	/*-------------------------------------*/	/* create SC command REGISTER         */	/*-------------------------------------*/	/* create header                       */	if (cr_header(SC_REGISTER, sec_mess))		return (-1);	/* set parameters			  */	SCREG.units = memory_units;	SCREG.kid = auth_key_id;	SCREG.acv = sec_status & 0xFF;	SCREG.fn = DF_name;	/* call create_trans			  */	if (create_trans(sct_id, TRUE))		return (-1);	/*----------------------------------------------*/	/* normal end => release response storage       */	/*----------------------------------------------*/	sta_aux_bytestr_free(&response);#ifdef TEST	fprintf(stdout, "\n***** Normal end of   sca_register *****\n\n");#endif	return (0);

⌨️ 快捷键说明

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