📄 staauth.c
字号:
/* *//* IN DESCRIPTION *//* sct_id SCT identifier *//* *//* auth_proc_id Identifier of the authentication*//* procedure: *//* des_auth (4) *//* *//* auth_object_id Identifier of the object to be *//* authenticated: *//* smartcard (2), *//* sct (3), *//* sct_sc (5), *//* INITIAL (6), *//* *//* OUT *//* *//* *//* RETURN DESCRIPTION *//* 0 o.k *//* -1 error *//* M_EPROCID *//* M_EOBJECTID *//* *//* 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 *//* ESIDUNK *//* ERDERR */ /* *//* set_errmsg *//* *//* sta_aux_bytestr_free *//* *//*-------------------------------------------------------------*/intsca_auth(sct_id, auth_proc_id, auth_object_id) int sct_id; AuthProcId auth_proc_id; AuthObjectId auth_object_id;{ /*----------------------------------------------------------*/ /* Definitions */ /*----------------------------------------------------------*/ int rc; unsigned int acp; /*----------------------------------------------------------*/ /* Statements */ /*----------------------------------------------------------*/ rc = 0; sca_errno = M_NOERR; sca_errmsg = NULL; sc_expect = TRUE;#ifdef TEST fprintf(stdout, "\n***** STAMOD-Routine sca_auth *****\n\n"); fprintf(stdout, "TRACE of the input parameters : \n"); fprintf(stdout, "sct_id : %d\n", sct_id); fprintf(stdout, "auth_proc_id : %d\n", auth_proc_id); fprintf(stdout, "auth_object_id : %d\n", auth_object_id); fprintf(stdout, "\n\n");#endif /*-----------------------------------------------------*/ /* call check_sct_sc */ /*-----------------------------------------------------*/ if (check_sct_sc(sct_id, sc_expect) == -1) return (-1); /*-----------------------------------------------------*/ /* Check input parameters */ /*-----------------------------------------------------*/ /*-----------------------------------------------------*/ /* Check auth_proc_id and auth_object_id and */ /* set acp */ /*-----------------------------------------------------*/ if (auth_proc_id == des_auth) { if (auth_object_id == smartcard) acp = SC_DES; else if (auth_object_id == sct) acp = SCT_DES; else if (auth_object_id == sct_sc) acp = SC_SCT_DES; else if (auth_object_id == INITIAL) acp = SCT_INITIAL; else { sca_errno = M_EOBJECTID; set_errmsg(); return (-1); } } /* end if (auth_proc_id == des_auth) */ else { sca_errno = M_EPROCID; set_errmsg(); return (-1); } /* end else */ /*-----------------------------------------------------*/ /* Prepare parameters for the SCT Interface */ /*-----------------------------------------------------*/ command = S_AUTH; request.rq_p1.kid = 0x00; request.rq_p2.acp = acp; /*-----------------------------------------------------*/ /* 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_auth *********************************************\n\n");#endif return (sca_errno);} /* end sca_auth *//*-------------------------------------------------------------*//* E N D O F P R O C E D U R E sca_auth *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//* | GMD *//* +-----*//* PROC sca_gen_dev_key VERSION 1.0 *//* DATE August 1992 *//* BY L.Eckstein *//* *//* DESCRIPTION *//* Generate device key (DES ) *//* *//* *//* *//* *//* IN DESCRIPTION *//* sct_id SCT identifier *//* *//* key_id Key-id which determines the *//* generated key. *//* *//* alg_id Algorithm Identifier *//* The following values are *//* possible: *//* desCBC *//* *//* key_dev_purpose Structure which contains *//* the purpose, the status and *//* the type of the generated key *//* *//* OUT *//* *//* *//* RETURN DESCRIPTION *//* 0 o.k *//* -1 error *//* EINVKID *//* EINVALGID *//* M_EKEYDEV *//* *//* 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_algid ERROR-Codes *//* EINVALGID *//* EKEYLENINV *//* *//* get_sct_keyid ERROR-Codes *//* EINVKID *//* *//* get_alg_number ERROR-Codes *//* (only in case of TEST) EINVALGID *//* *//* 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_gen_dev_key(sct_id, key_id, alg_id, key_dev_purpose) int sct_id; KeyId *key_id; AlgId *alg_id; KeyDevPurpose *key_dev_purpose;{ /*----------------------------------------------------------*/ /* Definitions */ /*----------------------------------------------------------*/ int i; int rc; char sct_keyid; /* char representation of the key_id */ KeyAlgId sct_algid; /* SCT specific alg_id */ DevKeyInfo sct_devkeyinfo; /*----------------------------------------------------------*/ /* Statements */ /*----------------------------------------------------------*/ rc = 0; sca_errno = M_NOERR; sca_errmsg = NULL;#ifdef TEST fprintf(stdout, "\n***** STAMOD-Routine sca_gen_dev_key *****\n\n"); fprintf(stdout, "TRACE of the input parameters : \n"); fprintf(stdout, "sct_id : %d\n", sct_id); print_keyid(key_id); switch (aux_ObjId2AlgEnc(alg_id->objid)) { case DES: fprintf(stdout, "alg_id : DES-CBC\n"); break; default: fprintf(stdout, "alg_id : not supported\n"); break; } print_keydevpurpose(key_dev_purpose);#endif /*-----------------------------------------------------*/ /* Check input parameters */ /*-----------------------------------------------------*/ /*-----------------------------------------------------*/ /* check key_id and get keyid in char representation */ /*-----------------------------------------------------*/ if ((sct_keyid = get_sct_keyid(key_id)) == -1) return (-1); if (key_id->key_level == SCT) { sca_errno = EINVKID; set_errmsg(); return (-1); } /*-----------------------------------------------------*/ /* check algid and get sct specific alg_id */ /*-----------------------------------------------------*/ if ((sct_algid = get_sct_algid(alg_id)) == -1) return (-1); if (sct_algid != S_DES_CBC) { sca_errno = EINVALGID; set_errmsg(); return (-1); } /*-----------------------------------------------------*/ /* check key_dev_purpose */ /*-----------------------------------------------------*/ if (key_dev_purpose == NULL) { sca_errno = M_EKEYDEV; set_errmsg(); return (-1); } if (((key_dev_purpose->key_purpose.authenticate != TRUE) && (key_dev_purpose->key_purpose.authenticate != FALSE)) || ((key_dev_purpose->key_purpose.sec_mess_auth != TRUE) && (key_dev_purpose->key_purpose.sec_mess_auth != FALSE)) || ((key_dev_purpose->key_purpose.sec_mess_con != TRUE) && (key_dev_purpose->key_purpose.sec_mess_con != FALSE)) || (key_dev_purpose->key_dev_status != DEV_ANY) || (key_dev_purpose->key_type != MASTER)) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -