|
Packit |
8df227 |
/*
|
|
Packit |
8df227 |
pakchois PKCS#11 interface -- error mapping
|
|
Packit |
8df227 |
Copyright (C) 2008, Joe Orton <joe@manyfish.co.uk>
|
|
Packit |
8df227 |
|
|
Packit |
8df227 |
This library is free software; you can redistribute it and/or
|
|
Packit |
8df227 |
modify it under the terms of the GNU Library General Public
|
|
Packit |
8df227 |
License as published by the Free Software Foundation; either
|
|
Packit |
8df227 |
version 2 of the License, or (at your option) any later version.
|
|
Packit |
8df227 |
|
|
Packit |
8df227 |
This library is distributed in the hope that it will be useful,
|
|
Packit |
8df227 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
8df227 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
8df227 |
Library General Public License for more details.
|
|
Packit |
8df227 |
|
|
Packit |
8df227 |
You should have received a copy of the GNU Library General Public
|
|
Packit |
8df227 |
License along with this library; if not, write to the Free
|
|
Packit |
8df227 |
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
|
Packit |
8df227 |
MA 02111-1307, USA
|
|
Packit |
8df227 |
*/
|
|
Packit |
8df227 |
|
|
Packit |
8df227 |
/*
|
|
Packit |
8df227 |
This code is directly derived from the scute.org PKCS#11 cryptoki
|
|
Packit |
8df227 |
interface, which is:
|
|
Packit |
8df227 |
|
|
Packit |
8df227 |
Copyright 2006, 2007 g10 Code GmbH
|
|
Packit |
8df227 |
Copyright 2006 Andreas Jellinghaus
|
|
Packit |
8df227 |
|
|
Packit |
8df227 |
This file is free software; as a special exception the author gives
|
|
Packit |
8df227 |
unlimited permission to copy and/or distribute it, with or without
|
|
Packit |
8df227 |
modifications, as long as this notice is preserved.
|
|
Packit |
8df227 |
|
|
Packit |
8df227 |
This file is distributed in the hope that it will be useful, but
|
|
Packit |
8df227 |
WITHOUT ANY WARRANTY, to the extent permitted by law; without even
|
|
Packit |
8df227 |
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
Packit |
8df227 |
PURPOSE.
|
|
Packit |
8df227 |
*/
|
|
Packit |
8df227 |
|
|
Packit |
8df227 |
#include "config.h"
|
|
Packit |
8df227 |
|
|
Packit |
8df227 |
#include "pakchois.h"
|
|
Packit |
8df227 |
|
|
Packit |
8df227 |
#ifdef ENABLE_NLS
|
|
Packit |
8df227 |
#include <libintl.h>
|
|
Packit |
8df227 |
#define _(x) dgettext(PACKAGE_NAME, x)
|
|
Packit |
8df227 |
#else
|
|
Packit |
8df227 |
#define _(x) x
|
|
Packit |
8df227 |
#endif
|
|
Packit |
8df227 |
|
|
Packit |
8df227 |
const char *pakchois_error(ck_rv_t rv)
|
|
Packit |
8df227 |
{
|
|
Packit |
8df227 |
if (rv >= CKR_VENDOR_DEFINED) {
|
|
Packit |
8df227 |
return _("Vendor defined error");
|
|
Packit |
8df227 |
}
|
|
Packit |
8df227 |
|
|
Packit |
8df227 |
switch (rv) {
|
|
Packit |
8df227 |
case CKR_OK: return _("OK");
|
|
Packit |
8df227 |
case CKR_CANCEL: return _("Cancel");
|
|
Packit |
8df227 |
case CKR_HOST_MEMORY: return _("Host memory");
|
|
Packit |
8df227 |
case CKR_SLOT_ID_INVALID: return _("Slot id invalid");
|
|
Packit |
8df227 |
case CKR_GENERAL_ERROR: return _("General error");
|
|
Packit |
8df227 |
case CKR_FUNCTION_FAILED: return _("Function failed");
|
|
Packit |
8df227 |
case CKR_ARGUMENTS_BAD: return _("Arguments bad");
|
|
Packit |
8df227 |
case CKR_NO_EVENT: return _("No event");
|
|
Packit |
8df227 |
case CKR_NEED_TO_CREATE_THREADS: return _("Need to create threads");
|
|
Packit |
8df227 |
case CKR_CANT_LOCK: return _("Can't lock");
|
|
Packit |
8df227 |
case CKR_ATTRIBUTE_READ_ONLY: return _("Attribute read only");
|
|
Packit |
8df227 |
case CKR_ATTRIBUTE_SENSITIVE: return _("Attribute sensitive");
|
|
Packit |
8df227 |
case CKR_ATTRIBUTE_TYPE_INVALID: return _("Attribute type invalid");
|
|
Packit |
8df227 |
case CKR_ATTRIBUTE_VALUE_INVALID: return _("Attribute value invalid");
|
|
Packit |
8df227 |
case CKR_DATA_INVALID: return _("Data invalid");
|
|
Packit |
8df227 |
case CKR_DATA_LEN_RANGE: return _("Data len range");
|
|
Packit |
8df227 |
case CKR_DEVICE_ERROR: return _("Device error");
|
|
Packit |
8df227 |
case CKR_DEVICE_MEMORY: return _("Device memory");
|
|
Packit |
8df227 |
case CKR_DEVICE_REMOVED: return _("Device removed");
|
|
Packit |
8df227 |
case CKR_ENCRYPTED_DATA_INVALID: return _("Encrypted data invalid");
|
|
Packit |
8df227 |
case CKR_ENCRYPTED_DATA_LEN_RANGE: return _("Encrypted data len range");
|
|
Packit |
8df227 |
case CKR_FUNCTION_CANCELED: return _("Function canceled");
|
|
Packit |
8df227 |
case CKR_FUNCTION_NOT_PARALLEL: return _("Function not parallel");
|
|
Packit |
8df227 |
case CKR_FUNCTION_NOT_SUPPORTED: return _("Function not supported");
|
|
Packit |
8df227 |
case CKR_KEY_HANDLE_INVALID: return _("Key handle invalid");
|
|
Packit |
8df227 |
case CKR_KEY_SIZE_RANGE: return _("Key size range");
|
|
Packit |
8df227 |
case CKR_KEY_TYPE_INCONSISTENT: return _("Key type inconsistent");
|
|
Packit |
8df227 |
case CKR_KEY_NOT_NEEDED: return _("Key not needed");
|
|
Packit |
8df227 |
case CKR_KEY_CHANGED: return _("Key changed");
|
|
Packit |
8df227 |
case CKR_KEY_NEEDED: return _("Key needed");
|
|
Packit |
8df227 |
case CKR_KEY_INDIGESTIBLE: return _("Key indigestible");
|
|
Packit |
8df227 |
case CKR_KEY_FUNCTION_NOT_PERMITTED: return _("Key function not permitted");
|
|
Packit |
8df227 |
case CKR_KEY_NOT_WRAPPABLE: return _("Key not wrappable");
|
|
Packit |
8df227 |
case CKR_KEY_UNEXTRACTABLE: return _("Key unextractable");
|
|
Packit |
8df227 |
case CKR_MECHANISM_INVALID: return _("Mechanism invalid");
|
|
Packit |
8df227 |
case CKR_MECHANISM_PARAM_INVALID: return _("Mechanism param invalid");
|
|
Packit |
8df227 |
case CKR_OBJECT_HANDLE_INVALID: return _("Object handle invalid");
|
|
Packit |
8df227 |
case CKR_OPERATION_ACTIVE: return _("Operation active");
|
|
Packit |
8df227 |
case CKR_OPERATION_NOT_INITIALIZED: return _("Operation not initialized");
|
|
Packit |
8df227 |
case CKR_PIN_INCORRECT: return _("PIN incorrect");
|
|
Packit |
8df227 |
case CKR_PIN_INVALID: return _("PIN invalid");
|
|
Packit |
8df227 |
case CKR_PIN_LEN_RANGE: return _("PIN len range");
|
|
Packit |
8df227 |
case CKR_PIN_EXPIRED: return _("PIN expired");
|
|
Packit |
8df227 |
case CKR_PIN_LOCKED: return _("PIN locked");
|
|
Packit |
8df227 |
case CKR_SESSION_CLOSED: return _("Session closed");
|
|
Packit |
8df227 |
case CKR_SESSION_COUNT: return _("Session count");
|
|
Packit |
8df227 |
case CKR_SESSION_HANDLE_INVALID: return _("Session handle invalid");
|
|
Packit |
8df227 |
case CKR_SESSION_PARALLEL_NOT_SUPPORTED: return _("Session parallel not supported");
|
|
Packit |
8df227 |
case CKR_SESSION_READ_ONLY: return _("Session read only");
|
|
Packit |
8df227 |
case CKR_SESSION_EXISTS: return _("Session exists");
|
|
Packit |
8df227 |
case CKR_SESSION_READ_ONLY_EXISTS: return _("Session read only exists");
|
|
Packit |
8df227 |
case CKR_SESSION_READ_WRITE_SO_EXISTS: return _("Session read write so exists");
|
|
Packit |
8df227 |
case CKR_SIGNATURE_INVALID: return _("Signature invalid");
|
|
Packit |
8df227 |
case CKR_SIGNATURE_LEN_RANGE: return _("Signature length range");
|
|
Packit |
8df227 |
case CKR_TEMPLATE_INCOMPLETE: return _("Template incomplete");
|
|
Packit |
8df227 |
case CKR_TEMPLATE_INCONSISTENT: return _("Template inconsistent");
|
|
Packit |
8df227 |
case CKR_TOKEN_NOT_PRESENT: return _("Token not present");
|
|
Packit |
8df227 |
case CKR_TOKEN_NOT_RECOGNIZED: return _("Token not recognized");
|
|
Packit |
8df227 |
case CKR_TOKEN_WRITE_PROTECTED: return _("Token write protected");
|
|
Packit |
8df227 |
case CKR_UNWRAPPING_KEY_HANDLE_INVALID: return _("Unwrapping key handle invalid");
|
|
Packit |
8df227 |
case CKR_UNWRAPPING_KEY_SIZE_RANGE: return _("Unwrapping key size range");
|
|
Packit |
8df227 |
case CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT: return _("Unwrapping key type inconsistent");
|
|
Packit |
8df227 |
case CKR_USER_ALREADY_LOGGED_IN: return _("User already logged in");
|
|
Packit |
8df227 |
case CKR_USER_NOT_LOGGED_IN: return _("User not logged in");
|
|
Packit |
8df227 |
case CKR_USER_PIN_NOT_INITIALIZED: return _("User PIN not initialized");
|
|
Packit |
8df227 |
case CKR_USER_TYPE_INVALID: return _("User type invalid");
|
|
Packit |
8df227 |
case CKR_USER_ANOTHER_ALREADY_LOGGED_IN: return _("Another user already logged in");
|
|
Packit |
8df227 |
case CKR_USER_TOO_MANY_TYPES: return _("User too many types");
|
|
Packit |
8df227 |
case CKR_WRAPPED_KEY_INVALID: return _("Wrapped key invalid");
|
|
Packit |
8df227 |
case CKR_WRAPPED_KEY_LEN_RANGE: return _("Wrapped key length range");
|
|
Packit |
8df227 |
case CKR_WRAPPING_KEY_HANDLE_INVALID: return _("Wrapping key handle invalid");
|
|
Packit |
8df227 |
case CKR_WRAPPING_KEY_SIZE_RANGE: return _("Wrapping key size range");
|
|
Packit |
8df227 |
case CKR_WRAPPING_KEY_TYPE_INCONSISTENT: return _("Wrapping key type inconsistent");
|
|
Packit |
8df227 |
case CKR_RANDOM_SEED_NOT_SUPPORTED: return _("Random seed not supported");
|
|
Packit |
8df227 |
case CKR_RANDOM_NO_RNG: return _("Random no rng");
|
|
Packit |
8df227 |
case CKR_DOMAIN_PARAMS_INVALID: return _("Domain params invalid");
|
|
Packit |
8df227 |
case CKR_BUFFER_TOO_SMALL: return _("Buffer too small");
|
|
Packit |
8df227 |
case CKR_SAVED_STATE_INVALID: return _("Saved state invalid");
|
|
Packit |
8df227 |
case CKR_INFORMATION_SENSITIVE: return _("Information sensitive");
|
|
Packit |
8df227 |
case CKR_STATE_UNSAVEABLE: return _("State unsaveable");
|
|
Packit |
8df227 |
case CKR_CRYPTOKI_NOT_INITIALIZED: return _("Cryptoki not initialized");
|
|
Packit |
8df227 |
case CKR_CRYPTOKI_ALREADY_INITIALIZED: return _("Cryptoki already initialized");
|
|
Packit |
8df227 |
case CKR_MUTEX_BAD: return _("Mutex bad");
|
|
Packit |
8df227 |
case CKR_MUTEX_NOT_LOCKED: return _("Mutex not locked");
|
|
Packit |
8df227 |
case CKR_FUNCTION_REJECTED: return _("Function rejected");
|
|
Packit |
8df227 |
default:
|
|
Packit |
8df227 |
break;
|
|
Packit |
8df227 |
}
|
|
Packit |
8df227 |
|
|
Packit |
8df227 |
return _("Unknown error");
|
|
Packit |
8df227 |
}
|