📄 stadev.c
字号:
/* RETURN DESCRIPTION *//* 0 o.k *//* -1 error *//* M_EKEYATTR *//* *//* CALLED FUNCTIONS *//* set_errmsg *//*-------------------------------------------------------------*/intcheck_key_attr_list(kind_of_key, key_attr_list) KindOfKey kind_of_key; KeyAttrList *key_attr_list;{ /*----------------------------------------------------------*/ /* Definitions */ /*----------------------------------------------------------*/#define PURPOSE key_attr_list->key_attr.key_purpose#define PRESENT key_attr_list->key_attr.key_presentation#define OPMODE key_attr_list->key_attr.key_op_mode#define MACLEN key_attr_list->key_attr.MAC_length int rc; /*----------------------------------------------------------*/ /* Statements */ /*----------------------------------------------------------*/ /*-----------------------------------------------------*/ /* Check key attr list */ /*-----------------------------------------------------*/ if (key_attr_list == KEYATTRNULL) { sca_errno = M_EKEYATTR; set_errmsg(); return (-1); } /*-----------------------------------------------------*/ /* Check key install mode */ /*-----------------------------------------------------*/ if ((key_attr_list->key_inst_mode != INST) && (key_attr_list->key_inst_mode != REPL)) { sca_errno = M_EKEYATTR; set_errmsg(); return (-1); } /*-----------------------------------------------------*/ /* Check key purpose depending on kind of key : */ /* */ /* USER_KEY: key_purpose is set by this function: */ /* key_purpose.authenticate to FALSE */ /* key_purpose.sec_mess_auth to FALSE */ /* key_purpose.sec_mess_con to FALSE */ /* key_purpose.cipherment to TRUE */ /* */ /* PIN_KEY: key_purpose is set by this function: */ /* key_purpose.authenticate to TRUE */ /* key_purpose.sec_mess_auth to FALSE */ /* key_purpose.sec_mess_con to FALSE */ /* key_purpose.cipherment to FALSE */ /* */ /* */ /* PUK_KEY: see PIN_KEY */ /* */ /* DEVICE_KEY: */ /* At least one of the following three */ /* must be set to TRUE: */ /* 1) key_purpose.authenticate, */ /* 2) key_purpose.sec_mess_auth, */ /* 3) key_purpose.sec_mess_con, */ /* key_purpose.cipherment must be FALSE */ /*-----------------------------------------------------*/ switch (kind_of_key) { case USER_KEY: PURPOSE.authenticate = FALSE; PURPOSE.sec_mess_auth = FALSE; PURPOSE.sec_mess_con = FALSE; PURPOSE.cipherment = TRUE; break; case PIN_KEY: case PUK_KEY: PURPOSE.authenticate = TRUE; PURPOSE.sec_mess_auth = FALSE; PURPOSE.sec_mess_con = FALSE; PURPOSE.cipherment = FALSE; break; case DEVICE_KEY: if (((PURPOSE.authenticate != TRUE) && (PURPOSE.sec_mess_auth != TRUE) && (PURPOSE.sec_mess_con != TRUE)) || (PURPOSE.cipherment != FALSE)) { sca_errno = M_EKEYATTR; set_errmsg(); return (-1); } break; default: sca_errno = M_EKEYATTR; set_errmsg(); return (-1); } /* end case */ /*-----------------------------------------------------*/ /* Check key presentation */ /*-----------------------------------------------------*/ if ((PRESENT != KEY_GLOBAL) && (PRESENT != KEY_LOCAL)) { sca_errno = M_EKEYATTR; set_errmsg(); return (-1); } /*-----------------------------------------------------*/ /* Check key operation mode */ /*-----------------------------------------------------*/ if ((OPMODE != REPLACE) && (OPMODE != NO_REPLACE)) { sca_errno = M_EKEYATTR; set_errmsg(); return (-1); } /*-----------------------------------------------------*/ /* Set MAC length */ /*-----------------------------------------------------*/ MACLEN = 4; /*-----------------------------------------------------*/ /* Check key fault presentation counter */ /* If key is not an authentication key, key_fpc */ /* is set to 0 by this function. */ /*-----------------------------------------------------*/ if (PURPOSE.authenticate == FALSE) key_attr_list->key_fpc = 0; else { if ((key_attr_list->key_fpc < 0) || (key_attr_list->key_fpc > MAX_KPFC)) { sca_errno = M_EKEYATTR; set_errmsg(); return (-1); } } /* end else */ /*-----------------------------------------------------*/ /* Check key status */ /* If kind_of_key is not PIN or PUK, */ /* key_status.PIN_check is set to FALSE. */ /*-----------------------------------------------------*/ if ((kind_of_key == PIN_KEY) || (kind_of_key == PUK_KEY)) { if ((key_attr_list->key_status.PIN_check != FALSE) && (key_attr_list->key_status.PIN_check != TRUE)) { sca_errno = M_EKEYATTR; set_errmsg(); return (-1); } } else key_attr_list->key_status.PIN_check = FALSE; if ((key_attr_list->key_status.key_state != KEY_NORMAL) && (key_attr_list->key_status.key_state != KEY_LOCKED)) { sca_errno = M_EKEYATTR; set_errmsg(); return (-1); } /*-----------------------------------------------------*/ /* Normal End */ /*-----------------------------------------------------*/ return (0);}/*-------------------------------------------------------------*//* E N D O F P R O C E D U R E check_key_attr_list *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//* | GMD *//* +-----*//* PROC check_sec_mess VERSION 1.0 *//* DATE Januar 1992 *//* BY Ursula Viebeg *//* *//* DESCRIPTION *//* Check security modes for command and response *//* *//* *//* IN DESCRIPTION *//* sec_mess security mode(s) *//* *//* *//* OUT *//* *//* *//* RETURN DESCRIPTION *//* 0 o.k *//* -1 error *//* M_ESECMESS *//* *//* CALLED FUNCTIONS *//* set_errmsg *//*-------------------------------------------------------------*/intcheck_sec_mess(sec_mess) SecMess *sec_mess;{ /*----------------------------------------------------------*/ /* Definitions */ /*----------------------------------------------------------*/ int rc; /*----------------------------------------------------------*/ /* Statements */ /*----------------------------------------------------------*/ if ((sec_mess->command != SEC_NORMAL) && (sec_mess->command != AUTHENTIC) && (sec_mess->command != CONCEALED) && (sec_mess->command != COMBINED)) { sca_errno = M_ESECMESS; set_errmsg(); return (-1); } if ((sec_mess->response != SEC_NORMAL) && (sec_mess->response != AUTHENTIC) && (sec_mess->response != CONCEALED) && (sec_mess->response != COMBINED)) { sca_errno = M_ESECMESS; set_errmsg(); return (-1); } /*-----------------------------------------------------*/ /* Normal End */ /*-----------------------------------------------------*/ return (0);}/*-------------------------------------------------------------*//* E N D O F P R O C E D U R E check_sec_mess *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//* | GMD *//* +-----*//* PROC set_errmsg VERSION 1.0 *//* DATE Januar 1992 *//* BY U.Viebeg *//* *//* DESCRIPTION *//* sets global sca_errmsg according to the global error *//* variable sca_errno *//* *//* *//* IN DESCRIPTION *//* OUT *//* *//* *//* RETURN DESCRIPTION *//* 0 o.k *//* *//* CALLED FUNCTIONS *//* sct_get_errmsg *//* *//*-------------------------------------------------------------*/intset_errmsg(){ /*----------------------------------------------------------*/ /* Definitions */ /*----------------------------------------------------------*/ unsigned int err_no; int rc; /*----------------------------------------------------------*/ /* Statements */ /*----------------------------------------------------------*/ /*-----------------------------------------------------*/ /* if value of sca_errno is invalid */ /* then initialize sca_errno and sca_errmsg */ /*-----------------------------------------------------*/ if (sca_errno <= 0) { sca_errno = 0; sca_errmsg = NULL; return (M_NOERR); } /*-----------------------------------------------------*/ /* if sca_errno < MIN_STAMOD_ERRNO */ /* then take error list of the SCT Interface */ /* else take error list of STAMOD */ /*-----------------------------------------------------*/ if (sca_errno < MIN_STAMOD_ERRNO) { err_no = sca_errno; /* error from SCT-Interface */ sct_get_errmsg(err_no); sca_errmsg = sct_errmsg; } else { /* error from STAMOD */ err_no = sca_errno - MIN_STAMOD_ERRNO; if (err_no >= 0) sca_errmsg = stamod_error[err_no].msg; else sca_errmsg = NULL; } /* end else */ return (0);} /* end set_errmsg *//*-------------------------------------------------------------*//* E N D O F P R O C E D U R E set_errmsg *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//* | GMD *//* +-----*//* PROC err_analyse VERSION 1.0 *//* DATE Januar 1992 *//* BY Levona Eckstein *//* *//* DESCRIPTION *//* Error analyse and error handling *//* *//* *//* IN DESCRIPTION *//* sct_id SCT identifier *//* *//* OUT *//* *//* *//* RETURN DESCRIPTION *//* *//* CALLED FUNCTIONS *//* sct_close ERROR-Codes *//* ENOSHELL *//* EOPERR *//* EEMPTY *//* ECLERR *//* ESIDUNK *//* ERDERR *//* *//* *//*-------------------------------------------------------------*/voiderr_analyse(sct_id) int sct_id;{ /*----------------------------------------------------------*/ /* Definitions */ /*----------------------------------------------------------*/ /*----
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -