47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * CDDL HEADER START
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * The contents of this file are subject to the terms of the
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * Common Development and Distribution License (the "License").
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * You may not use this file except in compliance with the License.
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * or http://www.opensolaris.org/os/licensing.
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * See the License for the specific language governing permissions
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * and limitations under the License.
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * When distributing Covered Code, include this CDDL HEADER in each
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * If applicable, add the following below this CDDL HEADER, with the
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * fields enclosed by brackets "[]" replaced with your own identifying
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * information: Portions Copyright [yyyy] [name of copyright owner]
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * CDDL HEADER END
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * Use is subject to license terms.
33f5ff17089e3a43e6e730bf80384c233123dbd9Milan Jurik * Copyright 2012 Milan Jurik. All rights reserved.
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * This file implements the inittoken operation for this tool.
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * The basic flow of the process is to load the PKCS#11 module,
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * find the token to be initialize , login using the SO pin,
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll * and call C_InitToken.
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll/* ARGSUSED */
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll /* Parse command line options. Do NOT i18n/l10n. */
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll "n:(newlabel)"
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll /* No additional args allowed. */
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll if ((rv = kmf_initialize(&handle, NULL, NULL)) != KMF_OK)
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll if ((rv = get_pin(gettext("Enter SO PIN:"), NULL, &sopin, &sopinlen))
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll gettext("Unable to get SO PIN for token"));
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll if ((currlabel == NULL || !strlen(currlabel))) {
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll gettext("The current token is not identified by label."));
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll rv = kmf_pk11_init_token(handle, currlabel, newlabel,
47e946e784719ae402ace34695f67b0e6e76ae5cWyllys Ingersoll (void) fprintf(stdout, gettext("Token %s initialized.\n"),