示例#1
0
/*
 * Lock the pin file
 */
static int
gpk_lock_pinfile(struct sc_profile *profile, sc_pkcs15_card_t *p15card,
		sc_file_t *pinfile)
{
	struct sc_path	path;
	struct sc_file	*parent = NULL;
	int		r;

	SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE);
	/* Select the parent DF */
	path = pinfile->path;
	if (path.len >= 2)
		path.len -= 2;
	if (path.len == 0)
		sc_format_path("3F00", &path);
	if ((r = sc_select_file(p15card->card, &path, &parent)) < 0)
		return r;

	/* Present PINs etc as necessary */
	r = sc_pkcs15init_authenticate(profile, p15card, parent, SC_AC_OP_LOCK);
	if (r >= 0)
		r = gpk_lock(p15card->card, pinfile, SC_AC_OP_WRITE);

	sc_file_free(parent);
	SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, r);
}
/*
 * Lock the pin file
 */
static int
gpk_lock_pinfile(struct sc_profile *profile, sc_card_t *card,
                 sc_file_t *pinfile)
{
    struct sc_path	path;
    struct sc_file	*parent = NULL;
    int		r;

    /* Select the parent DF */
    path = pinfile->path;
    if (path.len >= 2)
        path.len -= 2;
    if (path.len == 0)
        sc_format_path("3F00", &path);
    if ((r = sc_select_file(card, &path, &parent)) < 0)
        return r;

    /* Present PINs etc as necessary */
    r = sc_pkcs15init_authenticate(profile, card, parent, SC_AC_OP_LOCK);
    if (r >= 0)
        r = gpk_lock(card, pinfile, SC_AC_OP_WRITE);

    sc_file_free(parent);
    return r;
}