Ejemplo n.º 1
0
/*
 * C_FindObjectsFinal is a pure wrapper to the underlying provider.
 * The only argument checked is whether or not hSession is valid.
 */
CK_RV
C_FindObjectsFinal(CK_SESSION_HANDLE hSession)
{
    CK_RV rv;
    pkcs11_session_t *sessp;

    /* Check for a fastpath */
    if (purefastpath || policyfastpath) {
        return (fast_funcs->C_FindObjectsFinal(hSession));
    }

    if (!pkcs11_initialized) {
        return (CKR_CRYPTOKI_NOT_INITIALIZED);
    }

    /* Obtain the session pointer */
    HANDLE2SESSION(hSession, sessp, rv);

    if (rv != CKR_OK) {
        return (rv);
    }

    /* Pass data to the provider */
    rv = FUNCLIST(sessp->se_slotid)->C_FindObjectsFinal(sessp->se_handle);

    /* Present consistent interface to the application */
    if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
        return (CKR_FUNCTION_FAILED);
    }

    return (rv);
}
Ejemplo n.º 2
0
/*
 * C_SetAttributeValue is a pure wrapper to the underlying provider.
 * The only argument checked is whether or not hSession is valid.
 */
CK_RV
C_SetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
                    CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
{
    CK_RV rv;
    pkcs11_session_t *sessp;

    /* Check for a fastpath */
    if (purefastpath || policyfastpath) {
        return (fast_funcs->C_SetAttributeValue(hSession, hObject,
                                                pTemplate, ulCount));
    }

    if (!pkcs11_initialized) {
        return (CKR_CRYPTOKI_NOT_INITIALIZED);
    }

    /* Obtain the session pointer */
    HANDLE2SESSION(hSession, sessp, rv);

    if (rv != CKR_OK) {
        return (rv);
    }

    /* Pass data to the provider */
    rv = FUNCLIST(sessp->se_slotid)->C_SetAttributeValue(sessp->se_handle,
            hObject, pTemplate, ulCount);

    /* Present consistent interface to the application */
    if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
        return (CKR_FUNCTION_FAILED);
    }

    return (rv);
}
Ejemplo n.º 3
0
/*
 * C_VerifyRecover is a pure wrapper to the underlying provider.
 * The only argument checked is whether or not hSession is valid.
 */
CK_RV
C_VerifyRecover(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSignature,
    CK_ULONG ulSignatureLen, CK_BYTE_PTR pData, CK_ULONG_PTR pulDataLen)
{
	CK_RV rv;
	pkcs11_session_t *sessp;

	/* Check for a fastpath */
	if (purefastpath || policyfastpath) {
		return (fast_funcs->C_VerifyRecover(hSession, pSignature,
			    ulSignatureLen, pData, pulDataLen));
	}

	if (!pkcs11_initialized) {
		return (CKR_CRYPTOKI_NOT_INITIALIZED);
	}

	/* Obtain the session pointer */
	HANDLE2SESSION(hSession, sessp, rv);

	if (rv != CKR_OK) {
		return (rv);
	}

	/* Pass data to the provider */
	rv = FUNCLIST(sessp->se_slotid)->C_VerifyRecover(sessp->se_handle,
	    pSignature, ulSignatureLen, pData, pulDataLen);

	/* Present consistent interface to the application */
	if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
		return (CKR_FUNCTION_FAILED);
	}

	return (rv);
}
Ejemplo n.º 4
0
/*
 * C_VerifyRecoverInit will verify that the session handle is valid within
 * the framework, that the mechanism is not disabled for the slot
 * associated with this session, and then redirect to the underlying
 * provider.  Policy is only checked for C_VerifyRecoverInit, since it is
 * required to be called before C_VerifyRecover.
 */
CK_RV
C_VerifyRecoverInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
    CK_OBJECT_HANDLE hKey)
{
	CK_RV rv;
	pkcs11_session_t *sessp;
	CK_SLOT_ID slotid;

	/* Check for a fastpath */
	if (purefastpath || policyfastpath) {
		if (policyfastpath &&
		    pkcs11_is_dismech(fast_slot, pMechanism->mechanism)) {
			return (CKR_MECHANISM_INVALID);
		}
		return (fast_funcs->C_VerifyRecoverInit(hSession, pMechanism,
			    hKey));
	}

	if (!pkcs11_initialized) {
		return (CKR_CRYPTOKI_NOT_INITIALIZED);
	}

	/* Obtain the session pointer */
	HANDLE2SESSION(hSession, sessp, rv);

	if (rv != CKR_OK) {
		return (rv);
	}

	slotid = sessp->se_slotid;

	/* Make sure this is not a disabled mechanism */
	if (pkcs11_is_dismech(slotid, pMechanism->mechanism)) {
		return (CKR_MECHANISM_INVALID);
	}

	/* Initialize the digest with the underlying provider */
	rv = FUNCLIST(slotid)->C_VerifyRecoverInit(sessp->se_handle,
	    pMechanism, hKey);

	/* Present consistent interface to the application */
	if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
		return (CKR_FUNCTION_FAILED);
	}

	return (rv);


}
Ejemplo n.º 5
0
/*
 * C_Encrypt is a pure wrapper to the underlying provider.
 * The only argument checked is whether or not hSession is valid.
 */
CK_RV
C_Encrypt(CK_SESSION_HANDLE hSession,
    CK_BYTE_PTR pData,
    CK_ULONG ulDataLen,
    CK_BYTE_PTR pEncryptedData,
    CK_ULONG_PTR pulEncryptedDataLen)
{
	CK_RV rv;
	pkcs11_session_t *sessp;

	/* Check for a fastpath */
	if (purefastpath || policyfastpath) {
		return (fast_funcs->C_Encrypt(hSession, pData, ulDataLen,
			    pEncryptedData, pulEncryptedDataLen));
	}

	if (!pkcs11_initialized) {
		return (CKR_CRYPTOKI_NOT_INITIALIZED);
	}

	/* Obtain the session pointer */
	HANDLE2SESSION(hSession, sessp, rv);

	if (rv != CKR_OK) {
		return (rv);
	}

	/* Initialize the digest with the underlying provider */
	rv = FUNCLIST(sessp->se_slotid)->C_Encrypt(sessp->se_handle, pData,
	    ulDataLen, pEncryptedData, pulEncryptedDataLen);

	/* Present consistent interface to the application */
	if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
		return (CKR_FUNCTION_FAILED);
	}

	return (rv);
}