[gnome-keyring: 5/6] gkm: Add gkm_log_xxx() functions for stringizing
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring: 5/6] gkm: Add gkm_log_xxx() functions for stringizing
- Date: Tue, 19 Jun 2012 11:07:07 +0000 (UTC)
commit 75df449520f2ca8acd38af51b0520a70b0c3b754
Author: Stef Walter <stefw gnome org>
Date: Tue Jun 19 13:05:25 2012 +0200
gkm: Add gkm_log_xxx() functions for stringizing
Move gkm_util_rv_xxx() to gkm_log_rv() and add gkm_log_attr_type()
pkcs11/gkm/Makefile.am | 1 +
pkcs11/gkm/gkm-debug.h | 2 +
pkcs11/gkm/gkm-log.c | 291 +++++++++++++++++++++++++++++++++++
pkcs11/gkm/gkm-log.h | 33 ++++
pkcs11/gkm/gkm-test.c | 10 +-
pkcs11/gkm/gkm-trust.c | 4 +-
pkcs11/gkm/gkm-util.c | 120 --------------
pkcs11/gkm/gkm-util.h | 4 -
pkcs11/wrap-layer/gkm-wrap-login.c | 11 +-
pkcs11/wrap-layer/gkm-wrap-prompt.c | 17 +-
10 files changed, 349 insertions(+), 144 deletions(-)
---
diff --git a/pkcs11/gkm/Makefile.am b/pkcs11/gkm/Makefile.am
index 9928c6b..fe1900e 100644
--- a/pkcs11/gkm/Makefile.am
+++ b/pkcs11/gkm/Makefile.am
@@ -36,6 +36,7 @@ libgkm_la_SOURCES = \
gkm-file-tracker.c gkm-file-tracker.h \
gkm-generic-key.c gkm-generic-key.h \
gkm-hkdf-mechanism.c gkm-hkdf-mechanism.h \
+ gkm-log.c gkm-log.h \
gkm-manager.c gkm-manager.h \
gkm-memory-store.c gkm-memory-store.h \
gkm-mock.c gkm-mock.h \
diff --git a/pkcs11/gkm/gkm-debug.h b/pkcs11/gkm/gkm-debug.h
index 26b01ad..bab7b7c 100644
--- a/pkcs11/gkm/gkm-debug.h
+++ b/pkcs11/gkm/gkm-debug.h
@@ -22,6 +22,8 @@
#include "config.h"
+#include "gkm-log.h"
+
#include <glib.h>
G_BEGIN_DECLS
diff --git a/pkcs11/gkm/gkm-log.c b/pkcs11/gkm/gkm-log.c
new file mode 100644
index 0000000..4e81712
--- /dev/null
+++ b/pkcs11/gkm/gkm-log.c
@@ -0,0 +1,291 @@
+/*
+ * gnome-keyring
+ *
+ * Copyright (C) 2008 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include "gkm-log.h"
+
+#include "pkcs11/pkcs11.h"
+#include "pkcs11/pkcs11i.h"
+#include "pkcs11/pkcs11n.h"
+#include "pkcs11/pkcs11x.h"
+
+const gchar*
+gkm_log_rv (CK_RV rv)
+{
+ const gchar *string = NULL;
+
+ switch (rv) {
+ #define X(x) case x: string = #x; break;
+ X (CKR_OK)
+ X (CKR_NO_EVENT)
+ X (CKR_FUNCTION_NOT_PARALLEL)
+ X (CKR_SESSION_PARALLEL_NOT_SUPPORTED)
+ X (CKR_CANCEL)
+ X (CKR_FUNCTION_CANCELED)
+ X (CKR_HOST_MEMORY)
+ X (CKR_SLOT_ID_INVALID)
+ X (CKR_GENERAL_ERROR)
+ X (CKR_FUNCTION_FAILED)
+ X (CKR_ARGUMENTS_BAD)
+ X (CKR_NEED_TO_CREATE_THREADS)
+ X (CKR_CANT_LOCK)
+ X (CKR_ATTRIBUTE_READ_ONLY)
+ X (CKR_ATTRIBUTE_SENSITIVE)
+ X (CKR_ATTRIBUTE_TYPE_INVALID)
+ X (CKR_ATTRIBUTE_VALUE_INVALID)
+ X (CKR_DATA_INVALID)
+ X (CKR_DATA_LEN_RANGE)
+ X (CKR_DEVICE_ERROR)
+ X (CKR_DEVICE_MEMORY)
+ X (CKR_DEVICE_REMOVED)
+ X (CKR_ENCRYPTED_DATA_INVALID)
+ X (CKR_ENCRYPTED_DATA_LEN_RANGE)
+ X (CKR_FUNCTION_NOT_SUPPORTED)
+ X (CKR_KEY_HANDLE_INVALID)
+ X (CKR_KEY_SIZE_RANGE)
+ X (CKR_KEY_TYPE_INCONSISTENT)
+ X (CKR_KEY_NOT_NEEDED)
+ X (CKR_KEY_CHANGED)
+ X (CKR_KEY_NEEDED)
+ X (CKR_KEY_INDIGESTIBLE)
+ X (CKR_KEY_FUNCTION_NOT_PERMITTED)
+ X (CKR_KEY_NOT_WRAPPABLE)
+ X (CKR_KEY_UNEXTRACTABLE)
+ X (CKR_MECHANISM_INVALID)
+ X (CKR_MECHANISM_PARAM_INVALID)
+ X (CKR_OBJECT_HANDLE_INVALID)
+ X (CKR_OPERATION_ACTIVE)
+ X (CKR_OPERATION_NOT_INITIALIZED)
+ X (CKR_PIN_INCORRECT)
+ X (CKR_PIN_INVALID)
+ X (CKR_PIN_LEN_RANGE)
+ X (CKR_PIN_EXPIRED)
+ X (CKR_PIN_LOCKED)
+ X (CKR_SESSION_CLOSED)
+ X (CKR_SESSION_COUNT)
+ X (CKR_SESSION_HANDLE_INVALID)
+ X (CKR_SESSION_READ_ONLY)
+ X (CKR_SESSION_EXISTS)
+ X (CKR_SESSION_READ_ONLY_EXISTS)
+ X (CKR_SESSION_READ_WRITE_SO_EXISTS)
+ X (CKR_SIGNATURE_INVALID)
+ X (CKR_SIGNATURE_LEN_RANGE)
+ X (CKR_TEMPLATE_INCOMPLETE)
+ X (CKR_TEMPLATE_INCONSISTENT)
+ X (CKR_TOKEN_NOT_PRESENT)
+ X (CKR_TOKEN_NOT_RECOGNIZED)
+ X (CKR_TOKEN_WRITE_PROTECTED)
+ X (CKR_UNWRAPPING_KEY_HANDLE_INVALID)
+ X (CKR_UNWRAPPING_KEY_SIZE_RANGE)
+ X (CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT)
+ X (CKR_USER_ALREADY_LOGGED_IN)
+ X (CKR_USER_NOT_LOGGED_IN)
+ X (CKR_USER_PIN_NOT_INITIALIZED)
+ X (CKR_USER_TYPE_INVALID)
+ X (CKR_USER_ANOTHER_ALREADY_LOGGED_IN)
+ X (CKR_USER_TOO_MANY_TYPES)
+ X (CKR_WRAPPED_KEY_INVALID)
+ X (CKR_WRAPPED_KEY_LEN_RANGE)
+ X (CKR_WRAPPING_KEY_HANDLE_INVALID)
+ X (CKR_WRAPPING_KEY_SIZE_RANGE)
+ X (CKR_WRAPPING_KEY_TYPE_INCONSISTENT)
+ X (CKR_RANDOM_SEED_NOT_SUPPORTED)
+ X (CKR_RANDOM_NO_RNG)
+ X (CKR_DOMAIN_PARAMS_INVALID)
+ X (CKR_BUFFER_TOO_SMALL)
+ X (CKR_SAVED_STATE_INVALID)
+ X (CKR_INFORMATION_SENSITIVE)
+ X (CKR_STATE_UNSAVEABLE)
+ X (CKR_CRYPTOKI_NOT_INITIALIZED)
+ X (CKR_CRYPTOKI_ALREADY_INITIALIZED)
+ X (CKR_MUTEX_BAD)
+ X (CKR_MUTEX_NOT_LOCKED)
+ X (CKR_FUNCTION_REJECTED)
+ #undef X
+ }
+
+ if (string == NULL) {
+ gchar buffer[64];
+ g_snprintf (buffer, sizeof (buffer), "CKR_0x%08lX", rv);
+ string = g_intern_string (buffer);
+ }
+
+ return string;
+}
+
+const gchar*
+gkm_log_attr_type (CK_ATTRIBUTE_TYPE type)
+{
+ const gchar *string = NULL;
+
+ switch (type) {
+ #define X(x) case x: string = #x; break;
+ X (CKA_CLASS)
+ X (CKA_TOKEN)
+ X (CKA_PRIVATE)
+ X (CKA_LABEL)
+ X (CKA_APPLICATION)
+ X (CKA_VALUE)
+ X (CKA_OBJECT_ID)
+ X (CKA_CERTIFICATE_TYPE)
+ X (CKA_ISSUER)
+ X (CKA_SERIAL_NUMBER)
+ X (CKA_AC_ISSUER)
+ X (CKA_OWNER)
+ X (CKA_ATTR_TYPES)
+ X (CKA_TRUSTED)
+ X (CKA_CERTIFICATE_CATEGORY)
+ X (CKA_JAVA_MIDP_SECURITY_DOMAIN)
+ X (CKA_URL)
+ X (CKA_HASH_OF_SUBJECT_PUBLIC_KEY)
+ X (CKA_HASH_OF_ISSUER_PUBLIC_KEY)
+ X (CKA_CHECK_VALUE)
+ X (CKA_KEY_TYPE)
+ X (CKA_SUBJECT)
+ X (CKA_ID)
+ X (CKA_SENSITIVE)
+ X (CKA_ENCRYPT)
+ X (CKA_DECRYPT)
+ X (CKA_WRAP)
+ X (CKA_UNWRAP)
+ X (CKA_SIGN)
+ X (CKA_SIGN_RECOVER)
+ X (CKA_VERIFY)
+ X (CKA_VERIFY_RECOVER)
+ X (CKA_DERIVE)
+ X (CKA_START_DATE)
+ X (CKA_END_DATE)
+ X (CKA_MODULUS)
+ X (CKA_MODULUS_BITS)
+ X (CKA_PUBLIC_EXPONENT)
+ X (CKA_PRIVATE_EXPONENT)
+ X (CKA_PRIME_1)
+ X (CKA_PRIME_2)
+ X (CKA_EXPONENT_1)
+ X (CKA_EXPONENT_2)
+ X (CKA_COEFFICIENT)
+ X (CKA_PRIME)
+ X (CKA_SUBPRIME)
+ X (CKA_BASE)
+ X (CKA_PRIME_BITS)
+ /* X (CKA_SUBPRIME_BITS) */
+ /* X (CKA_SUB_PRIME_BITS) */
+ X (CKA_VALUE_BITS)
+ X (CKA_VALUE_LEN)
+ X (CKA_EXTRACTABLE)
+ X (CKA_LOCAL)
+ X (CKA_NEVER_EXTRACTABLE)
+ X (CKA_ALWAYS_SENSITIVE)
+ X (CKA_KEY_GEN_MECHANISM)
+ X (CKA_MODIFIABLE)
+ X (CKA_ECDSA_PARAMS)
+ /* X (CKA_EC_PARAMS) */
+ X (CKA_EC_POINT)
+ X (CKA_SECONDARY_AUTH)
+ X (CKA_AUTH_PIN_FLAGS)
+ X (CKA_ALWAYS_AUTHENTICATE)
+ X (CKA_WRAP_WITH_TRUSTED)
+ X (CKA_WRAP_TEMPLATE)
+ X (CKA_UNWRAP_TEMPLATE)
+ X (CKA_HW_FEATURE_TYPE)
+ X (CKA_RESET_ON_INIT)
+ X (CKA_HAS_RESET)
+ X (CKA_PIXEL_X)
+ X (CKA_PIXEL_Y)
+ X (CKA_RESOLUTION)
+ X (CKA_CHAR_ROWS)
+ X (CKA_CHAR_COLUMNS)
+ X (CKA_COLOR)
+ X (CKA_BITS_PER_PIXEL)
+ X (CKA_CHAR_SETS)
+ X (CKA_ENCODING_METHODS)
+ X (CKA_MIME_TYPES)
+ X (CKA_MECHANISM_TYPE)
+ X (CKA_REQUIRED_CMS_ATTRIBUTES)
+ X (CKA_DEFAULT_CMS_ATTRIBUTES)
+ X (CKA_SUPPORTED_CMS_ATTRIBUTES)
+ X (CKA_ALLOWED_MECHANISMS)
+ X (CKA_X_ASSERTION_TYPE)
+ X (CKA_X_CERTIFICATE_VALUE)
+ X (CKA_X_PURPOSE)
+ X (CKA_X_PEER)
+ X (CKA_NETSCAPE_URL)
+ X (CKA_NETSCAPE_EMAIL)
+ X (CKA_NETSCAPE_SMIME_INFO)
+ X (CKA_NETSCAPE_SMIME_TIMESTAMP)
+ X (CKA_NETSCAPE_PKCS8_SALT)
+ X (CKA_NETSCAPE_PASSWORD_CHECK)
+ X (CKA_NETSCAPE_EXPIRES)
+ X (CKA_NETSCAPE_KRL)
+ X (CKA_NETSCAPE_PQG_COUNTER)
+ X (CKA_NETSCAPE_PQG_SEED)
+ X (CKA_NETSCAPE_PQG_H)
+ X (CKA_NETSCAPE_PQG_SEED_BITS)
+ X (CKA_NETSCAPE_MODULE_SPEC)
+ X (CKA_TRUST_DIGITAL_SIGNATURE)
+ X (CKA_TRUST_NON_REPUDIATION)
+ X (CKA_TRUST_KEY_ENCIPHERMENT)
+ X (CKA_TRUST_DATA_ENCIPHERMENT)
+ X (CKA_TRUST_KEY_AGREEMENT)
+ X (CKA_TRUST_KEY_CERT_SIGN)
+ X (CKA_TRUST_CRL_SIGN)
+ X (CKA_TRUST_SERVER_AUTH)
+ X (CKA_TRUST_CLIENT_AUTH)
+ X (CKA_TRUST_CODE_SIGNING)
+ X (CKA_TRUST_EMAIL_PROTECTION)
+ X (CKA_TRUST_IPSEC_END_SYSTEM)
+ X (CKA_TRUST_IPSEC_TUNNEL)
+ X (CKA_TRUST_IPSEC_USER)
+ X (CKA_TRUST_TIME_STAMPING)
+ X (CKA_TRUST_STEP_UP_APPROVED)
+ X (CKA_CERT_SHA1_HASH)
+ X (CKA_CERT_MD5_HASH)
+ X (CKA_NETSCAPE_DB)
+ X (CKA_NETSCAPE_TRUST)
+ X (CKA_GNOME_UNIQUE)
+ X (CKA_GNOME_TRANSIENT)
+ X (CKA_GNOME_INTERNAL_SHA1)
+ X (CKA_G_LOCKED)
+ X (CKA_G_CREATED)
+ X (CKA_G_MODIFIED)
+ X (CKA_G_FIELDS)
+ X (CKA_G_COLLECTION)
+ X (CKA_G_MATCHED)
+ X (CKA_G_SCHEMA)
+ X (CKA_G_LOGIN_COLLECTION)
+ X (CKA_G_DESTRUCT_IDLE)
+ X (CKA_G_DESTRUCT_AFTER)
+ X (CKA_G_DESTRUCT_USES)
+ X (CKA_G_OBJECT)
+ X (CKA_G_CREDENTIAL)
+ X (CKA_G_CREDENTIAL_TEMPLATE)
+ #undef X
+ }
+
+ if (string == NULL) {
+ gchar buffer[64];
+ g_snprintf (buffer, sizeof (buffer), "CKA_0x%08lX", type);
+ string = g_intern_string (buffer);
+ }
+
+ return string;
+}
diff --git a/pkcs11/gkm/gkm-log.h b/pkcs11/gkm/gkm-log.h
new file mode 100644
index 0000000..192f7e8
--- /dev/null
+++ b/pkcs11/gkm/gkm-log.h
@@ -0,0 +1,33 @@
+/*
+ * gnome-keyring
+ *
+ * Copyright (C) 2008 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef GKM_LOG_H_
+#define GKM_LOG_H_
+
+#include <glib.h>
+
+#include "pkcs11/pkcs11.h"
+
+const gchar* gkm_log_rv (CK_RV rv);
+
+const gchar* gkm_log_attr_type (CK_ATTRIBUTE_TYPE type);
+
+#endif /* GKM_LOG_H_ */
diff --git a/pkcs11/gkm/gkm-test.c b/pkcs11/gkm/gkm-test.c
index 3937014..3628e51 100644
--- a/pkcs11/gkm/gkm-test.c
+++ b/pkcs11/gkm/gkm-test.c
@@ -22,6 +22,7 @@
#include "config.h"
#include "gkm-attributes.h"
+#include "gkm-log.h"
#include "gkm-test.h"
#include "gkm-util.h"
@@ -37,12 +38,9 @@ gkm_assertion_message_cmprv (const gchar *domain, const gchar *file, gint line,
const gchar *func, const gchar *expr,
CK_RV arg1, const gchar *cmp, CK_RV arg2)
{
- gchar *a1, *a2, *s;
- a1 = gkm_util_rv_to_string (arg1);
- a2 = gkm_util_rv_to_string (arg2);
- s = g_strdup_printf ("assertion failed (%s): (%s %s %s)", expr, a1, cmp, a2);
- g_free (a1);
- g_free (a2);
+ gchar *s;
+ s = g_strdup_printf ("assertion failed (%s): (%s %s %s)", expr,
+ gkm_log_rv (arg1), cmp, gkm_log_rv (arg2));
g_assertion_message (domain, file, line, func, s);
g_free (s);
}
diff --git a/pkcs11/gkm/gkm-trust.c b/pkcs11/gkm/gkm-trust.c
index 22b0e6a..2c7d8ca 100644
--- a/pkcs11/gkm/gkm-trust.c
+++ b/pkcs11/gkm/gkm-trust.c
@@ -24,6 +24,7 @@
#include "gkm-trust.h"
#include "gkm-attributes.h"
+#include "gkm-log.h"
#include "gkm-object.h"
#include "gkm-oids.h"
@@ -129,7 +130,8 @@ gkm_trust_get_attribute (GkmObject *base, GkmSession *session, CK_ATTRIBUTE_PTR
case CKA_ISSUER:
case CKA_CERT_MD5_HASH:
case CKA_CERT_SHA1_HASH:
- g_warning ("derived class should have provided these attributes");
+ g_warning ("derived class should have provided %s attribute",
+ gkm_log_attr_type (attr->type));
return CKR_ATTRIBUTE_TYPE_INVALID;
default:
diff --git a/pkcs11/gkm/gkm-util.c b/pkcs11/gkm/gkm-util.c
index 731eb46..b501698 100644
--- a/pkcs11/gkm/gkm-util.c
+++ b/pkcs11/gkm/gkm-util.c
@@ -139,123 +139,3 @@ gkm_util_dispose_unref (gpointer object)
g_object_run_dispose (G_OBJECT (object));
g_object_unref (object);
}
-
-static const gchar*
-defined_rv_to_string (CK_RV rv)
-{
- #define GKM_X(rv) case rv: return #rv;
- switch (rv) {
-
- /* These are not really errors, or not current */
- GKM_X (CKR_OK)
- GKM_X (CKR_NO_EVENT)
- GKM_X (CKR_FUNCTION_NOT_PARALLEL)
- GKM_X (CKR_SESSION_PARALLEL_NOT_SUPPORTED)
- GKM_X (CKR_CANCEL)
- GKM_X (CKR_FUNCTION_CANCELED)
- GKM_X (CKR_HOST_MEMORY)
- GKM_X (CKR_SLOT_ID_INVALID)
- GKM_X (CKR_GENERAL_ERROR)
- GKM_X (CKR_FUNCTION_FAILED)
- GKM_X (CKR_ARGUMENTS_BAD)
- GKM_X (CKR_NEED_TO_CREATE_THREADS)
- GKM_X (CKR_CANT_LOCK)
- GKM_X (CKR_ATTRIBUTE_READ_ONLY)
- GKM_X (CKR_ATTRIBUTE_SENSITIVE)
- GKM_X (CKR_ATTRIBUTE_TYPE_INVALID)
- GKM_X (CKR_ATTRIBUTE_VALUE_INVALID)
- GKM_X (CKR_DATA_INVALID)
- GKM_X (CKR_DATA_LEN_RANGE)
- GKM_X (CKR_DEVICE_ERROR)
- GKM_X (CKR_DEVICE_MEMORY)
- GKM_X (CKR_DEVICE_REMOVED)
- GKM_X (CKR_ENCRYPTED_DATA_INVALID)
- GKM_X (CKR_ENCRYPTED_DATA_LEN_RANGE)
- GKM_X (CKR_FUNCTION_NOT_SUPPORTED)
- GKM_X (CKR_KEY_HANDLE_INVALID)
- GKM_X (CKR_KEY_SIZE_RANGE)
- GKM_X (CKR_KEY_TYPE_INCONSISTENT)
- GKM_X (CKR_KEY_NOT_NEEDED)
- GKM_X (CKR_KEY_CHANGED)
- GKM_X (CKR_KEY_NEEDED)
- GKM_X (CKR_KEY_INDIGESTIBLE)
- GKM_X (CKR_KEY_FUNCTION_NOT_PERMITTED)
- GKM_X (CKR_KEY_NOT_WRAPPABLE)
- GKM_X (CKR_KEY_UNEXTRACTABLE)
- GKM_X (CKR_MECHANISM_INVALID)
- GKM_X (CKR_MECHANISM_PARAM_INVALID)
- GKM_X (CKR_OBJECT_HANDLE_INVALID)
- GKM_X (CKR_OPERATION_ACTIVE)
- GKM_X (CKR_OPERATION_NOT_INITIALIZED)
- GKM_X (CKR_PIN_INCORRECT)
- GKM_X (CKR_PIN_INVALID)
- GKM_X (CKR_PIN_LEN_RANGE)
- GKM_X (CKR_PIN_EXPIRED)
- GKM_X (CKR_PIN_LOCKED)
- GKM_X (CKR_SESSION_CLOSED)
- GKM_X (CKR_SESSION_COUNT)
- GKM_X (CKR_SESSION_HANDLE_INVALID)
- GKM_X (CKR_SESSION_READ_ONLY)
- GKM_X (CKR_SESSION_EXISTS)
- GKM_X (CKR_SESSION_READ_ONLY_EXISTS)
- GKM_X (CKR_SESSION_READ_WRITE_SO_EXISTS)
- GKM_X (CKR_SIGNATURE_INVALID)
- GKM_X (CKR_SIGNATURE_LEN_RANGE)
- GKM_X (CKR_TEMPLATE_INCOMPLETE)
- GKM_X (CKR_TEMPLATE_INCONSISTENT)
- GKM_X (CKR_TOKEN_NOT_PRESENT)
- GKM_X (CKR_TOKEN_NOT_RECOGNIZED)
- GKM_X (CKR_TOKEN_WRITE_PROTECTED)
- GKM_X (CKR_UNWRAPPING_KEY_HANDLE_INVALID)
- GKM_X (CKR_UNWRAPPING_KEY_SIZE_RANGE)
- GKM_X (CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT)
- GKM_X (CKR_USER_ALREADY_LOGGED_IN)
- GKM_X (CKR_USER_NOT_LOGGED_IN)
- GKM_X (CKR_USER_PIN_NOT_INITIALIZED)
- GKM_X (CKR_USER_TYPE_INVALID)
- GKM_X (CKR_USER_ANOTHER_ALREADY_LOGGED_IN)
- GKM_X (CKR_USER_TOO_MANY_TYPES)
- GKM_X (CKR_WRAPPED_KEY_INVALID)
- GKM_X (CKR_WRAPPED_KEY_LEN_RANGE)
- GKM_X (CKR_WRAPPING_KEY_HANDLE_INVALID)
- GKM_X (CKR_WRAPPING_KEY_SIZE_RANGE)
- GKM_X (CKR_WRAPPING_KEY_TYPE_INCONSISTENT)
- GKM_X (CKR_RANDOM_SEED_NOT_SUPPORTED)
- GKM_X (CKR_RANDOM_NO_RNG)
- GKM_X (CKR_DOMAIN_PARAMS_INVALID)
- GKM_X (CKR_BUFFER_TOO_SMALL)
- GKM_X (CKR_SAVED_STATE_INVALID)
- GKM_X (CKR_INFORMATION_SENSITIVE)
- GKM_X (CKR_STATE_UNSAVEABLE)
- GKM_X (CKR_CRYPTOKI_NOT_INITIALIZED)
- GKM_X (CKR_CRYPTOKI_ALREADY_INITIALIZED)
- GKM_X (CKR_MUTEX_BAD)
- GKM_X (CKR_MUTEX_NOT_LOCKED)
- GKM_X (CKR_FUNCTION_REJECTED)
- default:
- g_message ("unknown error: %lu", (gulong)rv);
- return "CKR_?UNKNOWN?";
- }
-
- #undef GKM_X
-}
-
-gchar*
-gkm_util_rv_to_string (CK_RV rv)
-{
- gchar *string = g_strdup (defined_rv_to_string (rv));
- if (string == NULL)
- string = g_strdup_printf ("0x%08lx", (gulong)rv);
- return string;
-}
-
-const gchar*
-gkm_util_rv_stringize (CK_RV rv)
-{
- const gchar *string = defined_rv_to_string (rv);
- if (string == NULL) {
- g_message ("unknown error: %lu", (gulong)rv);
- string = "CKR_?UNKNOWN?";
- }
- return string;
-}
diff --git a/pkcs11/gkm/gkm-util.h b/pkcs11/gkm/gkm-util.h
index 702eff7..c9af5a7 100644
--- a/pkcs11/gkm/gkm-util.h
+++ b/pkcs11/gkm/gkm-util.h
@@ -64,8 +64,4 @@ CK_ULONG gkm_util_next_handle (void);
void gkm_util_dispose_unref (gpointer object);
-const gchar* gkm_util_rv_stringize (CK_RV rv);
-
-gchar* gkm_util_rv_to_string (CK_RV rv);
-
#endif /* GKM_UTIL_H_ */
diff --git a/pkcs11/wrap-layer/gkm-wrap-login.c b/pkcs11/wrap-layer/gkm-wrap-login.c
index 5b563c5..3126137 100644
--- a/pkcs11/wrap-layer/gkm-wrap-login.c
+++ b/pkcs11/wrap-layer/gkm-wrap-login.c
@@ -25,6 +25,7 @@
#include "gkm-wrap-login.h"
#include "gkm/gkm-attributes.h"
+#include "gkm/gkm-log.h"
#include "gkm/gkm-util.h"
#include "egg/egg-secure-memory.h"
@@ -255,7 +256,7 @@ find_login_keyring_item (CK_FUNCTION_LIST_PTR module, CK_SESSION_HANDLE session,
gkm_template_free (attrs);
if (rv != CKR_OK) {
- g_warning ("couldn't create search for login keyring: %s", gkm_util_rv_stringize (rv));
+ g_warning ("couldn't create search for login keyring: %s", gkm_log_rv (rv));
return 0;
}
@@ -357,7 +358,7 @@ gkm_wrap_login_attach_secret (const gchar *label, const gchar *secret,
rv = (module->C_CreateObject) (session, ((CK_ATTRIBUTE_PTR)template->data),
template->len, &item);
if (rv != CKR_OK)
- g_warning ("couldn't store secret in login keyring: %s", gkm_util_rv_stringize (rv));
+ g_warning ("couldn't store secret in login keyring: %s", gkm_log_rv (rv));
/* Before freeing, truncate our password attribute we tacked on the end */
g_array_set_size (template, original_len);
@@ -421,7 +422,7 @@ gkm_wrap_login_lookup_secret (const gchar *first, ...)
} else {
if (rv != CKR_OBJECT_HANDLE_INVALID)
g_warning ("couldn't read stored secret from login keyring: %s",
- gkm_util_rv_stringize (rv));
+ gkm_log_rv (rv));
egg_secure_free (password);
password = NULL;
}
@@ -429,7 +430,7 @@ gkm_wrap_login_lookup_secret (const gchar *first, ...)
/* Failure. Remember object can go away due to race */
} else if (rv != CKR_OK && rv != CKR_OBJECT_HANDLE_INVALID) {
g_warning ("couldn't get stored secret from login keyring: %s",
- gkm_util_rv_stringize (rv));
+ gkm_log_rv (rv));
}
}
@@ -472,7 +473,7 @@ gkm_wrap_login_remove_secret (const gchar *first, ...)
rv = (module->C_DestroyObject) (session, item);
if (rv != CKR_OK && rv != CKR_OBJECT_HANDLE_INVALID)
g_warning ("couldn't remove stored secret from login keyring: %s",
- gkm_util_rv_stringize (rv));
+ gkm_log_rv (rv));
}
(module->C_CloseSession) (session);
diff --git a/pkcs11/wrap-layer/gkm-wrap-prompt.c b/pkcs11/wrap-layer/gkm-wrap-prompt.c
index 185a92d..62a3c46 100644
--- a/pkcs11/wrap-layer/gkm-wrap-prompt.c
+++ b/pkcs11/wrap-layer/gkm-wrap-prompt.c
@@ -28,6 +28,7 @@
#include "egg/egg-secure-memory.h"
#include "gkm/gkm-attributes.h"
+#include "gkm/gkm-log.h"
#include "gkm/gkm-util.h"
#include "pkcs11/pkcs11.h"
@@ -426,7 +427,7 @@ get_unlock_options_from_object (GkmWrapPrompt *self, CK_ULONG_PTR n_options)
if (rv != CKR_OK) {
if (rv != CKR_ATTRIBUTE_TYPE_INVALID)
g_warning ("couldn't get credential template for prompt: %s",
- gkm_util_rv_to_string (rv));
+ gkm_log_rv (rv));
return NULL;
}
@@ -438,7 +439,7 @@ get_unlock_options_from_object (GkmWrapPrompt *self, CK_ULONG_PTR n_options)
rv = (self->module->C_GetAttributeValue) (self->session, self->object, &attr, 1);
if (rv != CKR_OK) {
g_warning ("couldn't read credential template for prompt: %s",
- gkm_util_rv_to_string (rv));
+ gkm_log_rv (rv));
return NULL;
}
@@ -452,7 +453,7 @@ get_unlock_options_from_object (GkmWrapPrompt *self, CK_ULONG_PTR n_options)
rv = (self->module->C_GetAttributeValue) (self->session, self->object, &attr, 1);
if (rv != CKR_OK) {
g_warning ("couldn't retrieve credential template for prompt: %s",
- gkm_util_rv_to_string (rv));
+ gkm_log_rv (rv));
return NULL;
}
@@ -477,7 +478,7 @@ set_unlock_options_on_object (GkmWrapPrompt *self, CK_ATTRIBUTE_PTR options, CK_
if (rv != CKR_OK && rv != CKR_ATTRIBUTE_TYPE_INVALID) {
if (rv != CKR_TOKEN_WRITE_PROTECTED)
g_warning ("Couldn't set credential template for prompt: %s",
- gkm_util_rv_to_string (rv));
+ gkm_log_rv (rv));
}
}
@@ -545,7 +546,7 @@ get_attributes_from_object (GkmWrapPrompt *self, CK_ULONG *n_attrs)
rv = (self->module->C_GetAttributeValue) (self->session, self->object, attrs, G_N_ELEMENTS (attrs));
if (rv != CKR_OK && rv != CKR_ATTRIBUTE_TYPE_INVALID) {
g_warning ("Couldn't retrieve information about object to unlock: %s",
- gkm_util_rv_to_string (rv));
+ gkm_log_rv (rv));
return NULL;
}
@@ -559,7 +560,7 @@ get_attributes_from_object (GkmWrapPrompt *self, CK_ULONG *n_attrs)
rv = (self->module->C_GetAttributeValue) (self->session, self->object, attrs, G_N_ELEMENTS (attrs));
if (rv != CKR_OK && rv != CKR_ATTRIBUTE_TYPE_INVALID) {
g_warning ("couldn't retrieve credential template for prompt: %s",
- gkm_util_rv_to_string (rv));
+ gkm_log_rv (rv));
return NULL;
}
@@ -841,7 +842,7 @@ fix_login_keyring_if_unlock_failed (GkmWrapPrompt *self, const gchar *password)
if (rv != CKR_OK) {
g_warning ("couldn't create credential to fix login password: %s",
- gkm_util_rv_to_string (rv));
+ gkm_log_rv (rv));
return;
}
@@ -853,7 +854,7 @@ fix_login_keyring_if_unlock_failed (GkmWrapPrompt *self, const gchar *password)
rv = (self->module->C_SetAttributeValue) (self->session, self->object, attrs, 1);
if (rv != CKR_OK) {
g_warning ("couldn't change credential to fix login keyring password: %s",
- gkm_util_rv_to_string (rv));
+ gkm_log_rv (rv));
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]