Added basic version of login.
This commit is contained in:
@@ -248,6 +248,8 @@ typedef CK_ULONG CK_USER_TYPE;
|
|||||||
#define CKU_SO 0
|
#define CKU_SO 0
|
||||||
/* Normal user */
|
/* Normal user */
|
||||||
#define CKU_USER 1
|
#define CKU_USER 1
|
||||||
|
/* Context specific */
|
||||||
|
#define CKU_CONTEXT_SPECIFIC 2
|
||||||
|
|
||||||
|
|
||||||
/* CK_STATE enumerates the session states */
|
/* CK_STATE enumerates the session states */
|
||||||
|
|||||||
+26
-2
@@ -42,7 +42,7 @@ static ykcs11_slot_t slots[YKCS11_MAX_SLOTS];
|
|||||||
static CK_ULONG n_slots = 0;
|
static CK_ULONG n_slots = 0;
|
||||||
static CK_ULONG n_tokenless_slots = 0;
|
static CK_ULONG n_tokenless_slots = 0;
|
||||||
|
|
||||||
extern CK_FUNCTION_LIST function_list;
|
extern CK_FUNCTION_LIST function_list; // TODO: check all return values
|
||||||
|
|
||||||
/* General Purpose */
|
/* General Purpose */
|
||||||
|
|
||||||
@@ -464,7 +464,31 @@ CK_DEFINE_FUNCTION(CK_RV, C_Login)(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
DIN;
|
DIN;
|
||||||
DBG(("TODO!!!"));
|
CK_ULONG tries;
|
||||||
|
|
||||||
|
if (piv_state == NULL)
|
||||||
|
return CKR_CRYPTOKI_NOT_INITIALIZED;
|
||||||
|
|
||||||
|
if (userType != CKU_USER &&
|
||||||
|
userType != CKU_SO &&
|
||||||
|
userType != CKU_CONTEXT_SPECIFIC)
|
||||||
|
return CKR_ARGUMENTS_BAD;
|
||||||
|
|
||||||
|
if (ulPinLen < PIV_MIN_PIN_LEN ||
|
||||||
|
ulPinLen > PIV_MAX_PIN_LEN)
|
||||||
|
return CKR_ARGUMENTS_BAD;
|
||||||
|
|
||||||
|
//TODO: check session (read only?)
|
||||||
|
DBG(("user %lu, pin %s, pinlen %lu", userType, pPin, ulPinLen));
|
||||||
|
|
||||||
|
tries = 0;
|
||||||
|
if (ykpiv_verify(piv_state, pPin, (int *)&tries) != YKPIV_OK) {
|
||||||
|
DBG(("You loose! %lu", tries));
|
||||||
|
return CKR_PIN_INCORRECT;
|
||||||
|
}
|
||||||
|
|
||||||
|
DBG(("You win! %lu", tries))
|
||||||
|
|
||||||
DOUT;
|
DOUT;
|
||||||
return CKR_OK;
|
return CKR_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user