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

📄 sta_r_w.c

📁 SecuDe是一个由安全应用程序接口组成,对验证机制、证件处理、PEM、X.400报文处理和密钥管理提供支持。SecuDe提供DES、 RSA杂凑函数、密钥生成以及数字签名的生成和核实等多种密码机制。
💻 C
📖 第 1 页 / 共 4 页
字号:
/*			      	       BY   Levona Eckstein    *//*							       *//* DESCRIPTION						       *//*  Write data in elementary file on the smartcard.            *//*							       *//*							       *//* IN			     DESCRIPTION		       *//*   sct_id		       SCT identifier		       *//*                                                             *//*   file_id                   File identifier                 *//*							       *//*   data_sel                  Offset where the data shall     *//*			       be written		       *//*   in_data                   Data to be written              *//*			                 		       */ /* 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_write_data(sct_id, file_id, data_sel, in_data, sec_mess)	int             sct_id;	FileId         *file_id;	DataSel        *data_sel;	OctetString    *in_data;	SecMess        *sec_mess;{	/*----------------------------------------------------------*/	/* Definitions					       */	/*----------------------------------------------------------*/	int             i;	/*----------------------------------------------------------*/	/* Statements					       */	/*----------------------------------------------------------*/#ifdef TEST	fprintf(stdout, "\n***** STAMOD-Routine sca_write_data *****\n\n");	fprintf(stdout, "TRACE of the input parameters : \n");	fprintf(stdout, "sct_id                  : %d\n", sct_id);	print_fileid(file_id);	print_datasel(data_sel);	fprintf(stdout, "in_data                 : \n");	fprintf(stdout, "    noctets             : %d\n", in_data->noctets);	fprintf(stdout, "    octets              : \n");	aux_fxdump(stdout, in_data->octets, in_data->noctets, 0);	print_secmess(sec_mess);#endif	/*-------------------------------------*/	/* call check_sct_sc                  */	/*-------------------------------------*/	if (check_sct_sc(sct_id, TRUE))		return (-1);	/*-------------------------------------*/	/* create SC command WRITEF           */	/*-------------------------------------*/	/* create header                       */	if (cr_header(SC_WRITEF, sec_mess))		return (-1);	/* set parameters			  */	SCWRITEF.data_sel = data_sel;	SCWRITEF.fid = file_id;	SCWRITEF.lwrdata = (unsigned) in_data->noctets;	SCWRITEF.wrdata = in_data->octets;	/* 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_write_data *****\n\n");#endif	return (0);}/*-------------------------------------------------------------*//* E N D   O F	 P R O C E D U R E	sca_write_data         *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//*						         | GMD *//*						         +-----*//* PROC  sca_write_file          VERSION   1.0	    	       *//*				     DATE   Januar 1992	       *//*			      	       BY   Levona Eckstein    *//*							       *//* DESCRIPTION						       *//*  Write complete file on the smartcard.                      *//*							       *//*							       *//* IN			     DESCRIPTION		       *//*   sct_id		       SCT identifier		       *//*                                                             *//*   file_id                   File identifier                 *//*							       *//*   data_struc                Data structure                  *//*			       (LIN_FIX or LIN_VAR)  	       *//*   in_data                   Data to be written              *//*			                 		       */ /* sec_mess		       security modes                  *//* *//* OUT							       *//*							       *//*							       *//* RETURN		     DESCRIPTION	      	       *//*   0	         	       o.k			       *//*  -1			       error			       *//*			         M_EPOINTER  		       *//*				 M_EDATASTRUC		       *//*							       *//* 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_write_file(sct_id, file_id, data_struc, in_data, sec_mess)	int             sct_id;	FileId         *file_id;	DataStruc       data_struc;	RecordList     *in_data;	SecMess        *sec_mess;{	/*----------------------------------------------------------*/	/* Definitions					       */	/*----------------------------------------------------------*/	RecordList     *dp_tail;	/*----------------------------------------------------------*/	/* Statements					       */	/*----------------------------------------------------------*/#ifdef TEST	fprintf(stdout, "\n***** STAMOD-Routine sca_write_file *****\n\n");	fprintf(stdout, "TRACE of the input parameters : \n");	fprintf(stdout, "sct_id                  : %d\n", sct_id);	print_fileid(file_id);	print_datastruc(data_struc);	print_recordlist(in_data);	print_secmess(sec_mess);#endif	/*-------------------------------------*/	/* check parameter                    */	/*-------------------------------------*/	if ((data_struc != LIN_FIX) &&	    (data_struc != LIN_VAR)) {		sca_errno = M_EDATASTRUC;		set_errmsg();		return (-1);	}	if (in_data == RECNULL) {		/* file empty */		sca_errno = M_EPOINTER;		set_errmsg();		return (-1);	}	/*-------------------------------------*/	/* call check_sct_sc                  */	/*-------------------------------------*/	if (check_sct_sc(sct_id, TRUE))		return (-1);	/*-------------------------------------*/	/* create SC command WRITEF           */	/*-------------------------------------*/	/* create header                       */	if (cr_header(SC_WRITEF, sec_mess))		return (-1);	/* set parameters			  */	SCWRITEF.data_sel->data_struc = data_struc;	if (data_struc == LIN_FIX)		SCWRITEF.data_sel->data_ref.record_sel.record_id = FIRST_FIX_RID;	else		SCWRITEF.data_sel->data_ref.record_sel.record_id = FIRST_VAR_RID;	SCWRITEF.fid = file_id;	SCWRITEF.data_sel->data_ref.record_sel.record_pos = 0;	dp_tail = in_data;	while (dp_tail != RECNULL) {		if ((dp_tail->record.noctets == 0) ||		    (dp_tail->record.octets == NULL)) {			/* file complete processed */			return (0);		}		SCWRITEF.lwrdata = (unsigned) dp_tail->record.noctets;		SCWRITEF.wrdata = dp_tail->record.octets;		/* call create_trans			  */		if (create_trans(sct_id, TRUE))			return (-1);		/*----------------------------------------------*/		/* normal end => release response storage       */		/*----------------------------------------------*/		sta_aux_bytestr_free(&response);		/*----------------------------------------------*/		/* transfer next record                         */		/*----------------------------------------------*/		SCWRITEF.data_sel->data_ref.record_sel.record_id++;		dp_tail = dp_tail->next;	}#ifdef TEST	fprintf(stdout, "\n***** Normal end of   sca_write_file *****\n\n");#endif	return (0);}/*-------------------------------------------------------------*//* E N D   O F	 P R O C E D U R E	sca_write_file	       *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//*						         | GMD *//*						         +-----*//* PROC  sca_delete_record        VERSION   1.0	    	       *//*				     DATE   Januar 1992	       *//*			      	       BY   Levona Eckstein    *//*							       *//* DESCRIPTION						       *//*  Delete record in elementary file on the smartcard.         *//*							       *//*							       *//* IN			     DESCRIPTION		       *//*   sct_id		       SCT identifier		       *//*                                                             *//*   file_id                   File identifier                 *//*							       *//*   record_id                 Record identifier               *//*			                         	       */ /* 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                     */

⌨️ 快捷键说明

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