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

📄 stasc.c

📁 SecuDe是一个由安全应用程序接口组成,对验证机制、证件处理、PEM、X.400报文处理和密钥管理提供支持。SecuDe提供DES、 RSA杂凑函数、密钥生成以及数字签名的生成和核实等多种密码机制。
💻 C
📖 第 1 页 / 共 5 页
字号:
/*---------------------------------------------------------------------------+-----*//*							                     | GMD *//*   SYSTEM   STAPAC  -  Version 1.0		                             +-----*//*							                           *//*---------------------------------------------------------------------------------*//*							                           *//*    PACKAGE	STAMOD-stasc                                VERSION 1.0	           *//*					                       DATE Januar 1992    *//*					                         BY Ursula Viebeg  *//*					                            Levona Eckstein*//*			       				                           *//*    FILENAME     					                           *//*	stasc.c                          		         		   *//*							                           *//*    DESCRIPTION	   				                           *//*      This modul provides all functions for file handling and data access        *//*      on the smartcard  of the smartcard application interface                   *//*							                           *//*    EXPORT		    DESCRIPTION 		                           *//*	sca_trans()	      Transfer of a smartcard command   	           *//*							                           *//*	sca_create_file()     Create file on the smartcard                         *//*							                           *//*	sca_register()        Registering of applications       	           *//*							                           *//*	sca_select_file()     Select file on the smartcard	                   *//*										   *//*      sca_close_file()      Close file on the smartcard                          *//*										   *//*      sca_lock_file()       Lock working elementary file on the smartcard        *//*										   *//*      sca_unlock_file()     Unlock WEF on the smartcard                          *//*										   *//*      sca_delete_file()     Delete file on the smartcard                         *//*										   *//*      request;              body of the SCT commands                             *//*      response;             body of the response of the SCT                      *//*      command;              INS-Code of the SCT command                          *//*      sc_param;             structure of parameters for the                      *//*                            SC-commands                                          *//*      sc_apdu;              generated apdu of the SC-command                     *//*      create_trans();							           *//* 	cr_header();								   *//*	get_bits();								   *//*                                                                                 *//*							                           *//*                                                                                 *//*    IMPORT		    DESCRIPTION 		                           *//*                                 -  aux_xdmp.c (libcrypt)                        *//*                                                                                 *//*	aux_fxdump()                  dump buffer in File	                   *//*							                           *//*                                 -  sta_free.c (libsm)                           *//*                                                                                 *//*      sta_aux_bytestr_free()        set the bytes-buffer in Bytestring free      *//*                                                                                 *//*				   -  sctint.c (libsm)                             *//*							                           *//*      sct_interface()               Send SCT command / receive SCT response      *//*							                           *//*      sct_errno                     global error variable set by SCT-interface   *//*							                           *//*      sct_errmsg                    global pointer to error message set by       *//*                                    SCT-interface                                *//*                                                                                 *//*				   -  sccom.c (libsm)				   *//*                                                                                 *//*      sc_create()                   create SC-request APDU                       *//*                                                                                 *//*      sc_check()                    check SC-response APDU                       *//*									 	   *//*      sc_errno                      global error variable set by SC-interface    *//*										   *//*      sc_errmsg                     global pointer to error message set by       *//*                                    SC-interface                                 *//*                                                                                 *//*				   -  sta_dev.c (libsm)                            *//*                                                                                 *//*      check_sct_sc()                check SCT and SC                             *//*                                                                                 *//*      check_sec_mess()              check security mode(s) for command and response*//*                                                                                 *//*      set_errmsg()                  set sca_errmsg                               *//*                                                                                 *//*      err_analyse()                 error analyse and handling                   *//*                                                                                 *//*      sca_errno                     global error variable set by STAMOD          *//*                                                                                 *//*      sca_errmsg                    global pointer to error message set by STAMOD*//*                                                                                 *//*				   -  staprint.c   (libsm) for TEST-output         *//*                                                                                 *//*      print_filecat()							           *//*      print_filetype()                                                           *//*      print_datastruc()                                                          *//*      print_filecontinfo()                                                       *//*      print_secmess()                                                            *//*      print_filesel()                                                            *//*      print_fileid()                                                             *//*      print_inforeq()                                                            *//*      print_closecontext()                                                       *//*      print_datasel()                                                            *//*      print_datastruc()                                                          *//*      print_keyid()                                                              *//*      print_recordlist()                                                         *//*      print_transmode()                                                          *//*                                                                                 *//*                                                                                 *//*    INTERNAL                                                                     *//*                                                                                 *//*---------------------------------------------------------------------------------*//*-------------------------------------------------------------*//*   include-Files					       *//*-------------------------------------------------------------*/#include "stamod.h"#include "stamsg.h"#include "sctint.h"#include "sccom.h"#ifndef MAC#include <sys/types.h>#include <sys/stat.h>#else#include <stdlib.h>#endif /* !MAC */#include <stdio.h>#include <fcntl.h>#include <string.h>/*-------------------------------------------------------------*//*   extern declarations				       *//*-------------------------------------------------------------*/extern int      sct_interface();extern void     sta_aux_bytestr_free();extern void     aux_fxdump();extern int      sc_create();extern int      sc_check();extern int      check_sct_sc();extern int      check_sec_mess();extern int      set_errmsg();extern void     err_analyse();extern unsigned int sca_errno;	/* error number set by STAMOD-      */ /* stadevice			       */extern char    *sca_errmsg;	/* pointer to error message set by  */ /* STAMOD-stadevice                 */extern unsigned int sct_errno;	/* error number set by SCT-Interface */extern char    *sct_errmsg;	/* pointer to error msg set by      */ /* SCT-Interface                    */extern unsigned int sc_errno;	/* error number set by SC-Interface */extern char    *sc_errmsg;	/* pointer to error msg set by      */ /* SC-Interface */#ifdef TESTextern void     print_filecat();extern void     print_filetype();extern void     print_datastruc();extern void     print_filecontinfo();extern void     print_secmess();extern void     print_filesel();extern void     print_fileid();extern void     print_inforeq();extern void     print_closecontext();extern void     print_datasel();extern void     print_keyid();extern void     print_recordlist();extern void     print_transmode();#endif/*-------------------------------------------------------------*//*   globale variable and function definitions	               *//*-------------------------------------------------------------*/Request         request;	/* body of the SCT commands         */Bytestring      response;	/* body of the response of the SCT  */int             command;	/* INS-Code of the SCT command      */struct s_command sc_param;	/* structure of parameters for the  */ /* SC-commands                      */Bytestring      sc_apdu;	/* generated apdu of the SC-command */int             create_trans();int             cr_header();unsigned int    get_bits();/*-------------------------------------------------------------*//*   type definitions					       *//*-------------------------------------------------------------*//* definitions for the SC-Interface */#define SCCMD                   sc_param.sc_header.inscode#define SCHEAD                  sc_param.sc_header#define SCSELECT                sc_param.sc_uval.sc_select#define SCREG                   sc_param.sc_uval.sc_register#define SCCREATE                sc_param.sc_uval.sc_create#define SCCLOSE                 sc_param.sc_uval.sc_close#define SCDELFILE               sc_param.sc_uval.sc_delfile#define SCLOCKF                 sc_param.sc_uval.sc_lockfile/*-------------------------------------------------------------*//*   local Variable definitions			               *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//*   local procedure definitions	                       *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//*						         | GMD *//*						         +-----*//* PROC  sca_trans                VERSION   1.0	    	       *//*				     DATE   Januar 1992	       *//*			      	       BY   Levona Eckstein    *//*							       *//* DESCRIPTION						       *//*  Transfer of a smartcard command.         	               *//*							       *//*							       *//* IN			     DESCRIPTION		       *//*   sct_id		       SCT identifier		       *//*                                                             *//*   sc_command                Smartcard command               *//*							       *//*   trans_mode		       Transfer mode                   *//*			       (TRANSP,SECURE)   	       *//*							       *//* OUT							       *//*   sc_response               Response of the smartcard       *//*							       *//* RETURN		     DESCRIPTION	      	       *//*   0	         	       o.k			       *//*  -1			       error			       *//*			         M_EPOINTER                    *//*                               M_EMEMORY                     *//*				 M_ESECMODE		       *//*							       *//* CALLED FUNCTIONS					       *//*  check_sct_sc               ERROR-Codes		       *//*			         ENOCARD		       *//*			         ESIDUNK		       *//*			 	 ENOSHELL		       *//*                               EOPERR                        *//*			         EEMPTY                        *//*                               EMEMAVAIL                     *//*                               ECLERR                        *//*                               ERDERR                        *//*                               EINVARG		       *//*                               ETOOLONG		       *//*                               T1 - ERROR                    *//*							       *//*							       *//*  create_trans   	       ERROR-Codes	               *//*                               EINVARG		       *//*                               ETOOLONG		       *//*                               EMEMAVAIL		       *//*                               ESIDUNK                       *//*                               EPARMISSED                    *//*                               INVPAR                        *//*                               EINVINS                       *//*                               sw1/sw2 from SCT response     *//*                               T1 - ERROR                    */ /* *//* *//*-------------------------------------------------------------*/intsca_trans(sct_id, sc_command, trans_mode, sc_response)	int             sct_id;	OctetString    *sc_command;	TransMode       trans_mode;	OctetString    *sc_response;{	/*----------------------------------------------------------*/	/* Definitions					       */	/*----------------------------------------------------------*/	int             i;	Bytestring      bstring;	/*----------------------------------------------------------*/	/* Statements					       */	/*----------------------------------------------------------*/#ifdef TEST	fprintf(stdout, "\n***** STAMOD-Routine sca_trans *****\n\n");	fprintf(stdout, "TRACE of the input parameters : \n");	fprintf(stdout, "sct_id                  : %d\n", sct_id);	fprintf(stdout, "sc_command              : \n");	fprintf(stdout, "    noctets             : %d\n", sc_command->noctets);	fprintf(stdout, "    octets              : \n");	aux_fxdump(stdout, sc_command->octets, sc_command->noctets, 0);	print_transmode(trans_mode);#endif	/*-------------------------------------*/	/* check parameter                    */	/*-------------------------------------*/	if (sc_response == NULL) {		sca_errno = M_EPOINTER;		set_errmsg();		return (-1);	}	if ((trans_mode != TRANSP) &&	    (trans_mode != SECURE)) {		sca_errno = M_ESECMODE;		set_errmsg();		return (-1);	}	/*-------------------------------------*/	/* call check_sct_sc                  */	/*-------------------------------------*/	if (check_sct_sc(sct_id, TRUE))		return (-1);	/*-------------------------------------*/	/* create SCT command S_TRANS         */	/*-------------------------------------*/	command = S_TRANS;	request.rq_p1.secmode = trans_mode;	bstring.nbytes = sc_command->noctets;	bstring.bytes = sc_command->octets;	request.rq_datafield.sccommand = &bstring;

⌨️ 快捷键说明

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