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

📄 api_interface.c

📁 IBM的Linux上的PKCS#11实现
💻 C
📖 第 1 页 / 共 5 页
字号:
      st_err_log(5, __FILE__, __LINE__, __FUNCTION__);       return CKR_ARGUMENTS_BAD;   }   // Get local pointers to session   slotID = rSession.slotID;   sltp = &(Anchor->SltList[slotID]);   if (sltp->DLLoaded == FALSE ){      st_err_log(50, __FILE__, __LINE__);            return CKR_TOKEN_NOT_PRESENT;   }   if ( (fcn=sltp->FcnList) == NULL ){      st_err_log(50, __FILE__, __LINE__);      return CKR_TOKEN_NOT_PRESENT;   }   if (fcn->ST_DecryptDigestUpdate){      // Map the Session to the slot session      rv = fcn->ST_DecryptDigestUpdate(rSession,pEncryptedPart,ulEncryptedPartLen,pPart,pulPartLen);      LOGIT(LOG_DEBUG,"Called STDLL rv = 0x%x",rv);   } else {      st_err_log(142, __FILE__, __LINE__, __FUNCTION__);       rv = CKR_FUNCTION_NOT_SUPPORTED;   }   return rv;}//------------------------------------------------------------------------// API function C_DecryptFinal//------------------------------------------------------------------------//  Netscape Required////////------------------------------------------------------------------------CK_RV CK_ENTRY C_DecryptFinal ( CK_SESSION_HANDLE hSession,                       CK_BYTE_PTR       pLastPart,                       CK_ULONG_PTR      pulLastPartLen                     ){   CK_RV   rv;   API_Slot_t  *sltp;   STDLL_FcnList_t  *fcn;   CK_SLOT_ID        slotID;   Session_Struct_t   *sessp;   ST_SESSION_T rSession;   LOG("C_DecryptFinal");   if (API_Initialized() == FALSE ){      st_err_log(72, __FILE__, __LINE__);      return CKR_CRYPTOKI_NOT_INITIALIZED;   }   // Validate Session   if (!Valid_Session((Session_Struct_t *)hSession,&rSession)){      st_err_log(40, __FILE__, __LINE__);      return CKR_SESSION_HANDLE_INVALID;   }   // This may have to go to the STDLL for validation    // It is acceptable to have a Null pointer for the data since   // it is trying to get the length of the last part....   // The spec is unclear if a second call to Final is needed   // if there is no data in the last part.   if (!pulLastPartLen ){      st_err_log(5, __FILE__, __LINE__, __FUNCTION__);       return CKR_ARGUMENTS_BAD;   }   // Get local pointers to session   slotID = rSession.slotID;   sltp = &(Anchor->SltList[slotID]);   if (sltp->DLLoaded == FALSE ){      st_err_log(50, __FILE__, __LINE__);            return CKR_TOKEN_NOT_PRESENT;   }   if ( (fcn=sltp->FcnList) == NULL ){      st_err_log(50, __FILE__, __LINE__);      return CKR_TOKEN_NOT_PRESENT;   }   if (fcn->ST_DecryptFinal){      // Map the Session to the slot session      rv = fcn->ST_DecryptFinal(rSession,pLastPart,pulLastPartLen);      LOGIT(LOG_DEBUG,"Called STDLL rv = 0x%x",rv);   } else {      st_err_log(142, __FILE__, __LINE__, __FUNCTION__);       rv = CKR_FUNCTION_NOT_SUPPORTED;   }   return rv;} // end of C_DecryptFinal//------------------------------------------------------------------------// API function C_DecryptInit//------------------------------------------------------------------------////////------------------------------------------------------------------------CK_RV CK_ENTRY C_DecryptInit ( CK_SESSION_HANDLE hSession,                      CK_MECHANISM_PTR  pMechanism,                      CK_OBJECT_HANDLE  hKey                    ){   CK_RV   rv;   API_Slot_t  *sltp;   STDLL_FcnList_t  *fcn;   CK_SLOT_ID        slotID;   Session_Struct_t   *sessp;   ST_SESSION_T rSession;   LOG("C_DecryptInit");   if (API_Initialized() == FALSE ){      st_err_log(72, __FILE__, __LINE__);      return CKR_CRYPTOKI_NOT_INITIALIZED;   }   // Validate Session   if (!Valid_Session((Session_Struct_t *)hSession,&rSession)){      st_err_log(40, __FILE__, __LINE__);      return CKR_SESSION_HANDLE_INVALID;   }   // Null mechanism pointer is not good   if ( !pMechanism ) {      st_err_log(28, __FILE__, __LINE__);       return CKR_MECHANISM_INVALID;   }   // Get local pointers to session   slotID = rSession.slotID;   sltp = &(Anchor->SltList[slotID]);   if (sltp->DLLoaded == FALSE ){      st_err_log(50, __FILE__, __LINE__);            return CKR_TOKEN_NOT_PRESENT;   }   if ( (fcn=sltp->FcnList) == NULL ){      st_err_log(50, __FILE__, __LINE__);      return CKR_TOKEN_NOT_PRESENT;   }   if (fcn->ST_DecryptInit){      // Map the Session to the slot session      rv = fcn->ST_DecryptInit(rSession,pMechanism,hKey);      LOGIT(LOG_DEBUG,"Called STDLL rv = 0x%x",rv);   } else {      st_err_log(142, __FILE__, __LINE__, __FUNCTION__);       rv = CKR_FUNCTION_NOT_SUPPORTED;   }   return rv;} // end of C_DecryptInit//------------------------------------------------------------------------// API function C_DecryptUpdate//------------------------------------------------------------------------////////------------------------------------------------------------------------CK_RV CK_ENTRY C_DecryptUpdate ( CK_SESSION_HANDLE hSession,                        CK_BYTE_PTR       pEncryptedPart,                        CK_ULONG          ulEncryptedPartLen,                        CK_BYTE_PTR       pPart,                        CK_ULONG_PTR      pulPartLen                      ){   CK_RV   rv;   API_Slot_t  *sltp;   STDLL_FcnList_t  *fcn;   CK_SLOT_ID        slotID;   Session_Struct_t   *sessp;   ST_SESSION_T rSession;   LOG("C_DecryptUpdate");   if (API_Initialized() == FALSE ){      st_err_log(72, __FILE__, __LINE__);      return CKR_CRYPTOKI_NOT_INITIALIZED;   }   // Validate Session   if (!Valid_Session((Session_Struct_t *)hSession,&rSession)){      st_err_log(40, __FILE__, __LINE__);      return CKR_SESSION_HANDLE_INVALID;   }   // May have to let these go through and let the STDLL handle them   if ( !pEncryptedPart ||  !pulPartLen ){      st_err_log(5, __FILE__, __LINE__, __FUNCTION__);       return CKR_ARGUMENTS_BAD;   }   // Get local pointers to session   slotID = rSession.slotID;   sltp = &(Anchor->SltList[slotID]);   if (sltp->DLLoaded == FALSE ){      st_err_log(50, __FILE__, __LINE__);            return CKR_TOKEN_NOT_PRESENT;   }   if ( (fcn=sltp->FcnList) == NULL ){      st_err_log(50, __FILE__, __LINE__);      return CKR_TOKEN_NOT_PRESENT;   }   if (fcn->ST_DecryptUpdate){      // Map the Session to the slot session      rv = fcn->ST_DecryptUpdate(rSession,pEncryptedPart,ulEncryptedPartLen,pPart,pulPartLen);      LOGIT(LOG_DEBUG,"Called STDLL rv = 0x%x",rv);   } else {      st_err_log(142, __FILE__, __LINE__, __FUNCTION__);       rv = CKR_FUNCTION_NOT_SUPPORTED;   }   return rv;} // end of C_DecryptUpdate//------------------------------------------------------------------------// API function C_DecryptVerifyUpdate //------------------------------------------------------------------------CK_RV CK_ENTRY C_DecryptVerifyUpdate ( CK_SESSION_HANDLE hSession,                              CK_BYTE_PTR       pEncryptedPart,                              CK_ULONG          ulEncryptedPartLen,                              CK_BYTE_PTR       pPart,                              CK_ULONG_PTR      pulPartLen                            ){   CK_RV   rv;   API_Slot_t  *sltp;   STDLL_FcnList_t  *fcn;   CK_SLOT_ID        slotID;   Session_Struct_t   *sessp;   ST_SESSION_T rSession;   LOG("C_DecryptVerifyUpdate");   if (API_Initialized() == FALSE ){      st_err_log(72, __FILE__, __LINE__);      return CKR_CRYPTOKI_NOT_INITIALIZED;   }   // Validate Session   if (!Valid_Session((Session_Struct_t *)hSession,&rSession)){      st_err_log(40, __FILE__, __LINE__);      return CKR_SESSION_HANDLE_INVALID;   }   // May have to let these go through and let the STDLL handle them   if ( !pEncryptedPart || !pulPartLen ){      st_err_log(5, __FILE__, __LINE__, __FUNCTION__);       return CKR_ARGUMENTS_BAD;   }   // Get local pointers to session   slotID = rSession.slotID;   sltp = &(Anchor->SltList[slotID]);   if (sltp->DLLoaded == FALSE ){      st_err_log(50, __FILE__, __LINE__);            return CKR_TOKEN_NOT_PRESENT;   }   if ( (fcn=sltp->FcnList) == NULL ){      st_err_log(50, __FILE__, __LINE__);      return CKR_TOKEN_NOT_PRESENT;   }   if (fcn->ST_DecryptVerifyUpdate){      // Map the Session to the slot session      rv = fcn->ST_DecryptVerifyUpdate(rSession,pEncryptedPart,ulEncryptedPartLen,pPart,pulPartLen);      LOGIT(LOG_DEBUG,"Called STDLL rv = 0x%x",rv);   } else {      st_err_log(142, __FILE__, __LINE__, __FUNCTION__);       rv = CKR_FUNCTION_NOT_SUPPORTED;   }   return rv;}//------------------------------------------------------------------------// API function C_DeriveKey   //------------------------------------------------------------------------CK_RV CK_ENTRY C_DeriveKey ( CK_SESSION_HANDLE    hSession,                    CK_MECHANISM_PTR     pMechanism,                    CK_OBJECT_HANDLE     hBaseKey,                    CK_ATTRIBUTE_PTR     pTemplate,                    CK_ULONG             ulAttributeCount,                    CK_OBJECT_HANDLE_PTR phKey                  ){   CK_RV   rv;   API_Slot_t  *sltp;   STDLL_FcnList_t  *fcn;   CK_SLOT_ID        slotID;   Session_Struct_t   *sessp;   ST_SESSION_T rSession;   LOG("C_DeriveKey");   if (API_Initialized() == FALSE ){      st_err_log(72, __FILE__, __LINE__);      return CKR_CRYPTOKI_NOT_INITIALIZED;   }   // Validate Session   if (!Valid_Session((Session_Struct_t *)hSession,&rSession)){      st_err_log(40, __FILE__, __LINE__);      return CKR_SESSION_HANDLE_INVALID;   }   // Null phKey is invalid   // Null mechanism pointer  is invalid   // This is allowed for some SSL3 mechs.  the STDLL has to catch this   // condition since it validates the mechanism   //if (!phKey ) return CKR_ARGUMENTS_BAD;   if  (!pMechanism ){      st_err_log(28, __FILE__, __LINE__);       return CKR_MECHANISM_INVALID;   }   // Null template with attribute count is bad   //  but we will let a template with len 0 pass through   if (!pTemplate && ulAttributeCount ){      st_err_log(5, __FILE__, __LINE__, __FUNCTION__);       return CKR_ARGUMENTS_BAD;   }   // Get local pointers to session   slotID = rSession.slotID;   sltp = &(Anchor->SltList[slotID]);   if (sltp->DLLoaded == FALSE ){      st_err_log(50, __FILE__, __LINE__);            return CKR_TOKEN_NOT_PRESENT;   }   if ( (fcn=sltp->FcnList) == NULL ){      st_err_log(50, __FILE__, __LINE__);      return CKR_TOKEN_NOT_PRESENT;   }   if (fcn->ST_DeriveKey){      // Map the Session to the slot session      rv = fcn->ST_DeriveKey(rSession,pMechanism,hBaseKey,pTemplate,ulAttributeCount,phKey);      LOGIT(LOG_DEBUG,"Called STDLL rv = 0x%x",rv);   } else {      st_err_log(142, __FILE__, __LINE__, __FUNCTION__);       rv = CKR_FUNCTION_NOT_SUPPORTED;   }   return rv;}//------------------------------------------------------------------------// API function C_DestroyObject//------------------------------------------------------------------------//  Netscape Required////////------------------------------------------------------------------------CK_RV CK_ENTRY C_DestroyObject ( CK_SESSION_HANDLE hSession,                        CK_OBJECT_HANDLE  hObject                      ){   CK_RV   rv;   API_Slot_t  *sltp;   STDLL_FcnList_t  *fcn;   CK_SLOT_ID        slotID;   Session_Struct_t   *sessp;   ST_SESSION_T rSession;   LOG("C_DestrypObject");   if (API_Initialized() == FALSE ){      st_err_log(72, __FILE__, __LINE__);      return CKR_CRYPTOKI_NOT_INITIALIZED;   }   // Validate Session   if (!Valid_Session((Session_Struct_t *)hSession,&rSession)){

⌨️ 快捷键说明

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