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

📄 staauth.c

📁 SecuDe是一个由安全应用程序接口组成,对验证机制、证件处理、PEM、X.400报文处理和密钥管理提供支持。SecuDe提供DES、 RSA杂凑函数、密钥生成以及数字签名的生成和核实等多种密码机制。
💻 C
📖 第 1 页 / 共 5 页
字号:
	    (key_id->key_number > MAX_KEYID)) {		sca_errno = EINVKID;		set_errmsg();		return (-1);	}	if ((sct_keyid = get_sct_keyid(key_id)) == -1)	/* get char from key_id */		return (-1);	/*-----------------------------------------------------*/	/* Check pin record				       */	/*-----------------------------------------------------*/	if (pin->pin_type == PIN) {	/* check PIN */		kind_of_key = PIN_KEY;		if ((pin->PINBody.pin_info.min_len < 0) ||		    (pin->PINBody.pin_info.min_len > MAXL_PIN)) {			sca_errno = M_EPIN;			set_errmsg();			return (-1);		}		if (pin->PINBody.pin_info.pin == NULL) {			sca_errno = M_EPIN;			set_errmsg();			return (-1);		} else if (strlen(pin->PINBody.pin_info.pin) > MAXL_PIN) {			sca_errno = M_EPIN;			set_errmsg();			return (-1);		}		if (pin->PINBody.pin_info.clear_pin != NULL) {			if (strlen(pin->PINBody.pin_info.clear_pin) > MAXL_PIN) {				sca_errno = M_EPIN;				set_errmsg();				return (-1);			}		}	} else if (pin->pin_type == PUK) {	/* check PUK */		kind_of_key = PUK_KEY;		if (pin->PINBody.puk_info.puk == NULL) {			sca_errno = M_EPIN;			set_errmsg();			return (-1);		} else if (strlen(pin->PINBody.puk_info.puk) > MAXL_PIN) {			sca_errno = M_EPIN;			set_errmsg();			return (-1);		}		if ((pin->PINBody.puk_info.pin_key_id.key_level != SC_MF) &&		    (pin->PINBody.puk_info.pin_key_id.key_level != SC_DF) &&		    (pin->PINBody.puk_info.pin_key_id.key_level != SC_SF)) {			sca_errno = M_EPIN;			set_errmsg();			return (-1);		}		if ((pin->PINBody.puk_info.pin_key_id.key_number < 1) ||		(pin->PINBody.puk_info.pin_key_id.key_number > MAX_KEYID)) {			sca_errno = M_EPIN;			set_errmsg();			return (-1);		}	} else {		/* no PIN, no PUK */		sca_errno = M_EPIN;		set_errmsg();		return (-1);	}	/*-----------------------------------------------------*/	/* Check key_attr_list			       */	/*-----------------------------------------------------*/	if (check_key_attr_list(kind_of_key, key_attr_list) == -1)		return (-1);	/*-----------------------------------------------------*/	/* Prepare parameters for the SCT Interface          */	/*-----------------------------------------------------*/	command = S_INST_PIN;	request.rq_p1.kid = sct_keyid;	if (pin->pin_type == PIN)		pin_record.key_algid = S_PIN;	else		pin_record.key_algid = S_PUK;	pin_record.pin_attr = key_attr_list;	rc = get_PIN_PUK_body(pin, &pin_body);	if (rc == -1)		return (-1);	pin_record.pin_record = &pin_body;#ifdef TEST	fprintf(stdout, "pin_record->bytes: \n");	aux_fxdump(stdout, pin_record.pin_record->bytes, pin_record.pin_record->nbytes, 0);	fprintf(stdout, "\n");#endif	request.rq_datafield.pin = &pin_record;	/*-----------------------------------------------------*/	/* Call SCT Interface     			       */	/*-----------------------------------------------------*/	rc = sct_interface(sct_id, command, &request, &response);	if (rc < 0) {		sca_errno = sct_errno;		sca_errmsg = sct_errmsg;		err_analyse(sct_id);		sta_aux_bytestr_free(&pin_body);		return (-1);	}	/*-----------------------------------------------------*/	/* Normal End	 (Release storage)		       */	/*-----------------------------------------------------*/	sta_aux_bytestr_free(&pin_body);	sta_aux_bytestr_free(&response);#ifdef TEST	fprintf(stdout, "\n***** Normal end of   sca_inst_pin *********************************************\n\n");#endif	return (sca_errno);}				/* end sca_inst_pin *//*-------------------------------------------------------------*//* E N D   O F	 P R O C E D U R E	sca_inst_pin	       *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//*						         | GMD *//*						         +-----*//* PROC  sca_change_pin	          VERSION   1.0	    	       *//*				     DATE   Januar 1992	       *//*			      	       BY   U.Viebeg           *//*							       *//* DESCRIPTION						       *//*  Change PIN value on the smartcard                          *//*  A smartcard must be inserted.		               *//*							       *//*							       *//* IN			     DESCRIPTION		       *//*   sct_id		       SCT identifier		       *//*                                                             *//*   key_id	               key_id of the PIN to be         *//*                             changed		               *//*                                                             *//*   sec_mess	               Specification of the security   *//*			       mode(s) for the command and     *//*			       response exchange between SCT   *//*			       and smartcard.                  *//*							       *//* OUT							       *//*							       *//*							       *//* RETURN		     DESCRIPTION	      	       *//*   0	         	       o.k			       *//*  -1			       error			       *//*				 EINVKID		       *//*							       *//* CALLED FUNCTIONS					       *//*  check_sct_sc               ERROR-Codes		       *//*			         ENOCARD		       *//*			         ESIDUNK		       *//*			 	 ENOSHELL		       *//*                               EOPERR                        *//*			         EEMPTY                        *//*                               EMEMAVAIL                     *//*                               ECLERR                        *//*                               ESIDUNK                       *//*                               ERDERR                        *//*                               EINVARG		       *//*                               ETOOLONG		       *//*                               sw1/sw2 from SCT response     *//*                               T1 - ERROR                    *//*							       *//*  get_sct_keyid              ERROR-Codes		       *//*			         EINVKID		       *//*							       *//*  check_sec_mess             ERROR-Codes		       *//*			         M_ESECMESS		       *//*							       *//*  sct_interface	       ERROR-Codes	               *//*                               EINVARG		       *//*                               ETOOLONG		       *//*                               EMEMAVAIL		       *//*                               ESIDUNK                       *//*                               EPARMISSED                    *//*                               INVPAR                        *//*                               EINVINS                       *//*                               sw1/sw2 from SCT response     *//*                               T1 - ERROR                    *//*							       *//*  err_analyse		       ERROR_Codes	               *//*				 ENOSHELL		       *//*                               EOPERR                        *//*			         EEMPTY                        *//*                               ECLERR                        *//*                               ESIDUNK                       *//*                               ERDERR                        *//*							       *//*  set_errmsg						       *//*							       *//*  sta_aux_bytestr_free				       *//*							       *//*-------------------------------------------------------------*/intsca_change_pin(sct_id, key_id, sec_mess)	int             sct_id;	KeyId          *key_id;	SecMess        *sec_mess;{	/*----------------------------------------------------------*/	/* Definitions					       */	/*----------------------------------------------------------*/	int             rc;	char            sct_keyid;	/* char representation of the key_id */	/*----------------------------------------------------------*/	/* Statements					       */	/*----------------------------------------------------------*/	rc = 0;	sca_errno = M_NOERR;	sca_errmsg = NULL;	sc_expect = TRUE;#ifdef TEST	fprintf(stdout, "\n***** STAMOD-Routine sca_change_pin *****\n\n");	fprintf(stdout, "TRACE of the input parameters : \n");	fprintf(stdout, "sct_id		        : %d\n", sct_id);	print_keyid(key_id);	print_secmess(sec_mess);	fprintf(stdout, "\n\n");#endif	/*-----------------------------------------------------*/	/* call check_sct_sc    		               */	/*-----------------------------------------------------*/	if (check_sct_sc(sct_id, sc_expect) == -1)		return (-1);	/*-----------------------------------------------------*/	/* Check input parameters			       */	/*-----------------------------------------------------*/	/*-----------------------------------------------------*/	/* Check key_id				       */	/*-----------------------------------------------------*/	if ((key_id->key_level != SC_MF) &&	    (key_id->key_level != SC_DF) &&	    (key_id->key_level != SC_SF)) {		sca_errno = EINVKID;		set_errmsg();		return (-1);	}	if ((key_id->key_number < 1) ||	    (key_id->key_number > MAX_KEYID)) {		sca_errno = EINVKID;		set_errmsg();		return (-1);	}	if ((sct_keyid = get_sct_keyid(key_id)) == -1)	/* get char from key_id */		return (-1);	/*-----------------------------------------------------*/	/* Check sec_mess parameter			       */	/*-----------------------------------------------------*/	if (check_sec_mess(sec_mess) == -1)		return (-1);	/*-----------------------------------------------------*/	/* Prepare parameters for the SCT Interface          */	/*-----------------------------------------------------*/	command = S_CHANGE_PIN;	request.rq_p1.kid = sct_keyid;	request.rq_p2.sec_mode = sec_mess;	/*-----------------------------------------------------*/	/* Call SCT Interface     			       */	/*-----------------------------------------------------*/	rc = sct_interface(sct_id, command, &request, &response);	if (rc < 0) {		sca_errno = sct_errno;		sca_errmsg = sct_errmsg;		err_analyse(sct_id);		return (-1);	}	/*-----------------------------------------------------*/	/* Normal End	 (Release storage)		       */	/*-----------------------------------------------------*/	sta_aux_bytestr_free(&response);#ifdef TEST	fprintf(stdout, "\n***** Normal end of   sca_change_pin *********************************************\n\n");#endif	return (sca_errno);}				/* end sca_change_pin *//*-------------------------------------------------------------*//* E N D   O F	 P R O C E D U R E	sca_change_pin	       *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//*						         | GMD *//*						         +-----*//* PROC  sca_check_pin	          VERSION   1.0	    	       *//*				     DATE   Januar 1992	       *//*			      	       BY   U.Viebeg           *//*							       *//* DESCRIPTION						       *//*  PIN authentication			                       *//*  A smartcard must be inserted.		               *//*							       *//*							       *//* IN			     DESCRIPTION		       *//*   sct_id		       SCT identifier		       *//*                                                             *//*   key_id	               key_id of the PIN to be         *//*                             changed		               *//*                                                             *//*   sec_mess	               Specification of the security   *//*			       mode(s) for the command and     *//*			       response exchange between SCT   *//*			       and smartcard.                  *//*							       *//* OUT							       *//*							       *//*							       *//* RETURN		     DESCRIPTION	      	       *//*   0	         	       o.k			       *//*  -1			       error			       *//*				 EINVKID		       */

⌨️ 快捷键说明

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