/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <locale.h>
#include <cryptoutil.h>
#define DEFAULT_TOKEN_MINSIZE \
gettext("PIN must be at least %ld characters.\n")
#define DEFAULT_USER_MINSIZE \
gettext("Passphrase must be at least %ld characters.\n")
/*
* Default token name
*/
char *
pkcs11_default_token(void)
{
return (DEFAULT_PK11TOKEN);
}
/*
* Prompt user for a passphrase or the PIN for a token.
*
* An optional minimum length can be enforced. Caller can optionally also
* reprompt for the passphrase/PIN to confirm it was entered correctly.
* The caller must free the buffer containing the passphrase/PIN with free().
* 0 returned for success, -1 for failure with the first passphrase/PIN,
* -2 for failure with the optional second passphrase/PIN used to confirm.
*/
int
{
int tries;
if (token_name != NULL)
else
return (-1);
break;
if (token_name != NULL)
else
}
if (tries == 0) {
return (-1);
}
return (-1);
if (with_confirmation) {
if (token_name != NULL)
else
/* clean up */
return (-2);
}
/* clean up */
return (-2);
}
}
return (0);
}