static int starcos_C_DecryptInit(struct p11Object_t *pObject, CK_MECHANISM_PTR mech) { unsigned char *algotlv; FUNC_CALLED(); FUNC_RETURNS(getAlgorithmIdForDecryption(pObject->token, mech->mechanism, &algotlv)); }
static int sc_hsm_C_DecryptInit(struct p11Object_t *pObject, CK_MECHANISM_PTR mech) { int algo; FUNC_CALLED(); algo = getAlgorithmIdForDecryption(mech->mechanism); if (algo < 0) { FUNC_FAILS(CKR_MECHANISM_INVALID, "Mechanism not supported"); } FUNC_RETURNS(CKR_OK); }
static int sc_hsm_C_Decrypt(struct p11Object_t *pObject, CK_MECHANISM_TYPE mech, CK_BYTE_PTR pEncryptedData, CK_ULONG ulEncryptedDataLen, CK_BYTE_PTR pData, CK_ULONG_PTR pulDataLen) { int rc, algo; unsigned short SW1SW2; unsigned char scr[256]; FUNC_CALLED(); if (pData == NULL) { *pulDataLen = pObject->keysize >> 3; FUNC_RETURNS(CKR_OK); } algo = getAlgorithmIdForDecryption(mech); if (algo < 0) { FUNC_FAILS(CKR_MECHANISM_INVALID, "Mechanism not supported"); } rc = transmitAPDU(pObject->token->slot, 0x80, 0x62, (unsigned char)pObject->tokenid, (unsigned char)algo, ulEncryptedDataLen, pEncryptedData, 0, scr, sizeof(scr), &SW1SW2); if (rc < 0) { FUNC_FAILS(CKR_DEVICE_ERROR, "transmitAPDU failed"); } if (SW1SW2 != 0x9000) { FUNC_FAILS(CKR_ENCRYPTED_DATA_INVALID, "Decryption operation failed"); }