📄 staauth.c
字号:
sca_errno = M_EKEYDEV; set_errmsg(); return (-1); } if ((key_dev_purpose->key_purpose.authenticate == FALSE) && (key_dev_purpose->key_purpose.sec_mess_auth == FALSE) && (key_dev_purpose->key_purpose.sec_mess_con == FALSE)) { sca_errno = M_EKEYDEV; set_errmsg(); return (-1); }/************** input parameter check done *********************************/ /*-----------------------------------------------------*/ /* call check_sct_sc */ /*-----------------------------------------------------*/ if (check_sct_sc(sct_id, FALSE) == -1) return (-1); /*-----------------------------------------------------*/ /* Generate key (S_GEN_DEV_KEY) */ /*-----------------------------------------------------*/ /*-----------------------------------------------------*/ /* Prepare parameters for the SCT Interface */ /* */ /*-----------------------------------------------------*/ command = S_GEN_DEV_KEY; request.rq_p1.kid = sct_keyid; request.rq_p2.algid = sct_algid; sct_devkeyinfo.purpose = key_dev_purpose->key_purpose; sct_devkeyinfo.status = key_dev_purpose->key_dev_status; sct_devkeyinfo.type = key_dev_purpose->key_type; request.rq_datafield.dev_key_info = &sct_devkeyinfo; /*-----------------------------------------------------*/ /* 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); } /*-----------------------------------------------------*/ /* (Release storage) */ /*-----------------------------------------------------*/ sta_aux_bytestr_free(&response);#ifdef TEST fprintf(stdout, "\n***** Normal end of sca_gen_dev_key *********************************************\n\n");#endif return (sca_errno);} /* end sca_gen_dev_key *//*-------------------------------------------------------------*//* E N D O F P R O C E D U R E sca_gen_dev_key *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//* | GMD *//* +-----*//* PROC sca_inst_dev_key VERSION 1.0 *//* DATE August 1992 *//* BY L.Eckstein *//* *//* DESCRIPTION *//* Install device key (DES ) on SC *//* *//* *//* *//* *//* IN DESCRIPTION *//* sct_id SCT identifier *//* *//* key_dev_sel Structure which determines the *//* device key. *//* key_attr_list Structure which contains *//* additional information for *//* storing the device key on *//* the SC *//* *//* *//* OUT *//* *//* *//* RETURN DESCRIPTION *//* 0 o.k *//* -1 error *//* M_EPAR *//* 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_key_attr_list ERROR-Codes *//* M_EKEYATTR *//* *//* 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_inst_dev_key(sct_id, key_dev_sel, key_attr_list) int sct_id; KeyDevSel *key_dev_sel; KeyAttrList *key_attr_list;{ /*----------------------------------------------------------*/ /* Definitions */ /*----------------------------------------------------------*/ int i; int rc; char sct_keyid; /* char representation of the key_id */ DevInstKey sct_devinstkey; /*----------------------------------------------------------*/ /* Statements */ /*----------------------------------------------------------*/ rc = 0; sca_errno = M_NOERR; sca_errmsg = NULL;#ifdef TEST fprintf(stdout, "\n***** STAMOD-Routine sca_inst_dev_key *****\n\n"); fprintf(stdout, "TRACE of the input parameters : \n"); fprintf(stdout, "sct_id : %d\n", sct_id); print_keydevsel(key_dev_sel); print_keyattrlist(key_attr_list);#endif /*-----------------------------------------------------*/ /* Check input parameters */ /*-----------------------------------------------------*/ /*-----------------------------------------------------*/ /* check key_dev_sel */ /*-----------------------------------------------------*/ if (key_dev_sel == NULL) { sca_errno = M_EPAR; set_errmsg(); return (-1); } /*-----------------------------------------------------*/ /* check key_status and Key_id (only DEV_ANY allowed) */ /*-----------------------------------------------------*/ switch (key_dev_sel->key_status) { case DEV_ANY: if ((sct_keyid = get_sct_keyid(&key_dev_sel->dev_ref.key_id)) == -1) return (-1); if (key_dev_sel->dev_ref.key_id.key_level == SCT) { sca_errno = EINVKID; set_errmsg(); return (-1); }; sct_devinstkey.pval.kid = sct_keyid; break; default: sca_errno = M_EPAR; set_errmsg(); return (-1); } /*-----------------------------------------------------*/ /* key shall be installed on the SC, */ /* then - check key attribute list */ /*-----------------------------------------------------*/ if (check_key_attr_list(DEVICE_KEY, key_attr_list) == -1) return (-1);/************** input parameter check done *********************************/ /*-----------------------------------------------------*/ /* call check_sct_sc */ /*-----------------------------------------------------*/ if (check_sct_sc(sct_id, TRUE) == -1) return (-1); /*-----------------------------------------------------*/ /* Generate key (S_INST_DEV_KEY) */ /*-----------------------------------------------------*/ /*-----------------------------------------------------*/ /* Prepare parameters for the SCT Interface */ /* */ /*-----------------------------------------------------*/ command = S_INST_DEV_KEY; request.rq_p1.dev_inst_key = &sct_devinstkey; request.rq_p2.status = key_dev_sel->key_status; request.rq_datafield.keyattrlist = key_attr_list; /*-----------------------------------------------------*/ /* 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); } /*-----------------------------------------------------*/ /* (Release storage) */ /*-----------------------------------------------------*/ sta_aux_bytestr_free(&response);#ifdef TEST fprintf(stdout, "\n***** Normal end of sca_inst_dev_key *********************************************\n\n");#endif return (sca_errno);} /* end sca_inst_dev_key *//*-------------------------------------------------------------*//* E N D O F P R O C E D U R E sca_inst_dev_key *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//* | GMD *//* +-----*//* PROC sca_del_dev_key VERSION 1.0 *//* DATE August 1992 *//* BY L.Eckstein *//* *//* DESCRIPTION *//* Delete device key (DES ) in SCT *//* *//* *//* *//* *//* IN DESCRIPTION *//* sct_id SCT identifier *//* *//* key_dev_sel Structure which determines the *//* device key. *//* *//* *//* OUT *//* *//* *//* RETURN DESCRIPTION *//* 0 o.k *//* -1 error *//* M_EKEYDEV *//* EINVKID *//* M_EPAR *//* *//* 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 *//* *//* 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -