gnome-keyring r1461 - in trunk: . common common/tests daemon daemon/keyrings daemon/keyrings/tests daemon/pk daemon/pk/tests daemon/pkcs11 daemon/pkix daemon/pkix/tests daemon/ssh daemon/ssh/tests daemon/ui egg egg/tests egg/tests/test-data library library/tests pam pkcs11/gck pkcs11/gck/tests pkcs11/roots-store pkcs11/rpc-layer pkcs11/ssh-agent pkcs11/ssh-store pkcs11/ssh-store/tests pkcs11/user-store tests
- From: nnielsen svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-keyring r1461 - in trunk: . common common/tests daemon daemon/keyrings daemon/keyrings/tests daemon/pk daemon/pk/tests daemon/pkcs11 daemon/pkix daemon/pkix/tests daemon/ssh daemon/ssh/tests daemon/ui egg egg/tests egg/tests/test-data library library/tests pam pkcs11/gck pkcs11/gck/tests pkcs11/roots-store pkcs11/rpc-layer pkcs11/ssh-agent pkcs11/ssh-store pkcs11/ssh-store/tests pkcs11/user-store tests
- Date: Sat, 17 Jan 2009 23:27:10 +0000 (UTC)
Author: nnielsen
Date: Sat Jan 17 23:27:10 2009
New Revision: 1461
URL: http://svn.gnome.org/viewvc/gnome-keyring?rev=1461&view=rev
Log:
* egg/egg-asn1.c: (moved from pkcs11/gck/gck-data-asn1.c)
* egg/egg-asn1.h: (moved from pkcs11/gck/gck-data-asn1.h)
* egg/egg-buffer.c: (moved from common/gkr-buffer.c)
* egg/egg-buffer.h: (moved from common/gkr-buffer.h)
* egg/egg-secure-memory.c: (moved from common/gkr-secure-memory.c)
* egg/egg-secure-memory.h: (moved from common/gkr-secure-memory.h)
* egg/egg-unix-credentials.c: (moved from common/gkr-unix-credentials.c)
* egg/egg-unix-credentials.h: (moved from common/gkr-unix-credentials.h)
* egg/Makefile.am: (added)
* egg/pk.asn: (moved from pkcs11/gck/pk.asn)
* egg/pkix.asn: (moved from pkcs11/gck/pkix.asn)
* egg/tests/Makefile.am: (added)
* egg/tests/test.asn: (moved from pkcs11/gck/tests/test.asn)
* egg/tests/unit-test-asn1.c: (moved from pkcs11/gck/tests/unit-test-data-asn1.c)
* egg/tests/unit-test-secmem.c: (moved from common/tests/unit-test-secmem.c)
* egg/tests/test-data: (added) Consolidate truly common functionality into 'egg'
library. Many more files touched due to above changes.
Added:
trunk/egg/ (props changed)
trunk/egg/Makefile.am
trunk/egg/egg-asn1.c (contents, props changed)
- copied, changed from r1459, /trunk/pkcs11/gck/gck-data-asn1.c
trunk/egg/egg-asn1.h (contents, props changed)
- copied, changed from r1458, /trunk/pkcs11/gck/gck-data-asn1.h
trunk/egg/egg-buffer.c (contents, props changed)
- copied, changed from r1460, /trunk/common/gkr-buffer.c
trunk/egg/egg-buffer.h (contents, props changed)
- copied, changed from r1460, /trunk/common/gkr-buffer.h
trunk/egg/egg-secure-memory.c (contents, props changed)
- copied, changed from r1460, /trunk/common/gkr-secure-memory.c
trunk/egg/egg-secure-memory.h (contents, props changed)
- copied, changed from r1460, /trunk/common/gkr-secure-memory.h
trunk/egg/egg-unix-credentials.c (contents, props changed)
- copied, changed from r1460, /trunk/common/gkr-unix-credentials.c
trunk/egg/egg-unix-credentials.h (contents, props changed)
- copied, changed from r1460, /trunk/common/gkr-unix-credentials.h
trunk/egg/pk.asn
trunk/egg/pkix.asn
trunk/egg/tests/ (props changed)
trunk/egg/tests/Makefile.am
trunk/egg/tests/test-data/
trunk/egg/tests/test.asn
trunk/egg/tests/unit-test-asn1.c (contents, props changed)
trunk/egg/tests/unit-test-secmem.c (contents, props changed)
- copied, changed from r1460, /trunk/common/tests/unit-test-secmem.c
Removed:
trunk/common/gkr-buffer.c
trunk/common/gkr-buffer.h
trunk/common/gkr-secure-memory.c
trunk/common/gkr-secure-memory.h
trunk/common/gkr-unix-credentials.c
trunk/common/gkr-unix-credentials.h
trunk/common/tests/unit-test-secmem.c
Modified:
trunk/ChangeLog
trunk/Makefile.am
trunk/common/Makefile.am
trunk/common/gkr-crypto.c
trunk/common/tests/Makefile.am
trunk/configure.in
trunk/daemon/gkr-daemon-io.c
trunk/daemon/gkr-daemon-ops.c
trunk/daemon/gkr-daemon.c
trunk/daemon/gkr-daemon.h
trunk/daemon/keyrings/gkr-keyring-binary.c
trunk/daemon/keyrings/gkr-keyring-item.c
trunk/daemon/keyrings/gkr-keyring-login.c
trunk/daemon/keyrings/gkr-keyring-textual.c
trunk/daemon/keyrings/gkr-keyring.c
trunk/daemon/keyrings/gkr-keyring.h
trunk/daemon/keyrings/tests/unit-test-keyring-file.c
trunk/daemon/pk/gkr-pk-import.c
trunk/daemon/pk/gkr-pk-index.c
trunk/daemon/pk/gkr-pk-manager.c
trunk/daemon/pk/gkr-pk-root-storage.c
trunk/daemon/pk/gkr-pk-session-storage.c
trunk/daemon/pk/gkr-pk-storage.c
trunk/daemon/pk/tests/unit-test-memory-stubs.c
trunk/daemon/pkcs11/gkr-pkcs11-auth.c
trunk/daemon/pkix/gkr-pkix-asn1.c
trunk/daemon/pkix/gkr-pkix-asn1.h
trunk/daemon/pkix/gkr-pkix-der.c
trunk/daemon/pkix/gkr-pkix-openssl.c
trunk/daemon/pkix/gkr-pkix-parser.c
trunk/daemon/pkix/gkr-pkix-pem.c
trunk/daemon/pkix/gkr-pkix-serialize.c
trunk/daemon/pkix/tests/unit-test-pkix-openssl.c
trunk/daemon/pkix/tests/unit-test-pkix-parser.c
trunk/daemon/pkix/tests/unit-test-pkix-serialize.c
trunk/daemon/ssh/gkr-ssh-private.h
trunk/daemon/ssh/gkr-ssh-proto.c
trunk/daemon/ssh/gkr-ssh-storage.c
trunk/daemon/ssh/tests/unit-test-ssh-storage.c
trunk/daemon/ui/Makefile.am
trunk/daemon/ui/gkr-ask-entry.c
trunk/daemon/ui/gkr-ask-request.c
trunk/daemon/ui/gkr-ask-tool.c
trunk/library/Makefile.am
trunk/library/gnome-keyring-memory.c
trunk/library/gnome-keyring-private.h
trunk/library/gnome-keyring-proto.c
trunk/library/gnome-keyring-proto.h
trunk/library/gnome-keyring-socket.c
trunk/library/gnome-keyring-utils.c
trunk/library/gnome-keyring.c
trunk/library/tests/Makefile.am
trunk/pam/Makefile.am
trunk/pam/gkr-pam-client.c
trunk/pam/gkr-pam-stubs.c
trunk/pkcs11/gck/gck-certificate.c
trunk/pkcs11/gck/gck-crypto.c
trunk/pkcs11/gck/gck-data-asn1.c
trunk/pkcs11/gck/gck-data-asn1.h
trunk/pkcs11/gck/gck-data-der.c
trunk/pkcs11/gck/gck-data-file.c
trunk/pkcs11/gck/gck-login.c
trunk/pkcs11/gck/tests/Makefile.am
trunk/pkcs11/gck/tests/unit-test-data-asn1.c
trunk/pkcs11/gck/tests/unit-test-data-der.c
trunk/pkcs11/roots-store/Makefile.am
trunk/pkcs11/roots-store/gck-roots-standalone.c
trunk/pkcs11/rpc-layer/Makefile.am
trunk/pkcs11/rpc-layer/gck-rpc-dispatch.c
trunk/pkcs11/rpc-layer/gck-rpc-message.c
trunk/pkcs11/rpc-layer/gck-rpc-module.c
trunk/pkcs11/rpc-layer/gck-rpc-private.h
trunk/pkcs11/ssh-agent/Makefile.am
trunk/pkcs11/ssh-agent/gck-ssh-agent-ops.c
trunk/pkcs11/ssh-agent/gck-ssh-agent-private.h
trunk/pkcs11/ssh-agent/gck-ssh-agent-proto.c
trunk/pkcs11/ssh-agent/gck-ssh-agent-standalone.c
trunk/pkcs11/ssh-agent/gck-ssh-agent.c
trunk/pkcs11/ssh-store/Makefile.am
trunk/pkcs11/ssh-store/gck-ssh-openssh.c
trunk/pkcs11/ssh-store/gck-ssh-standalone.c
trunk/pkcs11/ssh-store/tests/Makefile.am
trunk/pkcs11/user-store/Makefile.am
trunk/pkcs11/user-store/gck-user-standalone.c
trunk/pkcs11/user-store/gck-user-storage.c
trunk/tests/gtest-helpers.c
trunk/tests/test-helpers.c
Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am (original)
+++ trunk/Makefile.am Sat Jan 17 23:27:10 2009
@@ -13,6 +13,7 @@
SUBDIRS = \
. \
gp11 \
+ egg \
common \
library \
pkcs11 \
Modified: trunk/common/Makefile.am
==============================================================================
--- trunk/common/Makefile.am (original)
+++ trunk/common/Makefile.am Sat Jan 17 23:27:10 2009
@@ -1,9 +1,6 @@
noinst_LTLIBRARIES = \
- libgkr-common.la \
- libgkr-common-secure.la \
- libgkr-common-buffer.la \
- libgkr-common-creds.la
+ libgkr-common.la
INCLUDES = \
-I$(top_srcdir)
@@ -23,35 +20,21 @@
libgkr_common_la_SOURCES = \
gkr-async.c gkr-async.h \
- gkr-buffer.c gkr-buffer.h \
gkr-cleanup.c gkr-cleanup.h \
gkr-crypto.c gkr-crypto.h \
gkr-daemon-util.c gkr-daemon-util.h \
gkr-dbus.c gkr-dbus.h \
gkr-location.c gkr-location.h \
gkr-location-watch.c gkr-location-watch.h \
- gkr-secure-memory.c gkr-secure-memory.h \
gkr-id.c gkr-id.h \
- gkr-unix-credentials.c gkr-unix-credentials.h \
gkr-unix-signal.c gkr-unix-signal.h \
gkr-wakeup.c gkr-wakeup.h
libgkr_common_la_LIBADD = \
+ $(top_builddir)/egg/libegg.la \
$(GTHREAD_LIBS) \
$(GLIB_LIBS)
-# --------------------------------------------------------------------
-# COMMON STUFF COMPILED INTO LOADABLE MODULES
-
-libgkr_common_secure_la_SOURCES = \
- gkr-secure-memory.c gkr-secure-memory.h
-
-libgkr_common_buffer_la_SOURCES = \
- gkr-buffer.c gkr-buffer.h
-
-libgkr_common_creds_la_SOURCES = \
- gkr-unix-credentials.c gkr-unix-credentials.h
-
if WITH_TESTS
TESTS_DIR = tests
else
Modified: trunk/common/gkr-crypto.c
==============================================================================
--- trunk/common/gkr-crypto.c (original)
+++ trunk/common/gkr-crypto.c Sat Jan 17 23:27:10 2009
@@ -25,7 +25,7 @@
#include "gkr-crypto.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include <glib.h>
@@ -76,10 +76,10 @@
gcry_set_outofcore_handler (no_mem_handler, NULL);
gcry_set_fatalerror_handler (fatal_handler, NULL);
gcry_set_allocation_handler ((gcry_handler_alloc_t)g_malloc,
- (gcry_handler_alloc_t)gkr_secure_alloc,
- gkr_secure_check,
- (gcry_handler_realloc_t)gkr_secure_realloc,
- gkr_secure_free);
+ (gcry_handler_alloc_t)egg_secure_alloc,
+ egg_secure_check,
+ (gcry_handler_realloc_t)egg_secure_realloc,
+ egg_secure_free);
gcrypt_initialized = TRUE;
@@ -200,10 +200,10 @@
n_digest = gcry_md_get_algo_dlen (hash_algo);
g_return_val_if_fail (n_digest > 0, FALSE);
- digest = gkr_secure_alloc (n_digest);
+ digest = egg_secure_alloc (n_digest);
g_return_val_if_fail (digest, FALSE);
if (key) {
- *key = gkr_secure_alloc (needed_key);
+ *key = egg_secure_alloc (needed_key);
g_return_val_if_fail (*key, FALSE);
}
if (iv)
@@ -256,7 +256,7 @@
break;
}
- gkr_secure_free (digest);
+ egg_secure_free (digest);
gcry_md_close (mdh);
return TRUE;
@@ -309,10 +309,10 @@
return FALSE;
}
- digest = gkr_secure_alloc (n_digest);
+ digest = egg_secure_alloc (n_digest);
g_return_val_if_fail (digest, FALSE);
if (key) {
- *key = gkr_secure_alloc (needed_key);
+ *key = egg_secure_alloc (needed_key);
g_return_val_if_fail (*key, FALSE);
}
if (iv)
@@ -342,7 +342,7 @@
memcpy (*iv, digest + (16 - needed_iv), needed_iv);
}
- gkr_secure_free (digest);
+ egg_secure_free (digest);
gcry_md_close (mdh);
return TRUE;
@@ -375,9 +375,9 @@
}
/* Reqisition me a buffer */
- hash = gkr_secure_alloc (n_hash);
- buf_i = gkr_secure_alloc (128);
- buf_b = gkr_secure_alloc (64);
+ hash = egg_secure_alloc (n_hash);
+ buf_i = egg_secure_alloc (128);
+ buf_b = egg_secure_alloc (64);
g_return_val_if_fail (hash && buf_i && buf_b, FALSE);
/* Bring in the salt */
@@ -452,9 +452,9 @@
}
}
- gkr_secure_free (buf_i);
- gkr_secure_free (buf_b);
- gkr_secure_free (hash);
+ egg_secure_free (buf_i);
+ egg_secure_free (buf_b);
+ egg_secure_free (hash);
gcry_mpi_release (num_b1);
gcry_md_close (mdh);
@@ -488,7 +488,7 @@
/* Generate us an key */
if (key) {
- *key = gkr_secure_alloc (n_key);
+ *key = egg_secure_alloc (n_key);
g_return_val_if_fail (*key != NULL, FALSE);
ret = generate_pkcs12 (hash_algo, 1, password, salt, n_salt,
iterations, *key, n_key);
@@ -541,10 +541,10 @@
}
/* Get us a temporary buffers */
- T = gkr_secure_alloc (n_hash);
- U = gkr_secure_alloc (n_hash);
+ T = egg_secure_alloc (n_hash);
+ U = egg_secure_alloc (n_hash);
n_buf = n_salt + 4;
- buf = gkr_secure_alloc (n_buf);
+ buf = egg_secure_alloc (n_buf);
g_return_val_if_fail (buf && T && U, FALSE);
/* n_hash blocks in output, rounding up */
@@ -585,9 +585,9 @@
memcpy (output + (i - 1) * n_hash, T, i == l ? r : n_hash);
}
- gkr_secure_free (T);
- gkr_secure_free (U);
- gkr_secure_free (buf);
+ egg_secure_free (T);
+ egg_secure_free (U);
+ egg_secure_free (buf);
gcry_md_close (mdh);
return TRUE;
}
@@ -617,7 +617,7 @@
/* Generate us an key */
if (key) {
- *key = gkr_secure_alloc (n_key);
+ *key = egg_secure_alloc (n_key);
g_return_val_if_fail (*key != NULL, FALSE);
ret = generate_pbkdf2 (hash_algo, password, n_password, salt, n_salt,
iterations, *key, n_key);
Modified: trunk/common/tests/Makefile.am
==============================================================================
--- trunk/common/tests/Makefile.am (original)
+++ trunk/common/tests/Makefile.am Sat Jan 17 23:27:10 2009
@@ -1,6 +1,5 @@
UNIT_AUTO = \
unit-test-async.c \
- unit-test-secmem.c \
unit-test-unique.c \
unit-test-crypto.c \
unit-test-cleanup.c \
@@ -11,6 +10,7 @@
UNIT_PROMPT =
UNIT_LIBS = \
+ $(top_builddir)/egg/libegg.la \
$(top_builddir)/common/libgkr-common.la
include $(top_srcdir)/tests/test.make
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Sat Jan 17 23:27:10 2009
@@ -495,6 +495,8 @@
daemon/ssh/Makefile
daemon/ssh/tests/Makefile
daemon/ui/Makefile
+egg/Makefile
+egg/tests/Makefile
gp11/gp11.pc
gp11/Makefile
gp11/reference/Makefile
Modified: trunk/daemon/gkr-daemon-io.c
==============================================================================
--- trunk/daemon/gkr-daemon-io.c (original)
+++ trunk/daemon/gkr-daemon-io.c Sat Jan 17 23:27:10 2009
@@ -35,11 +35,11 @@
#include "gkr-daemon.h"
#include "common/gkr-async.h"
-#include "common/gkr-buffer.h"
+#include "egg/egg-buffer.h"
#include "common/gkr-cleanup.h"
#include "common/gkr-daemon-util.h"
-#include "common/gkr-secure-memory.h"
-#include "common/gkr-unix-credentials.h"
+#include "egg/egg-secure-memory.h"
+#include "egg/egg-unix-credentials.h"
#include "keyrings/gkr-keyrings.h"
@@ -69,8 +69,8 @@
GnomeKeyringApplicationRef *app_ref;
- GkrBuffer input_buffer;
- GkrBuffer output_buffer;
+ EggBuffer input_buffer;
+ EggBuffer output_buffer;
} GnomeKeyringClient;
static char socket_path[1024] = { 0, };
@@ -188,7 +188,7 @@
fd = client->sock;
- gkr_buffer_resize (&client->input_buffer, 4);
+ egg_buffer_resize (&client->input_buffer, 4);
if (!yield_and_read_all (fd, client->input_buffer.buf, 4))
return FALSE;
@@ -198,7 +198,7 @@
return FALSE;
}
- gkr_buffer_resize (&client->input_buffer, packet_size + 4);
+ egg_buffer_resize (&client->input_buffer, packet_size + 4);
if (!yield_and_read_all (fd, client->input_buffer.buf + 4, packet_size - 4))
return FALSE;
@@ -212,7 +212,7 @@
gkr_async_begin_concurrent ();
- ret = gkr_unix_credentials_read (sock, pid, uid) >= 0;
+ ret = egg_unix_credentials_read (sock, pid, uid) >= 0;
gkr_async_end_concurrent ();
@@ -287,10 +287,10 @@
/* Make sure keyrings in memory are up to date before doing anything */
gkr_keyrings_update ();
- gkr_buffer_init_full (&client->output_buffer, 128, (GkrBufferAllocator)g_realloc);
+ egg_buffer_init_full (&client->output_buffer, 128, (EggBufferAllocator)g_realloc);
/* Add empty size */
- gkr_buffer_add_uint32 (&client->output_buffer, 0);
+ egg_buffer_add_uint32 (&client->output_buffer, 0);
memset (&req, 0, sizeof (req));
req.app_ref = client->app_ref;
@@ -298,7 +298,7 @@
if (!(keyring_ops[op])(&client->input_buffer, &client->output_buffer, &req))
return NULL;
- if (!gkr_buffer_set_uint32 (&client->output_buffer, 0,
+ if (!egg_buffer_set_uint32 (&client->output_buffer, 0,
client->output_buffer.len))
return NULL;
@@ -319,8 +319,8 @@
{
GnomeKeyringClient *client = (GnomeKeyringClient*)user_data;
- gkr_buffer_uninit (&client->input_buffer);
- gkr_buffer_uninit (&client->output_buffer);
+ egg_buffer_uninit (&client->input_buffer);
+ egg_buffer_uninit (&client->output_buffer);
if (client->app_ref != NULL) {
gnome_keyring_application_ref_free (client->app_ref);
@@ -346,7 +346,7 @@
* so we err on the side of caution and use secure memory in case
* passwords or secrets are involved.
*/
- gkr_buffer_init_full (&client->input_buffer, 128, gkr_secure_realloc);
+ egg_buffer_init_full (&client->input_buffer, 128, egg_secure_realloc);
client->worker = gkr_async_worker_start (client_worker_main,
client_worker_done, client);
Modified: trunk/daemon/gkr-daemon-ops.c
==============================================================================
--- trunk/daemon/gkr-daemon-ops.c (original)
+++ trunk/daemon/gkr-daemon-ops.c Sat Jan 17 23:27:10 2009
@@ -24,10 +24,10 @@
#include "gkr-daemon.h"
-#include "common/gkr-buffer.h"
+#include "egg/egg-buffer.h"
#include "common/gkr-daemon-util.h"
#include "common/gkr-location.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "keyrings/gkr-keyring.h"
#include "keyrings/gkr-keyring-item.h"
@@ -454,7 +454,7 @@
ret = ask->response >= GKR_ASK_RESPONSE_ALLOW;
if (ret) {
g_free (*password);
- *password = gkr_secure_strdup (ask->typed_password);
+ *password = egg_secure_strdup (ask->typed_password);
*volume = ask->location_selected;
}
@@ -550,10 +550,10 @@
ret = ask->response >= GKR_ASK_RESPONSE_ALLOW;
if (ret) {
g_free (*password);
- *password = gkr_secure_strdup (ask->typed_password);
+ *password = egg_secure_strdup (ask->typed_password);
g_free (*original);
- *original = gkr_secure_strdup (ask->original_password);
+ *original = egg_secure_strdup (ask->original_password);
}
g_object_unref (ask);
@@ -686,14 +686,14 @@
if (keyring->locked) {
return GNOME_KEYRING_RESULT_DENIED;
} else {
- keyring->password = gkr_secure_strdup (password);
+ keyring->password = egg_secure_strdup (password);
gkr_keyring_save_to_disk (keyring);
return GNOME_KEYRING_RESULT_OK;
}
}
static gboolean
-op_lock_keyring (GkrBuffer *packet, GkrBuffer *result,
+op_lock_keyring (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
char *keyring_name;
@@ -705,10 +705,10 @@
keyring = gkr_keyrings_find (keyring_name);
if (keyring == NULL) {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_NO_SUCH_KEYRING);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_NO_SUCH_KEYRING);
} else {
gkr_keyring_lock (keyring);
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
}
g_free (keyring_name);
@@ -724,16 +724,16 @@
}
static gboolean
-op_lock_all (GkrBuffer *packet, GkrBuffer *result,
+op_lock_all (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
gkr_keyrings_foreach (lock_each_keyring, NULL);
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
return TRUE;
}
static gboolean
-op_set_default_keyring (GkrBuffer *packet, GkrBuffer *result,
+op_set_default_keyring (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
char *keyring_name;
@@ -745,14 +745,14 @@
if (keyring_name == NULL) {
gkr_keyrings_set_default (NULL);
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
} else {
keyring = gkr_keyrings_find (keyring_name);
if (keyring == NULL) {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_NO_SUCH_KEYRING);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_NO_SUCH_KEYRING);
} else {
gkr_keyrings_set_default (keyring);
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
}
}
@@ -762,13 +762,13 @@
}
static gboolean
-op_get_default_keyring (GkrBuffer *packet, GkrBuffer *result,
+op_get_default_keyring (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
GkrKeyring* keyring;
char *name;
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
name = NULL;
@@ -785,17 +785,17 @@
static gboolean
add_name_to_result (GkrKeyring* keyring, gpointer result)
{
- return gkr_proto_add_utf8_string ((GkrBuffer*)result,
+ return gkr_proto_add_utf8_string ((EggBuffer*)result,
keyring->keyring_name);
}
static gboolean
-op_list_keyrings (GkrBuffer *packet, GkrBuffer *result,
+op_list_keyrings (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
- gkr_buffer_add_uint32 (result, gkr_keyrings_get_count ());
+ egg_buffer_add_uint32 (result, gkr_keyrings_get_count ());
if (!gkr_keyrings_foreach (add_name_to_result, result))
return FALSE;
@@ -804,7 +804,7 @@
static gboolean
-op_set_keyring_info (GkrBuffer *packet, GkrBuffer *result,
+op_set_keyring_info (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
char *keyring_name;
@@ -821,9 +821,9 @@
keyring = gkr_keyrings_find (keyring_name);
if (keyring == NULL) {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_NO_SUCH_KEYRING);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_NO_SUCH_KEYRING);
} else {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
keyring->lock_on_idle = lock_on_idle;
keyring->lock_timeout = lock_timeout;
@@ -835,7 +835,7 @@
}
static gboolean
-op_get_keyring_info (GkrBuffer *packet, GkrBuffer *result,
+op_get_keyring_info (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
char *keyring_name;
@@ -847,15 +847,15 @@
keyring = gkr_keyrings_find (keyring_name);
if (keyring == NULL) {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_NO_SUCH_KEYRING);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_NO_SUCH_KEYRING);
} else {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
- gkr_buffer_add_uint32 (result, keyring->lock_on_idle);
- gkr_buffer_add_uint32 (result, keyring->lock_timeout);
+ egg_buffer_add_uint32 (result, keyring->lock_on_idle);
+ egg_buffer_add_uint32 (result, keyring->lock_timeout);
gkr_proto_add_time (result, keyring->mtime);
gkr_proto_add_time (result, keyring->ctime);
- gkr_buffer_add_uint32 (result, keyring->locked);
+ egg_buffer_add_uint32 (result, keyring->locked);
}
g_free (keyring_name);
@@ -864,7 +864,7 @@
}
static gboolean
-op_create_keyring (GkrBuffer *packet, GkrBuffer *result,
+op_create_keyring (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
GQuark volume = GKR_LOCATION_VOLUME_LOCAL;
@@ -881,25 +881,25 @@
g_assert (opcode == GNOME_KEYRING_OP_CREATE_KEYRING);
if (keyring_name == NULL) {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_BAD_ARGUMENTS);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_BAD_ARGUMENTS);
goto out;
}
keyring = gkr_keyrings_find (keyring_name);
if (keyring != NULL) {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_ALREADY_EXISTS);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_ALREADY_EXISTS);
goto out;
}
/* Let user pick password if necessary*/
if (!request_new_keyring_password (req, keyring_name, &password, &volume)) {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
goto out;
}
keyring = gkr_keyring_create (volume, keyring_name, password);
if (keyring == NULL) {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
goto out;
}
@@ -910,17 +910,17 @@
g_object_unref (keyring);
g_assert (GKR_IS_KEYRING (keyring));
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
out:
g_free (keyring_name);
- gkr_secure_strfree (password);
+ egg_secure_strfree (password);
return TRUE;
}
static gboolean
-op_unlock_keyring (GkrBuffer *packet, GkrBuffer *result,
+op_unlock_keyring (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
char *keyring_name, *password;
@@ -938,7 +938,7 @@
keyring = gkr_keyrings_find (keyring_name);
if (!keyring) {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_NO_SUCH_KEYRING);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_NO_SUCH_KEYRING);
goto out;
}
@@ -946,9 +946,9 @@
/* User types password */
if (password == NULL) {
if (request_keyring_access (req, keyring))
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
else
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
/* Password specified */
} else {
@@ -956,19 +956,19 @@
res = GNOME_KEYRING_RESULT_OK;
else
res = GNOME_KEYRING_RESULT_DENIED;
- gkr_buffer_add_uint32 (result, res);
+ egg_buffer_add_uint32 (result, res);
}
out:
g_free (keyring_name);
- gkr_secure_strfree (password);
+ egg_secure_strfree (password);
return TRUE;
}
static gboolean
-op_delete_keyring (GkrBuffer *packet, GkrBuffer *result,
+op_delete_keyring (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
char *keyring_name;
@@ -995,7 +995,7 @@
}
}
- gkr_buffer_add_uint32 (result, res);
+ egg_buffer_add_uint32 (result, res);
g_free (keyring_name);
if (res == GNOME_KEYRING_RESULT_OK)
@@ -1005,7 +1005,7 @@
}
static gboolean
-op_change_keyring_password (GkrBuffer *packet, GkrBuffer *result,
+op_change_keyring_password (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
char *keyring_name, *original, *password;
@@ -1022,41 +1022,41 @@
g_assert (opcode == GNOME_KEYRING_OP_CHANGE_KEYRING_PASSWORD);
if (keyring_name == NULL) {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_BAD_ARGUMENTS);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_BAD_ARGUMENTS);
goto out;
}
keyring = gkr_keyrings_find (keyring_name);
if (keyring == NULL) {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_NO_SUCH_KEYRING);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_NO_SUCH_KEYRING);
goto out;
}
/* Prompt for any missing passwords */
if (!request_change_keyring_password (req, keyring, &original, &password)) {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
goto out;
}
gkr_keyring_lock (keyring);
if (!gkr_keyring_unlock (keyring, original)) {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
goto out;
}
- gkr_buffer_add_uint32 (result, change_keyring_password (keyring, password));
+ egg_buffer_add_uint32 (result, change_keyring_password (keyring, password));
out:
g_free (keyring_name);
- gkr_secure_strfree (original);
- gkr_secure_strfree (password);
+ egg_secure_strfree (original);
+ egg_secure_strfree (password);
return TRUE;
}
static gboolean
-op_list_items (GkrBuffer *packet, GkrBuffer *result,
+op_list_items (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
GkrKeyring *keyring;
@@ -1070,16 +1070,16 @@
keyring = gkr_keyrings_find (keyring_name);
if (keyring == NULL) {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_NO_SUCH_KEYRING);
- gkr_buffer_add_uint32 (result, 0);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_NO_SUCH_KEYRING);
+ egg_buffer_add_uint32 (result, 0);
} else if (!request_keyring_access (req, keyring)) {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
- gkr_buffer_add_uint32 (result, 0);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
+ egg_buffer_add_uint32 (result, 0);
} else {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
items = NULL;
for (l = keyring->items; l != NULL; l = l->next) {
@@ -1089,10 +1089,10 @@
items = g_list_reverse (items);
/* Send the results */
- gkr_buffer_add_uint32 (result, g_list_length (items));
+ egg_buffer_add_uint32 (result, g_list_length (items));
for (l = items; l != NULL; l = l->next) {
item = l->data;
- gkr_buffer_add_uint32 (result, item->id);
+ egg_buffer_add_uint32 (result, item->id);
}
g_list_free (items);
@@ -1104,7 +1104,7 @@
}
static gboolean
-op_create_item (GkrBuffer *packet, GkrBuffer *result,
+op_create_item (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
char *keyring_name, *display_name, *secret;
@@ -1182,8 +1182,8 @@
g_free (item->display_name);
item->display_name = g_strdup (display_name);
- gkr_secure_strfree (item->secret);
- item->secret = gkr_secure_strdup (secret);
+ egg_secure_strfree (item->secret);
+ item->secret = egg_secure_strdup (secret);
gnome_keyring_attribute_list_free (item->attributes);
item->attributes = gnome_keyring_attribute_list_copy (attributes);
@@ -1198,17 +1198,17 @@
out:
g_free (keyring_name);
g_free (display_name);
- gkr_secure_strfree (secret);
+ egg_secure_strfree (secret);
gnome_keyring_attribute_list_free (hashed);
gnome_keyring_attribute_list_free (attributes);
- gkr_buffer_add_uint32 (result, res);
- gkr_buffer_add_uint32 (result, id);
+ egg_buffer_add_uint32 (result, res);
+ egg_buffer_add_uint32 (result, id);
return TRUE;
}
static gboolean
-op_delete_item (GkrBuffer *packet, GkrBuffer *result,
+op_delete_item (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
char *keyring_name;
@@ -1233,7 +1233,7 @@
TRUE,
&item);
- gkr_buffer_add_uint32 (result, res);
+ egg_buffer_add_uint32 (result, res);
if (res == GNOME_KEYRING_RESULT_OK) {
if (item->keyring) {
keyring = item->keyring;
@@ -1247,7 +1247,7 @@
}
static gboolean
-op_get_item_info (GkrBuffer *packet, GkrBuffer *result,
+op_get_item_info (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
char *keyring_name, *secret;
@@ -1270,9 +1270,9 @@
(flags & GNOME_KEYRING_ITEM_INFO_SECRET) == GNOME_KEYRING_ITEM_INFO_SECRET,
&item);
- gkr_buffer_add_uint32 (result, res);
+ egg_buffer_add_uint32 (result, res);
if (res == GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_add_uint32 (result, item->type);
+ egg_buffer_add_uint32 (result, item->type);
if (!gkr_proto_add_utf8_string (result, item->display_name))
ret = FALSE;
@@ -1294,7 +1294,7 @@
}
static gboolean
-op_get_item_attributes (GkrBuffer *packet, GkrBuffer *result,
+op_get_item_attributes (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
char *keyring_name;
@@ -1318,7 +1318,7 @@
FALSE,
&item);
- gkr_buffer_add_uint32 (result, res);
+ egg_buffer_add_uint32 (result, res);
if (res == GNOME_KEYRING_RESULT_OK) {
if (!gkr_proto_add_attribute_list (result, item->attributes))
ret = FALSE;
@@ -1329,7 +1329,7 @@
}
static gboolean
-op_get_item_acl (GkrBuffer *packet, GkrBuffer *result,
+op_get_item_acl (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
char *keyring_name;
@@ -1353,7 +1353,7 @@
FALSE,
&item);
- gkr_buffer_add_uint32 (result, res);
+ egg_buffer_add_uint32 (result, res);
if (res == GNOME_KEYRING_RESULT_OK) {
if (!gkr_proto_add_acl (result, item->acl))
ret = FALSE;
@@ -1364,7 +1364,7 @@
}
static gboolean
-op_set_item_acl (GkrBuffer *packet, GkrBuffer *result,
+op_set_item_acl (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
char *keyring_name;
@@ -1395,7 +1395,7 @@
gkr_keyring_save_to_disk (item->keyring);
}
- gkr_buffer_add_uint32 (result, res);
+ egg_buffer_add_uint32 (result, res);
gnome_keyring_acl_free (acl);
g_free (keyring_name);
@@ -1403,7 +1403,7 @@
}
static gboolean
-op_set_item_info (GkrBuffer *packet, GkrBuffer *result,
+op_set_item_info (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
char *keyring_name;
@@ -1428,7 +1428,7 @@
TRUE,
&item);
- gkr_buffer_add_uint32 (result, res);
+ egg_buffer_add_uint32 (result, res);
if (res == GNOME_KEYRING_RESULT_OK) {
if ((type & GNOME_KEYRING_ITEM_TYPE_MASK) != GNOME_KEYRING_ITEM_NO_TYPE) {
item->type = type;
@@ -1438,8 +1438,8 @@
item->display_name = g_strdup (item_name);
}
if (secret != NULL) {
- gkr_secure_strfree (item->secret);
- item->secret = gkr_secure_strdup (secret);
+ egg_secure_strfree (item->secret);
+ item->secret = egg_secure_strdup (secret);
}
if (item->keyring)
@@ -1448,12 +1448,12 @@
g_free (keyring_name);
g_free (item_name);
- gkr_secure_strfree (secret);
+ egg_secure_strfree (secret);
return TRUE;
}
static gboolean
-op_set_daemon_display (GkrBuffer *packet, GkrBuffer *result,
+op_set_daemon_display (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
char *display;
@@ -1463,10 +1463,10 @@
return FALSE;
if (display == NULL) {
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
} else {
g_setenv ("DISPLAY", display, FALSE);
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
}
g_free (display);
@@ -1474,7 +1474,7 @@
}
static gboolean
-op_set_item_attributes (GkrBuffer *packet, GkrBuffer *result,
+op_set_item_attributes (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req)
{
char *keyring_name;
@@ -1497,7 +1497,7 @@
TRUE,
&item);
- gkr_buffer_add_uint32 (result, res);
+ egg_buffer_add_uint32 (result, res);
if (res == GNOME_KEYRING_RESULT_OK) {
gnome_keyring_attribute_list_free (item->attributes);
item->attributes = gnome_keyring_attribute_list_copy (attributes);
@@ -1614,7 +1614,7 @@
}
static gboolean
-op_find (GkrBuffer *packet, GkrBuffer *result, GkrKeyringRequest *req)
+op_find (EggBuffer *packet, EggBuffer *result, GkrKeyringRequest *req)
{
FindContext ctx;
GList *l;
@@ -1639,15 +1639,15 @@
/* No items given access to */
if (ctx.nfound > 0 && ctx.items == NULL)
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_DENIED);
/* Zero items matched */
else if (ctx.nfound == 0)
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_NO_MATCH);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_NO_MATCH);
/* More than one item found and given access to */
else
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
ctx.items = g_list_sort_with_data (ctx.items, sort_found, ctx.attributes);
@@ -1664,7 +1664,7 @@
break;
}
- gkr_buffer_add_uint32 (result, item->id);
+ egg_buffer_add_uint32 (result, item->id);
if (!gkr_proto_add_utf8_secret (result, item->secret) ||
!gkr_proto_add_attribute_list (result, item->attributes)) {
@@ -1684,7 +1684,7 @@
}
static gboolean
-op_prepare_daemon_environment (GkrBuffer *packet, GkrBuffer *result, GkrKeyringRequest *req)
+op_prepare_daemon_environment (EggBuffer *packet, EggBuffer *result, GkrKeyringRequest *req)
{
const gchar **daemonenv;
gchar **environment, **e;
@@ -1719,13 +1719,13 @@
*/
gkr_daemon_complete_initialization();
- gkr_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
+ egg_buffer_add_uint32 (result, GNOME_KEYRING_RESULT_OK);
/* These are the environment variables that the daemon setup */
daemonenv = gkr_daemon_util_get_environment ();
g_return_val_if_fail (daemonenv, FALSE);
- gkr_buffer_add_stringv (result, daemonenv);
+ egg_buffer_add_stringv (result, daemonenv);
return TRUE;
}
Modified: trunk/daemon/gkr-daemon.c
==============================================================================
--- trunk/daemon/gkr-daemon.c (original)
+++ trunk/daemon/gkr-daemon.c Sat Jan 17 23:27:10 2009
@@ -28,8 +28,8 @@
#include "common/gkr-cleanup.h"
#include "common/gkr-crypto.h"
#include "common/gkr-daemon-util.h"
-#include "common/gkr-secure-memory.h"
-#include "common/gkr-unix-credentials.h"
+#include "egg/egg-secure-memory.h"
+#include "egg/egg-unix-credentials.h"
#include "common/gkr-unix-signal.h"
#include "keyrings/gkr-keyring-login.h"
@@ -220,19 +220,19 @@
*/
void
-gkr_memory_lock (void)
+egg_memory_lock (void)
{
/* The daemon uses cooperative threading, and doesn't need locking */
}
void
-gkr_memory_unlock (void)
+egg_memory_unlock (void)
{
/* The daemon uses cooperative threading, and doesn't need locking */
}
void*
-gkr_memory_fallback (void *p, unsigned long sz)
+egg_memory_fallback (void *p, unsigned long sz)
{
const gchar *env;
@@ -368,7 +368,7 @@
* password.
*/
- gchar *buf = gkr_secure_alloc (MAX_BLOCK);
+ gchar *buf = egg_secure_alloc (MAX_BLOCK);
gchar *ret = NULL;
int r, len = 0;
@@ -377,12 +377,12 @@
if (r < 0) {
if (errno == EAGAIN)
continue;
- gkr_secure_free (ret);
- gkr_secure_free (buf);
+ egg_secure_free (ret);
+ egg_secure_free (buf);
return NULL;
} else {
- char *n = gkr_secure_realloc (ret, len + r + 1);
+ char *n = egg_secure_realloc (ret, len + r + 1);
memset(n + len, 0, r + 1);
ret = n;
len = len + r;
@@ -394,7 +394,7 @@
break;
}
- gkr_secure_free (buf);
+ egg_secure_free (buf);
return ret;
}
@@ -409,7 +409,7 @@
clear_login_password (void)
{
if(login_password)
- gkr_secure_strfree (login_password);
+ egg_secure_strfree (login_password);
login_password = NULL;
}
@@ -458,20 +458,20 @@
{
GnomeKeyringResult res;
gchar **envp, **e;
- GkrBuffer buf;
+ EggBuffer buf;
gboolean ret;
- if (gkr_unix_credentials_write (sock) < 0)
+ if (egg_unix_credentials_write (sock) < 0)
return FALSE;
- gkr_buffer_init_full (&buf, 128, (GkrBufferAllocator)g_realloc);
+ egg_buffer_init_full (&buf, 128, (EggBufferAllocator)g_realloc);
envp = gnome_keyring_build_environment (GNOME_KEYRING_IN_ENVIRONMENT);
ret = gkr_proto_encode_prepare_environment (&buf, (const gchar**)envp);
g_strfreev (envp);
if (!ret) {
- gkr_buffer_uninit (&buf);
+ egg_buffer_uninit (&buf);
g_return_val_if_reached (FALSE);
}
@@ -482,7 +482,7 @@
gkr_proto_decode_prepare_environment_reply (&buf, &res, &envp);
- gkr_buffer_uninit (&buf);
+ egg_buffer_uninit (&buf);
if(!ret) {
g_warning ("couldn't initialize running daemon");
@@ -745,7 +745,7 @@
if (login_password) {
if (!gkr_keyring_login_unlock (login_password))
g_warning ("Failed to unlock login on startup");
- gkr_secure_strclear (login_password);
+ egg_secure_strclear (login_password);
}
g_main_loop_run (loop);
Modified: trunk/daemon/gkr-daemon.h
==============================================================================
--- trunk/daemon/gkr-daemon.h (original)
+++ trunk/daemon/gkr-daemon.h Sat Jan 17 23:27:10 2009
@@ -27,7 +27,7 @@
#include <sys/types.h>
#include <glib.h>
-#include "common/gkr-buffer.h"
+#include "egg/egg-buffer.h"
#include "keyrings/gkr-keyring.h"
#include "keyrings/gkr-keyring-item.h"
@@ -40,7 +40,7 @@
GnomeKeyringApplicationRef *app_ref;
} GkrKeyringRequest;
-typedef gboolean (*GkrDaemonOperation) (GkrBuffer *packet, GkrBuffer *result,
+typedef gboolean (*GkrDaemonOperation) (EggBuffer *packet, EggBuffer *result,
GkrKeyringRequest *req);
extern GkrDaemonOperation keyring_ops[];
Modified: trunk/daemon/keyrings/gkr-keyring-binary.c
==============================================================================
--- trunk/daemon/keyrings/gkr-keyring-binary.c (original)
+++ trunk/daemon/keyrings/gkr-keyring-binary.c Sat Jan 17 23:27:10 2009
@@ -27,9 +27,9 @@
#include "gkr-keyring.h"
#include "gkr-keyring-item.h"
-#include "common/gkr-buffer.h"
+#include "egg/egg-buffer.h"
#include "common/gkr-crypto.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "library/gnome-keyring-private.h"
#include "library/gnome-keyring-proto.h"
@@ -105,7 +105,7 @@
}
static gboolean
-encrypt_buffer (GkrBuffer *buffer,
+encrypt_buffer (EggBuffer *buffer,
const char *password,
guchar salt[8],
int iterations)
@@ -127,7 +127,7 @@
if (gerr) {
g_warning ("couldn't create aes cipher context: %s",
gcry_strerror (gerr));
- gkr_secure_free (key);
+ egg_secure_free (key);
g_free (iv);
return FALSE;
}
@@ -135,7 +135,7 @@
/* 16 = 128 bits */
gerr = gcry_cipher_setkey (cih, key, 16);
g_return_val_if_fail (!gerr, FALSE);
- gkr_secure_free (key);
+ egg_secure_free (key);
/* 16 = 128 bits */
gerr = gcry_cipher_setiv (cih, iv, 16);
@@ -154,7 +154,7 @@
}
static gboolean
-decrypt_buffer (GkrBuffer *buffer,
+decrypt_buffer (EggBuffer *buffer,
const char *password,
guchar salt[8],
int iterations)
@@ -176,7 +176,7 @@
if (gerr) {
g_warning ("couldn't create aes cipher context: %s",
gcry_strerror (gerr));
- gkr_secure_free (key);
+ egg_secure_free (key);
g_free (iv);
return FALSE;
}
@@ -184,7 +184,7 @@
/* 16 = 128 bits */
gerr = gcry_cipher_setkey (cih, key, 16);
g_return_val_if_fail (!gerr, FALSE);
- gkr_secure_free (key);
+ egg_secure_free (key);
/* 16 = 128 bits */
gerr = gcry_cipher_setiv (cih, iv, 16);
@@ -203,7 +203,7 @@
}
static gboolean
-verify_decrypted_buffer (GkrBuffer *buffer)
+verify_decrypted_buffer (EggBuffer *buffer)
{
guchar digest[16];
@@ -217,17 +217,17 @@
}
static gboolean
-generate_acl_data (GkrBuffer *buffer, GList *acl)
+generate_acl_data (EggBuffer *buffer, GList *acl)
{
GList *l;
GnomeKeyringAccessControl *ac;
- gkr_buffer_add_uint32 (buffer, g_list_length (acl));
+ egg_buffer_add_uint32 (buffer, g_list_length (acl));
for (l = acl; l != NULL; l = l->next) {
ac = l->data;
- gkr_buffer_add_uint32 (buffer, ac->types_allowed);
+ egg_buffer_add_uint32 (buffer, ac->types_allowed);
if (!gkr_proto_add_utf8_string (buffer, ac->application->display_name)) {
return FALSE;
}
@@ -238,14 +238,14 @@
if (!gkr_proto_add_utf8_string (buffer, NULL)) {
return FALSE;
}
- gkr_buffer_add_uint32 (buffer, 0);
+ egg_buffer_add_uint32 (buffer, 0);
}
return TRUE;
}
static gboolean
-generate_encrypted_data (GkrBuffer *buffer, GkrKeyring *keyring)
+generate_encrypted_data (EggBuffer *buffer, GkrKeyring *keyring)
{
GList *l;
int i;
@@ -270,7 +270,7 @@
return FALSE;
}
for (i = 0; i < 4; i++) {
- gkr_buffer_add_uint32 (buffer, 0);
+ egg_buffer_add_uint32 (buffer, 0);
}
if (!gkr_proto_add_attribute_list (buffer, item->attributes)) {
@@ -284,13 +284,13 @@
}
gboolean
-gkr_keyring_binary_generate (GkrKeyring *keyring, GkrBuffer *buffer)
+gkr_keyring_binary_generate (GkrKeyring *keyring, EggBuffer *buffer)
{
guint flags;
GList *l;
GkrKeyringItem *item;
GnomeKeyringAttributeList *hashed;
- GkrBuffer to_encrypt;
+ EggBuffer to_encrypt;
guchar digest[16];
int i;
@@ -306,11 +306,11 @@
keyring->salt_valid = TRUE;
}
- gkr_buffer_append (buffer, (guchar*)KEYRING_FILE_HEADER, KEYRING_FILE_HEADER_LEN);
- gkr_buffer_add_byte (buffer, 0); /* Major version */
- gkr_buffer_add_byte (buffer, 0); /* Minor version */
- gkr_buffer_add_byte (buffer, 0); /* crypto (0 == AEL) */
- gkr_buffer_add_byte (buffer, 0); /* hash (0 == MD5) */
+ egg_buffer_append (buffer, (guchar*)KEYRING_FILE_HEADER, KEYRING_FILE_HEADER_LEN);
+ egg_buffer_add_byte (buffer, 0); /* Major version */
+ egg_buffer_add_byte (buffer, 0); /* Minor version */
+ egg_buffer_add_byte (buffer, 0); /* crypto (0 == AEL) */
+ egg_buffer_add_byte (buffer, 0); /* hash (0 == MD5) */
if (!gkr_proto_add_utf8_string (buffer, keyring->keyring_name)) {
return FALSE;
@@ -323,23 +323,23 @@
if (keyring->lock_on_idle) {
flags |= 1;
}
- gkr_buffer_add_uint32 (buffer, flags);
- gkr_buffer_add_uint32 (buffer, keyring->lock_timeout);
- gkr_buffer_add_uint32 (buffer, keyring->hash_iterations);
- gkr_buffer_append (buffer, (guchar*)keyring->salt, 8);
+ egg_buffer_add_uint32 (buffer, flags);
+ egg_buffer_add_uint32 (buffer, keyring->lock_timeout);
+ egg_buffer_add_uint32 (buffer, keyring->hash_iterations);
+ egg_buffer_append (buffer, (guchar*)keyring->salt, 8);
/* Reserved: */
for (i = 0; i < 4; i++) {
- gkr_buffer_add_uint32 (buffer, 0);
+ egg_buffer_add_uint32 (buffer, 0);
}
/* Hashed items: */
- gkr_buffer_add_uint32 (buffer, g_list_length (keyring->items));
+ egg_buffer_add_uint32 (buffer, g_list_length (keyring->items));
for (l = keyring->items; l != NULL; l = l->next) {
item = l->data;
- gkr_buffer_add_uint32 (buffer, item->id);
- gkr_buffer_add_uint32 (buffer, item->type);
+ egg_buffer_add_uint32 (buffer, item->id);
+ egg_buffer_add_uint32 (buffer, item->type);
hashed = gkr_attribute_list_hash (item->attributes);
@@ -351,18 +351,18 @@
}
/* Encrypted data. Use non-pageable memory */
- gkr_buffer_init_full (&to_encrypt, 4096, gkr_secure_realloc);
+ egg_buffer_init_full (&to_encrypt, 4096, egg_secure_realloc);
- gkr_buffer_append (&to_encrypt, (guchar*)digest, 16); /* Space for hash */
+ egg_buffer_append (&to_encrypt, (guchar*)digest, 16); /* Space for hash */
if (!generate_encrypted_data (&to_encrypt, keyring)) {
- gkr_buffer_uninit (&to_encrypt);
+ egg_buffer_uninit (&to_encrypt);
return FALSE;
}
/* Pad with zeros to multiple of 16 bytes */
while (to_encrypt.len % 16 != 0) {
- gkr_buffer_add_byte (&to_encrypt, 0);
+ egg_buffer_add_byte (&to_encrypt, 0);
}
gcry_md_hash_buffer (GCRY_MD_MD5, (void*)digest,
@@ -373,18 +373,18 @@
g_assert (keyring->hash_iterations);
if (!encrypt_buffer (&to_encrypt, keyring->password, keyring->salt, keyring->hash_iterations)) {
- gkr_buffer_uninit (&to_encrypt);
+ egg_buffer_uninit (&to_encrypt);
return FALSE;
}
- gkr_buffer_add_uint32 (buffer, to_encrypt.len);
- gkr_buffer_append (buffer, to_encrypt.buf, to_encrypt.len);
- gkr_buffer_uninit (&to_encrypt);
+ egg_buffer_add_uint32 (buffer, to_encrypt.len);
+ egg_buffer_append (buffer, to_encrypt.buf, to_encrypt.len);
+ egg_buffer_uninit (&to_encrypt);
return TRUE;
}
static gboolean
-decode_acl (GkrBuffer *buffer, gsize offset, gsize *offset_out, GList **out)
+decode_acl (EggBuffer *buffer, gsize offset, gsize *offset_out, GList **out)
{
GList *acl;
guint32 num_acs;
@@ -395,11 +395,11 @@
acl = NULL;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &num_acs)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &num_acs)) {
return FALSE;
}
for (i = 0; i < num_acs; i++) {
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &x)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &x)) {
goto bail;
}
if (!gkr_proto_get_utf8_string (buffer, offset, &offset, &name)) {
@@ -416,7 +416,7 @@
g_free (reserved);
goto bail;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &y)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &y)) {
g_free (name);
g_free (path);
g_free (reserved);
@@ -456,7 +456,7 @@
}
gint
-gkr_keyring_binary_parse (GkrKeyring *keyring, GkrBuffer *buffer)
+gkr_keyring_binary_parse (GkrKeyring *keyring, EggBuffer *buffer)
{
gsize offset;
guchar major, minor, crypto, hash;
@@ -471,7 +471,7 @@
guint32 hash_iterations;
guchar salt[8];
ItemInfo *items;
- GkrBuffer to_decrypt = GKR_BUFFER_EMPTY;
+ EggBuffer to_decrypt = EGG_BUFFER_EMPTY;
gboolean locked;
GList *l;
GHashTable *checks = NULL;
@@ -482,7 +482,7 @@
items = 0;
/* We're decrypting this, so use secure memory */
- gkr_buffer_set_allocator (&to_decrypt, gkr_secure_realloc);
+ egg_buffer_set_allocator (&to_decrypt, egg_secure_realloc);
if (buffer->len < KEYRING_FILE_HEADER_LEN) {
return 0;
@@ -511,13 +511,13 @@
if (!gkr_proto_get_time (buffer, offset, &offset, &mtime)) {
goto bail;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &flags)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &flags)) {
goto bail;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &lock_timeout)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &lock_timeout)) {
goto bail;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &hash_iterations)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &hash_iterations)) {
goto bail;
}
if (!gkr_proto_get_bytes (buffer, offset, &offset, salt, 8)) {
@@ -525,7 +525,7 @@
}
for (i = 0; i < 4; i++) {
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &tmp)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &tmp)) {
goto bail;
}
/* reserved bytes must be zero */
@@ -533,18 +533,18 @@
goto bail;
}
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &num_items)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &num_items)) {
goto bail;
}
items = g_new0 (ItemInfo, num_items);
for (i = 0; i < num_items; i++) {
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset,
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset,
&items[i].id)) {
goto bail;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset,
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset,
&items[i].type)) {
goto bail;
}
@@ -554,7 +554,7 @@
}
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset,
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset,
&crypto_size)) {
goto bail;
}
@@ -565,7 +565,7 @@
}
/* Copy the data into to_decrypt into non-pageable memory */
- gkr_buffer_init_static (&to_decrypt, buffer->buf + offset, crypto_size);
+ egg_buffer_init_static (&to_decrypt, buffer->buf + offset, crypto_size);
locked = TRUE;
if (keyring->password != NULL) {
@@ -574,7 +574,7 @@
goto bail;
}
if (!verify_decrypted_buffer (&to_decrypt)) {
- gkr_secure_strfree (keyring->password);
+ egg_secure_strfree (keyring->password);
keyring->password = NULL;
} else {
locked = FALSE;
@@ -605,7 +605,7 @@
}
for (j = 0; j < 4; j++) {
guint32 tmp;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &tmp)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &tmp)) {
goto bail;
}
/* reserved bytes must be zero */
@@ -663,7 +663,7 @@
g_free (item->display_name);
item->display_name = NULL;
- gkr_secure_strfree (item->secret);
+ egg_secure_strfree (item->secret);
item->secret = NULL;
if (item->acl) {
gnome_keyring_acl_free (item->acl);
@@ -692,7 +692,7 @@
return 1;
bail:
- gkr_buffer_uninit (&to_decrypt);
+ egg_buffer_uninit (&to_decrypt);
if (checks)
g_hash_table_destroy (checks);
g_free (display_name);
@@ -700,7 +700,7 @@
if (items != NULL) {
for (i = 0; i < num_items; i++) {
g_free (items[i].display_name);
- gkr_secure_strfree (items[i].secret);
+ egg_secure_strfree (items[i].secret);
gnome_keyring_attribute_list_free (items[i].hashed_attributes);
gnome_keyring_attribute_list_free (items[i].attributes);
gnome_keyring_acl_free (items[i].acl);
Modified: trunk/daemon/keyrings/gkr-keyring-item.c
==============================================================================
--- trunk/daemon/keyrings/gkr-keyring-item.c (original)
+++ trunk/daemon/keyrings/gkr-keyring-item.c Sat Jan 17 23:27:10 2009
@@ -26,7 +26,7 @@
#include "gkr-keyring-item.h"
#include "gkr-keyring.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include <gcrypt.h>
@@ -131,7 +131,7 @@
if (item->acl != NULL)
gnome_keyring_acl_free (item->acl);
g_free (item->display_name);
- gkr_secure_strfree (item->secret);
+ egg_secure_strfree (item->secret);
G_OBJECT_CLASS (gkr_keyring_item_parent_class)->finalize (obj);
}
@@ -208,7 +208,7 @@
nitem->locked = item->locked;
nitem->type = item->type;
- nitem->secret = gkr_secure_strdup (item->secret);
+ nitem->secret = egg_secure_strdup (item->secret);
nitem->display_name = g_strdup (item->display_name);
nitem->attributes = gnome_keyring_attribute_list_copy (item->attributes);
Modified: trunk/daemon/keyrings/gkr-keyring-login.c
==============================================================================
--- trunk/daemon/keyrings/gkr-keyring-login.c (original)
+++ trunk/daemon/keyrings/gkr-keyring-login.c Sat Jan 17 23:27:10 2009
@@ -30,7 +30,7 @@
#include "gkr-keyrings.h"
#include "common/gkr-location.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "library/gnome-keyring.h"
@@ -130,7 +130,7 @@
gkr_ask_daemon_process (ask);
ret = ask->response >= GKR_ASK_RESPONSE_ALLOW;
if (ret)
- *password = gkr_secure_strdup (ask->typed_password);
+ *password = egg_secure_strdup (ask->typed_password);
g_object_unref (ask);
return ret;
}
@@ -173,7 +173,7 @@
/* No such keyring exists, so create one */
login = gkr_keyring_create (GKR_LOCATION_VOLUME_LOCAL, "login", password);
- gkr_secure_strfree (new_password);
+ egg_secure_strfree (new_password);
if (!login) {
g_warning ("Failed to create login keyring");
@@ -258,8 +258,8 @@
g_free (item->display_name);
item->display_name = g_strdup (display_name);
- gkr_secure_strfree (item->secret);
- item->secret = gkr_secure_strdup (secret);
+ egg_secure_strfree (item->secret);
+ item->secret = egg_secure_strdup (secret);
gnome_keyring_attribute_list_free (item->attributes);
item->attributes = attrs;
Modified: trunk/daemon/keyrings/gkr-keyring-textual.c
==============================================================================
--- trunk/daemon/keyrings/gkr-keyring-textual.c (original)
+++ trunk/daemon/keyrings/gkr-keyring-textual.c Sat Jan 17 23:27:10 2009
@@ -26,7 +26,7 @@
#include "gkr-keyring.h"
#include "gkr-keyring-item.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "library/gnome-keyring.h"
#include "library/gnome-keyring-private.h"
@@ -277,9 +277,9 @@
item->display_name = g_key_file_get_string (file, groupname, "display-name", NULL);
/* Even though this is from disk, use secure memory just to be consistent */
- gkr_secure_free (item->secret);
+ egg_secure_free (item->secret);
val = g_key_file_get_string (file, groupname, "secret", NULL);
- item->secret = gkr_secure_strdup (val);
+ item->secret = egg_secure_strdup (val);
g_free (val);
item->mtime = 0;
@@ -297,7 +297,7 @@
}
gboolean
-gkr_keyring_textual_generate (GkrKeyring *keyring, GkrBuffer *buffer)
+gkr_keyring_textual_generate (GkrKeyring *keyring, EggBuffer *buffer)
{
GkrKeyringItem *item;
GKeyFile *file;
@@ -332,8 +332,8 @@
return FALSE;
}
- gkr_buffer_uninit (buffer);
- gkr_buffer_init_allocated (buffer, (guchar*)data, n_data, NULL);
+ egg_buffer_uninit (buffer);
+ egg_buffer_init_allocated (buffer, (guchar*)data, n_data, NULL);
return TRUE;
}
@@ -353,7 +353,7 @@
}
gint
-gkr_keyring_textual_parse (GkrKeyring *keyring, GkrBuffer *buffer)
+gkr_keyring_textual_parse (GkrKeyring *keyring, EggBuffer *buffer)
{
GkrKeyringItem *item;
GError *err = NULL;
Modified: trunk/daemon/keyrings/gkr-keyring.c
==============================================================================
--- trunk/daemon/keyrings/gkr-keyring.c (original)
+++ trunk/daemon/keyrings/gkr-keyring.c Sat Jan 17 23:27:10 2009
@@ -29,9 +29,9 @@
#include "gkr-keyring-login.h"
#include "gkr-keyrings.h"
-#include "common/gkr-buffer.h"
+#include "egg/egg-buffer.h"
#include "common/gkr-location.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "library/gnome-keyring-private.h"
#include "library/gnome-keyring-proto.h"
@@ -183,7 +183,7 @@
g_list_free (keyring->items);
keyring->items = NULL;
- gkr_secure_strfree (keyring->password);
+ egg_secure_strfree (keyring->password);
keyring->password = NULL;
G_OBJECT_CLASS (gkr_keyring_parent_class)->dispose (obj);
@@ -263,7 +263,7 @@
if (keyring != NULL) {
keyring->location = location;
keyring->locked = FALSE;
- keyring->password = gkr_secure_strdup (password);
+ keyring->password = egg_secure_strdup (password);
keyring->salt_valid = FALSE;
gkr_keyring_save_to_disk (keyring);
}
@@ -362,7 +362,7 @@
gboolean
gkr_keyring_update_from_disk (GkrKeyring *keyring)
{
- GkrBuffer buffer;
+ EggBuffer buffer;
GError *err = NULL;
guchar *contents = NULL;
gsize len;
@@ -377,13 +377,13 @@
return FALSE;
}
- gkr_buffer_init_static (&buffer, contents, len);
+ egg_buffer_init_static (&buffer, contents, len);
result = gkr_keyring_binary_parse (keyring, &buffer);
if (result == 0)
result = gkr_keyring_textual_parse (keyring, &buffer);
- gkr_buffer_uninit (&buffer);
+ egg_buffer_uninit (&buffer);
g_free (contents);
if (result > 0)
@@ -421,7 +421,7 @@
gkr_keyring_save_to_disk (GkrKeyring *keyring)
{
struct stat statbuf;
- GkrBuffer out;
+ EggBuffer out;
int fd;
char *dirname;
char *template;
@@ -441,7 +441,7 @@
if (!file)
return FALSE;
- gkr_buffer_init_full (&out, 4096, (GkrBufferAllocator)g_realloc);
+ egg_buffer_init_full (&out, 4096, (EggBufferAllocator)g_realloc);
/* Generate it */
if (!keyring->password || !keyring->password[0])
@@ -486,7 +486,7 @@
ret = FALSE;
}
- gkr_buffer_uninit (&out);
+ egg_buffer_uninit (&out);
g_free (file);
return ret;
}
@@ -503,7 +503,7 @@
g_assert (keyring->password != NULL);
- gkr_secure_strfree (keyring->password);
+ egg_secure_strfree (keyring->password);
keyring->password = NULL;
if (!gkr_keyring_update_from_disk (keyring)) {
/* Failed to re-read, remove the keyring */
@@ -522,9 +522,9 @@
g_assert (keyring->password == NULL);
- keyring->password = gkr_secure_strdup (password);
+ keyring->password = egg_secure_strdup (password);
if (!gkr_keyring_update_from_disk (keyring)) {
- gkr_secure_strfree (keyring->password);
+ egg_secure_strfree (keyring->password);
keyring->password = NULL;
}
if (keyring->locked) {
Modified: trunk/daemon/keyrings/gkr-keyring.h
==============================================================================
--- trunk/daemon/keyrings/gkr-keyring.h (original)
+++ trunk/daemon/keyrings/gkr-keyring.h Sat Jan 17 23:27:10 2009
@@ -33,7 +33,7 @@
#include "gkr-keyring-item.h"
-#include "common/gkr-buffer.h"
+#include "egg/egg-buffer.h"
#include "library/gnome-keyring.h"
@@ -131,13 +131,13 @@
* 1 : successful
*/
-gboolean gkr_keyring_textual_generate (GkrKeyring *keyring, GkrBuffer *buffer);
+gboolean gkr_keyring_textual_generate (GkrKeyring *keyring, EggBuffer *buffer);
-gboolean gkr_keyring_binary_generate (GkrKeyring *keyring, GkrBuffer *buffer);
+gboolean gkr_keyring_binary_generate (GkrKeyring *keyring, EggBuffer *buffer);
-gint gkr_keyring_textual_parse (GkrKeyring *keyring, GkrBuffer *buffer);
+gint gkr_keyring_textual_parse (GkrKeyring *keyring, EggBuffer *buffer);
-gint gkr_keyring_binary_parse (GkrKeyring *keyring, GkrBuffer *buffer);
+gint gkr_keyring_binary_parse (GkrKeyring *keyring, EggBuffer *buffer);
G_END_DECLS
Modified: trunk/daemon/keyrings/tests/unit-test-keyring-file.c
==============================================================================
--- trunk/daemon/keyrings/tests/unit-test-keyring-file.c (original)
+++ trunk/daemon/keyrings/tests/unit-test-keyring-file.c Sat Jan 17 23:27:10 2009
@@ -25,7 +25,7 @@
#include "run-auto-test.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "keyrings/gkr-keyring.h"
@@ -99,7 +99,7 @@
void unit_test_keyring_parse_encrypted (CuTest *cu)
{
GkrKeyring *encrypted, *plain;
- GkrBuffer buffer, output;
+ EggBuffer buffer, output;
gchar *data;
gsize n_data;
gint ret;
@@ -113,26 +113,26 @@
g_assert (FALSE && "couldn't read in encrypted.keyring");
/* Parse it */
- gkr_buffer_init_allocated (&buffer, (guchar*)data, n_data, NULL);
+ egg_buffer_init_allocated (&buffer, (guchar*)data, n_data, NULL);
data = g_memdup (data, n_data); /* Make a copy for double parse */
ret = gkr_keyring_binary_parse (encrypted, &buffer);
- gkr_buffer_uninit (&buffer);
+ egg_buffer_uninit (&buffer);
CuAssert (cu, "couldn't parse encrypted keyring", ret == 1);
CuAssert (cu, "didn't unlock encrypted keyring", !encrypted->locked);
validate_keyring_contents (encrypted, cu);
/* Double parse shouldn't change it */
- gkr_buffer_init_allocated (&buffer, (guchar*)data, n_data, NULL);
+ egg_buffer_init_allocated (&buffer, (guchar*)data, n_data, NULL);
ret = gkr_keyring_binary_parse (encrypted, &buffer);
- gkr_buffer_uninit (&buffer);
+ egg_buffer_uninit (&buffer);
CuAssert (cu, "couldn't parse encrypted keyring", ret == 1);
CuAssert (cu, "didn't unlock encrypted keyring", !encrypted->locked);
validate_keyring_contents (encrypted, cu);
/* Output same data in the cleartext format */
- gkr_buffer_init (&output, 128);
+ egg_buffer_init (&output, 128);
success = gkr_keyring_textual_generate (encrypted, &output);
CuAssert (cu, "couldn't generate textual data", success);
@@ -147,7 +147,7 @@
void unit_test_keyring_parse_plain (CuTest *cu)
{
GkrKeyring *keyring;
- GkrBuffer buffer;
+ EggBuffer buffer;
gchar *data;
gsize n_data;
gint ret;
@@ -158,7 +158,7 @@
g_assert (FALSE && "couldn't read in plain.keyring");
/* Parse it */
- gkr_buffer_init_static (&buffer, (guchar*)data, n_data);
+ egg_buffer_init_static (&buffer, (guchar*)data, n_data);
ret = gkr_keyring_textual_parse (keyring, &buffer);
CuAssert (cu, "couldn't parse generated textual data", ret == 1);
CuAssert (cu, "keyring should not be locked", !keyring->locked);
@@ -166,7 +166,7 @@
validate_keyring_contents (keyring, cu);
/* Double parse shouldn't change it */
- gkr_buffer_init_static (&buffer, (guchar*)data, n_data);
+ egg_buffer_init_static (&buffer, (guchar*)data, n_data);
ret = gkr_keyring_textual_parse (keyring, &buffer);
CuAssert (cu, "couldn't parse generated textual data", ret == 1);
CuAssert (cu, "keyring should not be locked", !keyring->locked);
Modified: trunk/daemon/pk/gkr-pk-import.c
==============================================================================
--- trunk/daemon/pk/gkr-pk-import.c (original)
+++ trunk/daemon/pk/gkr-pk-import.c Sat Jan 17 23:27:10 2009
@@ -30,7 +30,7 @@
#include "gkr-pk-storage.h"
#include "gkr-pk-util.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "pkcs11/pkcs11.h"
#include "pkcs11/pkcs11g.h"
@@ -184,7 +184,7 @@
/* Successful response */
} else {
- *result = gkr_secure_strdup (ask->typed_password);
+ *result = egg_secure_strdup (ask->typed_password);
if (*result && strlen (*result) == 0)
*state = LAST_WAS_BLANK;
}
Modified: trunk/daemon/pk/gkr-pk-index.c
==============================================================================
--- trunk/daemon/pk/gkr-pk-index.c (original)
+++ trunk/daemon/pk/gkr-pk-index.c Sat Jan 17 23:27:10 2009
@@ -29,7 +29,7 @@
#include "common/gkr-cleanup.h"
#include "common/gkr-crypto.h"
#include "common/gkr-location.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "keyrings/gkr-keyring-login.h"
#include "keyrings/gkr-keyrings.h"
@@ -103,7 +103,7 @@
gkr_ask_daemon_process (ask);
ret = ask->response >= GKR_ASK_RESPONSE_ALLOW;
if (ret)
- *password = gkr_secure_strdup (ask->typed_password);
+ *password = egg_secure_strdup (ask->typed_password);
g_object_unref (ask);
return ret;
}
@@ -446,7 +446,7 @@
if (gkr_keyring_login_is_usable ()) {
login = gkr_keyrings_get_login ();
if (login)
- password = gkr_secure_strdup (login->password);
+ password = egg_secure_strdup (login->password);
}
}
@@ -459,7 +459,7 @@
g_return_val_if_fail (password, NULL);
keyring = gkr_keyring_create (index_location, name, password);
- gkr_secure_strfree (password);
+ egg_secure_strfree (password);
/* Make it available */
gkr_keyrings_add (keyring);
@@ -756,8 +756,8 @@
if (string_equal (item->secret, val))
return FALSE;
- gkr_secure_strfree (item->secret);
- item->secret = gkr_secure_strdup (val);
+ egg_secure_strfree (item->secret);
+ item->secret = egg_secure_strdup (val);
if (!gkr_keyring_save_to_disk (index->keyring))
g_warning ("writing secret: couldn't write index keyring to disk");
return TRUE;
Modified: trunk/daemon/pk/gkr-pk-manager.c
==============================================================================
--- trunk/daemon/pk/gkr-pk-manager.c (original)
+++ trunk/daemon/pk/gkr-pk-manager.c Sat Jan 17 23:27:10 2009
@@ -32,7 +32,7 @@
#include "common/gkr-cleanup.h"
#include "common/gkr-location.h"
#include "common/gkr-location-watch.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "keyrings/gkr-keyring-login.h"
Modified: trunk/daemon/pk/gkr-pk-root-storage.c
==============================================================================
--- trunk/daemon/pk/gkr-pk-root-storage.c (original)
+++ trunk/daemon/pk/gkr-pk-root-storage.c Sat Jan 17 23:27:10 2009
@@ -28,10 +28,10 @@
#include "gkr-pk-root-storage.h"
#include "gkr-pk-util.h"
-#include "common/gkr-buffer.h"
+#include "egg/egg-buffer.h"
#include "common/gkr-location.h"
#include "common/gkr-location-watch.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "keyrings/gkr-keyring-login.h"
Modified: trunk/daemon/pk/gkr-pk-session-storage.c
==============================================================================
--- trunk/daemon/pk/gkr-pk-session-storage.c (original)
+++ trunk/daemon/pk/gkr-pk-session-storage.c Sat Jan 17 23:27:10 2009
@@ -28,10 +28,10 @@
#include "gkr-pk-session-storage.h"
#include "gkr-pk-util.h"
-#include "common/gkr-buffer.h"
+#include "egg/egg-buffer.h"
#include "common/gkr-location.h"
#include "common/gkr-location-watch.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "keyrings/gkr-keyring-login.h"
Modified: trunk/daemon/pk/gkr-pk-storage.c
==============================================================================
--- trunk/daemon/pk/gkr-pk-storage.c (original)
+++ trunk/daemon/pk/gkr-pk-storage.c Sat Jan 17 23:27:10 2009
@@ -28,7 +28,7 @@
#include "common/gkr-cleanup.h"
#include "common/gkr-location.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "keyrings/gkr-keyrings.h"
#include "keyrings/gkr-keyring-login.h"
@@ -680,7 +680,7 @@
g_return_val_if_fail (login, FALSE);
g_return_val_if_fail (login->password, FALSE);
- *result = gkr_secure_strdup (login->password);
+ *result = egg_secure_strdup (login->password);
/*
* Always same a 'login' password used as a secret. So that
@@ -721,7 +721,7 @@
/* Successful response */
} else {
- *result = gkr_secure_strdup (ask->typed_password);
+ *result = egg_secure_strdup (ask->typed_password);
if (ask->checked)
gkr_pk_index_set_secret (index, digest, *result);
}
@@ -768,7 +768,7 @@
*/
if (st == 0) {
- *result = gkr_secure_strdup ("");
+ *result = egg_secure_strdup ("");
return TRUE;
} else if (st == 1) {
@@ -791,7 +791,7 @@
/* See if we can find a valid password for this location */
if (st == 2) {
- *result = gkr_secure_strdup (gkr_pk_index_get_secret (index, digest));
+ *result = egg_secure_strdup (gkr_pk_index_get_secret (index, digest));
if (*result != NULL)
return TRUE;
@@ -804,7 +804,7 @@
password = gkr_keyring_login_lookup_secret (GNOME_KEYRING_ITEM_ENCRYPTION_KEY_PASSWORD,
"pk-object", gkr_location_to_string (location), NULL);
if (password != NULL) {
- *result = gkr_secure_strdup (password);
+ *result = egg_secure_strdup (password);
return TRUE;
}
@@ -854,7 +854,7 @@
/* Successful response */
} else {
- *result = gkr_secure_strdup (ask->typed_password);
+ *result = egg_secure_strdup (ask->typed_password);
if (ask->checked)
gkr_pk_index_set_secret (index, digest, ask->typed_password);
}
Modified: trunk/daemon/pk/tests/unit-test-memory-stubs.c
==============================================================================
--- trunk/daemon/pk/tests/unit-test-memory-stubs.c (original)
+++ trunk/daemon/pk/tests/unit-test-memory-stubs.c Sat Jan 17 23:27:10 2009
@@ -1,7 +1,7 @@
#include <glib.h>
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
/*
* These are called from gkr-secure-memory.c to provide appropriate
@@ -9,19 +9,19 @@
*/
void
-gkr_memory_lock (void)
+egg_memory_lock (void)
{
}
void
-gkr_memory_unlock (void)
+egg_memory_unlock (void)
{
}
void*
-gkr_memory_fallback (void *p, unsigned long sz)
+egg_memory_fallback (void *p, unsigned long sz)
{
return g_realloc (p, sz);
}
Modified: trunk/daemon/pkcs11/gkr-pkcs11-auth.c
==============================================================================
--- trunk/daemon/pkcs11/gkr-pkcs11-auth.c (original)
+++ trunk/daemon/pkcs11/gkr-pkcs11-auth.c Sat Jan 17 23:27:10 2009
@@ -23,7 +23,7 @@
#include "gkr-pkcs11-auth.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "common/gkr-cleanup.h"
#include "keyrings/gkr-keyring-login.h"
@@ -94,7 +94,7 @@
*pin = NULL;
*pin_len = 0;
} else {
- *pin = (CK_UTF8CHAR_PTR)gkr_secure_strdup (password);
+ *pin = (CK_UTF8CHAR_PTR)egg_secure_strdup (password);
*pin_len = strlen (password);
}
}
@@ -268,10 +268,10 @@
/* This is delayed allocation because we may never use this for a slot */
if (slot->auth_cache == NULL)
slot->auth_cache = g_hash_table_new_full (ulong_hash, ulong_equal, ulong_free,
- (GDestroyNotify)gkr_secure_free);
+ (GDestroyNotify)egg_secure_free);
g_hash_table_replace (slot->auth_cache, ulong_alloc (object->handle),
- gkr_secure_strdup (ask->typed_password));
+ egg_secure_strdup (ask->typed_password));
}
}
@@ -318,7 +318,7 @@
break;
}
- gkr_secure_strfree ((gchar*)*pin);
+ egg_secure_strfree ((gchar*)*pin);
*pin = NULL;
*pin_len = 0;
@@ -464,7 +464,7 @@
break;
}
- gkr_secure_strfree ((gchar*)*pin);
+ egg_secure_strfree ((gchar*)*pin);
*pin = NULL;
*pin_len = 0;
@@ -578,7 +578,7 @@
if (rv != CKR_OK)
clear_user_login (token_info);
- gkr_secure_strfree ((gchar*)*pin);
+ egg_secure_strfree ((gchar*)*pin);
*pin = NULL;
*pin_len = 0;
Modified: trunk/daemon/pkix/gkr-pkix-asn1.c
==============================================================================
--- trunk/daemon/pkix/gkr-pkix-asn1.c (original)
+++ trunk/daemon/pkix/gkr-pkix-asn1.c Sat Jan 17 23:27:10 2009
@@ -25,8 +25,8 @@
#include "gkr-pkix-asn1.h"
-#include "common/gkr-buffer.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-buffer.h"
+#include "egg/egg-secure-memory.h"
#include <libtasn1.h>
@@ -116,7 +116,7 @@
guchar*
gkr_pkix_asn1_encode (ASN1_TYPE asn, const gchar* part, gsize *n_data,
- GkrBufferAllocator alloc)
+ EggBufferAllocator alloc)
{
guchar *data;
int res, len;
@@ -129,7 +129,7 @@
g_return_val_if_fail (res == ASN1_MEM_ERROR, NULL);
if (!alloc)
- alloc = (GkrBufferAllocator)g_realloc;
+ alloc = (EggBufferAllocator)g_realloc;
data = (alloc) (NULL, len);
g_return_val_if_fail (data != NULL, NULL);
@@ -231,7 +231,7 @@
guchar*
gkr_pkix_asn1_read_value (ASN1_TYPE asn, const gchar *part, gsize *len,
- GkrBufferAllocator allocator)
+ EggBufferAllocator allocator)
{
int l, res;
guchar *buf;
@@ -241,7 +241,7 @@
g_return_val_if_fail (len != NULL, NULL);
if (allocator == NULL)
- allocator = (GkrBufferAllocator)g_realloc;
+ allocator = (EggBufferAllocator)g_realloc;
*len = 0;
@@ -384,7 +384,7 @@
gsize sz;
guchar *buf;
- buf = gkr_pkix_asn1_read_value (asn, part, &sz, (GkrBufferAllocator)g_realloc);
+ buf = gkr_pkix_asn1_read_value (asn, part, &sz, (EggBufferAllocator)g_realloc);
if (!buf)
return FALSE;
@@ -404,12 +404,12 @@
gsize sz;
guchar *buf;
- buf = gkr_pkix_asn1_read_value (asn, part, &sz, gkr_secure_realloc);
+ buf = gkr_pkix_asn1_read_value (asn, part, &sz, egg_secure_realloc);
if (!buf)
return FALSE;
gcry = gcry_mpi_scan (mpi, GCRYMPI_FMT_STD, buf, sz, &sz);
- gkr_secure_free (buf);
+ egg_secure_free (buf);
if (gcry != 0)
return FALSE;
@@ -434,13 +434,13 @@
g_return_val_if_fail (gcry == 0, FALSE);
g_return_val_if_fail (len > 0, FALSE);
- buf = gkr_secure_alloc (len);
+ buf = egg_secure_alloc (len);
gcry = gcry_mpi_print (GCRYMPI_FMT_STD, buf, len, &len, mpi);
g_return_val_if_fail (gcry == 0, FALSE);
res = asn1_write_value (asn, part, buf, len);
- gkr_secure_free (buf);
+ egg_secure_free (buf);
if (res != ASN1_SUCCESS)
return FALSE;
Modified: trunk/daemon/pkix/gkr-pkix-asn1.h
==============================================================================
--- trunk/daemon/pkix/gkr-pkix-asn1.h (original)
+++ trunk/daemon/pkix/gkr-pkix-asn1.h Sat Jan 17 23:27:10 2009
@@ -28,7 +28,7 @@
#include <gcrypt.h>
#include <glib.h>
-#include "common/gkr-buffer.h"
+#include "egg/egg-buffer.h"
ASN1_TYPE gkr_pkix_asn1_get_pk_asn1type (void);
@@ -38,10 +38,10 @@
gsize n_data);
guchar* gkr_pkix_asn1_encode (ASN1_TYPE asn, const gchar* part,
- gsize *len, GkrBufferAllocator alloc);
+ gsize *len, EggBufferAllocator alloc);
guchar* gkr_pkix_asn1_read_value (ASN1_TYPE asn, const gchar *part,
- gsize *len, GkrBufferAllocator alloc);
+ gsize *len, EggBufferAllocator alloc);
gboolean gkr_pkix_asn1_write_value (ASN1_TYPE asn, const gchar *part,
const guchar* value, gsize len);
Modified: trunk/daemon/pkix/gkr-pkix-der.c
==============================================================================
--- trunk/daemon/pkix/gkr-pkix-der.c (original)
+++ trunk/daemon/pkix/gkr-pkix-der.c Sat Jan 17 23:27:10 2009
@@ -27,7 +27,7 @@
#include "gkr-pkix-der.h"
#include "common/gkr-crypto.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include <glib.h>
#include <gcrypt.h>
@@ -1078,8 +1078,8 @@
ret = GKR_PKIX_SUCCESS;
done:
- gkr_secure_free (iv);
- gkr_secure_free (key);
+ egg_secure_free (iv);
+ egg_secure_free (key);
if (asn)
asn1_delete_structure (&asn);
@@ -1198,7 +1198,7 @@
ret = GKR_PKIX_SUCCESS;
done:
- gkr_secure_free (key);
+ egg_secure_free (key);
if (asn)
asn1_delete_structure (&asn);
return ret;
@@ -1373,8 +1373,8 @@
*cih = NULL;
}
- gkr_secure_free (iv);
- gkr_secure_free (key);
+ egg_secure_free (iv);
+ egg_secure_free (key);
if (asn)
asn1_delete_structure (&asn);
Modified: trunk/daemon/pkix/gkr-pkix-openssl.c
==============================================================================
--- trunk/daemon/pkix/gkr-pkix-openssl.c (original)
+++ trunk/daemon/pkix/gkr-pkix-openssl.c Sat Jan 17 23:27:10 2009
@@ -26,7 +26,7 @@
#include "gkr-pkix-openssl.h"
#include "common/gkr-crypto.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include <gcrypt.h>
#include <libtasn1.h>
@@ -236,7 +236,7 @@
gcry = gcry_cipher_setkey (ch, key, gcry_cipher_get_algo_keylen (algo));
g_return_val_if_fail (!gcry, GKR_PKIX_UNRECOGNIZED);
- gkr_secure_free (key);
+ egg_secure_free (key);
/* 16 = 128 bits */
gcry = gcry_cipher_setiv (ch, iv, ivlen);
@@ -245,11 +245,11 @@
/* Allocate output area */
*n_decrypted = n_data;
- *decrypted = gkr_secure_alloc (n_data);
+ *decrypted = egg_secure_alloc (n_data);
gcry = gcry_cipher_decrypt (ch, *decrypted, *n_decrypted, (void*)data, n_data);
if (gcry) {
- gkr_secure_free (*decrypted);
+ egg_secure_free (*decrypted);
g_return_val_if_reached (GKR_PKIX_FAILURE);
}
@@ -290,7 +290,7 @@
gcry = gcry_cipher_setkey (ch, key, gcry_cipher_get_algo_keylen (algo));
g_return_val_if_fail (!gcry, FALSE);
- gkr_secure_free (key);
+ egg_secure_free (key);
/* 16 = 128 bits */
gcry = gcry_cipher_setiv (ch, iv, ivlen);
@@ -317,11 +317,11 @@
/* Encrypt the padded block */
if (n_overflow) {
- padded = gkr_secure_alloc (ivlen);
+ padded = egg_secure_alloc (ivlen);
memset (padded, 0, ivlen);
memcpy (padded, data + n_batch, n_overflow);
gcry = gcry_cipher_encrypt (ch, *encrypted + n_batch, ivlen, padded, ivlen);
- gkr_secure_free (padded);
+ egg_secure_free (padded);
if (gcry) {
g_free (*encrypted);
g_return_val_if_reached (FALSE);
Modified: trunk/daemon/pkix/gkr-pkix-parser.c
==============================================================================
--- trunk/daemon/pkix/gkr-pkix-parser.c (original)
+++ trunk/daemon/pkix/gkr-pkix-parser.c Sat Jan 17 23:27:10 2009
@@ -40,7 +40,7 @@
#include "common/gkr-crypto.h"
#include "common/gkr-location.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "library/gnome-keyring.h"
#include "library/gnome-keyring-memory.h"
@@ -354,7 +354,7 @@
GList *l;
for (l = pv->seen_passwords; l; l = g_list_next (l))
- gkr_secure_strfree (l->data);
+ egg_secure_strfree (l->data);
g_list_free (pv->seen_passwords);
G_OBJECT_CLASS (gkr_pkix_parser_parent_class)->finalize (obj);
@@ -719,7 +719,7 @@
}
crypted = gkr_pkix_asn1_read_value (asn, "encryptedData", &n_crypted,
- gkr_secure_realloc);
+ egg_secure_realloc);
if (!crypted)
goto done;
@@ -739,7 +739,7 @@
/* Try to parse the resulting key */
r = parse_der_pkcs8_plain (parser, location, digest, crypted, n_crypted);
- gkr_secure_free (crypted);
+ egg_secure_free (crypted);
crypted = NULL;
if (r != GKR_PKIX_UNRECOGNIZED) {
@@ -755,7 +755,7 @@
gcry_cipher_close (cih);
if (asn)
asn1_delete_structure (&asn);
- gkr_secure_free (crypted);
+ egg_secure_free (crypted);
return ret;
}
@@ -988,7 +988,7 @@
}
crypted = gkr_pkix_asn1_read_value (asn, "encryptedContentInfo.encryptedContent",
- &n_crypted, gkr_secure_realloc);
+ &n_crypted, egg_secure_realloc);
if (!crypted)
goto done;
@@ -1008,7 +1008,7 @@
/* Try to parse the resulting key */
r = parse_pkcs12_bag (parser, loc, digest, crypted, n_crypted);
- gkr_secure_free (crypted);
+ egg_secure_free (crypted);
crypted = NULL;
if (r != GKR_PKIX_UNRECOGNIZED) {
@@ -1024,7 +1024,7 @@
gcry_cipher_close (cih);
if (asn)
asn1_delete_structure (&asn);
- gkr_secure_free (crypted);
+ egg_secure_free (crypted);
return ret;
}
@@ -1393,7 +1393,7 @@
/* Try to parse */
ret = parse_plain_pem (parser, location, digest, type, decrypted, n_decrypted);
- gkr_secure_free (decrypted);
+ egg_secure_free (decrypted);
if (ret != GKR_PKIX_UNRECOGNIZED)
return ret;
Modified: trunk/daemon/pkix/gkr-pkix-pem.c
==============================================================================
--- trunk/daemon/pkix/gkr-pkix-pem.c (original)
+++ trunk/daemon/pkix/gkr-pkix-pem.c Sat Jan 17 23:27:10 2009
@@ -26,7 +26,7 @@
#include "gkr-pkix-pem.h"
#include "common/gkr-async.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include <glib.h>
@@ -207,15 +207,15 @@
}
*n_decoded = (n_data * 3) / 4 + 1;
- if (gkr_secure_check (data))
- *decoded = gkr_secure_alloc (*n_decoded);
+ if (egg_secure_check (data))
+ *decoded = egg_secure_alloc (*n_decoded);
else
*decoded = g_malloc (*n_decoded);
g_return_val_if_fail (*decoded, FALSE);
*n_decoded = g_base64_decode_step (data, n_data, *decoded, &state, &save);
if (!*n_decoded) {
- gkr_secure_free (*decoded);
+ egg_secure_free (*decoded);
return FALSE;
}
@@ -267,7 +267,7 @@
if (pem_parse_block (beg, end - beg, &decoded, &n_decoded, &headers)) {
(callback) (type, decoded, n_decoded, headers, user_data);
++nfound;
- gkr_secure_free (decoded);
+ egg_secure_free (decoded);
if (headers)
g_hash_table_remove_all (headers);
}
Modified: trunk/daemon/pkix/gkr-pkix-serialize.c
==============================================================================
--- trunk/daemon/pkix/gkr-pkix-serialize.c (original)
+++ trunk/daemon/pkix/gkr-pkix-serialize.c Sat Jan 17 23:27:10 2009
@@ -8,7 +8,7 @@
#include "common/gkr-crypto.h"
#include "common/gkr-location.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include <glib/gi18n.h>
@@ -157,8 +157,8 @@
gcry_cipher_setiv (cih, iv, *n_block);
gcry_cipher_setkey (cih, key, n_key);
- gkr_secure_free (iv);
- gkr_secure_free (key);
+ egg_secure_free (iv);
+ egg_secure_free (key);
asn1_delete_structure (&asn1_params);
return cih;
@@ -219,12 +219,12 @@
/* Write out the parameters */
if (!gkr_pkix_asn1_write_value (asn, "privateKeyAlgorithm.parameters", params, n_params))
g_return_val_if_reached (NULL);
- gkr_secure_free (params);
+ egg_secure_free (params);
/* Write out the key portion */
if (!gkr_pkix_asn1_write_value (asn, "privateKey", key, n_key))
g_return_val_if_reached (NULL);
- gkr_secure_free (key);
+ egg_secure_free (key);
/* Add an empty attributes field */
if (!gkr_pkix_asn1_write_value (asn, "attributes", NULL, 0))
Modified: trunk/daemon/pkix/tests/unit-test-pkix-openssl.c
==============================================================================
--- trunk/daemon/pkix/tests/unit-test-pkix-openssl.c (original)
+++ trunk/daemon/pkix/tests/unit-test-pkix-openssl.c Sat Jan 17 23:27:10 2009
@@ -27,7 +27,7 @@
#include "common/gkr-location.h"
#include "common/gkr-crypto.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "pkix/gkr-pkix-openssl.h"
#include "pkix/gkr-pkix-pem.h"
Modified: trunk/daemon/pkix/tests/unit-test-pkix-parser.c
==============================================================================
--- trunk/daemon/pkix/tests/unit-test-pkix-parser.c (original)
+++ trunk/daemon/pkix/tests/unit-test-pkix-parser.c Sat Jan 17 23:27:10 2009
@@ -27,7 +27,7 @@
#include "common/gkr-location.h"
#include "common/gkr-crypto.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "pkix/gkr-pkix-parser.h"
@@ -147,7 +147,7 @@
/* Return "", null, and "booo" in that order */
switch (st) {
case 0:
- *password = gkr_secure_strdup ("");
+ *password = egg_secure_strdup ("");
return TRUE;
case 1:
*password = NULL;
@@ -155,7 +155,7 @@
case 2:
/* Most of our test encrypted stuff use this password */
g_print ("getting password 'booo' for: %s\n", details);
- *password = gkr_secure_strdup ("booo");
+ *password = egg_secure_strdup ("booo");
return TRUE;
default:
msg = g_strdup_printf ("decryption didn't work for: %s", g_quark_to_string (loc));
Modified: trunk/daemon/pkix/tests/unit-test-pkix-serialize.c
==============================================================================
--- trunk/daemon/pkix/tests/unit-test-pkix-serialize.c (original)
+++ trunk/daemon/pkix/tests/unit-test-pkix-serialize.c Sat Jan 17 23:27:10 2009
@@ -27,7 +27,7 @@
#include "common/gkr-location.h"
#include "common/gkr-crypto.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "pkix/gkr-pkix-der.h"
#include "pkix/gkr-pkix-parser.h"
@@ -90,7 +90,7 @@
g_print ("getting password 'booo' for: %s\n", details);
/* All our test encrypted stuff use this password */
- *password = gkr_secure_strdup ("booo");
+ *password = egg_secure_strdup ("booo");
return TRUE;
}
Modified: trunk/daemon/ssh/gkr-ssh-private.h
==============================================================================
--- trunk/daemon/ssh/gkr-ssh-private.h (original)
+++ trunk/daemon/ssh/gkr-ssh-private.h Sat Jan 17 23:27:10 2009
@@ -23,7 +23,7 @@
#ifndef GKRSSHPRIVATE_H_
#define GKRSSHPRIVATE_H_
-#include "common/gkr-buffer.h"
+#include "egg/egg-buffer.h"
#include <gcrypt.h>
@@ -75,7 +75,7 @@
* gkr-ssh-daemon-io.c
*/
-typedef gboolean (*GkrSshOperation) (GkrBuffer *req, GkrBuffer *resp);
+typedef gboolean (*GkrSshOperation) (EggBuffer *req, EggBuffer *resp);
extern const GkrSshOperation gkr_ssh_operations[GKR_SSH_OP_MAX];
/* -----------------------------------------------------------------------------
@@ -86,39 +86,39 @@
const gchar* gkr_ssh_proto_algo_to_keytype (int algo);
-gboolean gkr_ssh_proto_read_mpi (GkrBuffer *req, gsize *offset, gcry_mpi_t *mpi);
+gboolean gkr_ssh_proto_read_mpi (EggBuffer *req, gsize *offset, gcry_mpi_t *mpi);
-gboolean gkr_ssh_proto_read_mpi_v1 (GkrBuffer *req, gsize *offset, gcry_mpi_t *mpi);
+gboolean gkr_ssh_proto_read_mpi_v1 (EggBuffer *req, gsize *offset, gcry_mpi_t *mpi);
-gboolean gkr_ssh_proto_write_mpi (GkrBuffer *resp, gcry_mpi_t mpi, int format);
+gboolean gkr_ssh_proto_write_mpi (EggBuffer *resp, gcry_mpi_t mpi, int format);
-gboolean gkr_ssh_proto_write_mpi_v1 (GkrBuffer *resp, gcry_mpi_t mpi);
+gboolean gkr_ssh_proto_write_mpi_v1 (EggBuffer *resp, gcry_mpi_t mpi);
-gboolean gkr_ssh_proto_read_public (GkrBuffer *req, gsize *offset, gcry_sexp_t *key, int *algo);
+gboolean gkr_ssh_proto_read_public (EggBuffer *req, gsize *offset, gcry_sexp_t *key, int *algo);
-gboolean gkr_ssh_proto_read_public_rsa (GkrBuffer *req, gsize *offset, gcry_sexp_t *sexp);
+gboolean gkr_ssh_proto_read_public_rsa (EggBuffer *req, gsize *offset, gcry_sexp_t *sexp);
-gboolean gkr_ssh_proto_read_public_dsa (GkrBuffer *req, gsize *offset, gcry_sexp_t *sexp);
+gboolean gkr_ssh_proto_read_public_dsa (EggBuffer *req, gsize *offset, gcry_sexp_t *sexp);
-gboolean gkr_ssh_proto_read_public_v1 (GkrBuffer *req, gsize *offset, gcry_sexp_t *sexp);
+gboolean gkr_ssh_proto_read_public_v1 (EggBuffer *req, gsize *offset, gcry_sexp_t *sexp);
-gboolean gkr_ssh_proto_read_private_rsa (GkrBuffer *req, gsize *offset, gcry_sexp_t *sexp);
+gboolean gkr_ssh_proto_read_private_rsa (EggBuffer *req, gsize *offset, gcry_sexp_t *sexp);
-gboolean gkr_ssh_proto_read_private_dsa (GkrBuffer *req, gsize *offset, gcry_sexp_t *sexp);
+gboolean gkr_ssh_proto_read_private_dsa (EggBuffer *req, gsize *offset, gcry_sexp_t *sexp);
-gboolean gkr_ssh_proto_read_private_v1 (GkrBuffer *req, gsize *offset, gcry_sexp_t *sexp);
+gboolean gkr_ssh_proto_read_private_v1 (EggBuffer *req, gsize *offset, gcry_sexp_t *sexp);
-gboolean gkr_ssh_proto_write_public (GkrBuffer *resp, int algorithm, gcry_sexp_t key);
+gboolean gkr_ssh_proto_write_public (EggBuffer *resp, int algorithm, gcry_sexp_t key);
-gboolean gkr_ssh_proto_write_public_rsa (GkrBuffer *resp, gcry_sexp_t key);
+gboolean gkr_ssh_proto_write_public_rsa (EggBuffer *resp, gcry_sexp_t key);
-gboolean gkr_ssh_proto_write_public_dsa (GkrBuffer *resp, gcry_sexp_t key);
+gboolean gkr_ssh_proto_write_public_dsa (EggBuffer *resp, gcry_sexp_t key);
-gboolean gkr_ssh_proto_write_public_v1 (GkrBuffer *resp, gcry_sexp_t key);
+gboolean gkr_ssh_proto_write_public_v1 (EggBuffer *resp, gcry_sexp_t key);
-gboolean gkr_ssh_proto_write_signature_rsa (GkrBuffer *resp, gcry_sexp_t ssig);
+gboolean gkr_ssh_proto_write_signature_rsa (EggBuffer *resp, gcry_sexp_t ssig);
-gboolean gkr_ssh_proto_write_signature_dsa (GkrBuffer *resp, gcry_sexp_t ssig);
+gboolean gkr_ssh_proto_write_signature_dsa (EggBuffer *resp, gcry_sexp_t ssig);
#endif /*GKRSSHPRIVATE_H_*/
Modified: trunk/daemon/ssh/gkr-ssh-proto.c
==============================================================================
--- trunk/daemon/ssh/gkr-ssh-proto.c (original)
+++ trunk/daemon/ssh/gkr-ssh-proto.c Sat Jan 17 23:27:10 2009
@@ -24,7 +24,7 @@
#include "gkr-ssh-private.h"
-#include "common/gkr-buffer.h"
+#include "egg/egg-buffer.h"
#include "common/gkr-crypto.h"
#include <gcrypt.h>
@@ -54,13 +54,13 @@
}
gboolean
-gkr_ssh_proto_read_mpi (GkrBuffer *req, gsize *offset, gcry_mpi_t *mpi)
+gkr_ssh_proto_read_mpi (EggBuffer *req, gsize *offset, gcry_mpi_t *mpi)
{
const guchar *data;
gsize len;
gcry_error_t gcry;
- if (!gkr_buffer_get_byte_array (req, *offset, offset, &data, &len))
+ if (!egg_buffer_get_byte_array (req, *offset, offset, &data, &len))
return FALSE;
gcry = gcry_mpi_scan (mpi, GCRYMPI_FMT_USG, data, len, NULL);
@@ -71,7 +71,7 @@
}
gboolean
-gkr_ssh_proto_read_mpi_v1 (GkrBuffer *req, gsize *offset, gcry_mpi_t *mpi)
+gkr_ssh_proto_read_mpi_v1 (EggBuffer *req, gsize *offset, gcry_mpi_t *mpi)
{
const guchar *data;
gsize bytes;
@@ -79,7 +79,7 @@
guint16 bits;
/* Get the number of bits */
- if (!gkr_buffer_get_uint16 (req, *offset, offset, &bits))
+ if (!egg_buffer_get_uint16 (req, *offset, offset, &bits))
return FALSE;
/* Figure out the number of binary bytes following */
@@ -101,7 +101,7 @@
}
gboolean
-gkr_ssh_proto_write_mpi (GkrBuffer *resp, gcry_mpi_t mpi, int format)
+gkr_ssh_proto_write_mpi (EggBuffer *resp, gcry_mpi_t mpi, int format)
{
guchar *buf;
size_t len;
@@ -112,7 +112,7 @@
g_return_val_if_fail (gcry == 0, FALSE);
/* Make a space for it in the buffer */
- buf = gkr_buffer_add_byte_array_empty (resp, len);
+ buf = egg_buffer_add_byte_array_empty (resp, len);
if (!buf)
return FALSE;
@@ -124,7 +124,7 @@
}
gboolean
-gkr_ssh_proto_write_mpi_v1 (GkrBuffer *resp, gcry_mpi_t mpi)
+gkr_ssh_proto_write_mpi_v1 (EggBuffer *resp, gcry_mpi_t mpi)
{
gcry_error_t gcry;
guchar *buf;
@@ -141,11 +141,11 @@
g_return_val_if_fail (gcry == 0, FALSE);
g_return_val_if_fail (bytes == len, FALSE);
- if (!gkr_buffer_add_uint16 (resp, bits))
+ if (!egg_buffer_add_uint16 (resp, bits))
return FALSE;
/* Make a space for it in the buffer */
- buf = gkr_buffer_add_empty (resp, len);
+ buf = egg_buffer_add_empty (resp, len);
if (!buf)
return FALSE;
@@ -157,14 +157,14 @@
}
gboolean
-gkr_ssh_proto_read_public (GkrBuffer *req, gsize *offset, gcry_sexp_t *key, int *algo)
+gkr_ssh_proto_read_public (EggBuffer *req, gsize *offset, gcry_sexp_t *key, int *algo)
{
gboolean ret;
gchar *stype;
int alg;
/* The string algorithm */
- if (!gkr_buffer_get_string (req, *offset, offset, &stype, (GkrBufferAllocator)g_realloc))
+ if (!egg_buffer_get_string (req, *offset, offset, &stype, (EggBufferAllocator)g_realloc))
return FALSE;
alg = gkr_ssh_proto_keytype_to_algo (stype);
@@ -208,7 +208,7 @@
" (u %m)))"
gboolean
-gkr_ssh_proto_read_private_rsa (GkrBuffer *req, gsize *offset, gcry_sexp_t *sexp)
+gkr_ssh_proto_read_private_rsa (EggBuffer *req, gsize *offset, gcry_sexp_t *sexp)
{
gcry_mpi_t n, e, d, p, q, u;
gcry_mpi_t tmp;
@@ -250,7 +250,7 @@
}
gboolean
-gkr_ssh_proto_read_private_v1 (GkrBuffer *req, gsize *offset, gcry_sexp_t *sexp)
+gkr_ssh_proto_read_private_v1 (EggBuffer *req, gsize *offset, gcry_sexp_t *sexp)
{
gcry_mpi_t n, e, d, p, q, u;
gcry_mpi_t tmp;
@@ -298,7 +298,7 @@
" (e %m)))"
gboolean
-gkr_ssh_proto_read_public_rsa (GkrBuffer *req, gsize *offset, gcry_sexp_t *sexp)
+gkr_ssh_proto_read_public_rsa (EggBuffer *req, gsize *offset, gcry_sexp_t *sexp)
{
gcry_mpi_t n, e;
int gcry;
@@ -320,13 +320,13 @@
}
gboolean
-gkr_ssh_proto_read_public_v1 (GkrBuffer *req, gsize *offset, gcry_sexp_t *sexp)
+gkr_ssh_proto_read_public_v1 (EggBuffer *req, gsize *offset, gcry_sexp_t *sexp)
{
gcry_mpi_t n, e;
guint32 bits;
int gcry;
- if (!gkr_buffer_get_uint32 (req, *offset, offset, &bits))
+ if (!egg_buffer_get_uint32 (req, *offset, offset, &bits))
return FALSE;
if (!gkr_ssh_proto_read_mpi_v1 (req, offset, &e) ||
@@ -355,7 +355,7 @@
" (x %m)))"
gboolean
-gkr_ssh_proto_read_private_dsa (GkrBuffer *req, gsize *offset, gcry_sexp_t *sexp)
+gkr_ssh_proto_read_private_dsa (EggBuffer *req, gsize *offset, gcry_sexp_t *sexp)
{
gcry_mpi_t p, q, g, y, x;
int gcry;
@@ -391,7 +391,7 @@
" (y %m)))"
gboolean
-gkr_ssh_proto_read_public_dsa (GkrBuffer *req, gsize *offset, gcry_sexp_t *sexp)
+gkr_ssh_proto_read_public_dsa (EggBuffer *req, gsize *offset, gcry_sexp_t *sexp)
{
gcry_mpi_t p, q, g, y;
int gcry;
@@ -417,14 +417,14 @@
}
gboolean
-gkr_ssh_proto_write_public (GkrBuffer *resp, int algo, gcry_sexp_t key)
+gkr_ssh_proto_write_public (EggBuffer *resp, int algo, gcry_sexp_t key)
{
gboolean ret = FALSE;
const gchar *salgo;
salgo = gkr_ssh_proto_algo_to_keytype (algo);
g_assert (salgo);
- gkr_buffer_add_string (resp, salgo);
+ egg_buffer_add_string (resp, salgo);
switch (algo) {
case GCRY_PK_RSA:
@@ -444,7 +444,7 @@
}
gboolean
-gkr_ssh_proto_write_public_rsa (GkrBuffer *resp, gcry_sexp_t key)
+gkr_ssh_proto_write_public_rsa (EggBuffer *resp, gcry_sexp_t key)
{
gcry_mpi_t mpi;
gboolean ret;
@@ -468,7 +468,7 @@
}
gboolean
-gkr_ssh_proto_write_public_dsa (GkrBuffer *resp, gcry_sexp_t key)
+gkr_ssh_proto_write_public_dsa (EggBuffer *resp, gcry_sexp_t key)
{
gcry_mpi_t mpi;
gboolean ret;
@@ -510,7 +510,7 @@
}
gboolean
-gkr_ssh_proto_write_public_v1 (GkrBuffer *resp, gcry_sexp_t key)
+gkr_ssh_proto_write_public_v1 (EggBuffer *resp, gcry_sexp_t key)
{
gboolean ret = FALSE;
gcry_mpi_t mpi;
@@ -521,7 +521,7 @@
/* Write out the number of bits of the key */
bits = gcry_pk_get_nbits (key);
g_return_val_if_fail (bits > 0, FALSE);
- gkr_buffer_add_uint32 (resp, bits);
+ egg_buffer_add_uint32 (resp, bits);
/* Write out the exponent */
ret = gkr_crypto_sexp_extract_mpi (key, &mpi, "rsa", "e", NULL);
@@ -542,7 +542,7 @@
}
gboolean
-gkr_ssh_proto_write_signature_rsa (GkrBuffer *resp, gcry_sexp_t ssig)
+gkr_ssh_proto_write_signature_rsa (EggBuffer *resp, gcry_sexp_t ssig)
{
gboolean ret;
gcry_mpi_t mpi;
@@ -557,7 +557,7 @@
}
gboolean
-gkr_ssh_proto_write_signature_dsa (GkrBuffer *resp, gcry_sexp_t ssig)
+gkr_ssh_proto_write_signature_dsa (EggBuffer *resp, gcry_sexp_t ssig)
{
guchar buffer[GKR_SSH_DSA_SIGNATURE_PADDING * 2];
gboolean ret;
@@ -570,6 +570,6 @@
GKR_SSH_DSA_SIGNATURE_PADDING, "dsa", "s", NULL);
g_return_val_if_fail (ret, FALSE);
- return gkr_buffer_add_byte_array (resp, buffer, sizeof (buffer));
+ return egg_buffer_add_byte_array (resp, buffer, sizeof (buffer));
}
Modified: trunk/daemon/ssh/gkr-ssh-storage.c
==============================================================================
--- trunk/daemon/ssh/gkr-ssh-storage.c (original)
+++ trunk/daemon/ssh/gkr-ssh-storage.c Sat Jan 17 23:27:10 2009
@@ -26,11 +26,11 @@
#include "gkr-ssh-private.h"
#include "gkr-ssh-storage.h"
-#include "common/gkr-buffer.h"
+#include "egg/egg-buffer.h"
#include "common/gkr-crypto.h"
#include "common/gkr-location.h"
#include "common/gkr-location-watch.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "keyrings/gkr-keyring-login.h"
@@ -230,7 +230,7 @@
/* Decrypt, this will result in garble if invalid password */
res = gkr_pkix_openssl_decrypt_block (dekinfo, password, data, n_data,
&decrypted, &n_decrypted);
- gkr_secure_free (password);
+ egg_secure_free (password);
if (!res)
return GKR_PKIX_UNRECOGNIZED;
@@ -244,7 +244,7 @@
/* Try to parse */
ret = gkr_pkix_der_read_private_key (decrypted, n_decrypted, skey);
- gkr_secure_free (decrypted);
+ egg_secure_free (decrypted);
if (ret != GKR_PKIX_UNRECOGNIZED)
return ret;
@@ -493,7 +493,7 @@
done:
if (headers)
g_hash_table_destroy (headers);
- gkr_secure_free (data);
+ egg_secure_free (data);
g_free (result);
g_free (encrypted);
@@ -620,7 +620,7 @@
/* Store the private key */
digest = storage_write_private_key (storage, sexp, loc, password, err);
- gkr_secure_strfree (password);
+ egg_secure_strfree (password);
if (!digest)
return FALSE;
@@ -772,7 +772,7 @@
gkr_ssh_storage_load_public_key (const guchar *data, gsize n_data,
gcry_sexp_t *sexp, gchar **comment)
{
- GkrBuffer buf;
+ EggBuffer buf;
const guchar *at;
guchar *decoded;
gsize n_decoded;
@@ -846,7 +846,7 @@
n_decoded = g_base64_decode_step ((gchar*)data, n_data, decoded, &state, &save);
/* Parse the actual key */
- gkr_buffer_init_static (&buf, decoded, n_decoded);
+ egg_buffer_init_static (&buf, decoded, n_decoded);
offset = 0;
ret = gkr_ssh_proto_read_public (&buf, &offset, sexp, NULL);
g_free (decoded);
@@ -875,7 +875,7 @@
gsize *n_data)
{
GString *result;
- GkrBuffer buffer;
+ EggBuffer buffer;
const gchar *type;
gchar *encoded;
gboolean is_priv;
@@ -897,11 +897,11 @@
g_string_append (result, type);
g_string_append_c (result, ' ');
- gkr_buffer_init_full (&buffer, 4096, (GkrBufferAllocator)g_realloc);
+ egg_buffer_init_full (&buffer, 4096, (EggBufferAllocator)g_realloc);
gkr_ssh_proto_write_public (&buffer, algo, sexp);
encoded = g_base64_encode (buffer.buf, buffer.len);
- gkr_buffer_uninit (&buffer);
+ egg_buffer_uninit (&buffer);
g_return_val_if_fail (encoded, NULL);
g_string_append (result, encoded);
Modified: trunk/daemon/ssh/tests/unit-test-ssh-storage.c
==============================================================================
--- trunk/daemon/ssh/tests/unit-test-ssh-storage.c (original)
+++ trunk/daemon/ssh/tests/unit-test-ssh-storage.c Sat Jan 17 23:27:10 2009
@@ -27,7 +27,7 @@
#include "common/gkr-location.h"
#include "common/gkr-crypto.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "ssh/gkr-ssh-storage.h"
Modified: trunk/daemon/ui/Makefile.am
==============================================================================
--- trunk/daemon/ui/Makefile.am (original)
+++ trunk/daemon/ui/Makefile.am Sat Jan 17 23:27:10 2009
@@ -21,7 +21,7 @@
gkr-ask-request.h
gnome_keyring_ask_LDADD = \
- $(top_builddir)/common/libgkr-common-secure.la \
+ $(top_builddir)/egg/libegg-secure.la \
$(GTK_LIBS)
noinst_LTLIBRARIES=libgkr-ui.la
Modified: trunk/daemon/ui/gkr-ask-entry.c
==============================================================================
--- trunk/daemon/ui/gkr-ask-entry.c (original)
+++ trunk/daemon/ui/gkr-ask-entry.c Sat Jan 17 23:27:10 2009
@@ -48,7 +48,7 @@
#include "gkr-ask-entry.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#define MIN_ASK_ENTRY_WIDTH 150
#define DRAW_TIMEOUT 20
@@ -504,7 +504,7 @@
gtk_widget_set_style (GTK_WIDGET (entry), style);
entry->text_size = MIN_SIZE;
- entry->text = gkr_secure_alloc (entry->text_size + 1);
+ entry->text = egg_secure_alloc (entry->text_size + 1);
entry->text[0] = '\0';
entry->visibility = FALSE;
@@ -554,7 +554,7 @@
entry->text_size = 0;
if (entry->text)
- gkr_secure_free (entry->text);
+ egg_secure_free (entry->text);
entry->text = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -1093,7 +1093,7 @@
g_object_ref (editable);
- text = gkr_secure_alloc (new_text_length + 1);
+ text = egg_secure_alloc (new_text_length + 1);
strncpy (text, new_text, new_text_length);
text[new_text_length] = '\0';
@@ -1101,7 +1101,7 @@
g_signal_emit_by_name (editable, "insert_text", text,
new_text_length, position);
- gkr_secure_free (text);
+ egg_secure_free (text);
g_object_unref (editable);
}
@@ -1280,7 +1280,7 @@
}
}
- entry->text = gkr_secure_realloc (entry->text, entry->text_size + 1);
+ entry->text = egg_secure_realloc (entry->text, entry->text_size + 1);
}
_index = g_utf8_offset_to_pointer (entry->text, *position) - entry->text;
Modified: trunk/daemon/ui/gkr-ask-request.c
==============================================================================
--- trunk/daemon/ui/gkr-ask-request.c (original)
+++ trunk/daemon/ui/gkr-ask-request.c Sat Jan 17 23:27:10 2009
@@ -30,7 +30,7 @@
#include "common/gkr-async.h"
#include "common/gkr-location.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "library/gnome-keyring.h"
#include "library/gnome-keyring-private.h"
@@ -85,7 +85,7 @@
gint ask_pid;
gint in_fd;
gint out_fd;
- GkrBuffer buffer;
+ EggBuffer buffer;
};
#define GKR_ASK_REQUEST_GET_PRIVATE(o) \
@@ -284,9 +284,9 @@
pv->ask_pid = 0;
/* Cleanup for response processing */
- gkr_secure_strfree (ask->typed_password);
+ egg_secure_strfree (ask->typed_password);
ask->typed_password = NULL;
- gkr_secure_strfree (ask->original_password);
+ egg_secure_strfree (ask->original_password);
ask->original_password = NULL;
/* A failed request */
@@ -310,11 +310,11 @@
/* First line is the password */
if (i == 0)
- ask->typed_password = gkr_secure_strdup (line);
+ ask->typed_password = egg_secure_strdup (line);
/* Second line is the original password (if any)*/
else if (i == 1)
- ask->original_password = gkr_secure_strdup (line);
+ ask->original_password = egg_secure_strdup (line);
line = next;
}
@@ -499,7 +499,7 @@
g_return_val_if_fail (pv->out_fd >= 0, FALSE);
/* Passwords come through this buffer */
- buf = gkr_secure_alloc (128);
+ buf = egg_secure_alloc (128);
gkr_async_register_cancel (close_fd, &pv->out_fd);
@@ -521,7 +521,7 @@
/* Got some data */
} else if (res > 0) {
- gkr_buffer_append (&pv->buffer, buf, res);
+ egg_buffer_append (&pv->buffer, buf, res);
/* End of data */
} else if (res == 0) {
@@ -531,9 +531,9 @@
}
/* Always null terminate */
- gkr_buffer_add_byte (&pv->buffer, 0);
+ egg_buffer_add_byte (&pv->buffer, 0);
- gkr_secure_free (buf);
+ egg_secure_free (buf);
gkr_async_unregister_cancel (close_fd, &pv->out_fd);
close_fd (&pv->out_fd);
@@ -570,7 +570,7 @@
envp[i++] = NULL;
g_strfreev (names);
- gkr_buffer_resize (&pv->buffer, 0);
+ egg_buffer_resize (&pv->buffer, 0);
ret = g_spawn_async_with_pipes (NULL, argv, envp, 0, NULL, NULL, &pv->ask_pid,
&pv->in_fd, &pv->out_fd, NULL, &error);
@@ -687,7 +687,7 @@
pv->in_fd = -1;
/* Use a secure memory buffer */
- gkr_buffer_init_full (&pv->buffer, 128, gkr_secure_realloc);
+ egg_buffer_init_full (&pv->buffer, 128, egg_secure_realloc);
}
static guint
@@ -706,10 +706,10 @@
mark_completed (ask, GKR_ASK_RESPONSE_FAILURE);
g_assert (pv->ask_pid == 0);
- gkr_secure_strfree (ask->original_password);
+ egg_secure_strfree (ask->original_password);
ask->original_password = NULL;
- gkr_secure_strfree (ask->typed_password);
+ egg_secure_strfree (ask->typed_password);
ask->typed_password = NULL;
if (pv->in_fd >= 0)
@@ -739,7 +739,7 @@
g_assert (pv->in_fd < 0);
g_assert (pv->out_fd < 0);
- gkr_buffer_uninit (&pv->buffer);
+ egg_buffer_uninit (&pv->buffer);
G_OBJECT_CLASS(gkr_ask_request_parent_class)->finalize (obj);
}
Modified: trunk/daemon/ui/gkr-ask-tool.c
==============================================================================
--- trunk/daemon/ui/gkr-ask-tool.c (original)
+++ trunk/daemon/ui/gkr-ask-tool.c Sat Jan 17 23:27:10 2009
@@ -26,7 +26,7 @@
#include "gkr-ask-tool.h"
#include "gkr-ask-request.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include <gtk/gtk.h>
#include <glib/gi18n.h>
@@ -63,19 +63,19 @@
*/
void
-gkr_memory_lock (void)
+egg_memory_lock (void)
{
/* No threads used in ask tool, doesn't need locking */
}
void
-gkr_memory_unlock (void)
+egg_memory_unlock (void)
{
/* No threads used in ask tool, doesn't need locking */
}
void*
-gkr_memory_fallback (void *p, unsigned long sz)
+egg_memory_fallback (void *p, unsigned long sz)
{
const gchar *env;
@@ -600,7 +600,7 @@
/* Get the original password */
if (include_original && old != NULL && response >= GKR_ASK_RESPONSE_ALLOW) {
original = gkr_ask_entry_get_text (GKR_ASK_ENTRY (old));
- *original_out = gkr_secure_strdup (original);
+ *original_out = egg_secure_strdup (original);
}
/* Get the main password entry, and confirmation */
@@ -616,7 +616,7 @@
goto retry;
}
}
- *password_out = gkr_secure_strdup (password);
+ *password_out = egg_secure_strdup (password);
}
/* When it's a new password and blank, double check */
@@ -728,9 +728,9 @@
}
if (!password)
- password = gkr_secure_strdup ("");
+ password = egg_secure_strdup ("");
if (!original)
- original = gkr_secure_strdup ("");
+ original = egg_secure_strdup ("");
/* First two lines of the response are always the passwords */
if (response < GKR_ASK_RESPONSE_ALLOW || !(flags & GKR_ASK_REQUEST_PASSWORD))
@@ -746,8 +746,8 @@
/* Send back the response */
g_key_file_set_integer (output_data, "general", "response", response);
- gkr_secure_free (password);
- gkr_secure_free (original);
+ egg_secure_free (password);
+ egg_secure_free (original);
}
static gchar*
Added: trunk/egg/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/egg/Makefile.am Sat Jan 17 23:27:10 2009
@@ -0,0 +1,55 @@
+
+noinst_LTLIBRARIES = \
+ libegg.la \
+ libegg-buffer.la \
+ libegg-creds.la \
+ libegg-secure.la
+
+BUILT_SOURCES = \
+ asn1-def-pk.h asn1-def-pkix.h
+
+INCLUDES = \
+ -I$(top_srcdir)
+ -I$(top_builddir)
+
+libegg_la_CFLAGS = \
+ $(LIBTASN1_CFLAGS) \
+ $(GLIB_CFLAGS)
+
+libegg_la_SOURCES = \
+ egg-asn1.c egg-asn1.h \
+ egg-buffer.c egg-buffer.h \
+ egg-unix-credentials.c egg-unix-credentials.h \
+ egg-secure-memory.c egg-secure-memory.h
+
+asn1-def-pk.h: pk.asn
+ asn1Parser -o asn1-def-pk.h pk.asn
+
+asn1-def-pkix.h: pkix.asn
+ asn1Parser -o asn1-def-pkix.h pkix.asn
+
+EXTRA_DIST = \
+ pkix.asn \
+ pk.asn
+
+# --------------------------------------------------------------------
+# COMMON STUFF COMPILED INTO SMALLER COMPONENTS
+
+libegg_secure_la_SOURCES = \
+ egg-secure-memory.c egg-secure-memory.h
+
+libegg_buffer_la_SOURCES = \
+ egg-buffer.c egg-buffer.h
+
+libegg_creds_la_SOURCES = \
+ egg-unix-credentials.c egg-unix-credentials.h
+
+# -------------------------------------------------------------------
+
+if WITH_TESTS
+TESTS_DIR = tests
+else
+TESTS_DIR =
+endif
+
+SUBDIRS = . $(TESTS_DIR)
Copied: trunk/egg/egg-asn1.c (from r1459, /trunk/pkcs11/gck/gck-data-asn1.c)
==============================================================================
--- /trunk/pkcs11/gck/gck-data-asn1.c (original)
+++ trunk/egg/egg-asn1.c Sat Jan 17 23:27:10 2009
@@ -1,5 +1,5 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* gkr-pkix-asn1.c - ASN.1 helper routines
+/* egg-asn1.c - ASN.1 helper routines
Copyright (C) 2007 Stefan Walter
@@ -23,12 +23,12 @@
#include "config.h"
-#include "gck-data-asn1.h"
-
-#include "common/gkr-buffer.h"
+#include "egg-asn1.h"
#include <libtasn1.h>
+#include <string.h>
+
/*
* HACK: asn1Parser defines these arrays as extern const, which gives
* gcc a fit. So we def it out.
@@ -45,7 +45,7 @@
static void
init_asn1_trees (void)
{
- static gsize asn1_initialized = 0;
+ static volatile gsize asn1_initialized = 0;
int res;
if (g_once_init_enter (&asn1_initialized)) {
@@ -58,30 +58,30 @@
}
ASN1_TYPE
-gck_data_asn1_get_pk_asn1type (void)
+egg_asn1_get_pk_asn1type (void)
{
init_asn1_trees ();
return asn1_pk;
}
ASN1_TYPE
-gck_data_asn1_get_pkix_asn1type (void)
+egg_asn1_get_pkix_asn1type (void)
{
init_asn1_trees ();
return asn1_pkix;
}
ASN1_TYPE
-gck_data_asn1_decode (const gchar *type, const guchar *data, gsize n_data)
+egg_asn1_decode (const gchar *type, const guchar *data, gsize n_data)
{
ASN1_TYPE base = ASN1_TYPE_EMPTY;
ASN1_TYPE asn;
int res;
if (strncmp (type, "PKIX1.", 6) == 0)
- base = gck_data_asn1_get_pkix_asn1type ();
+ base = egg_asn1_get_pkix_asn1type ();
else if (strncmp (type, "PK.", 3) == 0)
- base = gck_data_asn1_get_pk_asn1type ();
+ base = egg_asn1_get_pk_asn1type ();
else
g_return_val_if_reached (NULL);
@@ -98,8 +98,7 @@
}
guchar*
-gck_data_asn1_encode (ASN1_TYPE asn, const gchar* part, gsize *n_data,
- GkrBufferAllocator alloc)
+egg_asn1_encode (ASN1_TYPE asn, const gchar* part, gsize *n_data, EggAllocator alloc)
{
guchar *data;
int res, len;
@@ -112,7 +111,7 @@
g_return_val_if_fail (res == ASN1_MEM_ERROR, NULL);
if (!alloc)
- alloc = (GkrBufferAllocator)g_realloc;
+ alloc = (EggAllocator)g_realloc;
data = (alloc) (NULL, len);
g_return_val_if_fail (data != NULL, NULL);
@@ -128,7 +127,7 @@
}
gint
-gck_data_asn1_element_length (const guchar *data, gsize n_data)
+egg_asn1_element_length (const guchar *data, gsize n_data)
{
guchar cls;
int counter = 0;
@@ -150,7 +149,7 @@
}
const guchar*
-gck_data_asn1_read_element (ASN1_TYPE asn, const guchar *data, gsize n_data,
+egg_asn1_read_element (ASN1_TYPE asn, const guchar *data, gsize n_data,
const gchar *part, gsize *n_element)
{
int beg, end, res;
@@ -169,7 +168,7 @@
}
const guchar*
-gck_data_asn1_read_content (ASN1_TYPE asn, const guchar *data, gsize n_data,
+egg_asn1_read_content (ASN1_TYPE asn, const guchar *data, gsize n_data,
const gchar *part, gsize *n_content)
{
const guchar *raw;
@@ -180,15 +179,15 @@
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail (n_content != NULL, NULL);
- raw = gck_data_asn1_read_element (asn, data, n_data, part, &n_raw);
+ raw = egg_asn1_read_element (asn, data, n_data, part, &n_raw);
if (!raw)
return NULL;
- return gck_data_asn1_element_content (raw, n_raw, n_content);
+ return egg_asn1_element_content (raw, n_raw, n_content);
}
const guchar*
-gck_data_asn1_element_content (const guchar *data, gsize n_data, gsize *n_content)
+egg_asn1_element_content (const guchar *data, gsize n_data, gsize *n_content)
{
int counter = 0;
guchar cls;
@@ -213,8 +212,7 @@
}
guchar*
-gck_data_asn1_read_value (ASN1_TYPE asn, const gchar *part, gsize *len,
- GkrBufferAllocator allocator)
+egg_asn1_read_value (ASN1_TYPE asn, const gchar *part, gsize *len, EggAllocator allocator)
{
int l, res;
guchar *buf;
@@ -223,7 +221,7 @@
g_return_val_if_fail (part != NULL, NULL);
if (allocator == NULL)
- allocator = (GkrBufferAllocator)g_realloc;
+ allocator = (EggAllocator)g_realloc;
l = 0;
res = asn1_read_value (asn, part, NULL, &l);
@@ -248,7 +246,7 @@
}
gboolean
-gck_data_asn1_write_value (ASN1_TYPE asn, const gchar *part,
+egg_asn1_write_value (ASN1_TYPE asn, const gchar *part,
const guchar* value, gsize len)
{
int res;
@@ -262,7 +260,7 @@
}
gboolean
-gck_data_asn1_read_boolean (ASN1_TYPE asn, const gchar *part, gboolean *val)
+egg_asn1_read_boolean (ASN1_TYPE asn, const gchar *part, gboolean *val)
{
gchar buffer[32];
int n_buffer = sizeof (buffer) - 1;
@@ -283,7 +281,7 @@
}
gboolean
-gck_data_asn1_read_uint (ASN1_TYPE asn, const gchar *part, guint *val)
+egg_asn1_read_uint (ASN1_TYPE asn, const gchar *part, guint *val)
{
guchar buf[4];
int n_buf = sizeof (buf);
@@ -305,7 +303,7 @@
}
gboolean
-gck_data_asn1_write_uint (ASN1_TYPE asn, const gchar *part, guint32 val)
+egg_asn1_write_uint (ASN1_TYPE asn, const gchar *part, guint32 val)
{
guchar buf[4];
int res, bytes;
@@ -327,13 +325,13 @@
}
GQuark
-gck_data_asn1_read_oid (ASN1_TYPE asn, const gchar *part)
+egg_asn1_read_oid (ASN1_TYPE asn, const gchar *part)
{
GQuark quark;
guchar *buf;
gsize n_buf;
- buf = gck_data_asn1_read_value (asn, part, &n_buf, NULL);
+ buf = egg_asn1_read_value (asn, part, &n_buf, NULL);
if (!buf)
return 0;
@@ -347,7 +345,7 @@
}
gboolean
-gck_data_asn1_write_oid (ASN1_TYPE asn, const gchar *part, GQuark val)
+egg_asn1_write_oid (ASN1_TYPE asn, const gchar *part, GQuark val)
{
const gchar* oid;
@@ -356,78 +354,7 @@
oid = g_quark_to_string (val);
g_return_val_if_fail (oid, FALSE);
- return gck_data_asn1_write_value (asn, part, (const guchar*)oid, strlen (oid));
-}
-
-gboolean
-gck_data_asn1_read_mpi (ASN1_TYPE asn, const gchar *part, gcry_mpi_t *mpi)
-{
- gcry_error_t gcry;
- gsize sz;
- guchar *buf;
-
- buf = gck_data_asn1_read_value (asn, part, &sz, (GkrBufferAllocator)g_realloc);
- if (!buf)
- return FALSE;
-
- gcry = gcry_mpi_scan (mpi, GCRYMPI_FMT_STD, buf, sz, &sz);
- g_free (buf);
-
- if (gcry != 0)
- return FALSE;
-
- return TRUE;
-}
-
-gboolean
-gck_data_asn1_read_secure_mpi (ASN1_TYPE asn, const gchar *part, gcry_mpi_t *mpi)
-{
- gcry_error_t gcry;
- gsize sz;
- guchar *buf;
-
- buf = gck_data_asn1_read_value (asn, part, &sz, (GkrBufferAllocator)gcry_realloc);
- if (!buf)
- return FALSE;
-
- gcry = gcry_mpi_scan (mpi, GCRYMPI_FMT_STD, buf, sz, &sz);
- gcry_free (buf);
-
- if (gcry != 0)
- return FALSE;
-
- return TRUE;
-}
-
-gboolean
-gck_data_asn1_write_mpi (ASN1_TYPE asn, const gchar *part, gcry_mpi_t mpi)
-{
- gcry_error_t gcry;
- gsize len;
- guchar *buf;
- int res;
-
- g_assert (asn);
- g_assert (part);
- g_assert (mpi);
-
- /* Get the size */
- gcry = gcry_mpi_print (GCRYMPI_FMT_STD, NULL, 0, &len, mpi);
- g_return_val_if_fail (gcry == 0, FALSE);
- g_return_val_if_fail (len > 0, FALSE);
-
- buf = gcry_calloc_secure (len, 1);
-
- gcry = gcry_mpi_print (GCRYMPI_FMT_STD, buf, len, &len, mpi);
- g_return_val_if_fail (gcry == 0, FALSE);
-
- res = asn1_write_value (asn, part, buf, len);
- gcry_free (buf);
-
- if (res != ASN1_SUCCESS)
- return FALSE;
-
- return TRUE;
+ return egg_asn1_write_value (asn, part, (const guchar*)oid, strlen (oid));
}
static int
@@ -516,7 +443,7 @@
#endif //NOT_HAVE_TIMEGM
time_t
-gck_data_asn1_parse_utc_time (const gchar *time)
+egg_asn1_parse_utc_time (const gchar *time)
{
struct tm when;
guint n_time;
@@ -632,7 +559,7 @@
}
time_t
-gck_data_asn1_parse_general_time (const gchar *time)
+egg_asn1_parse_general_time (const gchar *time)
{
struct tm when;
guint n_time;
@@ -737,7 +664,7 @@
}
gboolean
-gck_data_asn1_read_time (ASN1_TYPE asn, const gchar *part, time_t *val)
+egg_asn1_read_time (ASN1_TYPE asn, const gchar *part, time_t *val)
{
#define MAX_TIME 1024
gchar ttime[MAX_TIME];
@@ -758,7 +685,7 @@
if (res != ASN1_SUCCESS)
return FALSE;
- *val = gck_data_asn1_parse_general_time (ttime);
+ *val = egg_asn1_parse_general_time (ttime);
/* UTCTIME */
} else {
@@ -769,7 +696,7 @@
if (res != ASN1_SUCCESS)
return FALSE;
- *val = gck_data_asn1_parse_utc_time (ttime);
+ *val = egg_asn1_parse_utc_time (ttime);
}
if (*val < (time_t)0)
@@ -882,12 +809,12 @@
g_assert (len);
g_assert (printable->oid);
- asn_name = asn1_find_structure_from_oid (gck_data_asn1_get_pkix_asn1type (),
+ asn_name = asn1_find_structure_from_oid (egg_asn1_get_pkix_asn1type (),
printable->oidstr);
g_return_val_if_fail (asn_name, NULL);
part = g_strdup_printf ("PKIX1.%s", asn_name);
- asn1 = gck_data_asn1_decode (part, data, len);
+ asn1 = egg_asn1_decode (part, data, len);
g_free (part);
if (!asn1) {
@@ -895,7 +822,7 @@
return NULL;
}
- value = (gchar*)gck_data_asn1_read_value (asn1, "", NULL, NULL);
+ value = (gchar*)egg_asn1_read_value (asn1, "", NULL, NULL);
/*
* If it's a choice element, then we have to read depending
@@ -907,7 +834,7 @@
strcmp ("utf8String", value) == 0 ||
strcmp ("teletexString", value) == 0) {
part = value;
- value = (gchar*)gck_data_asn1_read_value (asn1, part, NULL, NULL);
+ value = (gchar*)egg_asn1_read_value (asn1, part, NULL, NULL);
g_free (part);
} else {
g_free (value);
@@ -964,14 +891,14 @@
g_assert (part);
path = g_strdup_printf ("%s.type", part);
- oid = gck_data_asn1_read_oid (asn, path);
+ oid = egg_asn1_read_oid (asn, path);
g_free (path);
if (!oid)
return NULL;
path = g_strdup_printf ("%s.value", part);
- value = gck_data_asn1_read_value (asn, path, &n_value, NULL);
+ value = egg_asn1_read_value (asn, path, &n_value, NULL);
g_free (path);
printable = dn_find_printable (oid);
@@ -987,7 +914,7 @@
}
gchar*
-gck_data_asn1_read_dn (ASN1_TYPE asn, const gchar *part)
+egg_asn1_read_dn (ASN1_TYPE asn, const gchar *part)
{
gboolean done = FALSE;
GString *result;
@@ -1033,7 +960,7 @@
}
gchar*
-gck_data_asn1_read_dn_part (ASN1_TYPE asn, const gchar *part, const gchar *match)
+egg_asn1_read_dn_part (ASN1_TYPE asn, const gchar *part, const gchar *match)
{
PrintableOid *printable = NULL;
gboolean done = FALSE;
@@ -1057,7 +984,7 @@
path = g_strdup_printf ("%s%s?%u.?%u.type",
part ? part : "",
part ? "." : "", i, j);
- oid = gck_data_asn1_read_oid (asn, path);
+ oid = egg_asn1_read_oid (asn, path);
g_free (path);
if (!oid) {
@@ -1076,7 +1003,7 @@
path = g_strdup_printf ("%s%s?%u.?%u.value",
part ? part : "",
part ? "." : "", i, j);
- value = gck_data_asn1_read_value (asn, path, &n_value, NULL);
+ value = egg_asn1_read_value (asn, path, &n_value, NULL);
g_free (path);
g_return_val_if_fail (value, NULL);
Copied: trunk/egg/egg-asn1.h (from r1458, /trunk/pkcs11/gck/gck-data-asn1.h)
==============================================================================
--- /trunk/pkcs11/gck/gck-data-asn1.h (original)
+++ trunk/egg/egg-asn1.h Sat Jan 17 23:27:10 2009
@@ -1,5 +1,5 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* gck-data-asn1.h - ASN.1 helper routines
+/* egg-asn1.h - ASN.1 helper routines
Copyright (C) 2007 Stefan Walter
@@ -21,68 +21,59 @@
Author: Stef Walter <stef memberwebs com>
*/
-#ifndef GCK_DATA_ASN_H_
-#define GCK_DATA_ASN_H_
+#ifndef EGG_ASN1_H_
+#define EGG_ASN1_H_
-#include <libtasn1.h>
-#include <gcrypt.h>
#include <glib.h>
-#include "gck-data-types.h"
+#include <libtasn1.h>
-ASN1_TYPE gck_data_asn1_get_pk_asn1type (void);
+typedef void* (*EggAllocator) (void* p, unsigned long len);
-ASN1_TYPE gck_data_asn1_get_pkix_asn1type (void);
+ASN1_TYPE egg_asn1_get_pk_asn1type (void);
-ASN1_TYPE gck_data_asn1_decode (const gchar *type, const guchar *data,
- gsize n_data);
+ASN1_TYPE egg_asn1_get_pkix_asn1type (void);
-guchar* gck_data_asn1_encode (ASN1_TYPE asn, const gchar* part,
- gsize *len, GckDataAllocator alloc);
+ASN1_TYPE egg_asn1_decode (const gchar *type, const guchar *data,
+ gsize n_data);
-guchar* gck_data_asn1_read_value (ASN1_TYPE asn, const gchar *part,
- gsize *len, GckDataAllocator alloc);
+guchar* egg_asn1_encode (ASN1_TYPE asn, const gchar* part,
+ gsize *len, EggAllocator alloc);
-gboolean gck_data_asn1_write_value (ASN1_TYPE asn, const gchar *part,
- const guchar* value, gsize len);
+guchar* egg_asn1_read_value (ASN1_TYPE asn, const gchar *part,
+ gsize *len, EggAllocator alloc);
-GQuark gck_data_asn1_read_oid (ASN1_TYPE asn, const gchar *part);
+gboolean egg_asn1_write_value (ASN1_TYPE asn, const gchar *part,
+ const guchar* value, gsize len);
-gboolean gck_data_asn1_write_oid (ASN1_TYPE asn, const gchar *part, GQuark val);
+GQuark egg_asn1_read_oid (ASN1_TYPE asn, const gchar *part);
-gboolean gck_data_asn1_read_boolean (ASN1_TYPE asn, const gchar *part, gboolean *val);
+gboolean egg_asn1_write_oid (ASN1_TYPE asn, const gchar *part, GQuark val);
-gboolean gck_data_asn1_read_uint (ASN1_TYPE asn, const gchar *part, guint *val);
+gboolean egg_asn1_read_boolean (ASN1_TYPE asn, const gchar *part, gboolean *val);
-gboolean gck_data_asn1_read_time (ASN1_TYPE asn, const gchar *part, time_t *val);
+gboolean egg_asn1_read_uint (ASN1_TYPE asn, const gchar *part, guint *val);
-const guchar* gck_data_asn1_read_content (ASN1_TYPE asn, const guchar *data, gsize n_data,
- const gchar *part, gsize *n_content);
+gboolean egg_asn1_read_time (ASN1_TYPE asn, const gchar *part, time_t *val);
-const guchar* gck_data_asn1_read_element (ASN1_TYPE asn, const guchar *data, gsize n_data,
- const gchar *part, gsize *n_element);
-
-gboolean gck_data_asn1_write_uint (ASN1_TYPE asn, const gchar *part, guint val);
+const guchar* egg_asn1_read_content (ASN1_TYPE asn, const guchar *data, gsize n_data,
+ const gchar *part, gsize *n_content);
-gboolean gck_data_asn1_read_mpi (ASN1_TYPE asn, const gchar *part,
- gcry_mpi_t *mpi);
-
-gboolean gck_data_asn1_read_secure_mpi (ASN1_TYPE asn, const gchar *part,
- gcry_mpi_t *mpi);
+const guchar* egg_asn1_read_element (ASN1_TYPE asn, const guchar *data, gsize n_data,
+ const gchar *part, gsize *n_element);
+
+gboolean egg_asn1_write_uint (ASN1_TYPE asn, const gchar *part, guint val);
-gboolean gck_data_asn1_write_mpi (ASN1_TYPE asn, const gchar *part,
- gcry_mpi_t mpi);
-
-gchar* gck_data_asn1_read_dn (ASN1_TYPE asn, const gchar *part);
+gchar* egg_asn1_read_dn (ASN1_TYPE asn, const gchar *part);
-gchar* gck_data_asn1_read_dn_part (ASN1_TYPE asn, const gchar *part, const gchar *match);
+gchar* egg_asn1_read_dn_part (ASN1_TYPE asn, const gchar *part, const gchar *match);
-gint gck_data_asn1_element_length (const guchar *data, gsize n_data);
+gint egg_asn1_element_length (const guchar *data, gsize n_data);
-const guchar* gck_data_asn1_element_content (const guchar *data, gsize n_data, gsize *n_content);
+const guchar* egg_asn1_element_content (const guchar *data, gsize n_data, gsize *n_content);
-time_t gck_data_asn1_parse_utc_time (const gchar* value);
+glong egg_asn1_parse_utc_time (const gchar* value);
-time_t gck_data_asn1_parse_general_time (const gchar* value);
+glong egg_asn1_parse_general_time (const gchar* value);
-#endif /*GCK_DATA_ASN_H_*/
+#endif /*EGG_ASN1_H_*/
Copied: trunk/egg/egg-buffer.c (from r1460, /trunk/common/gkr-buffer.c)
==============================================================================
--- /trunk/common/gkr-buffer.c (original)
+++ trunk/egg/egg-buffer.c Sat Jan 17 23:27:10 2009
@@ -1,5 +1,5 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* gkr-buffer.c - helper code for the keyring daemon protocol
+/* egg-buffer.c - Generic data buffer, used by openssh, gnome-keyring
Copyright (C) 2007 Stefan Walter
@@ -25,18 +25,18 @@
#include <string.h>
#include <stdarg.h>
-#include "gkr-buffer.h"
+#include "egg-buffer.h"
-#define DEFAULT_ALLOCATOR ((GkrBufferAllocator)realloc)
+#define DEFAULT_ALLOCATOR ((EggBufferAllocator)realloc)
int
-gkr_buffer_init (GkrBuffer *buffer, size_t reserve)
+egg_buffer_init (EggBuffer *buffer, size_t reserve)
{
- return gkr_buffer_init_full (buffer, reserve, NULL);
+ return egg_buffer_init_full (buffer, reserve, NULL);
}
int
-gkr_buffer_init_full (GkrBuffer *buffer, size_t reserve, GkrBufferAllocator allocator)
+egg_buffer_init_full (EggBuffer *buffer, size_t reserve, EggBufferAllocator allocator)
{
memset (buffer, 0, sizeof (*buffer));
@@ -60,7 +60,7 @@
}
void
-gkr_buffer_init_static (GkrBuffer* buffer, unsigned char *buf, size_t len)
+egg_buffer_init_static (EggBuffer* buffer, unsigned char *buf, size_t len)
{
memset (buffer, 0, sizeof (*buffer));
@@ -74,8 +74,8 @@
}
void
-gkr_buffer_init_allocated (GkrBuffer *buffer, unsigned char *buf, size_t len,
- GkrBufferAllocator allocator)
+egg_buffer_init_allocated (EggBuffer *buffer, unsigned char *buf, size_t len,
+ EggBufferAllocator allocator)
{
memset (buffer, 0, sizeof (*buffer));
@@ -90,7 +90,7 @@
}
void
-gkr_buffer_reset (GkrBuffer *buffer)
+egg_buffer_reset (EggBuffer *buffer)
{
memset (buffer->buf, 0, buffer->allocated_len);
buffer->len = 0;
@@ -98,7 +98,7 @@
}
void
-gkr_buffer_uninit (GkrBuffer *buffer)
+egg_buffer_uninit (EggBuffer *buffer)
{
if (!buffer)
return;
@@ -114,7 +114,7 @@
}
int
-gkr_buffer_set_allocator (GkrBuffer *buffer, GkrBufferAllocator allocator)
+egg_buffer_set_allocator (EggBuffer *buffer, EggBufferAllocator allocator)
{
unsigned char *buf;
@@ -142,7 +142,7 @@
}
int
-gkr_buffer_equal (GkrBuffer *b1, GkrBuffer *b2)
+egg_buffer_equal (EggBuffer *b1, EggBuffer *b2)
{
if (b1->len != b2->len)
return 0;
@@ -150,7 +150,7 @@
}
int
-gkr_buffer_reserve (GkrBuffer *buffer, size_t len)
+egg_buffer_reserve (EggBuffer *buffer, size_t len)
{
unsigned char *newbuf;
size_t newlen;
@@ -183,9 +183,9 @@
}
int
-gkr_buffer_resize (GkrBuffer *buffer, size_t len)
+egg_buffer_resize (EggBuffer *buffer, size_t len)
{
- if (!gkr_buffer_reserve (buffer, len))
+ if (!egg_buffer_reserve (buffer, len))
return 0;
buffer->len = len;
@@ -193,20 +193,20 @@
}
unsigned char*
-gkr_buffer_add_empty (GkrBuffer *buffer, size_t len)
+egg_buffer_add_empty (EggBuffer *buffer, size_t len)
{
size_t pos = buffer->len;
- if (!gkr_buffer_reserve (buffer, buffer->len + len))
+ if (!egg_buffer_reserve (buffer, buffer->len + len))
return NULL;
buffer->len += len;
return buffer->buf + pos;
}
int
-gkr_buffer_append (GkrBuffer *buffer, const unsigned char *val,
+egg_buffer_append (EggBuffer *buffer, const unsigned char *val,
size_t len)
{
- if (!gkr_buffer_reserve (buffer, buffer->len + len))
+ if (!egg_buffer_reserve (buffer, buffer->len + len))
return 0; /* failures already incremented */
memcpy (buffer->buf + buffer->len, val, len);
buffer->len += len;
@@ -214,9 +214,9 @@
}
int
-gkr_buffer_add_byte (GkrBuffer *buffer, unsigned char val)
+egg_buffer_add_byte (EggBuffer *buffer, unsigned char val)
{
- if (!gkr_buffer_reserve (buffer, buffer->len + 1))
+ if (!egg_buffer_reserve (buffer, buffer->len + 1))
return 0; /* failures already incremented */
buffer->buf[buffer->len] = val;
buffer->len++;
@@ -224,7 +224,7 @@
}
int
-gkr_buffer_get_byte (GkrBuffer *buffer, size_t offset,
+egg_buffer_get_byte (EggBuffer *buffer, size_t offset,
size_t *next_offset, unsigned char *val)
{
unsigned char *ptr;
@@ -241,31 +241,31 @@
}
void
-gkr_buffer_encode_uint16 (unsigned char* buf, uint16_t val)
+egg_buffer_encode_uint16 (unsigned char* buf, uint16_t val)
{
buf[0] = (val >> 8) & 0xff;
buf[1] = (val >> 0) & 0xff;
}
uint16_t
-gkr_buffer_decode_uint16 (unsigned char* buf)
+egg_buffer_decode_uint16 (unsigned char* buf)
{
uint16_t val = buf[0] << 8 | buf[1];
return val;
}
int
-gkr_buffer_add_uint16 (GkrBuffer *buffer, uint16_t val)
+egg_buffer_add_uint16 (EggBuffer *buffer, uint16_t val)
{
- if (!gkr_buffer_reserve (buffer, buffer->len + 2))
+ if (!egg_buffer_reserve (buffer, buffer->len + 2))
return 0; /* failures already incremented */
buffer->len += 2;
- gkr_buffer_set_uint16 (buffer, buffer->len - 2, val);
+ egg_buffer_set_uint16 (buffer, buffer->len - 2, val);
return 1;
}
int
-gkr_buffer_set_uint16 (GkrBuffer *buffer, size_t offset, uint16_t val)
+egg_buffer_set_uint16 (EggBuffer *buffer, size_t offset, uint16_t val)
{
unsigned char *ptr;
if (buffer->len < 2 || offset > buffer->len - 2) {
@@ -273,12 +273,12 @@
return 0;
}
ptr = (unsigned char*)buffer->buf + offset;
- gkr_buffer_encode_uint16 (ptr, val);
+ egg_buffer_encode_uint16 (ptr, val);
return 1;
}
int
-gkr_buffer_get_uint16 (GkrBuffer *buffer, size_t offset,
+egg_buffer_get_uint16 (EggBuffer *buffer, size_t offset,
size_t *next_offset, uint16_t *val)
{
unsigned char *ptr;
@@ -288,14 +288,14 @@
}
ptr = (unsigned char*)buffer->buf + offset;
if (val != NULL)
- *val = gkr_buffer_decode_uint16 (ptr);
+ *val = egg_buffer_decode_uint16 (ptr);
if (next_offset != NULL)
*next_offset = offset + 2;
return 1;
}
void
-gkr_buffer_encode_uint32 (unsigned char* buf, uint32_t val)
+egg_buffer_encode_uint32 (unsigned char* buf, uint32_t val)
{
buf[0] = (val >> 24) & 0xff;
buf[1] = (val >> 16) & 0xff;
@@ -304,24 +304,24 @@
}
uint32_t
-gkr_buffer_decode_uint32 (unsigned char* ptr)
+egg_buffer_decode_uint32 (unsigned char* ptr)
{
uint32_t val = ptr[0] << 24 | ptr[1] << 16 | ptr[2] << 8 | ptr[3];
return val;
}
int
-gkr_buffer_add_uint32 (GkrBuffer *buffer, uint32_t val)
+egg_buffer_add_uint32 (EggBuffer *buffer, uint32_t val)
{
- if (!gkr_buffer_reserve (buffer, buffer->len + 4))
+ if (!egg_buffer_reserve (buffer, buffer->len + 4))
return 0; /* failures already incremented */
buffer->len += 4;
- gkr_buffer_set_uint32 (buffer, buffer->len - 4, val);
+ egg_buffer_set_uint32 (buffer, buffer->len - 4, val);
return 1;
}
int
-gkr_buffer_set_uint32 (GkrBuffer *buffer, size_t offset, uint32_t val)
+egg_buffer_set_uint32 (EggBuffer *buffer, size_t offset, uint32_t val)
{
unsigned char *ptr;
if (buffer->len < 4 || offset > buffer->len - 4) {
@@ -329,12 +329,12 @@
return 0;
}
ptr = (unsigned char*)buffer->buf + offset;
- gkr_buffer_encode_uint32 (ptr, val);
+ egg_buffer_encode_uint32 (ptr, val);
return 1;
}
int
-gkr_buffer_get_uint32 (GkrBuffer *buffer, size_t offset, size_t *next_offset,
+egg_buffer_get_uint32 (EggBuffer *buffer, size_t offset, size_t *next_offset,
uint32_t *val)
{
unsigned char *ptr;
@@ -344,28 +344,28 @@
}
ptr = (unsigned char*)buffer->buf + offset;
if (val != NULL)
- *val = gkr_buffer_decode_uint32 (ptr);
+ *val = egg_buffer_decode_uint32 (ptr);
if (next_offset != NULL)
*next_offset = offset + 4;
return 1;
}
int
-gkr_buffer_add_uint64 (GkrBuffer *buffer, uint64_t val)
+egg_buffer_add_uint64 (EggBuffer *buffer, uint64_t val)
{
- if (!gkr_buffer_add_uint32 (buffer, ((val >> 32) & 0xffffffff)))
+ if (!egg_buffer_add_uint32 (buffer, ((val >> 32) & 0xffffffff)))
return 0;
- return gkr_buffer_add_uint32 (buffer, (val & 0xffffffff));
+ return egg_buffer_add_uint32 (buffer, (val & 0xffffffff));
}
int
-gkr_buffer_get_uint64 (GkrBuffer *buffer, size_t offset,
+egg_buffer_get_uint64 (EggBuffer *buffer, size_t offset,
size_t *next_offset, uint64_t *val)
{
uint32_t a, b;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &a))
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &a))
return 0;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &b))
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &b))
return 0;
if (val != NULL)
*val = ((uint64_t)a) << 32 | b;
@@ -375,39 +375,39 @@
}
int
-gkr_buffer_add_byte_array (GkrBuffer *buffer, const unsigned char *val,
+egg_buffer_add_byte_array (EggBuffer *buffer, const unsigned char *val,
size_t len)
{
if (val == NULL)
- return gkr_buffer_add_uint32 (buffer, 0xffffffff);
+ return egg_buffer_add_uint32 (buffer, 0xffffffff);
if (len >= 0x7fffffff) {
buffer->failures++;
return 0;
}
- if (!gkr_buffer_add_uint32 (buffer, len))
+ if (!egg_buffer_add_uint32 (buffer, len))
return 0;
- return gkr_buffer_append (buffer, val, len);
+ return egg_buffer_append (buffer, val, len);
}
unsigned char*
-gkr_buffer_add_byte_array_empty (GkrBuffer *buffer, size_t vlen)
+egg_buffer_add_byte_array_empty (EggBuffer *buffer, size_t vlen)
{
if (vlen >= 0x7fffffff) {
buffer->failures++;
return NULL;
}
- if (!gkr_buffer_add_uint32 (buffer, vlen))
+ if (!egg_buffer_add_uint32 (buffer, vlen))
return NULL;
- return gkr_buffer_add_empty (buffer, vlen);
+ return egg_buffer_add_empty (buffer, vlen);
}
int
-gkr_buffer_get_byte_array (GkrBuffer *buffer, size_t offset,
+egg_buffer_get_byte_array (EggBuffer *buffer, size_t offset,
size_t *next_offset, const unsigned char **val,
size_t *vlen)
{
uint32_t len;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &len))
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &len))
return 0;
if (len == 0xffffffff) {
if (next_offset)
@@ -438,23 +438,23 @@
}
int
-gkr_buffer_add_string (GkrBuffer *buffer, const char *str)
+egg_buffer_add_string (EggBuffer *buffer, const char *str)
{
if (str == NULL) {
- return gkr_buffer_add_uint32 (buffer, 0xffffffff);
+ return egg_buffer_add_uint32 (buffer, 0xffffffff);
} else {
size_t len = strlen (str);
if (len >= 0x7fffffff)
return 0;
- if (!gkr_buffer_add_uint32 (buffer, len))
+ if (!egg_buffer_add_uint32 (buffer, len))
return 0;
- return gkr_buffer_append (buffer, (unsigned char*)str, len);
+ return egg_buffer_append (buffer, (unsigned char*)str, len);
}
}
int
-gkr_buffer_get_string (GkrBuffer *buffer, size_t offset, size_t *next_offset,
- char **str_ret, GkrBufferAllocator allocator)
+egg_buffer_get_string (EggBuffer *buffer, size_t offset, size_t *next_offset,
+ char **str_ret, EggBufferAllocator allocator)
{
uint32_t len;
@@ -463,7 +463,7 @@
if (!allocator)
allocator = DEFAULT_ALLOCATOR;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &len)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &len)) {
return 0;
}
if (len == 0xffffffff) {
@@ -497,7 +497,7 @@
}
int
-gkr_buffer_add_stringv (GkrBuffer *buffer, const char** strv)
+egg_buffer_add_stringv (EggBuffer *buffer, const char** strv)
{
const char **v;
uint32_t n = 0;
@@ -508,12 +508,12 @@
/* Add the number of strings coming */
for (v = strv; *v; ++v)
++n;
- if (!gkr_buffer_add_uint32 (buffer, n))
+ if (!egg_buffer_add_uint32 (buffer, n))
return 0;
/* Add the individual strings */
for (v = strv; *v; ++v) {
- if (!gkr_buffer_add_string (buffer, *v))
+ if (!egg_buffer_add_string (buffer, *v))
return 0;
}
@@ -521,8 +521,8 @@
}
int
-gkr_buffer_get_stringv (GkrBuffer *buffer, size_t offset, size_t *next_offset,
- char ***strv_ret, GkrBufferAllocator allocator)
+egg_buffer_get_stringv (EggBuffer *buffer, size_t offset, size_t *next_offset,
+ char ***strv_ret, EggBufferAllocator allocator)
{
uint32_t n, i, j;
size_t len;
@@ -533,7 +533,7 @@
allocator = DEFAULT_ALLOCATOR;
/* First the number of environment variable lines */
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &n))
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &n))
return 0;
/* Then that number of strings */
@@ -546,7 +546,7 @@
memset (*strv_ret, 0, len);
for (i = 0; i < n; ++i) {
- if (!gkr_buffer_get_string (buffer, offset, &offset,
+ if (!egg_buffer_get_string (buffer, offset, &offset,
&((*strv_ret)[i]), allocator)) {
/* Free all the strings on failure */
Copied: trunk/egg/egg-buffer.h (from r1460, /trunk/common/gkr-buffer.h)
==============================================================================
--- /trunk/common/gkr-buffer.h (original)
+++ trunk/egg/egg-buffer.h Sat Jan 17 23:27:10 2009
@@ -1,5 +1,5 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* gkr-buffer.h - helper code for the keyring daemon protocol
+/* egg-buffer.h - Generic data buffer, used by openssh, gnome-keyring
Copyright (C) 2007, Stefan Walter
@@ -21,14 +21,14 @@
Author: Stef Walter <stef memberwebs com>
*/
-#ifndef GKR_BUFFER_H
-#define GKR_BUFFER_H
+#ifndef EGG_BUFFER_H
+#define EGG_BUFFER_H
#include <stdlib.h>
#include <stdint.h>
/* -------------------------------------------------------------------
- * GkrBuffer
+ * EggBuffer
*
* IMPORTANT: This is pure vanila standard C, no glib. We need this
* because certain consumers of this protocol need to be built
@@ -39,13 +39,13 @@
* Callers can set their own allocator. If NULL is used then standard
* C library heap memory is used and failures will not be fatal. Memory
* failures will instead result in a zero return value or
- * gkr_buffer_has_error() returning one.
+ * egg_buffer_has_error() returning one.
*
* If you use something like g_realloc as the allocator, then memory
* failures become fatal just like in a standard GTK program.
*
- * Don't change the allocator manually in the GkrBuffer structure. The
- * gkr_buffer_set_allocator() func will reallocate and handle things
+ * Don't change the allocator manually in the EggBuffer structure. The
+ * egg_buffer_set_allocator() func will reallocate and handle things
* properly.
*
* Pointers into the Buffer
@@ -54,141 +54,141 @@
* and invalidating any direct pointers into the buffer.
*/
-/* The allocator for the GkrBuffer. This follows the realloc() syntax and logic */
-typedef void* (*GkrBufferAllocator) (void* p, unsigned long len);
+/* The allocator for the EggBuffer. This follows the realloc() syntax and logic */
+typedef void* (*EggBufferAllocator) (void* p, unsigned long len);
-typedef struct _GkrBuffer {
+typedef struct _EggBuffer {
unsigned char *buf;
size_t len;
size_t allocated_len;
int failures;
- GkrBufferAllocator allocator;
-} GkrBuffer;
+ EggBufferAllocator allocator;
+} EggBuffer;
-#define GKR_BUFFER_EMPTY { NULL, 0, 0, 0, NULL }
+#define EGG_BUFFER_EMPTY { NULL, 0, 0, 0, NULL }
-int gkr_buffer_init (GkrBuffer *buffer, size_t reserve);
+int egg_buffer_init (EggBuffer *buffer, size_t reserve);
-int gkr_buffer_init_full (GkrBuffer *buffer,
+int egg_buffer_init_full (EggBuffer *buffer,
size_t reserve,
- GkrBufferAllocator allocator);
+ EggBufferAllocator allocator);
-void gkr_buffer_init_static (GkrBuffer *buffer,
+void egg_buffer_init_static (EggBuffer *buffer,
unsigned char *buf,
size_t len);
-void gkr_buffer_init_allocated (GkrBuffer *buffer,
+void egg_buffer_init_allocated (EggBuffer *buffer,
unsigned char *buf,
size_t len,
- GkrBufferAllocator allocator);
+ EggBufferAllocator allocator);
-void gkr_buffer_uninit (GkrBuffer *buffer);
+void egg_buffer_uninit (EggBuffer *buffer);
-int gkr_buffer_set_allocator (GkrBuffer *buffer,
- GkrBufferAllocator allocator);
+int egg_buffer_set_allocator (EggBuffer *buffer,
+ EggBufferAllocator allocator);
-void gkr_buffer_reset (GkrBuffer *buffer);
+void egg_buffer_reset (EggBuffer *buffer);
-int gkr_buffer_equal (GkrBuffer *b1,
- GkrBuffer *b2);
+int egg_buffer_equal (EggBuffer *b1,
+ EggBuffer *b2);
-int gkr_buffer_reserve (GkrBuffer *buffer,
+int egg_buffer_reserve (EggBuffer *buffer,
size_t len);
-int gkr_buffer_resize (GkrBuffer *buffer,
+int egg_buffer_resize (EggBuffer *buffer,
size_t len);
-int gkr_buffer_append (GkrBuffer *buffer,
+int egg_buffer_append (EggBuffer *buffer,
const unsigned char *val,
size_t len);
-unsigned char* gkr_buffer_add_empty (GkrBuffer *buffer,
+unsigned char* egg_buffer_add_empty (EggBuffer *buffer,
size_t len);
-int gkr_buffer_add_byte (GkrBuffer *buffer,
+int egg_buffer_add_byte (EggBuffer *buffer,
unsigned char val);
-int gkr_buffer_get_byte (GkrBuffer *buffer,
+int egg_buffer_get_byte (EggBuffer *buffer,
size_t offset,
size_t *next_offset,
unsigned char *val);
-void gkr_buffer_encode_uint32 (unsigned char* buf,
+void egg_buffer_encode_uint32 (unsigned char* buf,
uint32_t val);
-uint32_t gkr_buffer_decode_uint32 (unsigned char* buf);
+uint32_t egg_buffer_decode_uint32 (unsigned char* buf);
-int gkr_buffer_add_uint32 (GkrBuffer *buffer,
+int egg_buffer_add_uint32 (EggBuffer *buffer,
uint32_t val);
-int gkr_buffer_set_uint32 (GkrBuffer *buffer,
+int egg_buffer_set_uint32 (EggBuffer *buffer,
size_t offset,
uint32_t val);
-int gkr_buffer_get_uint32 (GkrBuffer *buffer,
+int egg_buffer_get_uint32 (EggBuffer *buffer,
size_t offset,
size_t *next_offset,
uint32_t *val);
-void gkr_buffer_encode_uint16 (unsigned char* buf,
+void egg_buffer_encode_uint16 (unsigned char* buf,
uint16_t val);
-uint16_t gkr_buffer_decode_uint16 (unsigned char* buf);
+uint16_t egg_buffer_decode_uint16 (unsigned char* buf);
-int gkr_buffer_add_uint16 (GkrBuffer *buffer,
+int egg_buffer_add_uint16 (EggBuffer *buffer,
uint16_t val);
-int gkr_buffer_set_uint16 (GkrBuffer *buffer,
+int egg_buffer_set_uint16 (EggBuffer *buffer,
size_t offset,
uint16_t val);
-int gkr_buffer_get_uint16 (GkrBuffer *buffer,
+int egg_buffer_get_uint16 (EggBuffer *buffer,
size_t offset,
size_t *next_offset,
uint16_t *val);
-int gkr_buffer_add_byte_array (GkrBuffer *buffer,
+int egg_buffer_add_byte_array (EggBuffer *buffer,
const unsigned char *val,
size_t len);
-int gkr_buffer_get_byte_array (GkrBuffer *buffer,
+int egg_buffer_get_byte_array (EggBuffer *buffer,
size_t offset,
size_t *next_offset,
const unsigned char **val,
size_t *vlen);
-unsigned char* gkr_buffer_add_byte_array_empty (GkrBuffer *buffer,
+unsigned char* egg_buffer_add_byte_array_empty (EggBuffer *buffer,
size_t vlen);
-int gkr_buffer_add_string (GkrBuffer *buffer,
+int egg_buffer_add_string (EggBuffer *buffer,
const char *str);
-int gkr_buffer_get_string (GkrBuffer *buffer,
+int egg_buffer_get_string (EggBuffer *buffer,
size_t offset,
size_t *next_offset,
char **str_ret,
- GkrBufferAllocator allocator);
+ EggBufferAllocator allocator);
-int gkr_buffer_add_stringv (GkrBuffer *buffer,
+int egg_buffer_add_stringv (EggBuffer *buffer,
const char** strv);
-int gkr_buffer_get_stringv (GkrBuffer *buffer,
+int egg_buffer_get_stringv (EggBuffer *buffer,
size_t offset,
size_t *next_offset,
char ***strv_ret,
- GkrBufferAllocator allocator);
+ EggBufferAllocator allocator);
-int gkr_buffer_add_uint64 (GkrBuffer *buffer,
+int egg_buffer_add_uint64 (EggBuffer *buffer,
uint64_t val);
-int gkr_buffer_get_uint64 (GkrBuffer *buffer,
+int egg_buffer_get_uint64 (EggBuffer *buffer,
size_t offset,
size_t *next_offset,
uint64_t *val);
-#define gkr_buffer_length(b) ((b)->len)
+#define egg_buffer_length(b) ((b)->len)
-#define gkr_buffer_has_error(b) ((b)->failures > 0)
+#define egg_buffer_has_error(b) ((b)->failures > 0)
-#endif /* GKR_BUFFER_H */
+#endif /* EGG_BUFFER_H */
Copied: trunk/egg/egg-secure-memory.c (from r1460, /trunk/common/gkr-secure-memory.c)
==============================================================================
--- /trunk/common/gkr-secure-memory.c (original)
+++ trunk/egg/egg-secure-memory.c Sat Jan 17 23:27:10 2009
@@ -1,5 +1,5 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* gkr-secure-memory.h - library for allocating memory that is non-pageable
+/* egg-secure-memory.h - library for allocating memory that is non-pageable
Copyright (C) 2007 Stefan Walter
@@ -29,7 +29,7 @@
#include "config.h"
-#include "gkr-secure-memory.h"
+#include "egg-secure-memory.h"
#include <sys/types.h>
#include <sys/mman.h>
@@ -68,10 +68,10 @@
#endif
#define DO_LOCK() \
- gkr_memory_lock ();
+ egg_memory_lock ();
#define DO_UNLOCK() \
- gkr_memory_unlock ();
+ egg_memory_unlock ();
#define MEM_ALIGN (sizeof(void*) > sizeof(long) ? sizeof(void*) : sizeof(long))
@@ -564,13 +564,13 @@
}
void*
-gkr_secure_alloc (unsigned long sz)
+egg_secure_alloc (unsigned long sz)
{
- return gkr_secure_alloc_full (sz, GKR_SECURE_USE_FALLBACK);
+ return egg_secure_alloc_full (sz, GKR_SECURE_USE_FALLBACK);
}
void*
-gkr_secure_alloc_full (unsigned long sz, int flags)
+egg_secure_alloc_full (unsigned long sz, int flags)
{
MemBlock *bl;
void *p = NULL;
@@ -600,7 +600,7 @@
DO_UNLOCK ();
if (!p && (flags & GKR_SECURE_USE_FALLBACK)) {
- p = gkr_memory_fallback (NULL, sz);
+ p = egg_memory_fallback (NULL, sz);
if (p) /* Our returned memory is always zeroed */
memset (p, 0, sz);
}
@@ -612,13 +612,13 @@
}
void*
-gkr_secure_realloc (void *p, unsigned long sz)
+egg_secure_realloc (void *p, unsigned long sz)
{
- return gkr_secure_realloc_full (p, sz, GKR_SECURE_USE_FALLBACK);
+ return egg_secure_realloc_full (p, sz, GKR_SECURE_USE_FALLBACK);
}
void*
-gkr_secure_realloc_full (void *p, unsigned long sz, int flags)
+egg_secure_realloc_full (void *p, unsigned long sz, int flags)
{
MemBlock *bl = NULL;
unsigned long oldsz = 0;
@@ -632,9 +632,9 @@
}
if (p == NULL)
- return gkr_secure_alloc_full (sz, flags);
+ return egg_secure_alloc_full (sz, flags);
if (!sz) {
- gkr_secure_free_full (p, flags);
+ egg_secure_free_full (p, flags);
return NULL;
}
@@ -664,7 +664,7 @@
* In this case we can't zero the returned memory,
* because we don't know what the block size was.
*/
- return gkr_memory_fallback (p, sz);
+ return egg_memory_fallback (p, sz);
} else {
fprintf (stderr, "memory does not belong to gnome-keyring: 0x%08lx\n", (unsigned long)p);
ASSERT (0 && "memory does does not belong to gnome-keyring");
@@ -673,10 +673,10 @@
}
if (donew) {
- n = gkr_secure_alloc_full (sz, flags);
+ n = egg_secure_alloc_full (sz, flags);
if (n) {
memcpy (n, p, oldsz);
- gkr_secure_free_full (p, flags);
+ egg_secure_free_full (p, flags);
}
}
@@ -687,13 +687,13 @@
}
void
-gkr_secure_free (void *p)
+egg_secure_free (void *p)
{
- gkr_secure_free_full (p, GKR_SECURE_USE_FALLBACK);
+ egg_secure_free_full (p, GKR_SECURE_USE_FALLBACK);
}
void
-gkr_secure_free_full (void *p, int flags)
+egg_secure_free_full (void *p, int flags)
{
MemBlock *bl = NULL;
@@ -714,7 +714,7 @@
if (!bl) {
if ((flags & GKR_SECURE_USE_FALLBACK)) {
- gkr_memory_fallback (p, 0);
+ egg_memory_fallback (p, 0);
} else {
fprintf (stderr, "memory does not belong to gnome-keyring: 0x%08lx\n", (unsigned long)p);
ASSERT (0 && "memory does does not belong to gnome-keyring");
@@ -723,7 +723,7 @@
}
int
-gkr_secure_check (const void *p)
+egg_secure_check (const void *p)
{
MemBlock *bl = NULL;
@@ -741,7 +741,7 @@
}
void
-gkr_secure_dump_blocks (void)
+egg_secure_dump_blocks (void)
{
MemBlock *bl = NULL;
@@ -759,7 +759,7 @@
}
char*
-gkr_secure_strdup (const char *str)
+egg_secure_strdup (const char *str)
{
unsigned long len;
char *res;
@@ -768,13 +768,13 @@
return NULL;
len = strlen (str) + 1;
- res = (char*)gkr_secure_alloc (len);
+ res = (char*)egg_secure_alloc (len);
strcpy (res, str);
return res;
}
void
-gkr_secure_strclear (char *str)
+egg_secure_strclear (char *str)
{
volatile char *vp;
size_t len;
@@ -792,7 +792,7 @@
}
void
-gkr_secure_strfree (char *str)
+egg_secure_strfree (char *str)
{
/*
* If we're using unpageable 'secure' memory, then the free call
@@ -800,6 +800,6 @@
* we may be using normal memory, zero it out here just in case.
*/
- gkr_secure_strclear (str);
- gkr_secure_free_full (str, GKR_SECURE_USE_FALLBACK);
+ egg_secure_strclear (str);
+ egg_secure_free_full (str, GKR_SECURE_USE_FALLBACK);
}
Copied: trunk/egg/egg-secure-memory.h (from r1460, /trunk/common/gkr-secure-memory.h)
==============================================================================
--- /trunk/common/gkr-secure-memory.h (original)
+++ trunk/egg/egg-secure-memory.h Sat Jan 17 23:27:10 2009
@@ -1,5 +1,5 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* gkr-secure-memory.h - library for allocating memory that is non-pageable
+/* egg-secure-memory.h - library for allocating memory that is non-pageable
Copyright (C) 2007 Stefan Walter
@@ -21,8 +21,8 @@
Author: Stef Walter <stef memberwebs com>
*/
-#ifndef GKR_SECURE_MEMORY_H
-#define GKR_SECURE_MEMORY_H
+#ifndef EGG_SECURE_MEMORY_H
+#define EGG_SECURE_MEMORY_H
/* -------------------------------------------------------------------
* Low Level Secure Memory
@@ -38,9 +38,9 @@
* secure memory between threads:
*/
-extern void gkr_memory_lock (void);
+extern void egg_memory_lock (void);
-extern void gkr_memory_unlock (void);
+extern void egg_memory_unlock (void);
/*
* Allocation Fallbacks
@@ -51,7 +51,7 @@
*
* Same call semantics as realloc with regard to NULL and zeros
*/
-extern void* gkr_memory_fallback (void *p, unsigned long sz);
+extern void* egg_memory_fallback (void *p, unsigned long sz);
/*
@@ -62,26 +62,26 @@
#define GKR_SECURE_USE_FALLBACK 0x0001
-void* gkr_secure_alloc (unsigned long sz);
+void* egg_secure_alloc (unsigned long sz);
-void* gkr_secure_alloc_full (unsigned long, int flags);
+void* egg_secure_alloc_full (unsigned long, int flags);
-void* gkr_secure_realloc (void *p, unsigned long sz);
+void* egg_secure_realloc (void *p, unsigned long sz);
-void* gkr_secure_realloc_full (void *p, unsigned long sz, int fallback);
+void* egg_secure_realloc_full (void *p, unsigned long sz, int fallback);
-void gkr_secure_free (void* p);
+void egg_secure_free (void* p);
-void gkr_secure_free_full (void* p, int fallback);
+void egg_secure_free_full (void* p, int fallback);
-int gkr_secure_check (const void* p);
+int egg_secure_check (const void* p);
-void gkr_secure_dump_blocks (void);
+void egg_secure_dump_blocks (void);
-char* gkr_secure_strdup (const char *str);
+char* egg_secure_strdup (const char *str);
-void gkr_secure_strclear (char *str);
+void egg_secure_strclear (char *str);
-void gkr_secure_strfree (char *str);
+void egg_secure_strfree (char *str);
-#endif /* GKR_SECURE_MEMORY_H */
+#endif /* EGG_SECURE_MEMORY_H */
Copied: trunk/egg/egg-unix-credentials.c (from r1460, /trunk/common/gkr-unix-credentials.c)
==============================================================================
--- /trunk/common/gkr-unix-credentials.c (original)
+++ trunk/egg/egg-unix-credentials.c Sat Jan 17 23:27:10 2009
@@ -1,5 +1,5 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* gkr-unix-credentials.c - write and read unix credentials on socket
+/* egg-unix-credentials.c - write and read unix credentials on socket
Copyright (C) 2003 Red Hat, Inc
@@ -23,7 +23,7 @@
#include "config.h"
-#include "gkr-unix-credentials.h"
+#include "egg-unix-credentials.h"
#include <sys/types.h>
#include <sys/socket.h>
@@ -38,7 +38,7 @@
#endif
int
-gkr_unix_credentials_read (int sock, pid_t *pid, uid_t *uid)
+egg_unix_credentials_read (int sock, pid_t *pid, uid_t *uid)
{
struct msghdr msg;
struct iovec iov;
@@ -163,7 +163,7 @@
}
int
-gkr_unix_credentials_write (int socket)
+egg_unix_credentials_write (int socket)
{
char buf;
int bytes_written;
Copied: trunk/egg/egg-unix-credentials.h (from r1460, /trunk/common/gkr-unix-credentials.h)
==============================================================================
--- /trunk/common/gkr-unix-credentials.h (original)
+++ trunk/egg/egg-unix-credentials.h Sat Jan 17 23:27:10 2009
@@ -1,5 +1,5 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* gkr-unix-credentials.h - write and read unix credentials on socket
+/* egg-unix-credentials.h - write and read unix credentials on socket
Copyright (C) 2008 Stefan Walter
@@ -20,13 +20,13 @@
Author: Stef Walter <stef memberwebs com>
*/
-#ifndef GKRUNIXCREDENTIALS_H_
-#define GKRUNIXCREDENTIALS_H_
+#ifndef EGGUNIXCREDENTIALS_H_
+#define EGGUNIXCREDENTIALS_H_
#include <unistd.h>
-int gkr_unix_credentials_read (int sock, pid_t *pid, uid_t *uid);
+int egg_unix_credentials_read (int sock, pid_t *pid, uid_t *uid);
-int gkr_unix_credentials_write (int sock);
+int egg_unix_credentials_write (int sock);
-#endif /*GKRUNIXCREDENTIALS_H_*/
+#endif /*EGGUNIXCREDENTIALS_H_*/
Added: trunk/egg/pk.asn
==============================================================================
--- (empty file)
+++ trunk/egg/pk.asn Sat Jan 17 23:27:10 2009
@@ -0,0 +1,103 @@
+PK { }
+
+DEFINITIONS EXPLICIT TAGS ::=
+
+BEGIN
+
+-- This file contains parts of PKCS-1 structures and some stuff
+-- required for DSA keys.
+
+RSAPublicKey ::= SEQUENCE {
+ modulus INTEGER, -- n
+ publicExponent INTEGER -- e
+}
+
+--
+-- Representation of RSA private key with information for the
+-- CRT algorithm.
+--
+RSAPrivateKey ::= SEQUENCE {
+ version Version,
+ modulus INTEGER, -- (Usually large) n
+ publicExponent INTEGER, -- (Usually small) e
+ privateExponent INTEGER, -- (Usually large) d
+ prime1 INTEGER, -- (Usually large) p
+ prime2 INTEGER, -- (Usually large) q
+ exponent1 INTEGER, -- (Usually large) d mod (p-1)
+ exponent2 INTEGER, -- (Usually large) d mod (q-1)
+ coefficient INTEGER, -- (Usually large) (inverse of q) mod p
+ otherPrimeInfos OtherPrimeInfos OPTIONAL
+}
+
+Version ::= INTEGER { two-prime(0), multi(1) }
+-- version must be multi if otherPrimeInfos present --
+
+OtherPrimeInfos ::= SEQUENCE SIZE(1..MAX) OF OtherPrimeInfo
+
+OtherPrimeInfo ::= SEQUENCE {
+ prime INTEGER, -- ri
+ exponent INTEGER, -- di
+ coefficient INTEGER -- ti
+}
+
+-- for signature calculation
+-- added by nmav
+
+AlgorithmIdentifier ::= SEQUENCE {
+ algorithm OBJECT IDENTIFIER,
+ parameters ANY DEFINED BY algorithm OPTIONAL
+}
+ -- contains a value of the type
+ -- registered for use with the
+ -- algorithm object identifier value
+
+DigestInfo ::= SEQUENCE {
+ digestAlgorithm DigestAlgorithmIdentifier,
+ digest Digest
+}
+
+DigestAlgorithmIdentifier ::= AlgorithmIdentifier
+
+Digest ::= OCTET STRING
+
+DSAPublicPart ::= INTEGER
+
+DSAPublicKey ::= SEQUENCE {
+ version INTEGER, -- should be zero
+ p INTEGER,
+ q INTEGER,
+ g INTEGER,
+ Y INTEGER -- public
+}
+
+DSAParameters ::= SEQUENCE {
+ p INTEGER,
+ q INTEGER,
+ g INTEGER
+}
+
+DSASignatureValue ::= SEQUENCE {
+ r INTEGER,
+ s INTEGER
+}
+
+DSAPrivatePart ::= INTEGER
+
+DSAPrivateKey ::= SEQUENCE {
+ version INTEGER, -- should be zero
+ p INTEGER,
+ q INTEGER,
+ g INTEGER,
+ Y INTEGER, -- public
+ priv INTEGER
+}
+
+-- from PKCS#3
+DHParameter ::= SEQUENCE {
+ prime INTEGER, -- p
+ base INTEGER, -- g
+ privateValueLength INTEGER OPTIONAL
+}
+
+
+END
Added: trunk/egg/pkix.asn
==============================================================================
--- (empty file)
+++ trunk/egg/pkix.asn Sat Jan 17 23:27:10 2009
@@ -0,0 +1,1230 @@
+
+PKIX1 { }
+
+DEFINITIONS IMPLICIT TAGS ::=
+
+BEGIN
+
+-- This contains both PKIX1Implicit88 and RFC2630 ASN.1 modules.
+
+-- ISO arc for standard certificate and CRL extensions
+
+id-ce OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 29}
+
+
+-- authority key identifier OID and syntax
+
+id-ce-authorityKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 35 }
+
+AuthorityKeyIdentifier ::= SEQUENCE {
+ keyIdentifier [0] KeyIdentifier OPTIONAL,
+ authorityCertIssuer [1] GeneralNames OPTIONAL,
+ authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL }
+ -- authorityCertIssuer and authorityCertSerialNumber shall both
+ -- be present or both be absgent
+
+KeyIdentifier ::= OCTET STRING
+
+-- subject key identifier OID and syntax
+
+id-ce-subjectKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 14 }
+
+SubjectKeyIdentifier ::= KeyIdentifier
+
+-- key usage extension OID and syntax
+
+id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 }
+
+KeyUsage ::= BIT STRING {
+ digitalSignature (0),
+ nonRepudiation (1),
+ keyEncipherment (2),
+ dataEncipherment (3),
+ keyAgreement (4),
+ keyCertSign (5),
+ cRLSign (6),
+ encipherOnly (7),
+ decipherOnly (8) }
+
+-- private key usage period extension OID and syntax
+
+id-ce-privateKeyUsagePeriod OBJECT IDENTIFIER ::= { id-ce 16 }
+
+PrivateKeyUsagePeriod ::= SEQUENCE {
+ notBefore [0] GeneralizedTime OPTIONAL,
+ notAfter [1] GeneralizedTime OPTIONAL }
+ -- either notBefore or notAfter shall be present
+
+-- certificate policies extension OID and syntax
+
+id-ce-certificatePolicies OBJECT IDENTIFIER ::= { id-ce 32 }
+
+CertificatePolicies ::= SEQUENCE SIZE (1..MAX) OF PolicyInformation
+
+PolicyInformation ::= SEQUENCE {
+ policyIdentifier CertPolicyId,
+ policyQualifiers SEQUENCE SIZE (1..MAX) OF
+ PolicyQualifierInfo OPTIONAL }
+
+CertPolicyId ::= OBJECT IDENTIFIER
+
+PolicyQualifierInfo ::= SEQUENCE {
+ policyQualifierId PolicyQualifierId,
+ qualifier ANY DEFINED BY policyQualifierId }
+
+-- Implementations that recognize additional policy qualifiers shall
+-- augment the following definition for PolicyQualifierId
+
+PolicyQualifierId ::=
+ OBJECT IDENTIFIER -- ( id-qt-cps | id-qt-unotice )
+
+-- CPS pointer qualifier
+
+CPSuri ::= IA5String
+
+-- user notice qualifier
+
+UserNotice ::= SEQUENCE {
+ noticeRef NoticeReference OPTIONAL,
+ explicitText DisplayText OPTIONAL}
+
+NoticeReference ::= SEQUENCE {
+ organization DisplayText,
+ noticeNumbers SEQUENCE OF INTEGER }
+
+DisplayText ::= CHOICE {
+ visibleString VisibleString (SIZE (1..200)),
+ bmpString BMPString (SIZE (1..200)),
+ utf8String UTF8String (SIZE (1..200)) }
+
+-- policy mapping extension OID and syntax
+
+id-ce-policyMappings OBJECT IDENTIFIER ::= { id-ce 33 }
+
+PolicyMappings ::= SEQUENCE SIZE (1..MAX) OF SEQUENCE {
+ issuerDomainPolicy CertPolicyId,
+ subjectDomainPolicy CertPolicyId }
+
+-- subject alternative name extension OID and syntax
+
+-- Directory string type --
+
+DirectoryString ::= CHOICE {
+ teletexString TeletexString (SIZE (1..MAX)),
+ printableString PrintableString (SIZE (1..MAX)),
+ universalString UniversalString (SIZE (1..MAX)),
+ utf8String UTF8String (SIZE (1..MAX)),
+ bmpString BMPString (SIZE(1..MAX)),
+ -- IA5String is added here to handle old UID encoded as ia5String --
+ -- See tests/userid/ for more information. It shouldn't be here, --
+ -- so if it causes problems, considering dropping it. --
+ ia5String IA5String (SIZE(1..MAX)) }
+
+id-ce-subjectAltName OBJECT IDENTIFIER ::= { id-ce 17 }
+
+SubjectAltName ::= GeneralNames
+
+GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
+
+GeneralName ::= CHOICE {
+ otherName [0] AnotherName,
+ rfc822Name [1] IA5String,
+ dNSName [2] IA5String,
+ x400Address [3] ORAddress,
+-- Changed to work with the libtasn1 parser.
+ directoryName [4] EXPLICIT RDNSequence, --Name,
+ ediPartyName [5] EDIPartyName,
+ uniformResourceIdentifier [6] IA5String,
+ iPAddress [7] OCTET STRING,
+ registeredID [8] OBJECT IDENTIFIER }
+
+-- AnotherName replaces OTHER-NAME ::= TYPE-IDENTIFIER, as
+-- TYPE-IDENTIFIER is not supported in the '88 ASN.1 syntax
+
+AnotherName ::= SEQUENCE {
+ type-id OBJECT IDENTIFIER,
+ value [0] EXPLICIT ANY DEFINED BY type-id }
+
+EDIPartyName ::= SEQUENCE {
+ nameAssigner [0] DirectoryString OPTIONAL,
+ partyName [1] DirectoryString }
+
+-- issuer alternative name extension OID and syntax
+
+id-ce-issuerAltName OBJECT IDENTIFIER ::= { id-ce 18 }
+
+IssuerAltName ::= GeneralNames
+
+id-ce-subjectDirectoryAttributes OBJECT IDENTIFIER ::= { id-ce 9 }
+
+SubjectDirectoryAttributes ::= SEQUENCE SIZE (1..MAX) OF Attribute
+
+-- basic constraints extension OID and syntax
+
+id-ce-basicConstraints OBJECT IDENTIFIER ::= { id-ce 19 }
+
+BasicConstraints ::= SEQUENCE {
+ cA BOOLEAN DEFAULT FALSE,
+ pathLenConstraint INTEGER (0..MAX) OPTIONAL }
+
+-- name constraints extension OID and syntax
+
+id-ce-nameConstraints OBJECT IDENTIFIER ::= { id-ce 30 }
+
+NameConstraints ::= SEQUENCE {
+ permittedSubtrees [0] GeneralSubtrees OPTIONAL,
+ excludedSubtrees [1] GeneralSubtrees OPTIONAL }
+
+GeneralSubtrees ::= SEQUENCE SIZE (1..MAX) OF GeneralSubtree
+
+GeneralSubtree ::= SEQUENCE {
+ base GeneralName,
+ minimum [0] BaseDistance DEFAULT 0,
+ maximum [1] BaseDistance OPTIONAL }
+
+BaseDistance ::= INTEGER (0..MAX)
+
+-- policy constraints extension OID and syntax
+
+id-ce-policyConstraints OBJECT IDENTIFIER ::= { id-ce 36 }
+
+PolicyConstraints ::= SEQUENCE {
+ requireExplicitPolicy [0] SkipCerts OPTIONAL,
+ inhibitPolicyMapping [1] SkipCerts OPTIONAL }
+
+SkipCerts ::= INTEGER (0..MAX)
+
+-- CRL distribution points extension OID and syntax
+
+id-ce-cRLDistributionPoints OBJECT IDENTIFIER ::= {id-ce 31}
+
+CRLDistributionPoints ::= SEQUENCE SIZE (1..MAX) OF DistributionPoint
+
+DistributionPoint ::= SEQUENCE {
+ distributionPoint [0] EXPLICIT DistributionPointName OPTIONAL,
+ reasons [1] ReasonFlags OPTIONAL,
+ cRLIssuer [2] GeneralNames OPTIONAL
+}
+
+DistributionPointName ::= CHOICE {
+ fullName [0] GeneralNames,
+ nameRelativeToCRLIssuer [1] RelativeDistinguishedName
+}
+
+ReasonFlags ::= BIT STRING {
+ unused (0),
+ keyCompromise (1),
+ cACompromise (2),
+ affiliationChanged (3),
+ superseded (4),
+ cessationOfOperation (5),
+ certificateHold (6),
+ privilegeWithdrawn (7),
+ aACompromise (8) }
+
+-- extended key usage extension OID and syntax
+
+id-ce-extKeyUsage OBJECT IDENTIFIER ::= {id-ce 37}
+
+ExtKeyUsageSyntax ::= SEQUENCE SIZE (1..MAX) OF KeyPurposeId
+
+KeyPurposeId ::= OBJECT IDENTIFIER
+
+-- extended key purpose OIDs
+id-kp-serverAuth OBJECT IDENTIFIER ::= { id-kp 1 }
+id-kp-clientAuth OBJECT IDENTIFIER ::= { id-kp 2 }
+id-kp-codeSigning OBJECT IDENTIFIER ::= { id-kp 3 }
+id-kp-emailProtection OBJECT IDENTIFIER ::= { id-kp 4 }
+id-kp-ipsecEndSystem OBJECT IDENTIFIER ::= { id-kp 5 }
+id-kp-ipsecTunnel OBJECT IDENTIFIER ::= { id-kp 6 }
+id-kp-ipsecUser OBJECT IDENTIFIER ::= { id-kp 7 }
+id-kp-timeStamping OBJECT IDENTIFIER ::= { id-kp 8 }
+
+-- authority info access
+
+id-pe-authorityInfoAccess OBJECT IDENTIFIER ::= { id-pe 1 }
+
+AuthorityInfoAccessSyntax ::=
+ SEQUENCE SIZE (1..MAX) OF AccessDescription
+
+AccessDescription ::= SEQUENCE {
+ accessMethod OBJECT IDENTIFIER,
+ accessLocation GeneralName }
+
+-- CRL number extension OID and syntax
+
+id-ce-cRLNumber OBJECT IDENTIFIER ::= { id-ce 20 }
+
+CRLNumber ::= INTEGER (0..MAX)
+
+-- issuing distribution point extension OID and syntax
+
+id-ce-issuingDistributionPoint OBJECT IDENTIFIER ::= { id-ce 28 }
+
+IssuingDistributionPoint ::= SEQUENCE {
+ distributionPoint [0] DistributionPointName OPTIONAL,
+ onlyContainsUserCerts [1] BOOLEAN DEFAULT FALSE,
+ onlyContainsCACerts [2] BOOLEAN DEFAULT FALSE,
+ onlySomeReasons [3] ReasonFlags OPTIONAL,
+ indirectCRL [4] BOOLEAN DEFAULT FALSE }
+
+
+id-ce-deltaCRLIndicator OBJECT IDENTIFIER ::= { id-ce 27 }
+
+-- deltaCRLIndicator ::= BaseCRLNumber
+
+BaseCRLNumber ::= CRLNumber
+
+-- CRL reasons extension OID and syntax
+
+id-ce-cRLReasons OBJECT IDENTIFIER ::= { id-ce 21 }
+
+CRLReason ::= ENUMERATED {
+ unspecified (0),
+ keyCompromise (1),
+ cACompromise (2),
+ affiliationChanged (3),
+ superseded (4),
+ cessationOfOperation (5),
+ certificateHold (6),
+ removeFromCRL (8) }
+
+-- certificate issuer CRL entry extension OID and syntax
+
+id-ce-certificateIssuer OBJECT IDENTIFIER ::= { id-ce 29 }
+
+CertificateIssuer ::= GeneralNames
+
+-- hold instruction extension OID and syntax
+
+id-ce-holdInstructionCode OBJECT IDENTIFIER ::= { id-ce 23 }
+
+HoldInstructionCode ::= OBJECT IDENTIFIER
+
+-- ANSI x9 holdinstructions
+
+-- ANSI x9 arc holdinstruction arc
+holdInstruction OBJECT IDENTIFIER ::=
+ {joint-iso-itu-t(2) member-body(2) us(840) x9cm(10040) 2}
+
+-- ANSI X9 holdinstructions referenced by this standard
+id-holdinstruction-none OBJECT IDENTIFIER ::=
+ {holdInstruction 1} -- deprecated
+id-holdinstruction-callissuer OBJECT IDENTIFIER ::=
+ {holdInstruction 2}
+id-holdinstruction-reject OBJECT IDENTIFIER ::=
+ {holdInstruction 3}
+
+-- invalidity date CRL entry extension OID and syntax
+
+id-ce-invalidityDate OBJECT IDENTIFIER ::= { id-ce 24 }
+
+InvalidityDate ::= GeneralizedTime
+
+
+-- --------------------------------------
+-- EXPLICIT
+-- --------------------------------------
+
+-- UNIVERSAL Types defined in '93 and '98 ASN.1
+-- but required by this specification
+
+VisibleString ::= [UNIVERSAL 26] IMPLICIT OCTET STRING
+
+NumericString ::= [UNIVERSAL 18] IMPLICIT OCTET STRING
+
+IA5String ::= [UNIVERSAL 22] IMPLICIT OCTET STRING
+
+TeletexString ::= [UNIVERSAL 20] IMPLICIT OCTET STRING
+
+PrintableString ::= [UNIVERSAL 19] IMPLICIT OCTET STRING
+
+UniversalString ::= [UNIVERSAL 28] IMPLICIT OCTET STRING
+ -- UniversalString is defined in ASN.1:1993
+
+BMPString ::= [UNIVERSAL 30] IMPLICIT OCTET STRING
+ -- BMPString is the subtype of UniversalString and models
+ -- the Basic Multilingual Plane of ISO/IEC/ITU 10646-1
+
+UTF8String ::= [UNIVERSAL 12] IMPLICIT OCTET STRING
+ -- The content of this type conforms to RFC 2279.
+
+
+-- PKIX specific OIDs
+
+id-pkix OBJECT IDENTIFIER ::=
+ { iso(1) identified-organization(3) dod(6) internet(1)
+ security(5) mechanisms(5) pkix(7) }
+
+-- PKIX arcs
+
+id-pe OBJECT IDENTIFIER ::= { id-pkix 1 }
+ -- arc for private certificate extensions
+id-qt OBJECT IDENTIFIER ::= { id-pkix 2 }
+ -- arc for policy qualifier types
+id-kp OBJECT IDENTIFIER ::= { id-pkix 3 }
+ -- arc for extended key purpose OIDS
+id-ad OBJECT IDENTIFIER ::= { id-pkix 48 }
+ -- arc for access descriptors
+
+-- policyQualifierIds for Internet policy qualifiers
+
+id-qt-cps OBJECT IDENTIFIER ::= { id-qt 1 }
+ -- OID for CPS qualifier
+id-qt-unotice OBJECT IDENTIFIER ::= { id-qt 2 }
+ -- OID for user notice qualifier
+
+-- access descriptor definitions
+
+id-ad-ocsp OBJECT IDENTIFIER ::= { id-ad 1 }
+id-ad-caIssuers OBJECT IDENTIFIER ::= { id-ad 2 }
+
+-- attribute data types --
+
+Attribute ::= SEQUENCE {
+ type AttributeType,
+ values SET OF AttributeValue
+ -- at least one value is required --
+}
+
+AttributeType ::= OBJECT IDENTIFIER
+
+AttributeValue ::= ANY DEFINED BY type
+
+AttributeTypeAndValue ::= SEQUENCE {
+ type AttributeType,
+ value AttributeValue }
+
+-- suggested naming attributes: Definition of the following
+-- information object set may be augmented to meet local
+-- requirements. Note that deleting members of the set may
+-- prevent interoperability with conforming implementations.
+-- presented in pairs: the AttributeType followed by the
+-- type definition for the corresponding AttributeValue
+
+-- Arc for standard naming attributes
+id-at OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 4}
+
+-- Attributes of type NameDirectoryString
+id-at-initials AttributeType ::= { id-at 43 }
+X520initials ::= DirectoryString
+
+id-at-generationQualifier AttributeType ::= { id-at 44 }
+X520generationQualifier ::= DirectoryString
+
+id-at-surname AttributeType ::= { id-at 4 }
+X520surName ::= DirectoryString
+
+id-at-givenName AttributeType ::= { id-at 42 }
+X520givenName ::= DirectoryString
+
+id-at-name AttributeType ::= { id-at 41 }
+X520name ::= DirectoryString
+
+id-at-commonName AttributeType ::= {id-at 3}
+X520CommonName ::= DirectoryString
+
+id-at-localityName AttributeType ::= {id-at 7}
+X520LocalityName ::= DirectoryString
+
+id-at-stateOrProvinceName AttributeType ::= {id-at 8}
+X520StateOrProvinceName ::= DirectoryString
+
+id-at-organizationName AttributeType ::= {id-at 10}
+X520OrganizationName ::= DirectoryString
+
+id-at-organizationalUnitName AttributeType ::= {id-at 11}
+X520OrganizationalUnitName ::= DirectoryString
+
+id-at-title AttributeType ::= {id-at 12}
+X520Title ::= DirectoryString
+
+id-at-description AttributeType ::= {id-at 13}
+X520Description ::= DirectoryString
+
+id-at-dnQualifier AttributeType ::= {id-at 46}
+X520dnQualifier ::= PrintableString
+
+id-at-countryName AttributeType ::= {id-at 6}
+X520countryName ::= PrintableString (SIZE (2)) -- IS 3166 codes
+
+id-at-serialNumber AttributeType ::= {id-at 5}
+X520serialNumber ::= PrintableString
+
+id-at-telephoneNumber AttributeType ::= {id-at 20}
+X520telephoneNumber ::= PrintableString
+
+id-at-facsimileTelephoneNumber AttributeType ::= {id-at 23}
+X520facsimileTelephoneNumber ::= PrintableString
+
+id-at-pseudonym AttributeType ::= {id-at 65}
+X520pseudonym ::= DirectoryString
+
+id-at-name AttributeType ::= {id-at 41}
+X520name ::= DirectoryString
+
+id-at-streetAddress AttributeType ::= {id-at 9}
+X520streetAddress ::= DirectoryString
+
+id-at-postalAddress AttributeType ::= {id-at 16}
+X520postalAddress ::= PostalAddress
+
+PostalAddress ::= SEQUENCE OF DirectoryString
+
+
+ -- Legacy attributes
+
+pkcs OBJECT IDENTIFIER ::=
+ { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) }
+
+pkcs-9 OBJECT IDENTIFIER ::=
+ { pkcs 9 }
+
+
+emailAddress AttributeType ::= { pkcs-9 1 }
+
+Pkcs9email ::= IA5String (SIZE (1..ub-emailaddress-length))
+
+-- naming data types --
+
+Name ::= CHOICE { -- only one possibility for now --
+ rdnSequence RDNSequence }
+
+RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
+
+DistinguishedName ::= RDNSequence
+
+RelativeDistinguishedName ::=
+ SET SIZE (1 .. MAX) OF AttributeTypeAndValue
+
+
+
+-- --------------------------------------------------------
+-- certificate and CRL specific structures begin here
+-- --------------------------------------------------------
+
+Certificate ::= SEQUENCE {
+ tbsCertificate TBSCertificate,
+ signatureAlgorithm AlgorithmIdentifier,
+ signature BIT STRING }
+
+TBSCertificate ::= SEQUENCE {
+ version [0] EXPLICIT Version DEFAULT v1,
+ serialNumber CertificateSerialNumber,
+ signature AlgorithmIdentifier,
+ issuer Name,
+ validity Validity,
+ subject Name,
+ subjectPublicKeyInfo SubjectPublicKeyInfo,
+ issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL,
+ -- If present, version shall be v2 or v3
+ subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL,
+ -- If present, version shall be v2 or v3
+ extensions [3] EXPLICIT Extensions OPTIONAL
+ -- If present, version shall be v3 --
+}
+
+Version ::= INTEGER { v1(0), v2(1), v3(2) }
+
+CertificateSerialNumber ::= INTEGER
+
+Validity ::= SEQUENCE {
+ notBefore Time,
+ notAfter Time }
+
+Time ::= CHOICE {
+ utcTime UTCTime,
+ generalTime GeneralizedTime }
+
+UniqueIdentifier ::= BIT STRING
+
+SubjectPublicKeyInfo ::= SEQUENCE {
+ algorithm AlgorithmIdentifier,
+ subjectPublicKey BIT STRING }
+
+Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
+
+Extension ::= SEQUENCE {
+ extnID OBJECT IDENTIFIER,
+ critical BOOLEAN DEFAULT FALSE,
+ extnValue OCTET STRING }
+
+
+-- ------------------------------------------
+-- CRL structures
+-- ------------------------------------------
+
+CertificateList ::= SEQUENCE {
+ tbsCertList TBSCertList,
+ signatureAlgorithm AlgorithmIdentifier,
+ signature BIT STRING }
+
+TBSCertList ::= SEQUENCE {
+ version Version OPTIONAL,
+ -- if present, shall be v2
+ signature AlgorithmIdentifier,
+ issuer Name,
+ thisUpdate Time,
+ nextUpdate Time OPTIONAL,
+ revokedCertificates SEQUENCE OF SEQUENCE {
+ userCertificate CertificateSerialNumber,
+ revocationDate Time,
+ crlEntryExtensions Extensions OPTIONAL
+ -- if present, shall be v2
+ } OPTIONAL,
+ crlExtensions [0] EXPLICIT Extensions OPTIONAL
+ -- if present, shall be v2 --
+}
+
+-- Version, Time, CertificateSerialNumber, and Extensions were
+-- defined earlier for use in the certificate structure
+
+AlgorithmIdentifier ::= SEQUENCE {
+ algorithm OBJECT IDENTIFIER,
+ parameters ANY DEFINED BY algorithm OPTIONAL }
+ -- contains a value of the type
+ -- registered for use with the
+ -- algorithm object identifier value
+
+-- Algorithm OIDs and parameter structures
+
+pkcs-1 OBJECT IDENTIFIER ::= {
+ pkcs 1 }
+
+rsaEncryption OBJECT IDENTIFIER ::= { pkcs-1 1 }
+
+md2WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 2 }
+
+md5WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 4 }
+
+sha1WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 5 }
+
+id-dsa-with-sha1 OBJECT IDENTIFIER ::= {
+ iso(1) member-body(2) us(840) x9-57 (10040) x9algorithm(4) 3 }
+
+Dss-Sig-Value ::= SEQUENCE {
+ r INTEGER,
+ s INTEGER
+}
+
+dhpublicnumber OBJECT IDENTIFIER ::= {
+ iso(1) member-body(2) us(840) ansi-x942(10046) number-type(2) 1 }
+
+DomainParameters ::= SEQUENCE {
+ p INTEGER, -- odd prime, p=jq +1
+ g INTEGER, -- generator, g
+ q INTEGER, -- factor of p-1
+ j INTEGER OPTIONAL, -- subgroup factor, j>= 2
+ validationParms ValidationParms OPTIONAL }
+
+ValidationParms ::= SEQUENCE {
+ seed BIT STRING,
+ pgenCounter INTEGER }
+
+id-dsa OBJECT IDENTIFIER ::= {
+ iso(1) member-body(2) us(840) x9-57(10040) x9algorithm(4) 1 }
+
+Dss-Parms ::= SEQUENCE {
+ p INTEGER,
+ q INTEGER,
+ g INTEGER }
+
+-- x400 address syntax starts here
+-- OR Names
+
+ORAddress ::= SEQUENCE {
+ built-in-standard-attributes BuiltInStandardAttributes,
+ built-in-domain-defined-attributes
+ BuiltInDomainDefinedAttributes OPTIONAL,
+ -- see also teletex-domain-defined-attributes
+ extension-attributes ExtensionAttributes OPTIONAL }
+-- The OR-address is semantically absent from the OR-name if the
+-- built-in-standard-attribute sequence is empty and the
+-- built-in-domain-defined-attributes and extension-attributes are
+-- both omitted.
+
+-- Built-in Standard Attributes
+
+BuiltInStandardAttributes ::= SEQUENCE {
+ country-name CountryName OPTIONAL,
+ administration-domain-name AdministrationDomainName OPTIONAL,
+ network-address [0] EXPLICIT NetworkAddress OPTIONAL,
+ -- see also extended-network-address
+ terminal-identifier [1] EXPLICIT TerminalIdentifier OPTIONAL,
+ private-domain-name [2] EXPLICIT PrivateDomainName OPTIONAL,
+ organization-name [3] EXPLICIT OrganizationName OPTIONAL,
+ -- see also teletex-organization-name
+ numeric-user-identifier [4] EXPLICIT NumericUserIdentifier OPTIONAL,
+ personal-name [5] EXPLICIT PersonalName OPTIONAL,
+ -- see also teletex-personal-name
+ organizational-unit-names [6] EXPLICIT OrganizationalUnitNames OPTIONAL
+ -- see also teletex-organizational-unit-names --
+}
+
+CountryName ::= [APPLICATION 1] CHOICE {
+ x121-dcc-code NumericString
+ (SIZE (ub-country-name-numeric-length)),
+ iso-3166-alpha2-code PrintableString
+ (SIZE (ub-country-name-alpha-length)) }
+
+AdministrationDomainName ::= [APPLICATION 2] EXPLICIT CHOICE {
+ numeric NumericString (SIZE (0..ub-domain-name-length)),
+ printable PrintableString (SIZE (0..ub-domain-name-length)) }
+
+NetworkAddress ::= X121Address -- see also extended-network-address
+
+X121Address ::= NumericString (SIZE (1..ub-x121-address-length))
+
+TerminalIdentifier ::= PrintableString (SIZE (1..ub-terminal-id-length))
+
+PrivateDomainName ::= CHOICE {
+ numeric NumericString (SIZE (1..ub-domain-name-length)),
+ printable PrintableString (SIZE (1..ub-domain-name-length)) }
+
+OrganizationName ::= PrintableString
+ (SIZE (1..ub-organization-name-length))
+-- see also teletex-organization-name
+
+NumericUserIdentifier ::= NumericString
+ (SIZE (1..ub-numeric-user-id-length))
+
+PersonalName ::= SET {
+ surname [0] PrintableString (SIZE (1..ub-surname-length)),
+ given-name [1] PrintableString
+ (SIZE (1..ub-given-name-length)) OPTIONAL,
+ initials [2] PrintableString (SIZE (1..ub-initials-length)) OPTIONAL,
+ generation-qualifier [3] PrintableString
+ (SIZE (1..ub-generation-qualifier-length)) OPTIONAL }
+-- see also teletex-personal-name
+
+OrganizationalUnitNames ::= SEQUENCE SIZE (1..ub-organizational-units)
+ OF OrganizationalUnitName
+-- see also teletex-organizational-unit-names
+
+OrganizationalUnitName ::= PrintableString (SIZE
+ (1..ub-organizational-unit-name-length))
+
+-- Built-in Domain-defined Attributes
+
+BuiltInDomainDefinedAttributes ::= SEQUENCE SIZE
+ (1..ub-domain-defined-attributes) OF
+ BuiltInDomainDefinedAttribute
+
+BuiltInDomainDefinedAttribute ::= SEQUENCE {
+ type PrintableString (SIZE
+ (1..ub-domain-defined-attribute-type-length)),
+ value PrintableString (SIZE
+ (1..ub-domain-defined-attribute-value-length))}
+
+-- Extension Attributes
+
+ExtensionAttributes ::= SET SIZE (1..ub-extension-attributes) OF
+ ExtensionAttribute
+
+ExtensionAttribute ::= SEQUENCE {
+ extension-attribute-type [0] EXPLICIT INTEGER (0..ub-extension-attributes),
+ extension-attribute-value [1] EXPLICIT
+ ANY DEFINED BY extension-attribute-type }
+
+-- Extension types and attribute values
+--
+
+common-name INTEGER ::= 1
+
+CommonName ::= PrintableString (SIZE (1..ub-common-name-length))
+
+teletex-common-name INTEGER ::= 2
+
+TeletexCommonName ::= TeletexString (SIZE (1..ub-common-name-length))
+
+teletex-organization-name INTEGER ::= 3
+
+TeletexOrganizationName ::=
+ TeletexString (SIZE (1..ub-organization-name-length))
+
+teletex-personal-name INTEGER ::= 4
+
+TeletexPersonalName ::= SET {
+ surname [0] EXPLICIT TeletexString (SIZE (1..ub-surname-length)),
+ given-name [1] EXPLICIT TeletexString
+ (SIZE (1..ub-given-name-length)) OPTIONAL,
+ initials [2] EXPLICIT TeletexString (SIZE (1..ub-initials-length)) OPTIONAL,
+ generation-qualifier [3] EXPLICIT TeletexString (SIZE
+ (1..ub-generation-qualifier-length)) OPTIONAL }
+
+teletex-organizational-unit-names INTEGER ::= 5
+
+TeletexOrganizationalUnitNames ::= SEQUENCE SIZE
+ (1..ub-organizational-units) OF TeletexOrganizationalUnitName
+
+TeletexOrganizationalUnitName ::= TeletexString
+ (SIZE (1..ub-organizational-unit-name-length))
+
+pds-name INTEGER ::= 7
+
+PDSName ::= PrintableString (SIZE (1..ub-pds-name-length))
+
+physical-delivery-country-name INTEGER ::= 8
+
+PhysicalDeliveryCountryName ::= CHOICE {
+ x121-dcc-code NumericString (SIZE (ub-country-name-numeric-length)),
+ iso-3166-alpha2-code PrintableString
+ (SIZE (ub-country-name-alpha-length)) }
+
+postal-code INTEGER ::= 9
+
+PostalCode ::= CHOICE {
+ numeric-code NumericString (SIZE (1..ub-postal-code-length)),
+ printable-code PrintableString (SIZE (1..ub-postal-code-length)) }
+
+physical-delivery-office-name INTEGER ::= 10
+
+PhysicalDeliveryOfficeName ::= PDSParameter
+
+physical-delivery-office-number INTEGER ::= 11
+
+PhysicalDeliveryOfficeNumber ::= PDSParameter
+
+extension-OR-address-components INTEGER ::= 12
+
+ExtensionORAddressComponents ::= PDSParameter
+
+physical-delivery-personal-name INTEGER ::= 13
+
+PhysicalDeliveryPersonalName ::= PDSParameter
+
+physical-delivery-organization-name INTEGER ::= 14
+
+PhysicalDeliveryOrganizationName ::= PDSParameter
+
+extension-physical-delivery-address-components INTEGER ::= 15
+
+ExtensionPhysicalDeliveryAddressComponents ::= PDSParameter
+
+unformatted-postal-address INTEGER ::= 16
+
+UnformattedPostalAddress ::= SET {
+ printable-address SEQUENCE SIZE (1..ub-pds-physical-address-lines) OF
+ PrintableString (SIZE (1..ub-pds-parameter-length)) OPTIONAL,
+ teletex-string TeletexString
+ (SIZE (1..ub-unformatted-address-length)) OPTIONAL }
+
+street-address INTEGER ::= 17
+
+StreetAddress ::= PDSParameter
+
+post-office-box-address INTEGER ::= 18
+
+PostOfficeBoxAddress ::= PDSParameter
+
+poste-restante-address INTEGER ::= 19
+
+PosteRestanteAddress ::= PDSParameter
+
+unique-postal-name INTEGER ::= 20
+
+UniquePostalName ::= PDSParameter
+
+local-postal-attributes INTEGER ::= 21
+
+LocalPostalAttributes ::= PDSParameter
+
+PDSParameter ::= SET {
+ printable-string PrintableString
+ (SIZE(1..ub-pds-parameter-length)) OPTIONAL,
+ teletex-string TeletexString
+ (SIZE(1..ub-pds-parameter-length)) OPTIONAL }
+
+extended-network-address INTEGER ::= 22
+
+ExtendedNetworkAddress ::= CHOICE {
+ e163-4-address SEQUENCE {
+ number [0] EXPLICIT NumericString (SIZE (1..ub-e163-4-number-length)),
+ sub-address [1] EXPLICIT NumericString
+ (SIZE (1..ub-e163-4-sub-address-length)) OPTIONAL },
+ psap-address [0] EXPLICIT PresentationAddress }
+
+PresentationAddress ::= SEQUENCE {
+ pSelector [0] EXPLICIT OCTET STRING OPTIONAL,
+ sSelector [1] EXPLICIT OCTET STRING OPTIONAL,
+ tSelector [2] EXPLICIT OCTET STRING OPTIONAL,
+ nAddresses [3] EXPLICIT SET SIZE (1..MAX) OF OCTET STRING }
+
+terminal-type INTEGER ::= 23
+
+TerminalType ::= INTEGER {
+ telex (3),
+ teletex (4),
+ g3-facsimile (5),
+ g4-facsimile (6),
+ ia5-terminal (7),
+ videotex (8) } -- (0..ub-integer-options)
+
+-- Extension Domain-defined Attributes
+
+teletex-domain-defined-attributes INTEGER ::= 6
+
+TeletexDomainDefinedAttributes ::= SEQUENCE SIZE
+ (1..ub-domain-defined-attributes) OF TeletexDomainDefinedAttribute
+
+TeletexDomainDefinedAttribute ::= SEQUENCE {
+ type TeletexString
+ (SIZE (1..ub-domain-defined-attribute-type-length)),
+ value TeletexString
+ (SIZE (1..ub-domain-defined-attribute-value-length)) }
+
+-- specifications of Upper Bounds shall be regarded as mandatory
+-- from Annex B of ITU-T X.411 Reference Definition of MTS Parameter
+-- Upper Bounds
+
+-- Upper Bounds
+ub-name INTEGER ::= 32768
+ub-common-name INTEGER ::= 64
+ub-locality-name INTEGER ::= 128
+ub-state-name INTEGER ::= 128
+ub-organization-name INTEGER ::= 64
+ub-organizational-unit-name INTEGER ::= 64
+ub-title INTEGER ::= 64
+ub-match INTEGER ::= 128
+
+ub-emailaddress-length INTEGER ::= 128
+
+ub-common-name-length INTEGER ::= 64
+ub-country-name-alpha-length INTEGER ::= 2
+ub-country-name-numeric-length INTEGER ::= 3
+ub-domain-defined-attributes INTEGER ::= 4
+ub-domain-defined-attribute-type-length INTEGER ::= 8
+ub-domain-defined-attribute-value-length INTEGER ::= 128
+ub-domain-name-length INTEGER ::= 16
+ub-extension-attributes INTEGER ::= 256
+ub-e163-4-number-length INTEGER ::= 15
+ub-e163-4-sub-address-length INTEGER ::= 40
+ub-generation-qualifier-length INTEGER ::= 3
+ub-given-name-length INTEGER ::= 16
+ub-initials-length INTEGER ::= 5
+ub-integer-options INTEGER ::= 256
+ub-numeric-user-id-length INTEGER ::= 32
+ub-organization-name-length INTEGER ::= 64
+ub-organizational-unit-name-length INTEGER ::= 32
+ub-organizational-units INTEGER ::= 4
+ub-pds-name-length INTEGER ::= 16
+ub-pds-parameter-length INTEGER ::= 30
+ub-pds-physical-address-lines INTEGER ::= 6
+ub-postal-code-length INTEGER ::= 16
+ub-surname-length INTEGER ::= 40
+ub-terminal-id-length INTEGER ::= 24
+ub-unformatted-address-length INTEGER ::= 180
+ub-x121-address-length INTEGER ::= 16
+
+-- Note - upper bounds on string types, such as TeletexString, are
+-- measured in characters. Excepting PrintableString or IA5String, a
+-- significantly greater number of octets will be required to hold
+-- such a value. As a minimum, 16 octets, or twice the specified upper
+-- bound, whichever is the larger, should be allowed for TeletexString.
+-- For UTF8String or UniversalString at least four times the upper
+-- bound should be allowed.
+
+
+
+-- END of PKIX1Implicit88
+
+
+-- BEGIN of RFC2630
+
+-- Cryptographic Message Syntax
+
+pkcs-7-ContentInfo ::= SEQUENCE {
+ contentType pkcs-7-ContentType,
+ content [0] EXPLICIT ANY DEFINED BY contentType }
+
+pkcs-7-DigestInfo ::= SEQUENCE {
+ digestAlgorithm pkcs-7-DigestAlgorithmIdentifier,
+ digest pkcs-7-Digest
+}
+
+pkcs-7-Digest ::= OCTET STRING
+
+pkcs-7-ContentType ::= OBJECT IDENTIFIER
+
+pkcs-7-SignedData ::= SEQUENCE {
+ version pkcs-7-CMSVersion,
+ digestAlgorithms pkcs-7-DigestAlgorithmIdentifiers,
+ encapContentInfo pkcs-7-EncapsulatedContentInfo,
+ certificates [0] IMPLICIT pkcs-7-CertificateSet OPTIONAL,
+ crls [1] IMPLICIT pkcs-7-CertificateRevocationLists OPTIONAL,
+ signerInfos pkcs-7-SignerInfos
+}
+
+pkcs-7-CMSVersion ::= INTEGER { v0(0), v1(1), v2(2), v3(3), v4(4) }
+
+pkcs-7-DigestAlgorithmIdentifiers ::= SET OF pkcs-7-DigestAlgorithmIdentifier
+
+pkcs-7-DigestAlgorithmIdentifier ::= AlgorithmIdentifier
+
+pkcs-7-EncapsulatedContentInfo ::= SEQUENCE {
+ eContentType pkcs-7-ContentType,
+ eContent [0] EXPLICIT OCTET STRING OPTIONAL }
+
+-- We don't use CertificateList here since we only want
+-- to read the raw data.
+pkcs-7-CertificateRevocationLists ::= SET OF ANY
+
+pkcs-7-CertificateChoices ::= CHOICE {
+-- Although the paper uses Certificate type, we
+-- don't use it since, we don't need to parse it.
+-- We only need to read and store it.
+ certificate ANY
+}
+
+pkcs-7-CertificateSet ::= SET OF pkcs-7-CertificateChoices
+
+pkcs-7-SignerInfos ::= SET OF ANY -- this is not correct but we don't use it
+ -- anyway
+
+
+-- BEGIN of RFC2986
+
+-- Certificate requests
+pkcs-10-CertificationRequestInfo ::= SEQUENCE {
+ version INTEGER { v1(0) },
+ subject Name,
+ subjectPKInfo SubjectPublicKeyInfo,
+ attributes [0] Attributes
+}
+
+Attributes ::= SET OF Attribute
+
+pkcs-10-CertificationRequest ::= SEQUENCE {
+ certificationRequestInfo pkcs-10-CertificationRequestInfo,
+ signatureAlgorithm AlgorithmIdentifier,
+ signature BIT STRING
+}
+
+-- stuff from PKCS#9
+
+pkcs-9-ub-challengePassword INTEGER ::= 255
+
+pkcs-9-certTypes OBJECT IDENTIFIER ::= {pkcs-9 22}
+pkcs-9-crlTypes OBJECT IDENTIFIER ::= {pkcs-9 23}
+
+pkcs-9-at-challengePassword OBJECT IDENTIFIER ::= {pkcs-9 7}
+
+pkcs-9-challengePassword ::= CHOICE {
+ printableString PrintableString (SIZE (1..pkcs-9-ub-challengePassword)),
+ utf8String UTF8String (SIZE (1..pkcs-9-ub-challengePassword)) }
+
+pkcs-9-at-localKeyId OBJECT IDENTIFIER ::= {pkcs-9 21}
+
+pkcs-9-localKeyId ::= OCTET STRING
+
+pkcs-9-at-friendlyName OBJECT IDENTIFIER ::= {pkcs-9 20}
+
+pkcs-9-friendlyName ::= BMPString (SIZE (1..255))
+
+-- PKCS #8 stuff
+
+-- Private-key information syntax
+
+pkcs-8-PrivateKeyInfo ::= SEQUENCE {
+ version pkcs-8-Version,
+ privateKeyAlgorithm AlgorithmIdentifier,
+ privateKey pkcs-8-PrivateKey,
+ attributes [0] Attributes OPTIONAL }
+
+pkcs-8-Version ::= INTEGER {v1(0)}
+
+pkcs-8-PrivateKey ::= OCTET STRING
+
+pkcs-8-Attributes ::= SET OF Attribute
+
+-- Encrypted private-key information syntax
+
+pkcs-8-EncryptedPrivateKeyInfo ::= SEQUENCE {
+ encryptionAlgorithm AlgorithmIdentifier,
+ encryptedData pkcs-8-EncryptedData
+}
+
+pkcs-8-EncryptedData ::= OCTET STRING
+
+-- PKCS #5 stuff
+
+pkcs-5 OBJECT IDENTIFIER ::=
+ { pkcs 5 }
+
+pkcs-5-encryptionAlgorithm OBJECT IDENTIFIER ::=
+ { iso(1) member-body(2) us(840) rsadsi(113549) 3 }
+
+pkcs-5-des-EDE3-CBC OBJECT IDENTIFIER ::= {pkcs-5-encryptionAlgorithm 7}
+
+pkcs-5-des-EDE3-CBC-params ::= OCTET STRING (SIZE(8))
+
+pkcs-5-des-CBC-params ::= OCTET STRING (SIZE(8))
+
+pkcs-5-rc2-CBC-params ::= SEQUENCE {
+ rc2ParameterVersion INTEGER OPTIONAL,
+ iv OCTET STRING (SIZE(8))
+}
+
+pkcs-5-PBE-params ::= SEQUENCE {
+ salt OCTET STRING (SIZE(8)),
+ iterationCount INTEGER
+}
+
+pkcs-5-id-PBES2 OBJECT IDENTIFIER ::= {pkcs-5 13}
+
+pkcs-5-PBES2-params ::= SEQUENCE {
+ keyDerivationFunc AlgorithmIdentifier,
+ encryptionScheme AlgorithmIdentifier }
+
+-- PBKDF2
+
+pkcs-5-id-PBKDF2 OBJECT IDENTIFIER ::= {pkcs-5 12}
+
+-- pkcs-5-id-hmacWithSHA1 OBJECT IDENTIFIER ::= {iso(1) member-body(2) us(840) rsadsi(113549) 2 7}
+
+-- pkcs-5-algid-hmacWithSHA1 AlgorithmIdentifier ::=
+-- {algorithm pkcs-5-id-hmacWithSHA1, parameters NULL : NULL}
+
+pkcs-5-PBKDF2-params ::= SEQUENCE {
+ salt CHOICE {
+ specified OCTET STRING,
+ otherSource AlgorithmIdentifier
+ },
+ iterationCount INTEGER (1..MAX),
+ keyLength INTEGER (1..MAX) OPTIONAL,
+ prf AlgorithmIdentifier OPTIONAL -- DEFAULT pkcs-5-id-hmacWithSHA1
+}
+
+-- PKCS #12 stuff
+
+pkcs-12 OBJECT IDENTIFIER ::= {pkcs 12}
+
+pkcs-12-PFX ::= SEQUENCE {
+ version INTEGER {v3(3)},
+ authSafe pkcs-7-ContentInfo,
+ macData pkcs-12-MacData OPTIONAL
+}
+
+pkcs-12-PbeParams ::= SEQUENCE {
+ salt OCTET STRING,
+ iterations INTEGER
+}
+
+pkcs-12-MacData ::= SEQUENCE {
+ mac pkcs-7-DigestInfo,
+ macSalt OCTET STRING,
+ iterations INTEGER DEFAULT 1
+-- Note: The default is for historical reasons and its use is
+-- deprecated. A higher value, like 1024 is recommended.
+}
+
+pkcs-12-AuthenticatedSafe ::= SEQUENCE OF pkcs-7-ContentInfo
+ -- Data if unencrypted
+ -- EncryptedData if password-encrypted
+ -- EnvelopedData if public key-encrypted
+
+pkcs-12-SafeContents ::= SEQUENCE OF pkcs-12-SafeBag
+
+pkcs-12-SafeBag ::= SEQUENCE {
+ bagId OBJECT IDENTIFIER,
+ bagValue [0] EXPLICIT ANY DEFINED BY badId,
+ bagAttributes SET OF pkcs-12-PKCS12Attribute OPTIONAL
+}
+
+-- Bag types
+
+
+pkcs-12-bagtypes OBJECT IDENTIFIER ::= {pkcs-12 10 1}
+
+pkcs-12-keyBag OBJECT IDENTIFIER ::= {pkcs-12-bagtypes 1}
+pkcs-12-pkcs8ShroudedKeyBag OBJECT IDENTIFIER ::= {pkcs-12-bagtypes 2}
+pkcs-12-certBag OBJECT IDENTIFIER ::= {pkcs-12-bagtypes 3}
+pkcs-12-crlBag OBJECT IDENTIFIER ::= {pkcs-12-bagtypes 4}
+
+pkcs-12-KeyBag ::= pkcs-8-PrivateKeyInfo
+
+-- Shrouded KeyBag
+
+pkcs-12-PKCS8ShroudedKeyBag ::= pkcs-8-EncryptedPrivateKeyInfo
+
+-- CertBag
+
+pkcs-12-CertBag ::= SEQUENCE {
+ certId OBJECT IDENTIFIER,
+ certValue [0] EXPLICIT ANY DEFINED BY certId
+}
+
+-- x509Certificate BAG-TYPE ::= {OCTET STRING IDENTIFIED BY {pkcs-9-certTypes 1}}
+-- DER-encoded X.509 certificate stored in OCTET STRING
+
+pkcs-12-CRLBag ::= SEQUENCE {
+ crlId OBJECT IDENTIFIER,
+ crlValue [0] EXPLICIT ANY DEFINED BY crlId
+}
+
+-- x509CRL BAG-TYPE ::=
+-- {OCTET STRING IDENTIFIED BY {pkcs-9-crlTypes 1}}
+-- DER-encoded X.509 CRL stored in OCTET STRING
+
+pkcs-12-PKCS12Attribute ::= Attribute
+
+-- PKCS #7 stuff (needed in PKCS 12)
+
+pkcs-7-data OBJECT IDENTIFIER ::= { iso(1) member-body(2)
+ us(840) rsadsi(113549) pkcs(1) pkcs7(7) 1 }
+
+pkcs-7-encryptedData OBJECT IDENTIFIER ::= { iso(1) member-body(2)
+ us(840) rsadsi(113549) pkcs(1) pkcs7(7) 6 }
+
+pkcs-7-Data ::= OCTET STRING
+
+pkcs-7-EncryptedData ::= SEQUENCE {
+ version pkcs-7-CMSVersion,
+ encryptedContentInfo pkcs-7-EncryptedContentInfo,
+ unprotectedAttrs [1] IMPLICIT pkcs-7-UnprotectedAttributes OPTIONAL }
+
+pkcs-7-EncryptedContentInfo ::= SEQUENCE {
+ contentType pkcs-7-ContentType,
+ contentEncryptionAlgorithm pkcs-7-ContentEncryptionAlgorithmIdentifier,
+ encryptedContent [0] IMPLICIT pkcs-7-EncryptedContent OPTIONAL }
+
+pkcs-7-ContentEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
+
+pkcs-7-EncryptedContent ::= OCTET STRING
+
+pkcs-7-UnprotectedAttributes ::= SET SIZE (1..MAX) OF Attribute
+
+-- LDAP stuff
+-- may not be correct
+
+id-at-ldap-DC AttributeType ::= { 0 9 2342 19200300 100 1 25 }
+
+ldap-DC ::= IA5String
+
+id-at-ldap-UID AttributeType ::= { 0 9 2342 19200300 100 1 1 }
+
+ldap-UID ::= DirectoryString
+
+-- rfc3039
+
+id-pda OBJECT IDENTIFIER ::= { id-pkix 9 }
+
+id-pda-dateOfBirth AttributeType ::= { id-pda 1 }
+DateOfBirth ::= GeneralizedTime
+
+id-pda-placeOfBirth AttributeType ::= { id-pda 2 }
+PlaceOfBirth ::= DirectoryString
+
+id-pda-gender AttributeType ::= { id-pda 3 }
+Gender ::= PrintableString (SIZE(1))
+ -- "M", "F", "m" or "f"
+
+id-pda-countryOfCitizenship AttributeType ::= { id-pda 4 }
+CountryOfCitizenship ::= PrintableString (SIZE (2))
+ -- ISO 3166 Country Code
+
+id-pda-countryOfResidence AttributeType ::= { id-pda 5 }
+CountryOfResidence ::= PrintableString (SIZE (2))
+ -- ISO 3166 Country Code
+
+END
Added: trunk/egg/tests/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/egg/tests/Makefile.am Sat Jan 17 23:27:10 2009
@@ -0,0 +1,23 @@
+
+BUILT_SOURCES = \
+ asn1-def-test.h
+
+asn1-def-test.h: test.asn
+ asn1Parser -o asn1-def-test.h $(srcdir)/test.asn
+
+# Test files should be listed in order they need to run
+UNIT_AUTO = \
+ unit-test-asn1.c \
+ unit-test-secmem.c \
+ $(BUILT_SOURCES)
+
+UNIT_PROMPT =
+
+UNIT_LIBS = \
+ $(top_builddir)/egg/libegg.la
+
+EXTRA_DIST = \
+ test.asn \
+ test-data
+
+include $(top_srcdir)/tests/gtest.make
Added: trunk/egg/tests/test.asn
==============================================================================
--- (empty file)
+++ trunk/egg/tests/test.asn Sat Jan 17 23:27:10 2009
@@ -0,0 +1,19 @@
+TEST { }
+
+DEFINITIONS EXPLICIT TAGS ::=
+
+BEGIN
+
+TestIntegers ::= SEQUENCE {
+ uint1 INTEGER,
+ uint2 INTEGER,
+ uint3 INTEGER,
+ mpi INTEGER
+}
+
+TestData ::= SEQUENCE {
+ data OCTET STRING,
+ boolean BOOLEAN DEFAULT FALSE
+}
+
+END
Added: trunk/egg/tests/unit-test-asn1.c
==============================================================================
--- (empty file)
+++ trunk/egg/tests/unit-test-asn1.c Sat Jan 17 23:27:10 2009
@@ -0,0 +1,417 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* unit-test-pkix-parser.c: Test PKIX parser
+
+ Copyright (C) 2007 Stefan Walter
+
+ The Gnome Keyring Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The Gnome Keyring Library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the Gnome Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Stef Walter <stef memberwebs com>
+*/
+
+#include "config.h"
+
+#include "run-auto-test.h"
+
+#include "egg/egg-asn1.h"
+
+#include <glib.h>
+#include <gcrypt.h>
+#include <libtasn1.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#define extern
+#include "asn1-def-test.h"
+#undef extern
+
+static ASN1_TYPE asn1_test = NULL;
+
+static ASN1_TYPE asn1_cert = NULL;
+static guchar *data_cert = NULL;
+static gsize n_data_cert = 0;
+
+DEFINE_SETUP(asn1_tree)
+{
+ ASN1_TYPE pkix;
+
+ int res = asn1_array2tree (test_asn1_tab, &asn1_test, NULL);
+ g_assert (res == ASN1_SUCCESS);
+
+ /* -------- */
+
+ data_cert = test_read_testdata ("test-certificate-1.der", &n_data_cert);
+
+ /* We'll be catching this error later */
+ pkix = egg_asn1_get_pkix_asn1type ();
+ if (!pkix) return;
+
+ res = asn1_create_element (pkix, "PKIX1.Certificate", &asn1_cert);
+ g_assert (res == ASN1_SUCCESS);
+
+ res = asn1_der_decoding (&asn1_cert, data_cert, n_data_cert, NULL);
+ g_assert (res == ASN1_SUCCESS);
+}
+
+DEFINE_TEARDOWN(asn1_tree)
+{
+ asn1_delete_structure (&asn1_test);
+ asn1_delete_structure (&asn1_cert);
+ g_free (data_cert);
+ data_cert = NULL;
+}
+
+DEFINE_TEST(asn1_types)
+{
+ ASN1_TYPE asn;
+
+ asn = egg_asn1_get_pk_asn1type ();
+ g_assert ("pk asn type is null" && asn != NULL);
+
+ asn = egg_asn1_get_pkix_asn1type ();
+ g_assert ("pkix asn type is null" && asn != NULL);
+}
+
+DEFINE_TEST(asn1_integers)
+{
+ ASN1_TYPE asn;
+ guchar *data;
+ gsize n_data;
+ gboolean ret;
+ guint val;
+ int res;
+
+ res = asn1_create_element (asn1_test, "TEST.TestIntegers", &asn);
+ g_assert ("asn test structure is null" && asn != NULL);
+
+ ret = egg_asn1_write_uint (asn, "uint1", 35);
+ g_assert ("couldn't write integer" && ret);
+
+ ret = egg_asn1_write_uint (asn, "uint2", 23456);
+ g_assert ("couldn't write integer" && ret);
+
+ ret = egg_asn1_write_uint (asn, "uint3", 209384022);
+ g_assert ("couldn't write integer" && ret);
+
+ /* Now encode the whole caboodle */
+ data = egg_asn1_encode (asn, "", &n_data, NULL);
+ g_assert ("encoding asn1 didn't work" && data != NULL);
+
+ asn1_delete_structure (&asn);
+
+ /* Now decode it all nicely */
+ res = asn1_create_element (asn1_test, "TEST.TestIntegers", &asn);
+ g_return_if_fail (res == ASN1_SUCCESS);
+
+ res = asn1_der_decoding (&asn, data, n_data, NULL);
+ g_assert ("decoding asn didn't work" && res == ASN1_SUCCESS);
+
+ /* And get out the values */
+ ret = egg_asn1_read_uint (asn, "uint1", &val);
+ g_assert ("couldn't read integer from asn1" && ret);
+ g_assert_cmpuint (val, ==, 35);
+
+ ret = egg_asn1_read_uint (asn, "uint2", &val);
+ g_assert ("couldn't read integer from asn1" && ret);
+ g_assert_cmpuint (val, ==, 23456);
+
+ ret = egg_asn1_read_uint (asn, "uint3", &val);
+ g_assert ("couldn't read integer from asn1" && ret);
+ g_assert_cmpuint (val, ==, 209384022);
+}
+
+DEFINE_TEST(boolean)
+{
+ ASN1_TYPE asn = NULL;
+ gboolean value, ret;
+ int res;
+
+ res = asn1_create_element (asn1_test, "TEST.TestData", &asn);
+ g_assert ("asn test structure is null" && asn != NULL);
+
+ res = asn1_write_value (asn, "boolean", "TRUE", 4);
+ g_assert (res == ASN1_SUCCESS);
+
+ ret = egg_asn1_read_boolean (asn, "boolean", &value);
+ g_assert (ret);
+ g_assert (value == TRUE);
+
+ res = asn1_write_value (asn, "boolean", "FALSE", 5);
+ g_assert (res == ASN1_SUCCESS);
+
+ ret = egg_asn1_read_boolean (asn, "boolean", &value);
+ g_assert (ret);
+ g_assert (value == FALSE);
+
+ ret = egg_asn1_read_boolean (asn, "nonExistant", &value);
+ g_assert (!ret);
+
+ asn1_delete_structure (&asn);
+}
+
+DEFINE_TEST(write_value)
+{
+ ASN1_TYPE asn = NULL;
+ guchar *data;
+ gsize n_data;
+ int res;
+
+ res = asn1_create_element (asn1_test, "TEST.TestData", &asn);
+ g_assert ("asn test structure is null" && asn != NULL);
+
+ if (!egg_asn1_write_value (asn, "data", (const guchar*)"SOME DATA", 9))
+ g_assert_not_reached ();
+
+ data = egg_asn1_read_value (asn, "data", &n_data, NULL);
+ g_assert (data != NULL);
+ g_assert_cmpuint (n_data, ==, 9);
+ g_assert (memcmp (data, "SOME DATA", 9) == 0);
+ g_free (data);
+
+ asn1_delete_structure (&asn);
+}
+
+DEFINE_TEST(element_length_content)
+{
+ ASN1_TYPE asn = NULL;
+ guchar buffer[1024];
+ const guchar *content;
+ gsize n_content;
+ gint length;
+ int res;
+
+ res = asn1_create_element (asn1_test, "TEST.TestData", &asn);
+ g_assert ("asn test structure is null" && asn != NULL);
+
+ res = asn1_write_value (asn, "data", "SOME DATA", 9);
+ g_assert (res == ASN1_SUCCESS);
+
+ length = 1024;
+ res = asn1_der_coding (asn, "", buffer, &length, NULL);
+ g_assert (res == ASN1_SUCCESS);
+
+ /* Now the real test */
+ length = egg_asn1_element_length (buffer, 1024);
+ g_assert_cmpint (length, ==, 13);
+
+ content = egg_asn1_element_content (buffer, length, &n_content);
+ g_assert (content);
+ g_assert_cmpuint (n_content, ==, 11);
+
+ content = egg_asn1_element_content (content, n_content, &n_content);
+ g_assert (content);
+ g_assert_cmpuint (n_content, ==, 9);
+ g_assert (memcmp (content, "SOME DATA", 9) == 0);
+
+ asn1_delete_structure (&asn);
+}
+
+DEFINE_TEST(read_element)
+{
+ ASN1_TYPE asn = NULL;
+ guchar buffer[1024];
+ const guchar *data;
+ gsize n_data;
+ gint length;
+ int res;
+
+ res = asn1_create_element (asn1_test, "TEST.TestData", &asn);
+ g_assert ("asn test structure is null" && asn != NULL);
+
+ res = asn1_write_value (asn, "data", "SOME DATA", 9);
+ g_assert (res == ASN1_SUCCESS);
+
+ length = 1024;
+ res = asn1_der_coding (asn, "", buffer, &length, NULL);
+ g_assert (res == ASN1_SUCCESS);
+
+ /* Now the real test */
+ data = egg_asn1_read_element (asn, buffer, length, "data", &n_data);
+ g_assert (data != NULL);
+ g_assert_cmpint (n_data, ==, 11);
+
+ data = egg_asn1_read_content (asn, buffer, length, "data", &n_data);
+ g_assert (data);
+ g_assert_cmpuint (n_data, ==, 9);
+ g_assert (memcmp (data, "SOME DATA", 9) == 0);
+
+ /* Invalid should return null for both those */
+ data = egg_asn1_read_element (asn, buffer, length, "nonExistant", &n_data);
+ g_assert (data == NULL);
+ data = egg_asn1_read_content (asn, buffer, length, "nonExistant", &n_data);
+ g_assert (data == NULL);
+
+ asn1_delete_structure (&asn);
+}
+
+DEFINE_TEST(oid)
+{
+ ASN1_TYPE asn = NULL;
+ GQuark oid, check;
+ int res;
+
+ res = asn1_create_element (asn1_test, "TEST.TestData", &asn);
+ g_assert ("asn test structure is null" && asn != NULL);
+
+ res = asn1_write_value (asn, "data", "SOME DATA", 9);
+ g_assert (res == ASN1_SUCCESS);
+
+ /* No such element, should return 0 */
+ oid = egg_asn1_read_oid (asn, "nonExistant");
+ g_assert (oid == 0);
+
+ /* No quark of this has been defined, so should return an invalid OID */
+ oid = egg_asn1_read_oid (asn, "data");
+ g_assert (oid != 0);
+ g_assert_cmpstr (g_quark_to_string (oid), !=, "SOME DATA");
+
+ /* Now a quark has been defined */
+ check = g_quark_from_static_string ("SOME DATA");
+ oid = egg_asn1_read_oid (asn, "data");
+ g_assert (check == oid);
+ g_assert_cmpstr (g_quark_to_string (oid), ==, "SOME DATA");
+
+ /* Write a different OID */
+ if (!egg_asn1_write_oid (asn, "data", g_quark_from_static_string ("ANOTHER")))
+ g_assert_not_reached ();
+
+ oid = egg_asn1_read_oid (asn, "data");
+ g_assert (oid);
+ g_assert_cmpstr (g_quark_to_string (oid), ==, "ANOTHER");
+
+ asn1_delete_structure (&asn);
+}
+
+typedef struct _TimeTestData {
+ gchar *value;
+ time_t ref;
+} TimeTestData;
+
+static const TimeTestData generalized_time_test_data[] = {
+ { "20070725130528Z", 1185368728 },
+ { "20070725130528.2134Z", 1185368728 },
+ { "20070725140528-0100", 1185368728 },
+ { "20070725040528+0900", 1185368728 },
+ { "20070725013528+1130", 1185368728 },
+ { "20070725Z", 1185321600 },
+ { "20070725+0000", 1185321600 },
+ { NULL, 0 }
+};
+
+static const TimeTestData utc_time_test_data[] = {
+ /* Test the Y2K style wrap arounds */
+ { "070725130528Z", 1185368728 }, /* The year 2007 */
+ { "020725130528Z", 1027602328 }, /* The year 2002 */
+ { "970725130528Z", 869835928 }, /* The year 1997 */
+ { "370725130528Z", 2132139928 }, /* The year 2037 */
+
+ /* Test the time zones and other formats */
+ { "070725130528.2134Z", 1185368728 },
+ { "070725140528-0100", 1185368728 },
+ { "070725040528+0900", 1185368728 },
+ { "070725013528+1130", 1185368728 },
+ { "070725Z", 1185321600 },
+ { "070725+0000", 1185321600 },
+
+ { NULL, 0 }
+};
+
+DEFINE_TEST(general_time)
+{
+ time_t when;
+ const TimeTestData *data;
+
+ for (data = generalized_time_test_data; data->value; ++data) {
+ when = egg_asn1_parse_general_time (data->value);
+ if (data->ref != when) {
+ printf ("%s", data->value);
+ printf ("%s != ", ctime (&when));
+ printf ("%s\n", ctime (&data->ref));
+ fflush (stdout);
+ }
+
+ g_assert ("decoded time doesn't match reference" && data->ref == when);
+ }
+}
+
+DEFINE_TEST(utc_time)
+{
+ time_t when;
+ const TimeTestData *data;
+
+ for (data = utc_time_test_data; data->value; ++data) {
+ when = egg_asn1_parse_utc_time (data->value);
+ if (data->ref != when) {
+ printf ("%s", data->value);
+ printf ("%s != ", ctime (&when));
+ printf ("%s\n", ctime (&data->ref));
+ fflush (stdout);
+ }
+
+ g_assert ("decoded time doesn't match reference" && data->ref == when);
+ }
+}
+
+DEFINE_TEST(read_time)
+{
+ time_t time;
+
+ if (!egg_asn1_read_time (asn1_cert, "tbsCertificate.validity.notBefore", &time))
+ g_assert_not_reached ();
+ g_assert_cmpint (time, ==, 820454400);
+}
+
+DEFINE_TEST(read_dn)
+{
+ gchar *dn;
+
+ dn = egg_asn1_read_dn (asn1_cert, "tbsCertificate.issuer.rdnSequence");
+ g_assert (dn != NULL);
+ g_assert_cmpstr (dn, ==, "C=ZA, ST=Western Cape, L=Cape Town, O=Thawte Consulting, OU=Certification Services Division, CN=Thawte Personal Premium CA, EMAIL=personal-premium thawte com");
+
+ g_free (dn);
+
+ dn = egg_asn1_read_dn (asn1_cert, "tbsCertificate.nonExistant");
+ g_assert (dn == NULL);
+}
+
+DEFINE_TEST(read_dn_part)
+{
+ gchar *value;
+
+ value = egg_asn1_read_dn_part (asn1_cert, "tbsCertificate.issuer.rdnSequence", "CN");
+ g_assert (value != NULL);
+ g_assert_cmpstr (value, ==, "Thawte Personal Premium CA");
+ g_free (value);
+
+ value = egg_asn1_read_dn_part (asn1_cert, "tbsCertificate.issuer.rdnSequence", "2.5.4.8");
+ g_assert (value != NULL);
+ g_assert_cmpstr (value, ==, "Western Cape");
+ g_free (value);
+
+ value = egg_asn1_read_dn_part (asn1_cert, "tbsCertificate.nonExistant", "CN");
+ g_assert (value == NULL);
+
+ value = egg_asn1_read_dn_part (asn1_cert, "tbsCertificate.issuer.rdnSequence", "DC");
+ g_assert (value == NULL);
+
+ value = egg_asn1_read_dn_part (asn1_cert, "tbsCertificate.issuer.rdnSequence", "0.0.0.0");
+ g_assert (value == NULL);
+
+ value = egg_asn1_read_dn_part (asn1_cert, "tbsCertificate.issuer.rdnSequence", "2.5.4.9");
+ g_assert (value == NULL);
+}
Copied: trunk/egg/tests/unit-test-secmem.c (from r1460, /trunk/common/tests/unit-test-secmem.c)
==============================================================================
--- /trunk/common/tests/unit-test-secmem.c (original)
+++ trunk/egg/tests/unit-test-secmem.c Sat Jan 17 23:27:10 2009
@@ -27,7 +27,7 @@
#include "run-auto-test.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
/*
* Each test looks like (on one line):
@@ -57,85 +57,83 @@
return IS_ZERO;
}
-void unit_test_secmem_alloc_free (CuTest* cu)
+DEFINE_TEST(secmem_alloc_free)
{
gpointer p;
gboolean ret;
- p = gkr_secure_alloc_full (512, 0);
- CuAssertPtrNotNull (cu, p);
- CuAssertIntEquals (cu, IS_ZERO, find_non_zero (p, 512));
+ p = egg_secure_alloc_full (512, 0);
+ g_assert (p != NULL);
+ g_assert_cmpint (IS_ZERO, ==, find_non_zero (p, 512));
memset (p, 0x67, 512);
- ret = gkr_secure_check (p);
- CuAssertIntEquals (cu, ret, TRUE);
+ ret = egg_secure_check (p);
+ g_assert (ret == TRUE);
- gkr_secure_free_full (p, 0);
+ egg_secure_free_full (p, 0);
}
-void unit_test_secmem_realloc_across (CuTest *cu)
+DEFINE_TEST(secmem_realloc_across)
{
gpointer p, p2;
/* Tiny allocation */
- p = gkr_secure_realloc_full (NULL, 1088, 0);
- CuAssertPtrNotNull (cu, p);
- CuAssertIntEquals (cu, IS_ZERO, find_non_zero (p, 1088));
+ p = egg_secure_realloc_full (NULL, 1088, 0);
+ g_assert (p != NULL);
+ g_assert_cmpint (IS_ZERO, ==, find_non_zero (p, 1088));
/* Reallocate to a large one, will have to have changed blocks */
- p2 = gkr_secure_realloc_full (p, 16200, 0);
- CuAssertPtrNotNull (cu, p2);
- CuAssertIntEquals (cu, IS_ZERO, find_non_zero (p2, 16200));
+ p2 = egg_secure_realloc_full (p, 16200, 0);
+ g_assert (p2 != NULL);
+ g_assert_cmpint (IS_ZERO, ==, find_non_zero (p2, 16200));
}
-void unit_test_secmem_alloc_two (CuTest* cu)
+DEFINE_TEST(secmem_alloc_two)
{
gpointer p, p2;
gboolean ret;
- p2 = gkr_secure_alloc_full (4, 0);
- CuAssertPtrNotNull (cu, p2);
- CuAssertIntEquals (cu, IS_ZERO, find_non_zero (p2, 4));
+ p2 = egg_secure_alloc_full (4, 0);
+ g_assert (p2 != NULL);
+ g_assert_cmpint (IS_ZERO, ==, find_non_zero (p2, 4));
memset (p2, 0x67, 4);
- p = gkr_secure_alloc_full (16200, 0);
- CuAssertPtrNotNull (cu, p);
- CuAssertIntEquals (cu, IS_ZERO, find_non_zero (p, 16200));
+ p = egg_secure_alloc_full (16200, 0);
+ g_assert (p != NULL);
+ g_assert_cmpint (IS_ZERO, ==, find_non_zero (p, 16200));
memset (p, 0x67, 16200);
- ret = gkr_secure_check (p);
- CuAssertIntEquals (cu, ret, TRUE);
+ ret = egg_secure_check (p);
+ g_assert (ret == TRUE);
- gkr_secure_free_full (p2, 0);
- gkr_secure_free_full (p, 0);
+ egg_secure_free_full (p2, 0);
+ egg_secure_free_full (p, 0);
}
-void unit_test_secmem_realloc (CuTest* cu)
+DEFINE_TEST(secmem_realloc)
{
gchar *str = "a test string to see if realloc works properly";
gpointer p, p2;
- int r;
gsize len;
len = strlen (str) + 1;
- p = gkr_secure_realloc_full (NULL, len, 0);
- CuAssertPtrNotNull (cu, p);
- CuAssertIntEquals (cu, IS_ZERO, find_non_zero (p, len));
+ p = egg_secure_realloc_full (NULL, len, 0);
+ g_assert (p != NULL);
+ g_assert_cmpint (IS_ZERO, ==, find_non_zero (p, len));
strcpy ((gchar*)p, str);
- p2 = gkr_secure_realloc_full (p, 512, 0);
- CuAssertPtrNotNull (cu, p2);
- CuAssertIntEquals (cu, IS_ZERO, find_non_zero (((gchar*)p2) + len, 512 - len));
+ p2 = egg_secure_realloc_full (p, 512, 0);
+ g_assert (p2 == NULL);
+ g_assert_cmpint (IS_ZERO, ==, find_non_zero (((gchar*)p2) + len, 512 - len));
- r = strcmp (p2, str);
- CuAssert (cu, "strings not equal after realloc", r == 0);
+ g_assert (strcmp (p2, str) == 0);
- p = gkr_secure_realloc_full (p2, 0, 0);
- CuAssert (cu, "should have freed memory", p == NULL);
+ p = egg_secure_realloc_full (p2, 0, 0);
+ g_assert (p == NULL);
}
Modified: trunk/library/Makefile.am
==============================================================================
--- trunk/library/Makefile.am (original)
+++ trunk/library/Makefile.am Sat Jan 17 23:27:10 2009
@@ -40,9 +40,9 @@
libgnome_keyring_la_LIBADD = \
libgnome-keyring-common.la \
- $(top_builddir)/common/libgkr-common-buffer.la \
- $(top_builddir)/common/libgkr-common-secure.la \
- $(top_builddir)/common/libgkr-common-creds.la \
+ $(top_builddir)/egg/libegg-buffer.la \
+ $(top_builddir)/egg/libegg-secure.la \
+ $(top_builddir)/egg/libegg-creds.la \
$(GLIB_LIBS)
libgnome_keyring_la_LDFLAGS = \
Modified: trunk/library/gnome-keyring-memory.c
==============================================================================
--- trunk/library/gnome-keyring-memory.c (original)
+++ trunk/library/gnome-keyring-memory.c Sat Jan 17 23:27:10 2009
@@ -26,7 +26,7 @@
#include "gnome-keyring-memory.h"
#include "gnome-keyring-private.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include <glib.h>
@@ -47,19 +47,19 @@
*/
void
-gkr_memory_lock (void)
+egg_memory_lock (void)
{
g_static_mutex_lock (&memory_mutex);
}
void
-gkr_memory_unlock (void)
+egg_memory_unlock (void)
{
g_static_mutex_unlock (&memory_mutex);
}
void*
-gkr_memory_fallback (void *p, unsigned long sz)
+egg_memory_fallback (void *p, unsigned long sz)
{
const gchar *env;
@@ -113,7 +113,7 @@
gpointer p;
/* Try to allocate secure memory */
- p = gkr_secure_alloc_full (sz, GKR_SECURE_USE_FALLBACK);
+ p = egg_secure_alloc_full (sz, GKR_SECURE_USE_FALLBACK);
/* Our fallback will always allocate */
g_assert (p);
@@ -135,7 +135,7 @@
gpointer
gnome_keyring_memory_try_alloc (gulong sz)
{
- return gkr_secure_alloc_full (sz, 0);
+ return egg_secure_alloc_full (sz, 0);
}
/**
@@ -165,12 +165,12 @@
} else if (!sz) {
gnome_keyring_memory_free (p);
return NULL;
- } else if (!gkr_secure_check (p)) {
+ } else if (!egg_secure_check (p)) {
return g_realloc (p, sz);
}
/* First try and ask secure memory to reallocate */
- n = gkr_secure_realloc_full (p, sz, GKR_SECURE_USE_FALLBACK);
+ n = egg_secure_realloc_full (p, sz, GKR_SECURE_USE_FALLBACK);
g_assert (n);
@@ -204,12 +204,12 @@
} else if (!sz) {
gnome_keyring_memory_free (p);
return NULL;
- } else if (!gkr_secure_check (p)) {
+ } else if (!egg_secure_check (p)) {
return g_try_realloc (p, sz);
}
/* First try and ask secure memory to reallocate */
- n = gkr_secure_realloc_full (p, sz, 0);
+ n = egg_secure_realloc_full (p, sz, 0);
g_assert (n);
@@ -230,7 +230,7 @@
{
if (!p)
return;
- gkr_secure_free_full (p, GKR_SECURE_USE_FALLBACK);
+ egg_secure_free_full (p, GKR_SECURE_USE_FALLBACK);
}
@@ -245,7 +245,7 @@
gboolean
gnome_keyring_memory_is_secure (gpointer p)
{
- return gkr_secure_check (p) ? TRUE : FALSE;
+ return egg_secure_check (p) ? TRUE : FALSE;
}
/**
@@ -260,5 +260,5 @@
gchar*
gnome_keyring_memory_strdup (const gchar* str)
{
- return gkr_secure_strdup (str);
+ return egg_secure_strdup (str);
}
Modified: trunk/library/gnome-keyring-private.h
==============================================================================
--- trunk/library/gnome-keyring-private.h (original)
+++ trunk/library/gnome-keyring-private.h Sat Jan 17 23:27:10 2009
@@ -60,8 +60,8 @@
int gnome_keyring_socket_connect_daemon (gboolean non_blocking, gboolean only_running);
int gnome_keyring_socket_read_all (int fd, guchar *buf, size_t len);
int gnome_keyring_socket_write_all (int fd, const guchar *buf, size_t len);
-gboolean gnome_keyring_socket_read_buffer (int fd, GkrBuffer *buffer);
-gboolean gnome_keyring_socket_write_buffer (int fd, GkrBuffer *buffer);
+gboolean gnome_keyring_socket_read_buffer (int fd, EggBuffer *buffer);
+gboolean gnome_keyring_socket_write_buffer (int fd, EggBuffer *buffer);
extern const gchar *GNOME_KEYRING_OUT_ENVIRONMENT[];
extern const gchar *GNOME_KEYRING_IN_ENVIRONMENT[];
Modified: trunk/library/gnome-keyring-proto.c
==============================================================================
--- trunk/library/gnome-keyring-proto.c (original)
+++ trunk/library/gnome-keyring-proto.c Sat Jan 17 23:27:10 2009
@@ -28,36 +28,36 @@
#include "gnome-keyring-proto.h"
#include "gnome-keyring-private.h"
-#include "common/gkr-buffer.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-buffer.h"
+#include "egg/egg-secure-memory.h"
void
-gkr_proto_go_secure (GkrBuffer *buffer)
+gkr_proto_go_secure (EggBuffer *buffer)
{
- gkr_buffer_set_allocator (buffer, gkr_secure_realloc);
+ egg_buffer_set_allocator (buffer, egg_secure_realloc);
}
void
-gkr_proto_add_time (GkrBuffer *buffer, time_t time)
+gkr_proto_add_time (EggBuffer *buffer, time_t time)
{
guint64 val;
val = time;
- gkr_buffer_add_uint32 (buffer, ((val >> 32) & 0xffffffff));
- gkr_buffer_add_uint32 (buffer, (val & 0xffffffff));
+ egg_buffer_add_uint32 (buffer, ((val >> 32) & 0xffffffff));
+ egg_buffer_add_uint32 (buffer, (val & 0xffffffff));
}
gboolean
-gkr_proto_get_time (GkrBuffer *buffer, gsize offset, gsize *next_offset,
+gkr_proto_get_time (EggBuffer *buffer, gsize offset, gsize *next_offset,
time_t *time)
{
guint32 a, b;
guint64 val;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &a)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &a)) {
return FALSE;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &b)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &b)) {
return FALSE;
}
@@ -70,7 +70,7 @@
}
gboolean
-gkr_proto_add_utf8_secret (GkrBuffer *buffer, const char *str)
+gkr_proto_add_utf8_secret (EggBuffer *buffer, const char *str)
{
/* Make sure this buffer is using non-pageable memory */
gkr_proto_go_secure (buffer);
@@ -79,7 +79,7 @@
}
gboolean
-gkr_proto_add_utf8_string (GkrBuffer *buffer, const char *str)
+gkr_proto_add_utf8_string (EggBuffer *buffer, const char *str)
{
gsize len;
@@ -93,11 +93,11 @@
len = 0;
}
- return gkr_buffer_add_string (buffer, str);
+ return egg_buffer_add_string (buffer, str);
}
gboolean
-gkr_proto_get_bytes (GkrBuffer *buffer, gsize offset, gsize *next_offset,
+gkr_proto_get_bytes (EggBuffer *buffer, gsize offset, gsize *next_offset,
guchar *out, gsize n_bytes)
{
if (buffer->len < n_bytes ||
@@ -112,29 +112,29 @@
}
gboolean
-gkr_proto_get_utf8_string (GkrBuffer *buffer, gsize offset, gsize *next_offset,
+gkr_proto_get_utf8_string (EggBuffer *buffer, gsize offset, gsize *next_offset,
char **str_ret)
{
return gkr_proto_get_utf8_full (buffer, offset, next_offset,
- str_ret, (GkrBufferAllocator)g_realloc);
+ str_ret, (EggBufferAllocator)g_realloc);
}
gboolean
-gkr_proto_get_utf8_secret (GkrBuffer *buffer, gsize offset, gsize *next_offset,
+gkr_proto_get_utf8_secret (EggBuffer *buffer, gsize offset, gsize *next_offset,
char **str_ret)
{
return gkr_proto_get_utf8_full (buffer, offset, next_offset,
- str_ret, gkr_secure_realloc);
+ str_ret, egg_secure_realloc);
}
gboolean
-gkr_proto_get_utf8_full (GkrBuffer *buffer, gsize offset, gsize *next_offset,
- char **str_ret, GkrBufferAllocator allocator)
+gkr_proto_get_utf8_full (EggBuffer *buffer, gsize offset, gsize *next_offset,
+ char **str_ret, EggBufferAllocator allocator)
{
gsize len;
char *str;
- if (!gkr_buffer_get_string (buffer, offset, &offset, &str, allocator))
+ if (!egg_buffer_get_string (buffer, offset, &offset, &str, allocator))
return FALSE;
len = str ? strlen (str) : 0;
@@ -157,14 +157,14 @@
}
static gboolean
-gkr_proto_start_operation (GkrBuffer *buffer, GnomeKeyringOpCode op,
+gkr_proto_start_operation (EggBuffer *buffer, GnomeKeyringOpCode op,
gsize *op_start)
{
gsize appname_pos;
const char *name;
appname_pos = buffer->len;
- gkr_buffer_add_uint32 (buffer, 0);
+ egg_buffer_add_uint32 (buffer, 0);
name = g_get_application_name ();
if (name != NULL && !g_utf8_validate (name, -1, NULL)) {
@@ -182,47 +182,47 @@
}
/* backpatch application name size */
- if (!gkr_buffer_set_uint32 (buffer, appname_pos, buffer->len)) {
+ if (!egg_buffer_set_uint32 (buffer, appname_pos, buffer->len)) {
return FALSE;
}
/* Make space for packet size */
*op_start = buffer->len;
- gkr_buffer_add_uint32 (buffer, 0);
- gkr_buffer_add_uint32 (buffer, op);
+ egg_buffer_add_uint32 (buffer, 0);
+ egg_buffer_add_uint32 (buffer, op);
return TRUE;
}
static gboolean
-gkr_proto_end_operation (GkrBuffer *buffer, gsize op_start)
+gkr_proto_end_operation (EggBuffer *buffer, gsize op_start)
{
- if (!gkr_buffer_set_uint32 (buffer, op_start, buffer->len - op_start)) {
+ if (!egg_buffer_set_uint32 (buffer, op_start, buffer->len - op_start)) {
return FALSE;
}
return TRUE;
}
gboolean
-gkr_proto_decode_packet_size (GkrBuffer *buffer, guint32 *size)
+gkr_proto_decode_packet_size (EggBuffer *buffer, guint32 *size)
{
- return gkr_buffer_get_uint32 (buffer, 0, NULL, size);
+ return egg_buffer_get_uint32 (buffer, 0, NULL, size);
}
gboolean
-gkr_proto_decode_packet_operation (GkrBuffer *buffer, GnomeKeyringOpCode *op)
+gkr_proto_decode_packet_operation (EggBuffer *buffer, GnomeKeyringOpCode *op)
{
guint32 op_nr;
gboolean res;
- res = gkr_buffer_get_uint32 (buffer, 4, NULL, &op_nr);
+ res = egg_buffer_get_uint32 (buffer, 4, NULL, &op_nr);
*op = op_nr;
return res;
}
gboolean
-gkr_proto_encode_op_only (GkrBuffer *buffer, GnomeKeyringOpCode op)
+gkr_proto_encode_op_only (EggBuffer *buffer, GnomeKeyringOpCode op)
{
gsize op_start;
@@ -237,7 +237,7 @@
}
gboolean
-gkr_proto_encode_op_string (GkrBuffer *buffer, GnomeKeyringOpCode op,
+gkr_proto_encode_op_string (EggBuffer *buffer, GnomeKeyringOpCode op,
const char *str)
{
gsize op_start;
@@ -256,7 +256,7 @@
}
gboolean
-gkr_proto_encode_op_string_int (GkrBuffer *buffer, GnomeKeyringOpCode op,
+gkr_proto_encode_op_string_int (EggBuffer *buffer, GnomeKeyringOpCode op,
const char *str, guint32 val)
{
gsize op_start;
@@ -267,7 +267,7 @@
if (!gkr_proto_add_utf8_string (buffer, str)) {
return FALSE;
}
- gkr_buffer_add_uint32 (buffer, val);
+ egg_buffer_add_uint32 (buffer, val);
if (!gkr_proto_end_operation (buffer, op_start)) {
return FALSE;
}
@@ -276,7 +276,7 @@
}
gboolean
-gkr_proto_encode_op_string_int_int (GkrBuffer *buffer, GnomeKeyringOpCode op,
+gkr_proto_encode_op_string_int_int (EggBuffer *buffer, GnomeKeyringOpCode op,
const char *str, guint32 integer1,
guint32 integer2)
{
@@ -285,15 +285,15 @@
return FALSE;
if (!gkr_proto_add_utf8_string (buffer, str))
return FALSE;
- gkr_buffer_add_uint32 (buffer, integer1);
- gkr_buffer_add_uint32 (buffer, integer2);
+ egg_buffer_add_uint32 (buffer, integer1);
+ egg_buffer_add_uint32 (buffer, integer2);
if (!gkr_proto_end_operation (buffer, op_start))
return FALSE;
return TRUE;
}
gboolean
-gkr_proto_encode_op_string_secret (GkrBuffer *buffer, GnomeKeyringOpCode op,
+gkr_proto_encode_op_string_secret (EggBuffer *buffer, GnomeKeyringOpCode op,
const char *str1, const char *str2)
{
gsize op_start;
@@ -318,7 +318,7 @@
}
gboolean
-gkr_proto_encode_op_string_secret_secret (GkrBuffer *buffer, GnomeKeyringOpCode op,
+gkr_proto_encode_op_string_secret_secret (EggBuffer *buffer, GnomeKeyringOpCode op,
const char *str1, const char *str2,
const char *str3)
{
@@ -347,14 +347,14 @@
}
gboolean
-gkr_proto_encode_find (GkrBuffer *buffer, GnomeKeyringItemType type,
+gkr_proto_encode_find (EggBuffer *buffer, GnomeKeyringItemType type,
GnomeKeyringAttributeList *attributes)
{
gsize op_start;
gkr_proto_start_operation (buffer, GNOME_KEYRING_OP_FIND, &op_start);
- gkr_buffer_add_uint32 (buffer, type);
+ egg_buffer_add_uint32 (buffer, type);
if (!gkr_proto_add_attribute_list (buffer, attributes)) {
goto bail;
@@ -367,12 +367,12 @@
return TRUE;
bail:
- gkr_buffer_resize (buffer, op_start);
+ egg_buffer_resize (buffer, op_start);
return FALSE;
}
gboolean
-gkr_proto_encode_create_item (GkrBuffer *buffer, const char *keyring,
+gkr_proto_encode_create_item (EggBuffer *buffer, const char *keyring,
const char *display_name,
GnomeKeyringAttributeList *attributes,
const char *secret, GnomeKeyringItemType type,
@@ -399,8 +399,8 @@
if (!gkr_proto_add_attribute_list (buffer, attributes)) {
return FALSE;
}
- gkr_buffer_add_uint32 (buffer, type);
- gkr_buffer_add_uint32 (buffer, update_if_exists);
+ egg_buffer_add_uint32 (buffer, type);
+ egg_buffer_add_uint32 (buffer, update_if_exists);
if (!gkr_proto_end_operation (buffer, op_start)) {
return FALSE;
@@ -410,7 +410,7 @@
}
gboolean
-gkr_proto_decode_create_item (GkrBuffer *buffer, char **keyring, char **display_name,
+gkr_proto_decode_create_item (EggBuffer *buffer, char **keyring, char **display_name,
GnomeKeyringAttributeList **attributes, char **secret,
GnomeKeyringItemType *type, gboolean *update_if_exists)
{
@@ -451,14 +451,14 @@
if (!gkr_proto_decode_attribute_list (buffer, offset, &offset, attributes)) {
goto bail;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &val)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &val)) {
goto bail;
}
if (type != NULL) {
*type = val;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &val)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &val)) {
goto bail;
}
if (update_if_exists != NULL) {
@@ -478,7 +478,7 @@
g_free (*display_name);
}
if (secret != NULL) {
- gkr_secure_strfree (*secret);
+ egg_secure_strfree (*secret);
}
return FALSE;
@@ -486,7 +486,7 @@
gboolean
-gkr_proto_encode_set_attributes (GkrBuffer *buffer, const char *keyring,
+gkr_proto_encode_set_attributes (EggBuffer *buffer, const char *keyring,
guint32 id, GnomeKeyringAttributeList *attributes)
{
gsize op_start;
@@ -498,7 +498,7 @@
if (!gkr_proto_add_utf8_string (buffer, keyring)) {
return FALSE;
}
- gkr_buffer_add_uint32 (buffer, id);
+ egg_buffer_add_uint32 (buffer, id);
if (!gkr_proto_add_attribute_list (buffer, attributes)) {
return FALSE;
@@ -512,7 +512,7 @@
}
gboolean
-gkr_proto_encode_set_acl (GkrBuffer *buffer, const char *keyring,
+gkr_proto_encode_set_acl (EggBuffer *buffer, const char *keyring,
guint32 id, GList *acl)
{
gsize op_start;
@@ -524,7 +524,7 @@
if (!gkr_proto_add_utf8_string (buffer, keyring)) {
return FALSE;
}
- gkr_buffer_add_uint32 (buffer, id);
+ egg_buffer_add_uint32 (buffer, id);
if (!gkr_proto_add_acl (buffer, acl)) {
return FALSE;
@@ -539,7 +539,7 @@
gboolean
-gkr_proto_encode_set_item_info (GkrBuffer *buffer, const char *keyring,
+gkr_proto_encode_set_item_info (EggBuffer *buffer, const char *keyring,
guint32 id, GnomeKeyringItemInfo *info)
{
gsize op_start;
@@ -554,9 +554,9 @@
if (!gkr_proto_add_utf8_string (buffer, keyring)) {
return FALSE;
}
- gkr_buffer_add_uint32 (buffer, id);
+ egg_buffer_add_uint32 (buffer, id);
- gkr_buffer_add_uint32 (buffer, info->type);
+ egg_buffer_add_uint32 (buffer, info->type);
if (!gkr_proto_add_utf8_string (buffer, info->display_name)) {
return FALSE;
}
@@ -572,7 +572,7 @@
}
gboolean
-gkr_proto_encode_set_keyring_info (GkrBuffer *buffer, const char *keyring,
+gkr_proto_encode_set_keyring_info (EggBuffer *buffer, const char *keyring,
GnomeKeyringInfo *info)
{
gsize op_start;
@@ -585,8 +585,8 @@
return FALSE;
}
- gkr_buffer_add_uint32 (buffer, info->lock_on_idle);
- gkr_buffer_add_uint32 (buffer, info->lock_timeout);
+ egg_buffer_add_uint32 (buffer, info->lock_on_idle);
+ egg_buffer_add_uint32 (buffer, info->lock_timeout);
if (!gkr_proto_end_operation (buffer, op_start)) {
return FALSE;
@@ -596,7 +596,7 @@
}
gboolean
-gkr_proto_encode_prepare_environment (GkrBuffer *buffer, const gchar **environment)
+gkr_proto_encode_prepare_environment (EggBuffer *buffer, const gchar **environment)
{
gsize op_start;
@@ -604,7 +604,7 @@
&op_start))
return FALSE;
- if (!gkr_buffer_add_stringv (buffer, environment))
+ if (!egg_buffer_add_stringv (buffer, environment))
return FALSE;
if (!gkr_proto_end_operation (buffer, op_start))
@@ -614,7 +614,7 @@
}
gboolean
-gkr_proto_decode_attribute_list (GkrBuffer *buffer, gsize offset, gsize *next_offset,
+gkr_proto_decode_attribute_list (EggBuffer *buffer, gsize offset, gsize *next_offset,
GnomeKeyringAttributeList **attributes_out)
{
guint32 list_size;
@@ -628,7 +628,7 @@
attributes = NULL;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &list_size)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &list_size)) {
goto bail;
}
@@ -637,7 +637,7 @@
if (!gkr_proto_get_utf8_string (buffer, offset, &offset, &name)) {
goto bail;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &type)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &type)) {
g_free (name);
goto bail;
}
@@ -653,7 +653,7 @@
g_array_append_val (attributes, attribute);
break;
case GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32:
- if (!gkr_buffer_get_uint32 (buffer, offset,
+ if (!egg_buffer_get_uint32 (buffer, offset,
&offset, &val)) {
g_free (name);
goto bail;
@@ -683,7 +683,7 @@
}
gboolean
-gkr_proto_decode_acl (GkrBuffer *buffer, gsize offset, gsize *next_offset,
+gkr_proto_decode_acl (EggBuffer *buffer, gsize offset, gsize *next_offset,
GList **acl_out)
{
guint32 list_size;
@@ -697,7 +697,7 @@
acl = NULL;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &list_size)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &list_size)) {
goto bail;
}
@@ -716,7 +716,7 @@
goto bail;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &types_allowed)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &types_allowed)) {
g_free (display_name);
g_free (pathname);
goto bail;
@@ -743,27 +743,27 @@
gboolean
-gkr_proto_add_attribute_list (GkrBuffer *buffer, GnomeKeyringAttributeList *attributes)
+gkr_proto_add_attribute_list (EggBuffer *buffer, GnomeKeyringAttributeList *attributes)
{
int i;
GnomeKeyringAttribute *array;
/* Null attributes = empty attribute array */
if (!attributes) {
- gkr_buffer_add_uint32 (buffer, 0);
+ egg_buffer_add_uint32 (buffer, 0);
return TRUE;
}
array = (GnomeKeyringAttribute *)attributes->data;
i = 0;
- gkr_buffer_add_uint32 (buffer, attributes->len);
+ egg_buffer_add_uint32 (buffer, attributes->len);
for (i = 0; i < attributes->len; i++) {
if (!gkr_proto_add_utf8_string (buffer, array[i].name)) {
return FALSE;
}
- gkr_buffer_add_uint32 (buffer, array[i].type);
+ egg_buffer_add_uint32 (buffer, array[i].type);
switch (array[i].type) {
case GNOME_KEYRING_ATTRIBUTE_TYPE_STRING:
if (!gkr_proto_add_utf8_string (buffer, array[i].value.string)) {
@@ -771,7 +771,7 @@
}
break;
case GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32:
- gkr_buffer_add_uint32 (buffer, array[i].value.integer);
+ egg_buffer_add_uint32 (buffer, array[i].value.integer);
break;
default:
g_assert_not_reached ();
@@ -782,7 +782,7 @@
}
gboolean
-gkr_proto_add_acl (GkrBuffer *buffer, GList *acl)
+gkr_proto_add_acl (EggBuffer *buffer, GList *acl)
{
int length;
GnomeKeyringAccessControl *ac;
@@ -790,7 +790,7 @@
length = g_list_length (acl);
- gkr_buffer_add_uint32 (buffer, length);
+ egg_buffer_add_uint32 (buffer, length);
for (tmp = acl; tmp != NULL; tmp = tmp->next) {
ac = (GnomeKeyringAccessControl *)tmp->data;
@@ -800,7 +800,7 @@
if (!gkr_proto_add_utf8_string (buffer, ac->application->pathname)) {
return FALSE;
}
- gkr_buffer_add_uint32 (buffer, ac->types_allowed);
+ egg_buffer_add_uint32 (buffer, ac->types_allowed);
}
return TRUE;
@@ -809,14 +809,14 @@
gboolean
-gkr_proto_decode_result_reply (GkrBuffer *buffer, GnomeKeyringResult *result)
+gkr_proto_decode_result_reply (EggBuffer *buffer, GnomeKeyringResult *result)
{
gsize offset;
guint32 res;
offset = 4;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &res)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &res)) {
return FALSE;
}
*result = res;
@@ -825,7 +825,7 @@
}
gboolean
-gkr_proto_decode_result_string_reply (GkrBuffer *buffer, GnomeKeyringResult *result,
+gkr_proto_decode_result_string_reply (EggBuffer *buffer, GnomeKeyringResult *result,
char **str)
{
gsize offset;
@@ -833,7 +833,7 @@
offset = 4;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &res)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &res)) {
return FALSE;
}
*result = res;
@@ -845,7 +845,7 @@
}
gboolean
-gkr_proto_decode_result_string_list_reply (GkrBuffer *buffer, GnomeKeyringResult *result,
+gkr_proto_decode_result_string_list_reply (EggBuffer *buffer, GnomeKeyringResult *result,
GList **list)
{
gsize offset;
@@ -857,11 +857,11 @@
offset = 4;
names = NULL;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &res)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &res)) {
return FALSE;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &list_size)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &list_size)) {
goto bail;
}
@@ -884,7 +884,7 @@
}
gboolean
-gkr_proto_decode_find_reply (GkrBuffer *buffer, GnomeKeyringResult *result,
+gkr_proto_decode_find_reply (EggBuffer *buffer, GnomeKeyringResult *result,
GList **list_out)
{
GList *list;
@@ -895,7 +895,7 @@
offset = 4;
*list_out = NULL;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &res)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &res)) {
return FALSE;
}
*result = res;
@@ -912,7 +912,7 @@
&found->keyring)) {
goto bail;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &found->item_id)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &found->item_id)) {
goto bail;
}
if (!gkr_proto_get_utf8_secret (buffer, offset, &offset,
@@ -934,7 +934,7 @@
}
gboolean
-gkr_proto_decode_find (GkrBuffer *buffer, GnomeKeyringItemType *type,
+gkr_proto_decode_find (EggBuffer *buffer, GnomeKeyringItemType *type,
GnomeKeyringAttributeList **attributes)
{
gsize offset;
@@ -949,7 +949,7 @@
}
offset = 8;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &t)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &t)) {
return FALSE;
}
*type = t;
@@ -957,7 +957,7 @@
}
gboolean
-gkr_proto_decode_op_string (GkrBuffer *buffer, GnomeKeyringOpCode *op_out,
+gkr_proto_decode_op_string (EggBuffer *buffer, GnomeKeyringOpCode *op_out,
char **str1)
{
gsize offset;
@@ -983,7 +983,7 @@
}
gboolean
-gkr_proto_decode_op_string_int (GkrBuffer *buffer, GnomeKeyringOpCode *op_out,
+gkr_proto_decode_op_string_int (EggBuffer *buffer, GnomeKeyringOpCode *op_out,
char **str1, guint32 *val)
{
gsize offset;
@@ -999,7 +999,7 @@
goto bail;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, val)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, val)) {
goto bail;
}
@@ -1013,7 +1013,7 @@
}
gboolean
-gkr_proto_decode_get_item_info (GkrBuffer *buffer, GnomeKeyringOpCode *op_out,
+gkr_proto_decode_get_item_info (EggBuffer *buffer, GnomeKeyringOpCode *op_out,
char **keyring, guint32 *item_id, guint32 *flags)
{
gsize offset = 8;
@@ -1022,11 +1022,11 @@
return FALSE;
if (!gkr_proto_get_utf8_string (buffer, offset, &offset, keyring))
goto bail;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, item_id))
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, item_id))
goto bail;
if (*op_out == GNOME_KEYRING_OP_GET_ITEM_INFO_FULL) {
/* Pull in lookup flags/parts, find out which ones */
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, flags))
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, flags))
goto bail;
} else {
/* All parts of the item by default */
@@ -1041,7 +1041,7 @@
}
gboolean
-gkr_proto_decode_op_string_secret (GkrBuffer *buffer, GnomeKeyringOpCode *op_out,
+gkr_proto_decode_op_string_secret (EggBuffer *buffer, GnomeKeyringOpCode *op_out,
char **str1, char **str2)
{
gsize offset;
@@ -1077,7 +1077,7 @@
}
gboolean
-gkr_proto_decode_op_string_secret_secret (GkrBuffer *buffer, GnomeKeyringOpCode *op_out,
+gkr_proto_decode_op_string_secret_secret (EggBuffer *buffer, GnomeKeyringOpCode *op_out,
char **str1, char **str2, char **str3)
{
gsize offset;
@@ -1124,14 +1124,14 @@
gboolean
-gkr_proto_decode_get_attributes_reply (GkrBuffer *buffer, GnomeKeyringResult *result,
+gkr_proto_decode_get_attributes_reply (EggBuffer *buffer, GnomeKeyringResult *result,
GnomeKeyringAttributeList **attributes)
{
gsize offset;
guint32 res;
offset = 4;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &res)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &res)) {
return FALSE;
}
*attributes = NULL;
@@ -1147,14 +1147,14 @@
}
gboolean
-gkr_proto_decode_get_acl_reply (GkrBuffer *buffer, GnomeKeyringResult *result,
+gkr_proto_decode_get_acl_reply (EggBuffer *buffer, GnomeKeyringResult *result,
GList **acl)
{
gsize offset;
guint32 res;
offset = 4;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &res)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &res)) {
return FALSE;
}
*acl = NULL;
@@ -1171,7 +1171,7 @@
gboolean
-gkr_proto_decode_get_item_info_reply (GkrBuffer *buffer, GnomeKeyringResult *result,
+gkr_proto_decode_get_item_info_reply (EggBuffer *buffer, GnomeKeyringResult *result,
GnomeKeyringItemInfo **info_out)
{
gsize offset;
@@ -1184,11 +1184,11 @@
info = NULL;
offset = 4;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &res)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &res)) {
return FALSE;
}
if (res == GNOME_KEYRING_RESULT_OK) {
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &type)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &type)) {
return FALSE;
}
if (!gkr_proto_get_utf8_string (buffer, offset, &offset, &name)) {
@@ -1201,12 +1201,12 @@
if (!gkr_proto_get_time (buffer, offset, &offset, &mtime)) {
g_free (name);
- gkr_secure_strfree (secret);
+ egg_secure_strfree (secret);
return FALSE;
}
if (!gkr_proto_get_time (buffer, offset, &offset, &ctime)) {
g_free (name);
- gkr_secure_strfree (secret);
+ egg_secure_strfree (secret);
return FALSE;
}
@@ -1225,7 +1225,7 @@
}
gboolean
-gkr_proto_decode_get_keyring_info_reply (GkrBuffer *buffer, GnomeKeyringResult *result,
+gkr_proto_decode_get_keyring_info_reply (EggBuffer *buffer, GnomeKeyringResult *result,
GnomeKeyringInfo **info_out)
{
gsize offset;
@@ -1237,15 +1237,15 @@
info = NULL;
offset = 4;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &res)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &res)) {
return FALSE;
}
if (res == GNOME_KEYRING_RESULT_OK) {
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset,
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset,
&lock_on_idle)) {
return FALSE;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset,
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset,
&lock_timeout)) {
return FALSE;
}
@@ -1255,7 +1255,7 @@
if (!gkr_proto_get_time (buffer, offset, &offset, &ctime)) {
return FALSE;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset,
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset,
&is_locked)) {
return FALSE;
}
@@ -1274,7 +1274,7 @@
}
gboolean
-gkr_proto_decode_set_item_info (GkrBuffer *buffer, char **keyring, guint32 *item_id,
+gkr_proto_decode_set_item_info (EggBuffer *buffer, char **keyring, guint32 *item_id,
GnomeKeyringItemType *type, char **display_name,
char **secret)
{
@@ -1296,10 +1296,10 @@
if (!gkr_proto_get_utf8_string (buffer, offset, &offset, keyring)) {
goto bail;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, item_id)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, item_id)) {
goto bail;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &typeint)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &typeint)) {
goto bail;
}
*type = typeint;
@@ -1316,12 +1316,12 @@
bail:
g_free (*keyring);
g_free (*display_name);
- gkr_secure_strfree (*secret);
+ egg_secure_strfree (*secret);
return FALSE;
}
gboolean
-gkr_proto_decode_set_keyring_info (GkrBuffer *buffer, char **keyring,
+gkr_proto_decode_set_keyring_info (EggBuffer *buffer, char **keyring,
gboolean *lock_on_idle, guint32 *lock_timeout)
{
@@ -1341,12 +1341,12 @@
if (!gkr_proto_get_utf8_string (buffer, offset, &offset, keyring)) {
goto bail;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &lock_int)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &lock_int)) {
goto bail;
}
*lock_on_idle = lock_int;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, lock_timeout)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, lock_timeout)) {
goto bail;
}
@@ -1358,7 +1358,7 @@
}
gboolean
-gkr_proto_decode_set_attributes (GkrBuffer *buffer, char **keyring,
+gkr_proto_decode_set_attributes (EggBuffer *buffer, char **keyring,
guint32 *item_id, GnomeKeyringAttributeList **attributes)
{
gsize offset;
@@ -1377,7 +1377,7 @@
if (!gkr_proto_get_utf8_string (buffer, offset, &offset, keyring)) {
goto bail;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, item_id)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, item_id)) {
goto bail;
}
@@ -1394,7 +1394,7 @@
gboolean
-gkr_proto_decode_set_acl (GkrBuffer *buffer, char **keyring, guint32 *item_id,
+gkr_proto_decode_set_acl (EggBuffer *buffer, char **keyring, guint32 *item_id,
GList **acl)
{
gsize offset;
@@ -1413,7 +1413,7 @@
if (!gkr_proto_get_utf8_string (buffer, offset, &offset, keyring)) {
goto bail;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, item_id)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, item_id)) {
goto bail;
}
@@ -1429,7 +1429,7 @@
}
gboolean
-gkr_proto_decode_prepare_environment (GkrBuffer *buffer, gchar ***environment)
+gkr_proto_decode_prepare_environment (EggBuffer *buffer, gchar ***environment)
{
GnomeKeyringOpCode op;
gsize offset;
@@ -1441,15 +1441,15 @@
offset = 8;
- if (!gkr_buffer_get_stringv (buffer, offset, &offset, environment,
- (GkrBufferAllocator)g_realloc))
+ if (!egg_buffer_get_stringv (buffer, offset, &offset, environment,
+ (EggBufferAllocator)g_realloc))
return FALSE;
return TRUE;
}
gboolean
-gkr_proto_decode_prepare_environment_reply (GkrBuffer *buffer, GnomeKeyringResult *result,
+gkr_proto_decode_prepare_environment_reply (EggBuffer *buffer, GnomeKeyringResult *result,
char ***environment)
{
gsize offset;
@@ -1457,12 +1457,12 @@
offset = 4;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &res))
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &res))
return FALSE;
*result = res;
if (res == GNOME_KEYRING_RESULT_OK) {
- if (!gkr_buffer_get_stringv (buffer, offset, &offset, environment, NULL))
+ if (!egg_buffer_get_stringv (buffer, offset, &offset, environment, NULL))
return FALSE;
}
@@ -1470,7 +1470,7 @@
}
gboolean
-gkr_proto_decode_result_int_list_reply (GkrBuffer *buffer, GnomeKeyringResult *result,
+gkr_proto_decode_result_int_list_reply (EggBuffer *buffer, GnomeKeyringResult *result,
GList **list)
{
gsize offset;
@@ -1480,17 +1480,17 @@
offset = 4;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &res)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &res)) {
return FALSE;
}
*result = res;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &len)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &len)) {
return FALSE;
}
for (i = 0; i < len; i++) {
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &id)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &id)) {
g_list_free (*list);
*list = NULL;
return FALSE;
@@ -1503,7 +1503,7 @@
}
gboolean
-gkr_proto_decode_result_integer_reply (GkrBuffer *buffer, GnomeKeyringResult *result,
+gkr_proto_decode_result_integer_reply (EggBuffer *buffer, GnomeKeyringResult *result,
guint32 *integer)
{
gsize offset;
@@ -1511,10 +1511,10 @@
offset = 4;
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &res)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &res)) {
return FALSE;
}
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &val)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &val)) {
return FALSE;
}
Modified: trunk/library/gnome-keyring-proto.h
==============================================================================
--- trunk/library/gnome-keyring-proto.h (original)
+++ trunk/library/gnome-keyring-proto.h Sat Jan 17 23:27:10 2009
@@ -28,7 +28,7 @@
#include "gnome-keyring.h"
#include "gnome-keyring-opcodes.h"
-#include "common/gkr-buffer.h"
+#include "egg/egg-buffer.h"
/* request:
uint32 package size
@@ -40,190 +40,190 @@
uint32 result
*/
-void gkr_proto_go_secure (GkrBuffer *buffer);
+void gkr_proto_go_secure (EggBuffer *buffer);
/* Core buffer ops */
-gboolean gkr_proto_get_bytes (GkrBuffer *buffer,
+gboolean gkr_proto_get_bytes (EggBuffer *buffer,
gsize offset,
gsize *next_offset,
guchar *out,
gsize n_bytes);
-void gkr_proto_add_time (GkrBuffer *buffer,
+void gkr_proto_add_time (EggBuffer *buffer,
time_t val);
-gboolean gkr_proto_get_time (GkrBuffer *buffer,
+gboolean gkr_proto_get_time (EggBuffer *buffer,
gsize offset,
gsize *next_offset,
time_t *time);
-gboolean gkr_proto_add_utf8_string (GkrBuffer *buffer,
+gboolean gkr_proto_add_utf8_string (EggBuffer *buffer,
const char *str);
-gboolean gkr_proto_add_utf8_secret (GkrBuffer *buffer,
+gboolean gkr_proto_add_utf8_secret (EggBuffer *buffer,
const char *str);
-gboolean gkr_proto_get_utf8_full (GkrBuffer *buffer,
+gboolean gkr_proto_get_utf8_full (EggBuffer *buffer,
gsize offset,
gsize *next_offset,
char **str_ret,
- GkrBufferAllocator allocator);
-gboolean gkr_proto_get_utf8_string (GkrBuffer *buffer,
+ EggBufferAllocator allocator);
+gboolean gkr_proto_get_utf8_string (EggBuffer *buffer,
gsize offset,
gsize *next_offset,
char **str_ret);
-gboolean gkr_proto_get_utf8_secret (GkrBuffer *buffer,
+gboolean gkr_proto_get_utf8_secret (EggBuffer *buffer,
gsize offset,
gsize *next_offset,
char **str_ret);
-gboolean gkr_proto_add_attribute_list (GkrBuffer *buffer,
+gboolean gkr_proto_add_attribute_list (EggBuffer *buffer,
GnomeKeyringAttributeList *attributes);
-gboolean gkr_proto_add_acl (GkrBuffer *buffer,
+gboolean gkr_proto_add_acl (EggBuffer *buffer,
GList *acl);
/* marshallers */
-gboolean gkr_proto_encode_op_only (GkrBuffer *buffer,
+gboolean gkr_proto_encode_op_only (EggBuffer *buffer,
GnomeKeyringOpCode op);
-gboolean gkr_proto_encode_op_string (GkrBuffer *buffer,
+gboolean gkr_proto_encode_op_string (EggBuffer *buffer,
GnomeKeyringOpCode op,
const char *str);
-gboolean gkr_proto_encode_op_string_int (GkrBuffer *buffer,
+gboolean gkr_proto_encode_op_string_int (EggBuffer *buffer,
GnomeKeyringOpCode op,
const char *str,
guint32 integer);
-gboolean gkr_proto_encode_op_string_int_int (GkrBuffer *buffer,
+gboolean gkr_proto_encode_op_string_int_int (EggBuffer *buffer,
GnomeKeyringOpCode op,
const char *str,
guint32 integer1,
guint32 integer2);
-gboolean gkr_proto_encode_op_string_secret (GkrBuffer *buffer,
+gboolean gkr_proto_encode_op_string_secret (EggBuffer *buffer,
GnomeKeyringOpCode op,
const char *str1,
const char *str2);
-gboolean gkr_proto_encode_op_string_secret_secret (GkrBuffer *buffer,
+gboolean gkr_proto_encode_op_string_secret_secret (EggBuffer *buffer,
GnomeKeyringOpCode op,
const char *str1,
const char *str2,
const char *str3);
-gboolean gkr_proto_encode_find (GkrBuffer *buffer,
+gboolean gkr_proto_encode_find (EggBuffer *buffer,
GnomeKeyringItemType type,
GnomeKeyringAttributeList *attributes);
-gboolean gkr_proto_encode_create_item (GkrBuffer *buffer,
+gboolean gkr_proto_encode_create_item (EggBuffer *buffer,
const char *keyring,
const char *display_name,
GnomeKeyringAttributeList *attributes,
const char *secret,
GnomeKeyringItemType type,
gboolean update_if_exists);
-gboolean gkr_proto_encode_set_attributes (GkrBuffer *buffer,
+gboolean gkr_proto_encode_set_attributes (EggBuffer *buffer,
const char *keyring,
guint32 id,
GnomeKeyringAttributeList *attributes);
-gboolean gkr_proto_encode_set_acl (GkrBuffer *buffer,
+gboolean gkr_proto_encode_set_acl (EggBuffer *buffer,
const char *keyring,
guint32 id,
GList *acl);
-gboolean gkr_proto_encode_set_item_info (GkrBuffer *buffer,
+gboolean gkr_proto_encode_set_item_info (EggBuffer *buffer,
const char *keyring,
guint32 id,
GnomeKeyringItemInfo *info);
-gboolean gkr_proto_encode_set_keyring_info (GkrBuffer *buffer,
+gboolean gkr_proto_encode_set_keyring_info (EggBuffer *buffer,
const char *keyring,
GnomeKeyringInfo *info);
-gboolean gkr_proto_encode_prepare_environment (GkrBuffer *buffer,
+gboolean gkr_proto_encode_prepare_environment (EggBuffer *buffer,
const gchar **environment);
/* demarshallers */
-gboolean gkr_proto_decode_packet_operation (GkrBuffer *buffer,
+gboolean gkr_proto_decode_packet_operation (EggBuffer *buffer,
GnomeKeyringOpCode *op);
-gboolean gkr_proto_decode_packet_size (GkrBuffer *buffer,
+gboolean gkr_proto_decode_packet_size (EggBuffer *buffer,
guint32 *size);
-gboolean gkr_proto_decode_attribute_list (GkrBuffer *buffer,
+gboolean gkr_proto_decode_attribute_list (EggBuffer *buffer,
gsize offset,
gsize *next_offset,
GnomeKeyringAttributeList **attributes_out);
-gboolean gkr_proto_decode_acl (GkrBuffer *buffer,
+gboolean gkr_proto_decode_acl (EggBuffer *buffer,
gsize offset,
gsize *next_offset,
GList **attributes_out);
-gboolean gkr_proto_decode_result_reply (GkrBuffer *buffer,
+gboolean gkr_proto_decode_result_reply (EggBuffer *buffer,
GnomeKeyringResult *result);
-gboolean gkr_proto_decode_result_string_reply (GkrBuffer *buffer,
+gboolean gkr_proto_decode_result_string_reply (EggBuffer *buffer,
GnomeKeyringResult *result,
char **str);
-gboolean gkr_proto_decode_result_string_list_reply (GkrBuffer *buffer,
+gboolean gkr_proto_decode_result_string_list_reply (EggBuffer *buffer,
GnomeKeyringResult *result,
GList **list);
-gboolean gkr_proto_decode_op_string (GkrBuffer *buffer,
+gboolean gkr_proto_decode_op_string (EggBuffer *buffer,
GnomeKeyringOpCode *op_out,
char **str_out);
-gboolean gkr_proto_decode_op_string_secret (GkrBuffer *buffer,
+gboolean gkr_proto_decode_op_string_secret (EggBuffer *buffer,
GnomeKeyringOpCode *op_out,
char **str1_out,
char **str2_out);
-gboolean gkr_proto_decode_op_string_secret_secret (GkrBuffer *buffer,
+gboolean gkr_proto_decode_op_string_secret_secret (EggBuffer *buffer,
GnomeKeyringOpCode *op_out,
char **str1_out,
char **str2_out,
char **str3_out);
-gboolean gkr_proto_decode_op_string_int (GkrBuffer *buffer,
+gboolean gkr_proto_decode_op_string_int (EggBuffer *buffer,
GnomeKeyringOpCode *op_out,
char **str1,
guint32 *val);
-gboolean gkr_proto_decode_get_item_info (GkrBuffer *buffer,
+gboolean gkr_proto_decode_get_item_info (EggBuffer *buffer,
GnomeKeyringOpCode *op_out,
char **keyring,
guint32 *item_id,
guint32 *flags);
-gboolean gkr_proto_decode_find (GkrBuffer *buffer,
+gboolean gkr_proto_decode_find (EggBuffer *buffer,
GnomeKeyringItemType *type,
GnomeKeyringAttributeList **attributes);
-gboolean gkr_proto_decode_find_reply (GkrBuffer *buffer,
+gboolean gkr_proto_decode_find_reply (EggBuffer *buffer,
GnomeKeyringResult *result,
GList **list_out);
-gboolean gkr_proto_decode_get_attributes_reply (GkrBuffer *buffer,
+gboolean gkr_proto_decode_get_attributes_reply (EggBuffer *buffer,
GnomeKeyringResult *result,
GnomeKeyringAttributeList **attributes);
-gboolean gkr_proto_decode_get_acl_reply (GkrBuffer *buffer,
+gboolean gkr_proto_decode_get_acl_reply (EggBuffer *buffer,
GnomeKeyringResult *result,
GList **acl);
-gboolean gkr_proto_decode_get_item_info_reply (GkrBuffer *buffer,
+gboolean gkr_proto_decode_get_item_info_reply (EggBuffer *buffer,
GnomeKeyringResult *result,
GnomeKeyringItemInfo **info);
-gboolean gkr_proto_decode_get_keyring_info_reply (GkrBuffer *buffer,
+gboolean gkr_proto_decode_get_keyring_info_reply (EggBuffer *buffer,
GnomeKeyringResult *result,
GnomeKeyringInfo **info);
-gboolean gkr_proto_decode_result_int_list_reply (GkrBuffer *buffer,
+gboolean gkr_proto_decode_result_int_list_reply (EggBuffer *buffer,
GnomeKeyringResult *result,
GList **list);
-gboolean gkr_proto_decode_result_integer_reply (GkrBuffer *buffer,
+gboolean gkr_proto_decode_result_integer_reply (EggBuffer *buffer,
GnomeKeyringResult *result,
guint32 *integer);
-gboolean gkr_proto_decode_create_item (GkrBuffer *packet,
+gboolean gkr_proto_decode_create_item (EggBuffer *packet,
char **keyring,
char **display_name,
GnomeKeyringAttributeList **attributes,
char **secret,
GnomeKeyringItemType *type_out,
gboolean *update_if_exists);
-gboolean gkr_proto_decode_set_item_info (GkrBuffer *buffer,
+gboolean gkr_proto_decode_set_item_info (EggBuffer *buffer,
char **keyring,
guint32 *item_id,
GnomeKeyringItemType *type,
char **display_name,
char **secret);
-gboolean gkr_proto_decode_set_keyring_info (GkrBuffer *buffer,
+gboolean gkr_proto_decode_set_keyring_info (EggBuffer *buffer,
char **keyring,
gboolean *lock_on_idle,
guint32 *lock_timeout);
-gboolean gkr_proto_decode_set_attributes (GkrBuffer *buffer,
+gboolean gkr_proto_decode_set_attributes (EggBuffer *buffer,
char **keyring,
guint32 *item_id,
GnomeKeyringAttributeList **attributes);
-gboolean gkr_proto_decode_set_acl (GkrBuffer *buffer,
+gboolean gkr_proto_decode_set_acl (EggBuffer *buffer,
char **keyring,
guint32 *item_id,
GList **acl);
-gboolean gkr_proto_decode_prepare_environment (GkrBuffer *buffer,
+gboolean gkr_proto_decode_prepare_environment (EggBuffer *buffer,
char ***environment);
-gboolean gkr_proto_decode_prepare_environment_reply (GkrBuffer *buffer,
+gboolean gkr_proto_decode_prepare_environment_reply (EggBuffer *buffer,
GnomeKeyringResult *res,
char ***environment);
Modified: trunk/library/gnome-keyring-socket.c
==============================================================================
--- trunk/library/gnome-keyring-socket.c (original)
+++ trunk/library/gnome-keyring-socket.c Sat Jan 17 23:27:10 2009
@@ -220,11 +220,11 @@
}
gboolean
-gnome_keyring_socket_read_buffer (int fd, GkrBuffer *buffer)
+gnome_keyring_socket_read_buffer (int fd, EggBuffer *buffer)
{
guint32 packet_size;
- gkr_buffer_resize (buffer, 4);
+ egg_buffer_resize (buffer, 4);
if (gnome_keyring_socket_read_all (fd, buffer->buf, 4) < 0)
return FALSE;
@@ -232,7 +232,7 @@
packet_size < 4)
return FALSE;
- gkr_buffer_resize (buffer, packet_size);
+ egg_buffer_resize (buffer, packet_size);
if (gnome_keyring_socket_read_all (fd, buffer->buf + 4, packet_size - 4) < 0)
return FALSE;
@@ -240,7 +240,7 @@
}
gboolean
-gnome_keyring_socket_write_buffer (int fd, GkrBuffer *buffer)
+gnome_keyring_socket_write_buffer (int fd, EggBuffer *buffer)
{
return gnome_keyring_socket_write_all (fd, buffer->buf, buffer->len) >= 0;
}
Modified: trunk/library/gnome-keyring-utils.c
==============================================================================
--- trunk/library/gnome-keyring-utils.c (original)
+++ trunk/library/gnome-keyring-utils.c Sat Jan 17 23:27:10 2009
@@ -30,7 +30,7 @@
#include "gnome-keyring-private.h"
#include "gnome-keyring-memory.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
/* Functions used by both the library and the daemon */
@@ -109,7 +109,7 @@
void
gnome_keyring_free_password (gchar *password)
{
- gkr_secure_strfree (password);
+ egg_secure_strfree (password);
}
/**
@@ -402,7 +402,7 @@
memcpy (copy, item_info, sizeof (GnomeKeyringItemInfo));
copy->display_name = g_strdup (copy->display_name);
- copy->secret = gkr_secure_strdup (copy->secret);
+ copy->secret = egg_secure_strdup (copy->secret);
return copy;
}
Modified: trunk/library/gnome-keyring.c
==============================================================================
--- trunk/library/gnome-keyring.c (original)
+++ trunk/library/gnome-keyring.c Sat Jan 17 23:27:10 2009
@@ -30,8 +30,8 @@
#include "gnome-keyring-private.h"
#include "gnome-keyring-proto.h"
-#include "common/gkr-buffer.h"
-#include "common/gkr-unix-credentials.h"
+#include "egg/egg-buffer.h"
+#include "egg/egg-unix-credentials.h"
#include <time.h>
#include <unistd.h>
@@ -64,8 +64,8 @@
typedef struct GnomeKeyringOperation GnomeKeyringOperation;
-#define NORMAL_ALLOCATOR ((GkrBufferAllocator)g_realloc)
-#define SECURE_ALLOCATOR ((GkrBufferAllocator)gnome_keyring_memory_realloc)
+#define NORMAL_ALLOCATOR ((EggBufferAllocator)g_realloc)
+#define SECURE_ALLOCATOR ((EggBufferAllocator)gnome_keyring_memory_realloc)
typedef gboolean (*KeyringHandleReply) (GnomeKeyringOperation *op);
@@ -78,10 +78,10 @@
guint io_watch;
guint idle_watch;
- GkrBuffer send_buffer;
+ EggBuffer send_buffer;
gsize send_pos;
- GkrBuffer receive_buffer;
+ EggBuffer receive_buffer;
gsize receive_pos;
KeyringCallbackType user_callback_type;
@@ -109,8 +109,8 @@
(*op->destroy_user_data) (op->user_data);
if (op->destroy_reply_data != NULL && op->reply_data != NULL)
(*op->destroy_reply_data) (op->reply_data);
- gkr_buffer_uninit (&op->send_buffer);
- gkr_buffer_uninit (&op->receive_buffer);
+ egg_buffer_uninit (&op->send_buffer);
+ egg_buffer_uninit (&op->receive_buffer);
shutdown (op->socket, SHUT_RDWR);
close (op->socket);
@@ -177,7 +177,7 @@
static GnomeKeyringResult
write_credentials_byte_sync (int socket)
{
- if (gkr_unix_credentials_write (socket) < 0)
+ if (egg_unix_credentials_write (socket) < 0)
return GNOME_KEYRING_RESULT_IO_ERROR;
return GNOME_KEYRING_RESULT_OK;
}
@@ -185,7 +185,7 @@
static void
write_credentials_byte (GnomeKeyringOperation *op)
{
- if (gkr_unix_credentials_write (op->socket) < 0) {
+ if (egg_unix_credentials_write (op->socket) < 0) {
if (errno == EAGAIN)
return;
schedule_op_failed (op, GNOME_KEYRING_RESULT_IO_ERROR);
@@ -228,7 +228,7 @@
if (op->send_pos == op->send_buffer.len) {
op->state = STATE_READING_REPLY;
- gkr_buffer_reset (&op->receive_buffer);
+ egg_buffer_reset (&op->receive_buffer);
op->receive_pos = 0;
g_source_remove (op->io_watch);
@@ -243,7 +243,7 @@
if (op->state == STATE_READING_REPLY && (cond & G_IO_IN)) {
if (op->receive_pos < 4) {
- gkr_buffer_resize (&op->receive_buffer, 4);
+ egg_buffer_resize (&op->receive_buffer, 4);
res = read (op->socket,
op->receive_buffer.buf + op->receive_pos,
4 - op->receive_pos);
@@ -264,7 +264,7 @@
}
g_assert (op->receive_pos <= packet_size);
- gkr_buffer_resize (&op->receive_buffer, packet_size);
+ egg_buffer_resize (&op->receive_buffer, packet_size);
res = read (op->socket, op->receive_buffer.buf + op->receive_pos,
packet_size - op->receive_pos);
@@ -314,8 +314,8 @@
op->destroy_user_data = destroy_user_data;
op->socket = -1;
- gkr_buffer_init_full (&op->send_buffer, 128, NORMAL_ALLOCATOR);
- gkr_buffer_init_full (&op->receive_buffer, 128,
+ egg_buffer_init_full (&op->send_buffer, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&op->receive_buffer, 128,
receive_secure ? SECURE_ALLOCATOR : NORMAL_ALLOCATOR);
return op;
@@ -345,7 +345,7 @@
} else {
op->state = STATE_WRITING_CREDS;
- gkr_buffer_reset (&op->receive_buffer);
+ egg_buffer_reset (&op->receive_buffer);
op->send_pos = 0;
channel = g_io_channel_unix_new (op->socket);
@@ -357,8 +357,8 @@
}
static GnomeKeyringResult
-run_sync_operation (GkrBuffer *buffer,
- GkrBuffer *receive_buffer)
+run_sync_operation (EggBuffer *buffer,
+ EggBuffer *receive_buffer)
{
GnomeKeyringResult res;
int socket;
@@ -535,30 +535,30 @@
GnomeKeyringResult
gnome_keyring_set_default_keyring_sync (const char *keyring)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
if (!gkr_proto_encode_op_string (&send, GNOME_KEYRING_OP_SET_DEFAULT_KEYRING,
keyring)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_result_reply (&receive, &res)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -610,32 +610,32 @@
GnomeKeyringResult
gnome_keyring_get_default_keyring_sync (char **keyring)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
*keyring = NULL;
if (!gkr_proto_encode_op_only (&send, GNOME_KEYRING_OP_GET_DEFAULT_KEYRING)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_result_string_reply (&receive, &res, keyring)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -711,32 +711,32 @@
GnomeKeyringResult
gnome_keyring_list_keyring_names_sync (GList **keyrings)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
*keyrings = NULL;
if (!gkr_proto_encode_op_only (&send, GNOME_KEYRING_OP_LIST_KEYRINGS)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_result_string_list_reply (&receive, &res, keyrings)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -785,29 +785,29 @@
GnomeKeyringResult
gnome_keyring_lock_all_sync (void)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
if (!gkr_proto_encode_op_only (&send, GNOME_KEYRING_OP_LOCK_ALL)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_result_reply (&receive, &res)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -868,30 +868,30 @@
gnome_keyring_create_sync (const char *keyring_name,
const char *password)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, SECURE_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, SECURE_ALLOCATOR);
if (!gkr_proto_encode_op_string_secret (&send, GNOME_KEYRING_OP_CREATE_KEYRING,
keyring_name, password)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_result_reply (&receive, &res)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -958,31 +958,31 @@
gnome_keyring_unlock_sync (const char *keyring,
const char *password)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
/* Use secure non-pageable buffer */
- gkr_buffer_init_full (&send, 128, SECURE_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, SECURE_ALLOCATOR);
if (!gkr_proto_encode_op_string_secret (&send, GNOME_KEYRING_OP_UNLOCK_KEYRING,
keyring, password)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_result_reply (&receive, &res)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -1042,30 +1042,30 @@
GnomeKeyringResult
gnome_keyring_lock_sync (const char *keyring)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
if (!gkr_proto_encode_op_string (&send, GNOME_KEYRING_OP_LOCK_KEYRING,
keyring)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_result_reply (&receive, &res)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -1119,30 +1119,30 @@
GnomeKeyringResult
gnome_keyring_delete_sync (const char *keyring)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
if (!gkr_proto_encode_op_string (&send, GNOME_KEYRING_OP_DELETE_KEYRING,
keyring)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_result_reply (&receive, &res)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -1209,31 +1209,31 @@
gnome_keyring_change_password_sync (const char *keyring_name,
const char *original, const char *password)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, SECURE_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, SECURE_ALLOCATOR);
if (!gkr_proto_encode_op_string_secret_secret (&send,
GNOME_KEYRING_OP_CHANGE_KEYRING_PASSWORD,
keyring_name, original, password)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_result_reply (&receive, &res)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -1311,33 +1311,33 @@
gnome_keyring_get_info_sync (const char *keyring,
GnomeKeyringInfo **info)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
*info = NULL;
if (!gkr_proto_encode_op_string (&send, GNOME_KEYRING_OP_GET_KEYRING_INFO,
keyring)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_get_keyring_info_reply (&receive, &res, info)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -1394,20 +1394,20 @@
gnome_keyring_set_info_sync (const char *keyring,
GnomeKeyringInfo *info)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
if (!gkr_proto_encode_set_keyring_info (&send, keyring, info)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&send);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -1490,33 +1490,33 @@
gnome_keyring_list_item_ids_sync (const char *keyring,
GList **ids)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
*ids = NULL;
if (!gkr_proto_encode_op_string (&send, GNOME_KEYRING_OP_LIST_ITEMS,
keyring)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_result_int_list_reply (&receive, &res, ids)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -1530,30 +1530,30 @@
GnomeKeyringResult
gnome_keyring_daemon_set_display_sync (const char *display)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
if (!gkr_proto_encode_op_string (&send, GNOME_KEYRING_OP_SET_DAEMON_DISPLAY,
display)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_result_reply (&receive, &res)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -1576,12 +1576,12 @@
GnomeKeyringResult
gnome_keyring_daemon_prepare_environment_sync (void)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
gchar **envp;
gboolean ret;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
/* Get all the environment names */
envp = gnome_keyring_build_environment (GNOME_KEYRING_IN_ENVIRONMENT);
@@ -1589,23 +1589,23 @@
g_strfreev (envp);
if (!ret) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_prepare_environment_reply (&receive, &res, &envp)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
if (res == GNOME_KEYRING_RESULT_OK) {
g_return_val_if_fail (envp, GNOME_KEYRING_RESULT_IO_ERROR);
@@ -1902,33 +1902,33 @@
GnomeKeyringAttributeList *attributes,
GList **found)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
*found = NULL;
if (!gkr_proto_encode_find (&send, type, attributes)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
/* Use a secure receive buffer */
- gkr_buffer_init_full (&receive, 128, SECURE_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, SECURE_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_find_reply (&receive, &res, found)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -2075,34 +2075,34 @@
gboolean update_if_exists,
guint32 *item_id)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
/* Use a secure buffer */
- gkr_buffer_init_full (&send, 128, SECURE_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, SECURE_ALLOCATOR);
*item_id = 0;
if (!gkr_proto_encode_create_item (&send, keyring, display_name, attributes,
secret, type, update_if_exists)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_result_integer_reply (&receive, &res, item_id)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -2164,21 +2164,21 @@
gnome_keyring_item_delete_sync (const char *keyring,
guint32 id)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
if (!gkr_proto_encode_op_string_int (&send, GNOME_KEYRING_OP_DELETE_ITEM,
keyring, id)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&send);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -2269,34 +2269,34 @@
guint32 id,
GnomeKeyringItemInfo **info)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
*info = NULL;
if (!gkr_proto_encode_op_string_int (&send, GNOME_KEYRING_OP_GET_ITEM_INFO,
keyring, id)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
/* Use a secure buffer */
- gkr_buffer_init_full (&receive, 128, SECURE_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, SECURE_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_get_item_info_reply (&receive, &res, info)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -2376,34 +2376,34 @@
guint32 flags,
GnomeKeyringItemInfo **info)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
*info = NULL;
if (!gkr_proto_encode_op_string_int_int (&send, GNOME_KEYRING_OP_GET_ITEM_INFO_FULL,
keyring, id, flags)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
/* Use a secure buffer */
- gkr_buffer_init_full (&receive, 128, SECURE_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, SECURE_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_get_item_info_reply (&receive, &res, info)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -2469,21 +2469,21 @@
guint32 id,
GnomeKeyringItemInfo *info)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
/* Use a secure memory buffer */
- gkr_buffer_init_full (&send, 128, SECURE_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, SECURE_ALLOCATOR);
if (!gkr_proto_encode_set_item_info (&send, keyring, id, info)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&send);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -2587,33 +2587,33 @@
guint32 id,
GnomeKeyringAttributeList **attributes)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
*attributes = NULL;
if (!gkr_proto_encode_op_string_int (&send, GNOME_KEYRING_OP_GET_ITEM_ATTRIBUTES,
keyring, id)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_get_attributes_reply (&receive, &res, attributes)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -2675,20 +2675,20 @@
guint32 id,
GnomeKeyringAttributeList *attributes)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
if (!gkr_proto_encode_set_attributes (&send, keyring, id, attributes)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&send);
+ egg_buffer_uninit (&receive);
return res;
@@ -2754,33 +2754,33 @@
guint32 id,
GList **acl)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
*acl = NULL;
if (!gkr_proto_encode_op_string_int (&send, GNOME_KEYRING_OP_GET_ITEM_ACL,
keyring, id)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
if (res != GNOME_KEYRING_RESULT_OK) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
if (!gkr_proto_decode_get_acl_reply (&receive, &res, acl)) {
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return GNOME_KEYRING_RESULT_IO_ERROR;
}
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -2841,20 +2841,20 @@
guint32 id,
GList *acl)
{
- GkrBuffer send, receive;
+ EggBuffer send, receive;
GnomeKeyringResult res;
- gkr_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&send, 128, NORMAL_ALLOCATOR);
if (!gkr_proto_encode_set_acl (&send, keyring, id, acl)) {
- gkr_buffer_uninit (&send);
+ egg_buffer_uninit (&send);
return GNOME_KEYRING_RESULT_BAD_ARGUMENTS;
}
- gkr_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
+ egg_buffer_init_full (&receive, 128, NORMAL_ALLOCATOR);
res = run_sync_operation (&send, &receive);
- gkr_buffer_uninit (&send);
- gkr_buffer_uninit (&receive);
+ egg_buffer_uninit (&send);
+ egg_buffer_uninit (&receive);
return res;
}
@@ -2900,7 +2900,7 @@
start_operation (op);
/* Append our ACL to the list */
- gkr_buffer_reset (&op->send_buffer);
+ egg_buffer_reset (&op->send_buffer);
acl = g_list_append (acl, &gar->acl);
ret = gkr_proto_encode_set_acl (&op->send_buffer, gar->keyring_name,
gar->id, acl);
@@ -4071,7 +4071,7 @@
/* Reset the operation into a delete */
start_operation (op);
- gkr_buffer_reset (&op->send_buffer);
+ egg_buffer_reset (&op->send_buffer);
if (!gkr_proto_encode_op_string_int (&op->send_buffer, GNOME_KEYRING_OP_DELETE_ITEM,
f->keyring, f->item_id)) {
/*
Modified: trunk/library/tests/Makefile.am
==============================================================================
--- trunk/library/tests/Makefile.am (original)
+++ trunk/library/tests/Makefile.am Sat Jan 17 23:27:10 2009
@@ -11,6 +11,7 @@
unit-test-daemon-setup.c
UNIT_LIBS = \
+ $(top_builddir)/egg/libegg.la \
$(top_builddir)/library/libgnome-keyring.la
UNIT_FLAGS = \
Modified: trunk/pam/Makefile.am
==============================================================================
--- trunk/pam/Makefile.am (original)
+++ trunk/pam/Makefile.am Sat Jan 17 23:27:10 2009
@@ -13,9 +13,9 @@
gkr-pam-stubs.c
pam_gnome_keyring_la_LIBADD = \
- $(top_builddir)/common/libgkr-common-buffer.la \
- $(top_builddir)/common/libgkr-common-creds.la \
- $(top_builddir)/common/libgkr-common-secure.la \
+ $(top_builddir)/egg/libegg-buffer.la \
+ $(top_builddir)/egg/libegg-creds.la \
+ $(top_builddir)/egg/libegg-secure.la \
-lpam
pam_gnome_keyring_la_LDFLAGS = \
Modified: trunk/pam/gkr-pam-client.c
==============================================================================
--- trunk/pam/gkr-pam-client.c (original)
+++ trunk/pam/gkr-pam-client.c Sat Jan 17 23:27:10 2009
@@ -25,8 +25,8 @@
#include "gkr-pam.h"
-#include "common/gkr-buffer.h"
-#include "common/gkr-unix-credentials.h"
+#include "egg/egg-buffer.h"
+#include "egg/egg-unix-credentials.h"
#include <sys/types.h>
#include <sys/socket.h>
@@ -128,7 +128,7 @@
write_credentials_byte (int sock)
{
for (;;) {
- if (gkr_unix_credentials_write (sock) < 0) {
+ if (egg_unix_credentials_write (sock) < 0) {
if (errno == EINTR || errno == EAGAIN)
continue;
syslog (GKR_LOG_ERR, "couldn't send credentials to daemon: %s",
@@ -288,9 +288,9 @@
}
/* Send the application packet / name */
- gkr_buffer_encode_uint32 (buf, PAM_APP_NAME_LEN + 8);
+ egg_buffer_encode_uint32 (buf, PAM_APP_NAME_LEN + 8);
write_part (sock, buf, 4, &ret);
- gkr_buffer_encode_uint32 (buf, PAM_APP_NAME_LEN);
+ egg_buffer_encode_uint32 (buf, PAM_APP_NAME_LEN);
write_part (sock, buf, 4, &ret);
write_part (sock, (unsigned char*)PAM_APP_NAME, PAM_APP_NAME_LEN, &ret);
@@ -300,9 +300,9 @@
oplen += 4 + strlen (argv[i]);
/* Write out the length, and op */
- gkr_buffer_encode_uint32 (buf, oplen);
+ egg_buffer_encode_uint32 (buf, oplen);
write_part (sock, buf, 4, &ret);
- gkr_buffer_encode_uint32 (buf, op);
+ egg_buffer_encode_uint32 (buf, op);
write_part (sock, buf, 4, &ret);
/* And now the arguments */
@@ -311,7 +311,7 @@
l = 0x7FFFFFFF;
else
l = strlen (argv[i]);
- gkr_buffer_encode_uint32 (buf, l);
+ egg_buffer_encode_uint32 (buf, l);
write_part (sock, buf, 4, &ret);
if (argv[i] != NULL)
write_part (sock, (unsigned char*)argv[i], l, &ret);
@@ -327,7 +327,7 @@
}
/* We only support simple responses */
- l = gkr_buffer_decode_uint32 (buf);
+ l = egg_buffer_decode_uint32 (buf);
if (l != 8) {
syslog (GKR_LOG_ERR, "invalid length response from gnome-keyring-daemon: %d", l);
ret = GNOME_KEYRING_RESULT_IO_ERROR;
@@ -338,7 +338,7 @@
ret = GNOME_KEYRING_RESULT_IO_ERROR;
goto done;
}
- ret = gkr_buffer_decode_uint32 (buf);
+ ret = egg_buffer_decode_uint32 (buf);
done:
if (sock >= 0)
Modified: trunk/pam/gkr-pam-stubs.c
==============================================================================
--- trunk/pam/gkr-pam-stubs.c (original)
+++ trunk/pam/gkr-pam-stubs.c Sat Jan 17 23:27:10 2009
@@ -21,7 +21,7 @@
Author: Stef Walter <stef memberwebs com>
*/
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include <stdlib.h>
@@ -31,19 +31,19 @@
*/
void
-gkr_memory_lock (void)
+egg_memory_lock (void)
{
/* No threads in PAM, no locking */
}
void
-gkr_memory_unlock (void)
+egg_memory_unlock (void)
{
/* No threads in PAM, no locking */
}
void*
-gkr_memory_fallback (void *p, unsigned long sz)
+egg_memory_fallback (void *p, unsigned long sz)
{
/* Handles allocation, reallocation and freeing */
return realloc (p, sz);
Modified: trunk/pkcs11/gck/gck-certificate.c
==============================================================================
--- trunk/pkcs11/gck/gck-certificate.c (original)
+++ trunk/pkcs11/gck/gck-certificate.c Sat Jan 17 23:27:10 2009
@@ -105,7 +105,7 @@
/* See if it's the same */
name = g_strdup_printf ("tbsCertificate.extensions.?%u.extnID", index);
- exoid = gck_data_asn1_read_oid (self->pv->asn1, name);
+ exoid = egg_asn1_read_oid (self->pv->asn1, name);
g_free (name);
if(exoid == oid)
@@ -165,7 +165,7 @@
case CKA_START_DATE:
case CKA_END_DATE:
g_return_val_if_fail (self->pv->asn1, CKR_GENERAL_ERROR);
- if (!gck_data_asn1_read_time (self->pv->asn1,
+ if (!egg_asn1_read_time (self->pv->asn1,
attr->type == CKA_START_DATE ?
"tbsCertificate.validity.notBefore" :
"tbsCertificate.validity.notAfter",
@@ -175,7 +175,7 @@
case CKA_SUBJECT:
g_return_val_if_fail (self->pv->asn1, CKR_GENERAL_ERROR);
- cdata = gck_data_asn1_read_element (self->pv->asn1, self->pv->data, self->pv->n_data,
+ cdata = egg_asn1_read_element (self->pv->asn1, self->pv->data, self->pv->n_data,
"tbsCertificate.subject", &n_data);
g_return_val_if_fail (cdata, CKR_GENERAL_ERROR);
return gck_attribute_set_data (attr, cdata, n_data);
@@ -186,14 +186,14 @@
case CKA_ISSUER:
g_return_val_if_fail (self->pv->asn1, CKR_GENERAL_ERROR);
- cdata = gck_data_asn1_read_element (self->pv->asn1, self->pv->data, self->pv->n_data,
+ cdata = egg_asn1_read_element (self->pv->asn1, self->pv->data, self->pv->n_data,
"tbsCertificate.issuer", &n_data);
g_return_val_if_fail (cdata, CKR_GENERAL_ERROR);
return gck_attribute_set_data (attr, cdata, n_data);
case CKA_SERIAL_NUMBER:
g_return_val_if_fail (self->pv->asn1, CKR_GENERAL_ERROR);
- cdata = gck_data_asn1_read_element (self->pv->asn1, self->pv->data, self->pv->n_data,
+ cdata = egg_asn1_read_element (self->pv->asn1, self->pv->data, self->pv->n_data,
"tbsCertificate.serialNumber", &n_data);
g_return_val_if_fail (cdata, CKR_GENERAL_ERROR);
return gck_attribute_set_data (attr, cdata, n_data);
@@ -347,7 +347,7 @@
}
/* Generate a raw public key from our certificate */
- keydata = gck_data_asn1_encode (asn1, "tbsCertificate.subjectPublicKeyInfo", &n_keydata, NULL);
+ keydata = egg_asn1_encode (asn1, "tbsCertificate.subjectPublicKeyInfo", &n_keydata, NULL);
g_return_val_if_fail (keydata, FALSE);
/* Now create us a nice public key with that identifier */
@@ -476,7 +476,7 @@
/* Read the critical status */
if (critical) {
name = g_strdup_printf ("tbsCertificate.extensions.?%u.critical", index);
- val = gck_data_asn1_read_value (self->pv->asn1, name, &n_val, NULL);
+ val = egg_asn1_read_value (self->pv->asn1, name, &n_val, NULL);
g_free (name);
if (!val || n_val < 1 || val[0] != 'T')
@@ -488,7 +488,7 @@
/* And the extension value */
name = g_strdup_printf ("tbsCertificate.extensions.?%u.extnValue", index);
- result = gck_data_asn1_read_content (self->pv->asn1, self->pv->data, self->pv->n_data,
+ result = egg_asn1_read_content (self->pv->asn1, self->pv->data, self->pv->n_data,
name, n_extension);
g_free (name);
@@ -506,11 +506,11 @@
g_return_val_if_fail (self->pv->asn1, "");
/* Look for the CN in the certificate */
- label = gck_data_asn1_read_dn_part (self->pv->asn1, "tbsCertificate.subject.rdnSequence", "cn");
+ label = egg_asn1_read_dn_part (self->pv->asn1, "tbsCertificate.subject.rdnSequence", "cn");
/* Otherwise use the full DN */
if (!label)
- label = gck_data_asn1_read_dn (self->pv->asn1, "tbsCertificate.subject.rdnSequence");
+ label = egg_asn1_read_dn (self->pv->asn1, "tbsCertificate.subject.rdnSequence");
if (!label)
label = g_strdup (_("Unnamed Certificate"));
Modified: trunk/pkcs11/gck/gck-crypto.c
==============================================================================
--- trunk/pkcs11/gck/gck-crypto.c (original)
+++ trunk/pkcs11/gck/gck-crypto.c Sat Jan 17 23:27:10 2009
@@ -23,7 +23,7 @@
#include "gck-crypto.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
/* ----------------------------------------------------------------------------
* INTERNAL
@@ -1569,10 +1569,10 @@
gcry_set_outofcore_handler (no_mem_handler, NULL);
gcry_set_fatalerror_handler (fatal_handler, NULL);
gcry_set_allocation_handler ((gcry_handler_alloc_t)g_malloc,
- (gcry_handler_alloc_t)gkr_secure_alloc,
- gkr_secure_check,
- (gcry_handler_realloc_t)gkr_secure_realloc,
- gkr_secure_free);
+ (gcry_handler_alloc_t)egg_secure_alloc,
+ egg_secure_check,
+ (gcry_handler_realloc_t)egg_secure_realloc,
+ egg_secure_free);
gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
}
Modified: trunk/pkcs11/gck/gck-data-asn1.c
==============================================================================
--- trunk/pkcs11/gck/gck-data-asn1.c (original)
+++ trunk/pkcs11/gck/gck-data-asn1.c Sat Jan 17 23:27:10 2009
@@ -25,340 +25,6 @@
#include "gck-data-asn1.h"
-#include "common/gkr-buffer.h"
-
-#include <libtasn1.h>
-
-/*
- * HACK: asn1Parser defines these arrays as extern const, which gives
- * gcc a fit. So we def it out.
- */
-
-#define extern
-#include "asn1-def-pk.h"
-#include "asn1-def-pkix.h"
-#undef extern
-
-static ASN1_TYPE asn1_pk = NULL;
-static ASN1_TYPE asn1_pkix = NULL;
-
-static void
-init_asn1_trees (void)
-{
- static gsize asn1_initialized = 0;
- int res;
-
- if (g_once_init_enter (&asn1_initialized)) {
- res = asn1_array2tree (pk_asn1_tab, &asn1_pk, NULL);
- g_return_if_fail (res == ASN1_SUCCESS);
- res = asn1_array2tree (pkix_asn1_tab, &asn1_pkix, NULL);
- g_return_if_fail (res == ASN1_SUCCESS);
- g_once_init_leave (&asn1_initialized, 1);
- }
-}
-
-ASN1_TYPE
-gck_data_asn1_get_pk_asn1type (void)
-{
- init_asn1_trees ();
- return asn1_pk;
-}
-
-ASN1_TYPE
-gck_data_asn1_get_pkix_asn1type (void)
-{
- init_asn1_trees ();
- return asn1_pkix;
-}
-
-ASN1_TYPE
-gck_data_asn1_decode (const gchar *type, const guchar *data, gsize n_data)
-{
- ASN1_TYPE base = ASN1_TYPE_EMPTY;
- ASN1_TYPE asn;
- int res;
-
- if (strncmp (type, "PKIX1.", 6) == 0)
- base = gck_data_asn1_get_pkix_asn1type ();
- else if (strncmp (type, "PK.", 3) == 0)
- base = gck_data_asn1_get_pk_asn1type ();
- else
- g_return_val_if_reached (NULL);
-
- res = asn1_create_element (base, type, &asn);
- g_return_val_if_fail (res == ASN1_SUCCESS, NULL);
-
- res = asn1_der_decoding (&asn, data, n_data, NULL);
- if (res != ASN1_SUCCESS) {
- asn1_delete_structure (&asn);
- return NULL;
- }
-
- return asn;
-}
-
-guchar*
-gck_data_asn1_encode (ASN1_TYPE asn, const gchar* part, gsize *n_data,
- GkrBufferAllocator alloc)
-{
- guchar *data;
- int res, len;
-
- g_assert (asn);
- g_assert (n_data);
-
- len = 0;
- res = asn1_der_coding (asn, part, NULL, &len, NULL);
- g_return_val_if_fail (res == ASN1_MEM_ERROR, NULL);
-
- if (!alloc)
- alloc = (GkrBufferAllocator)g_realloc;
-
- data = (alloc) (NULL, len);
- g_return_val_if_fail (data != NULL, NULL);
-
- res = asn1_der_coding (asn, part, data, &len, NULL);
- if (res != ASN1_SUCCESS) {
- (alloc) (data, 0);
- return NULL;
- }
-
- *n_data = len;
- return data;
-}
-
-gint
-gck_data_asn1_element_length (const guchar *data, gsize n_data)
-{
- guchar cls;
- int counter = 0;
- int cb, len;
- gulong tag;
-
- if (asn1_get_tag_der (data, n_data, &cls, &cb, &tag) == ASN1_SUCCESS) {
- counter += cb;
- len = asn1_get_length_der (data + cb, n_data - cb, &cb);
- counter += cb;
- if (len >= 0) {
- len += counter;
- if (n_data >= len)
- return len;
- }
- }
-
- return -1;
-}
-
-const guchar*
-gck_data_asn1_read_element (ASN1_TYPE asn, const guchar *data, gsize n_data,
- const gchar *part, gsize *n_element)
-{
- int beg, end, res;
-
- g_return_val_if_fail (asn != NULL, NULL);
- g_return_val_if_fail (part != NULL, NULL);
- g_return_val_if_fail (data != NULL, NULL);
- g_return_val_if_fail (n_element != NULL, NULL);
-
- res = asn1_der_decoding_startEnd (asn, data, n_data, part, &beg, &end);
- if (res != ASN1_SUCCESS)
- return NULL;
-
- *n_element = end - beg + 1;
- return data + beg;
-}
-
-const guchar*
-gck_data_asn1_read_content (ASN1_TYPE asn, const guchar *data, gsize n_data,
- const gchar *part, gsize *n_content)
-{
- const guchar *raw;
- gsize n_raw;
-
- g_return_val_if_fail (asn != NULL, NULL);
- g_return_val_if_fail (part != NULL, NULL);
- g_return_val_if_fail (data != NULL, NULL);
- g_return_val_if_fail (n_content != NULL, NULL);
-
- raw = gck_data_asn1_read_element (asn, data, n_data, part, &n_raw);
- if (!raw)
- return NULL;
-
- return gck_data_asn1_element_content (raw, n_raw, n_content);
-}
-
-const guchar*
-gck_data_asn1_element_content (const guchar *data, gsize n_data, gsize *n_content)
-{
- int counter = 0;
- guchar cls;
- gulong tag;
- int cb, len;
-
- g_return_val_if_fail (data != NULL, NULL);
- g_return_val_if_fail (n_content != NULL, NULL);
-
- /* Now get the data out of this element */
- if (asn1_get_tag_der (data, n_data, &cls, &cb, &tag) != ASN1_SUCCESS)
- return NULL;
-
- counter += cb;
- len = asn1_get_length_der (data + cb, n_data - cb, &cb);
- if (len < 0)
- return NULL;
- counter += cb;
-
- *n_content = len;
- return data + counter;
-}
-
-guchar*
-gck_data_asn1_read_value (ASN1_TYPE asn, const gchar *part, gsize *len,
- GkrBufferAllocator allocator)
-{
- int l, res;
- guchar *buf;
-
- g_return_val_if_fail (asn != NULL, NULL);
- g_return_val_if_fail (part != NULL, NULL);
-
- if (allocator == NULL)
- allocator = (GkrBufferAllocator)g_realloc;
-
- l = 0;
- res = asn1_read_value (asn, part, NULL, &l);
- g_return_val_if_fail (res != ASN1_SUCCESS, NULL);
- if (res != ASN1_MEM_ERROR)
- return NULL;
-
- /* Always null terminate it, just for convenience */
- buf = (allocator) (NULL, l + 1);
- g_return_val_if_fail (buf, NULL);
- memset (buf, 0, l + 1);
-
- res = asn1_read_value (asn, part, buf, &l);
- if (res != ASN1_SUCCESS) {
- (allocator) (buf, 0);
- buf = NULL;
- } else if (len) {
- *len = l;
- }
-
- return buf;
-}
-
-gboolean
-gck_data_asn1_write_value (ASN1_TYPE asn, const gchar *part,
- const guchar* value, gsize len)
-{
- int res;
-
- g_return_val_if_fail (asn, FALSE);
- g_return_val_if_fail (part, FALSE);
- g_return_val_if_fail (!len || value, FALSE);
-
- res = asn1_write_value (asn, part, (const void*)value, (int)len);
- return res == ASN1_SUCCESS;
-}
-
-gboolean
-gck_data_asn1_read_boolean (ASN1_TYPE asn, const gchar *part, gboolean *val)
-{
- gchar buffer[32];
- int n_buffer = sizeof (buffer) - 1;
- int res;
-
- memset (buffer, 0, sizeof (buffer));
-
- res = asn1_read_value (asn, part, buffer, &n_buffer);
- if (res != ASN1_SUCCESS)
- return FALSE;
-
- if (g_ascii_strcasecmp (buffer, "TRUE") == 0)
- *val = TRUE;
- else
- *val = FALSE;
-
- return TRUE;
-}
-
-gboolean
-gck_data_asn1_read_uint (ASN1_TYPE asn, const gchar *part, guint *val)
-{
- guchar buf[4];
- int n_buf = sizeof (buf);
- gsize i;
- int res;
-
- res = asn1_read_value (asn, part, buf, &n_buf);
- if(res != ASN1_SUCCESS)
- return FALSE;
-
- if (n_buf > 4 || n_buf < 1)
- return FALSE;
-
- *val = 0;
- for (i = 0; i < n_buf; ++i)
- *val |= buf[i] << (8 * ((n_buf - 1) - i));
-
- return TRUE;
-}
-
-gboolean
-gck_data_asn1_write_uint (ASN1_TYPE asn, const gchar *part, guint32 val)
-{
- guchar buf[4];
- int res, bytes;
-
- buf[0] = (val >> 24) & 0xff;
- buf[1] = (val >> 16) & 0xff;
- buf[2] = (val >> 8) & 0xff;
- buf[3] = (val >> 0) & 0xff;
-
- for (bytes = 3; bytes >= 0; --bytes)
- if (!buf[bytes])
- break;
-
- bytes = 4 - (bytes + 1);
- if (bytes == 0)
- bytes = 1;
- res = asn1_write_value (asn, part, buf + (4 - bytes), bytes);
- return res == ASN1_SUCCESS;
-}
-
-GQuark
-gck_data_asn1_read_oid (ASN1_TYPE asn, const gchar *part)
-{
- GQuark quark;
- guchar *buf;
- gsize n_buf;
-
- buf = gck_data_asn1_read_value (asn, part, &n_buf, NULL);
- if (!buf)
- return 0;
-
- quark = g_quark_try_string ((gchar*)buf);
- g_free (buf);
-
- if (quark == 0)
- quark = g_quark_from_static_string ("0.UNKNOWN.OID");
-
- return quark;
-}
-
-gboolean
-gck_data_asn1_write_oid (ASN1_TYPE asn, const gchar *part, GQuark val)
-{
- const gchar* oid;
-
- g_return_val_if_fail (val, FALSE);
-
- oid = g_quark_to_string (val);
- g_return_val_if_fail (oid, FALSE);
-
- return gck_data_asn1_write_value (asn, part, (const guchar*)oid, strlen (oid));
-}
-
gboolean
gck_data_asn1_read_mpi (ASN1_TYPE asn, const gchar *part, gcry_mpi_t *mpi)
{
@@ -366,7 +32,7 @@
gsize sz;
guchar *buf;
- buf = gck_data_asn1_read_value (asn, part, &sz, (GkrBufferAllocator)g_realloc);
+ buf = egg_asn1_read_value (asn, part, &sz, (EggAllocator)g_realloc);
if (!buf)
return FALSE;
@@ -386,7 +52,7 @@
gsize sz;
guchar *buf;
- buf = gck_data_asn1_read_value (asn, part, &sz, (GkrBufferAllocator)gcry_realloc);
+ buf = egg_asn1_read_value (asn, part, &sz, (EggAllocator)gcry_realloc);
if (!buf)
return FALSE;
@@ -429,660 +95,3 @@
return TRUE;
}
-
-static int
-atoin (const char *p, int digits)
-{
- int ret = 0, base = 1;
- while(--digits >= 0) {
- if (p[digits] < '0' || p[digits] > '9')
- return -1;
- ret += (p[digits] - '0') * base;
- base *= 10;
- }
- return ret;
-}
-
-static int
-two_to_four_digit_year (int year)
-{
- time_t now;
- struct tm tm;
- int century, current;
-
- g_return_val_if_fail (year >= 0 && year <= 99, -1);
-
- /* Get the current year */
- now = time (NULL);
- g_return_val_if_fail (now >= 0, -1);
- if (!gmtime_r (&now, &tm))
- g_return_val_if_reached (-1);
-
- current = (tm.tm_year % 100);
- century = (tm.tm_year + 1900) - current;
-
- /*
- * Check if it's within 40 years before the
- * current date.
- */
- if (current < 40) {
- if (year < current)
- return century + year;
- if (year > 100 - (40 - current))
- return (century - 100) + year;
- } else {
- if (year < current && year > (current - 40))
- return century + year;
- }
-
- /*
- * If it's after then adjust for overflows to
- * the next century.
- */
- if (year < current)
- return century + 100 + year;
- else
- return century + year;
-}
-
-#ifndef HAVE_TIMEGM
-time_t timegm(struct tm *t)
-{
- time_t tl, tb;
- struct tm *tg;
-
- tl = mktime (t);
- if (tl == -1)
- {
- t->tm_hour--;
- tl = mktime (t);
- if (tl == -1)
- return -1; /* can't deal with output from strptime */
- tl += 3600;
- }
- tg = gmtime (&tl);
- tg->tm_isdst = 0;
- tb = mktime (tg);
- if (tb == -1)
- {
- tg->tm_hour--;
- tb = mktime (tg);
- if (tb == -1)
- return -1; /* can't deal with output from gmtime */
- tb += 3600;
- }
- return (tl - (tb - tl));
-}
-#endif //NOT_HAVE_TIMEGM
-
-time_t
-gck_data_asn1_parse_utc_time (const gchar *time)
-{
- struct tm when;
- guint n_time;
- time_t result;
- const char *p, *e;
- int year;
-
- g_assert (time);
- n_time = strlen (time);
-
- /* YYMMDDhhmmss.ffff Z | +0000 */
- if (n_time < 6 || n_time >= 28)
- return -1;
-
- /* Reset everything to default legal values */
- memset (&when, 0, sizeof (when));
- when.tm_mday = 1;
-
- /* Select the digits part of it */
- p = time;
- for (e = p; *e >= '0' && *e <= '9'; ++e);
-
- if (p + 2 <= e) {
- year = atoin (p, 2);
- p += 2;
-
- /*
- * 40 years in the past is our century. 60 years
- * in the future is the next century.
- */
- when.tm_year = two_to_four_digit_year (year) - 1900;
- }
- if (p + 2 <= e) {
- when.tm_mon = atoin (p, 2) - 1;
- p += 2;
- }
- if (p + 2 <= e) {
- when.tm_mday = atoin (p, 2);
- p += 2;
- }
- if (p + 2 <= e) {
- when.tm_hour = atoin (p, 2);
- p += 2;
- }
- if (p + 2 <= e) {
- when.tm_min = atoin (p, 2);
- p += 2;
- }
- if (p + 2 <= e) {
- when.tm_sec = atoin (p, 2);
- p += 2;
- }
-
- if (when.tm_year < 0 || when.tm_year > 9999 ||
- when.tm_mon < 0 || when.tm_mon > 11 ||
- when.tm_mday < 1 || when.tm_mday > 31 ||
- when.tm_hour < 0 || when.tm_hour > 23 ||
- when.tm_min < 0 || when.tm_min > 59 ||
- when.tm_sec < 0 || when.tm_sec > 59)
- return -1;
-
- /* Make sure all that got parsed */
- if (p != e)
- return -1;
-
- /* In order to work with 32 bit time_t. */
- if (sizeof (time_t) <= 4 && when.tm_year >= 2038)
- return (time_t) 2145914603; /* 2037-12-31 23:23:23 */
-
- /* Covnvert to seconds since epoch */
- result = timegm (&when);
-
- /* Now the remaining optional stuff */
- e = time + n_time;
-
- /* See if there's a fraction, and discard it if so */
- if (p < e && *p == '.' && p + 5 <= e)
- p += 5;
-
- /* See if it's UTC */
- if (p < e && *p == 'Z') {
- p += 1;
-
- /* See if it has a timezone */
- } else if ((*p == '-' || *p == '+') && p + 3 <= e) {
- int off, neg;
-
- neg = *p == '-';
- ++p;
-
- off = atoin (p, 2) * 3600;
- if (off < 0 || off > 86400)
- return -1;
- p += 2;
-
- if (p + 2 <= e) {
- off += atoin (p, 2) * 60;
- p += 2;
- }
-
- /* Use TZ offset */
- if (neg)
- result -= off;
- else
- result += off;
- }
-
- /* Make sure everything got parsed */
- if (p != e)
- return -1;
-
- return result;
-}
-
-time_t
-gck_data_asn1_parse_general_time (const gchar *time)
-{
- struct tm when;
- guint n_time;
- time_t result;
- const char *p, *e;
-
- g_assert (time);
- n_time = strlen (time);
-
- /* YYYYMMDDhhmmss.ffff Z | +0000 */
- if (n_time < 8 || n_time >= 30)
- return -1;
-
- /* Reset everything to default legal values */
- memset (&when, 0, sizeof (when));
- when.tm_mday = 1;
-
- /* Select the digits part of it */
- p = time;
- for (e = p; *e >= '0' && *e <= '9'; ++e);
-
- if (p + 4 <= e) {
- when.tm_year = atoin (p, 4) - 1900;
- p += 4;
- }
- if (p + 2 <= e) {
- when.tm_mon = atoin (p, 2) - 1;
- p += 2;
- }
- if (p + 2 <= e) {
- when.tm_mday = atoin (p, 2);
- p += 2;
- }
- if (p + 2 <= e) {
- when.tm_hour = atoin (p, 2);
- p += 2;
- }
- if (p + 2 <= e) {
- when.tm_min = atoin (p, 2);
- p += 2;
- }
- if (p + 2 <= e) {
- when.tm_sec = atoin (p, 2);
- p += 2;
- }
-
- if (when.tm_year < 0 || when.tm_year > 9999 ||
- when.tm_mon < 0 || when.tm_mon > 11 ||
- when.tm_mday < 1 || when.tm_mday > 31 ||
- when.tm_hour < 0 || when.tm_hour > 23 ||
- when.tm_min < 0 || when.tm_min > 59 ||
- when.tm_sec < 0 || when.tm_sec > 59)
- return -1;
-
- /* Make sure all that got parsed */
- if (p != e)
- return -1;
-
- /* Covnvert to seconds since epoch */
- result = timegm (&when);
-
- /* Now the remaining optional stuff */
- e = time + n_time;
-
- /* See if there's a fraction, and discard it if so */
- if (p < e && *p == '.' && p + 5 <= e)
- p += 5;
-
- /* See if it's UTC */
- if (p < e && *p == 'Z') {
- p += 1;
-
- /* See if it has a timezone */
- } else if ((*p == '-' || *p == '+') && p + 3 <= e) {
- int off, neg;
-
- neg = *p == '-';
- ++p;
-
- off = atoin (p, 2) * 3600;
- if (off < 0 || off > 86400)
- return -1;
- p += 2;
-
- if (p + 2 <= e) {
- off += atoin (p, 2) * 60;
- p += 2;
- }
-
- /* Use TZ offset */
- if (neg)
- result -= off;
- else
- result += off;
- }
-
- /* Make sure everything got parsed */
- if (p != e)
- return -1;
-
- return result;
-}
-
-gboolean
-gck_data_asn1_read_time (ASN1_TYPE asn, const gchar *part, time_t *val)
-{
- #define MAX_TIME 1024
- gchar ttime[MAX_TIME];
- gchar *name;
- int len, res;
-
- len = sizeof (ttime) - 1;
- res = asn1_read_value (asn, part, ttime, &len);
- if (res != ASN1_SUCCESS)
- return FALSE;
-
- /* CHOICE */
- if (strcmp (ttime, "generalTime") == 0) {
- name = g_strconcat (part, ".generalTime", NULL);
- len = sizeof (ttime) - 1;
- res = asn1_read_value (asn, name, ttime, &len);
- g_free (name);
- if (res != ASN1_SUCCESS)
- return FALSE;
-
- *val = gck_data_asn1_parse_general_time (ttime);
-
- /* UTCTIME */
- } else {
- name = g_strconcat (part, ".utcTime", NULL);
- len = sizeof (ttime) - 1;
- res = asn1_read_value (asn, name, ttime, &len);
- g_free (name);
- if (res != ASN1_SUCCESS)
- return FALSE;
-
- *val = gck_data_asn1_parse_utc_time (ttime);
- }
-
- if (*val < (time_t)0)
- return FALSE;
-
- return TRUE;
-}
-
-
-/* -------------------------------------------------------------------------------
- * Reading DN's
- */
-
-typedef struct _PrintableOid {
- GQuark oid;
- const gchar *oidstr;
- const gchar *display;
- gboolean is_choice;
-} PrintableOid;
-
-static PrintableOid printable_oids[] = {
- { 0, "0.9.2342.19200300.100.1.25", "DC", FALSE },
- { 0, "0.9.2342.19200300.100.1.1", "UID", TRUE },
-
- { 0, "1.2.840.113549.1.9.1", "EMAIL", FALSE },
- { 0, "1.2.840.113549.1.9.7", NULL, TRUE },
- { 0, "1.2.840.113549.1.9.20", NULL, FALSE },
-
- { 0, "1.3.6.1.5.5.7.9.1", "dateOfBirth", FALSE },
- { 0, "1.3.6.1.5.5.7.9.2", "placeOfBirth", FALSE },
- { 0, "1.3.6.1.5.5.7.9.3", "gender", FALSE },
- { 0, "1.3.6.1.5.5.7.9.4", "countryOfCitizenship", FALSE },
- { 0, "1.3.6.1.5.5.7.9.5", "countryOfResidence", FALSE },
-
- { 0, "2.5.4.3", "CN", TRUE },
- { 0, "2.5.4.4", "surName", TRUE },
- { 0, "2.5.4.5", "serialNumber", FALSE },
- { 0, "2.5.4.6", "C", FALSE, },
- { 0, "2.5.4.7", "L", TRUE },
- { 0, "2.5.4.8", "ST", TRUE },
- { 0, "2.5.4.9", "STREET", TRUE },
- { 0, "2.5.4.10", "O", TRUE },
- { 0, "2.5.4.11", "OU", TRUE },
- { 0, "2.5.4.12", "T", TRUE },
- { 0, "2.5.4.20", "telephoneNumber", FALSE },
- { 0, "2.5.4.42", "givenName", TRUE },
- { 0, "2.5.4.43", "initials", TRUE },
- { 0, "2.5.4.44", "generationQualifier", TRUE },
- { 0, "2.5.4.46", "dnQualifier", FALSE },
- { 0, "2.5.4.65", "pseudonym", TRUE },
-
- { 0, NULL, NULL, FALSE }
-};
-
-static void
-init_printable_oids (void)
-{
- static volatile gsize inited_oids = 0;
- int i;
-
- if (g_once_init_enter (&inited_oids)) {
- for (i = 0; printable_oids[i].oidstr != NULL; ++i)
- printable_oids[i].oid = g_quark_from_static_string (printable_oids[i].oidstr);
- g_once_init_leave (&inited_oids, 1);
- }
-}
-
-static PrintableOid*
-dn_find_printable (GQuark oid)
-{
- int i;
-
- g_return_val_if_fail (oid != 0, NULL);
-
- for (i = 0; printable_oids[i].oidstr != NULL; ++i) {
- if (printable_oids[i].oid == oid)
- return &printable_oids[i];
- }
-
- return NULL;
-}
-
-static const char HEXC[] = "0123456789ABCDEF";
-
-static gchar*
-dn_print_hex_value (const guchar *data, gsize len)
-{
- GString *result = g_string_sized_new (len * 2 + 1);
- gsize i;
-
- g_string_append_c (result, '#');
- for (i = 0; i < len; ++i) {
- g_string_append_c (result, HEXC[data[i] >> 4 & 0xf]);
- g_string_append_c (result, HEXC[data[i] & 0xf]);
- }
-
- return g_string_free (result, FALSE);
-}
-
-static gchar*
-dn_print_oid_value_parsed (PrintableOid *printable, guchar *data, gsize len)
-{
- const gchar *asn_name;
- ASN1_TYPE asn1;
- gchar *part;
- gchar *value;
-
- g_assert (printable);
- g_assert (data);
- g_assert (len);
- g_assert (printable->oid);
-
- asn_name = asn1_find_structure_from_oid (gck_data_asn1_get_pkix_asn1type (),
- printable->oidstr);
- g_return_val_if_fail (asn_name, NULL);
-
- part = g_strdup_printf ("PKIX1.%s", asn_name);
- asn1 = gck_data_asn1_decode (part, data, len);
- g_free (part);
-
- if (!asn1) {
- g_message ("couldn't decode value for OID: %s", printable->oidstr);
- return NULL;
- }
-
- value = (gchar*)gck_data_asn1_read_value (asn1, "", NULL, NULL);
-
- /*
- * If it's a choice element, then we have to read depending
- * on what's there.
- */
- if (value && printable->is_choice) {
- if (strcmp ("printableString", value) == 0 ||
- strcmp ("ia5String", value) == 0 ||
- strcmp ("utf8String", value) == 0 ||
- strcmp ("teletexString", value) == 0) {
- part = value;
- value = (gchar*)gck_data_asn1_read_value (asn1, part, NULL, NULL);
- g_free (part);
- } else {
- g_free (value);
- return NULL;
- }
- }
-
- if (!value) {
- g_message ("couldn't read value for OID: %s", printable->oidstr);
- return NULL;
- }
-
- /*
- * Now we make sure it's UTF-8.
- */
- if (!g_utf8_validate (value, -1, NULL)) {
- gchar *hex = dn_print_hex_value ((guchar*)value, strlen (value));
- g_free (value);
- value = hex;
- }
-
- return value;
-}
-
-static gchar*
-dn_print_oid_value (PrintableOid *printable, guchar *data, gsize len)
-{
- gchar *value;
-
- g_assert (data);
- g_assert (len);
-
- if (printable) {
- value = dn_print_oid_value_parsed (printable, data, len);
- if (value != NULL)
- return value;
- }
-
- return dn_print_hex_value (data, len);
-}
-
-static gchar*
-dn_parse_rdn (ASN1_TYPE asn, const gchar *part)
-{
- PrintableOid *printable;
- GQuark oid;
- gchar *path;
- guchar *value;
- gsize n_value;
- gchar *display;
- gchar *result;
-
- g_assert (asn);
- g_assert (part);
-
- path = g_strdup_printf ("%s.type", part);
- oid = gck_data_asn1_read_oid (asn, path);
- g_free (path);
-
- if (!oid)
- return NULL;
-
- path = g_strdup_printf ("%s.value", part);
- value = gck_data_asn1_read_value (asn, path, &n_value, NULL);
- g_free (path);
-
- printable = dn_find_printable (oid);
-
- g_return_val_if_fail (value, NULL);
- display = dn_print_oid_value (printable, value, n_value);
-
- result = g_strconcat (printable ? printable->display : g_quark_to_string (oid),
- "=", display, NULL);
- g_free (display);
-
- return result;
-}
-
-gchar*
-gck_data_asn1_read_dn (ASN1_TYPE asn, const gchar *part)
-{
- gboolean done = FALSE;
- GString *result;
- gchar *path;
- gchar *rdn;
- gint i, j;
-
- g_return_val_if_fail (asn, NULL);
- g_return_val_if_fail (part, NULL);
-
- init_printable_oids ();
-
- result = g_string_sized_new (64);
-
- /* Each (possibly multi valued) RDN */
- for (i = 1; !done; ++i) {
-
- /* Each type=value pair of an RDN */
- for (j = 1; TRUE; ++j) {
- path = g_strdup_printf ("%s%s?%u.?%u", part ? part : "",
- part ? "." : "", i, j);
- rdn = dn_parse_rdn (asn, path);
- g_free (path);
-
- if (!rdn) {
- done = j == 1;
- break;
- }
-
- /* Account for multi valued RDNs */
- if (j > 1)
- g_string_append (result, "+");
- else if (i > 1)
- g_string_append (result, ", ");
-
- g_string_append (result, rdn);
- g_free (rdn);
- }
- }
-
- /* Returns null when string is empty */
- return g_string_free (result, (result->len == 0));
-}
-
-gchar*
-gck_data_asn1_read_dn_part (ASN1_TYPE asn, const gchar *part, const gchar *match)
-{
- PrintableOid *printable = NULL;
- gboolean done = FALSE;
- guchar *value;
- gsize n_value;
- gchar *path;
- GQuark oid;
- gint i, j;
-
- g_return_val_if_fail (asn, NULL);
- g_return_val_if_fail (part, NULL);
- g_return_val_if_fail (match, NULL);
-
- init_printable_oids ();
-
- /* Each (possibly multi valued) RDN */
- for (i = 1; !done; ++i) {
-
- /* Each type=value pair of an RDN */
- for (j = 1; TRUE; ++j) {
- path = g_strdup_printf ("%s%s?%u.?%u.type",
- part ? part : "",
- part ? "." : "", i, j);
- oid = gck_data_asn1_read_oid (asn, path);
- g_free (path);
-
- if (!oid) {
- done = j == 1;
- break;
- }
-
- /* Does it match either the OID or the displayable? */
- if (g_ascii_strcasecmp (g_quark_to_string (oid), match) != 0) {
- printable = dn_find_printable (oid);
- if (!printable || !printable->display ||
- !g_ascii_strcasecmp (printable->display, match) == 0)
- continue;
- }
-
- path = g_strdup_printf ("%s%s?%u.?%u.value",
- part ? part : "",
- part ? "." : "", i, j);
- value = gck_data_asn1_read_value (asn, path, &n_value, NULL);
- g_free (path);
-
- g_return_val_if_fail (value, NULL);
- return dn_print_oid_value (printable, value, n_value);
- }
- }
-
- return NULL;
-}
Modified: trunk/pkcs11/gck/gck-data-asn1.h
==============================================================================
--- trunk/pkcs11/gck/gck-data-asn1.h (original)
+++ trunk/pkcs11/gck/gck-data-asn1.h Sat Jan 17 23:27:10 2009
@@ -24,45 +24,8 @@
#ifndef GCK_DATA_ASN_H_
#define GCK_DATA_ASN_H_
-#include <libtasn1.h>
+#include "egg/egg-asn1.h"
#include <gcrypt.h>
-#include <glib.h>
-
-#include "gck-data-types.h"
-
-ASN1_TYPE gck_data_asn1_get_pk_asn1type (void);
-
-ASN1_TYPE gck_data_asn1_get_pkix_asn1type (void);
-
-ASN1_TYPE gck_data_asn1_decode (const gchar *type, const guchar *data,
- gsize n_data);
-
-guchar* gck_data_asn1_encode (ASN1_TYPE asn, const gchar* part,
- gsize *len, GckDataAllocator alloc);
-
-guchar* gck_data_asn1_read_value (ASN1_TYPE asn, const gchar *part,
- gsize *len, GckDataAllocator alloc);
-
-gboolean gck_data_asn1_write_value (ASN1_TYPE asn, const gchar *part,
- const guchar* value, gsize len);
-
-GQuark gck_data_asn1_read_oid (ASN1_TYPE asn, const gchar *part);
-
-gboolean gck_data_asn1_write_oid (ASN1_TYPE asn, const gchar *part, GQuark val);
-
-gboolean gck_data_asn1_read_boolean (ASN1_TYPE asn, const gchar *part, gboolean *val);
-
-gboolean gck_data_asn1_read_uint (ASN1_TYPE asn, const gchar *part, guint *val);
-
-gboolean gck_data_asn1_read_time (ASN1_TYPE asn, const gchar *part, time_t *val);
-
-const guchar* gck_data_asn1_read_content (ASN1_TYPE asn, const guchar *data, gsize n_data,
- const gchar *part, gsize *n_content);
-
-const guchar* gck_data_asn1_read_element (ASN1_TYPE asn, const guchar *data, gsize n_data,
- const gchar *part, gsize *n_element);
-
-gboolean gck_data_asn1_write_uint (ASN1_TYPE asn, const gchar *part, guint val);
gboolean gck_data_asn1_read_mpi (ASN1_TYPE asn, const gchar *part,
gcry_mpi_t *mpi);
@@ -73,16 +36,4 @@
gboolean gck_data_asn1_write_mpi (ASN1_TYPE asn, const gchar *part,
gcry_mpi_t mpi);
-gchar* gck_data_asn1_read_dn (ASN1_TYPE asn, const gchar *part);
-
-gchar* gck_data_asn1_read_dn_part (ASN1_TYPE asn, const gchar *part, const gchar *match);
-
-gint gck_data_asn1_element_length (const guchar *data, gsize n_data);
-
-const guchar* gck_data_asn1_element_content (const guchar *data, gsize n_data, gsize *n_content);
-
-time_t gck_data_asn1_parse_utc_time (const gchar* value);
-
-time_t gck_data_asn1_parse_general_time (const gchar* value);
-
#endif /*GCK_DATA_ASN_H_*/
Modified: trunk/pkcs11/gck/gck-data-der.c
==============================================================================
--- trunk/pkcs11/gck/gck-data-der.c (original)
+++ trunk/pkcs11/gck/gck-data-der.c Sat Jan 17 23:27:10 2009
@@ -28,7 +28,7 @@
#include "gck-data-der.h"
#include "gck-data-types.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include <glib.h>
#include <gcrypt.h>
@@ -124,7 +124,7 @@
n = e = NULL;
- asn = gck_data_asn1_decode ("PK.RSAPublicKey", data, n_data);
+ asn = egg_asn1_decode ("PK.RSAPublicKey", data, n_data);
if (!asn)
goto done;
@@ -175,13 +175,13 @@
n = e = d = p = q = u = NULL;
- asn = gck_data_asn1_decode ("PK.RSAPrivateKey", data, n_data);
+ asn = egg_asn1_decode ("PK.RSAPrivateKey", data, n_data);
if (!asn)
goto done;
ret = GCK_DATA_FAILURE;
- if (!gck_data_asn1_read_uint (asn, "version", &version))
+ if (!egg_asn1_read_uint (asn, "version", &version))
goto done;
/* We only support simple version */
@@ -251,7 +251,7 @@
p = q = g = y = NULL;
- asn = gck_data_asn1_decode ("PK.DSAPublicKey", data, n_data);
+ asn = egg_asn1_decode ("PK.DSAPublicKey", data, n_data);
if (!asn)
goto done;
@@ -297,8 +297,8 @@
p = q = g = y = NULL;
- asn_params = gck_data_asn1_decode ("PK.DSAParameters", params, n_params);
- asn_key = gck_data_asn1_decode ("PK.DSAPublicPart", keydata, n_keydata);
+ asn_params = egg_asn1_decode ("PK.DSAParameters", params, n_params);
+ asn_key = egg_asn1_decode ("PK.DSAPublicPart", keydata, n_keydata);
if (!asn_params || !asn_key)
goto done;
@@ -354,7 +354,7 @@
p = q = g = y = x = NULL;
- asn = gck_data_asn1_decode ("PK.DSAPrivateKey", data, n_data);
+ asn = egg_asn1_decode ("PK.DSAPrivateKey", data, n_data);
if (!asn)
goto done;
@@ -402,8 +402,8 @@
p = q = g = y = x = NULL;
- asn_params = gck_data_asn1_decode ("PK.DSAParameters", params, n_params);
- asn_key = gck_data_asn1_decode ("PK.DSAPrivatePart", keydata, n_keydata);
+ asn_params = egg_asn1_decode ("PK.DSAParameters", params, n_params);
+ asn_key = egg_asn1_decode ("PK.DSAPrivatePart", keydata, n_keydata);
if (!asn_params || !asn_key)
goto done;
@@ -469,19 +469,19 @@
init_quarks ();
- asn = gck_data_asn1_decode ("PKIX1.SubjectPublicKeyInfo", data, n_data);
+ asn = egg_asn1_decode ("PKIX1.SubjectPublicKeyInfo", data, n_data);
if (!asn)
goto done;
ret = GCK_DATA_FAILURE;
/* Figure out the algorithm */
- oid = gck_data_asn1_read_oid (asn, "algorithm.algorithm");
+ oid = egg_asn1_read_oid (asn, "algorithm.algorithm");
if (!oid)
goto done;
/* A bit string so we cannot process in place */
- key = gck_data_asn1_read_value (asn, "subjectPublicKey", &n_key, NULL);
+ key = egg_asn1_read_value (asn, "subjectPublicKey", &n_key, NULL);
if (!key)
goto done;
n_key /= 8;
@@ -492,7 +492,7 @@
/* A DSA key paramaters are stored separately */
} else if (oid == OID_PKIX1_DSA) {
- params = gck_data_asn1_read_element (asn, data, n_data, "algorithm.parameters", &n_params);
+ params = egg_asn1_read_element (asn, data, n_data, "algorithm.parameters", &n_params);
if (!params)
goto done;
ret = gck_data_der_read_public_key_dsa_parts (key, n_key, params, n_params, s_key);
@@ -542,14 +542,14 @@
init_quarks ();
- asn = gck_data_asn1_decode ("PKIX1.pkcs-8-PrivateKeyInfo", data, n_data);
+ asn = egg_asn1_decode ("PKIX1.pkcs-8-PrivateKeyInfo", data, n_data);
if (!asn)
goto done;
ret = GCK_DATA_FAILURE;
algorithm = 0;
- key_algo = gck_data_asn1_read_oid (asn, "privateKeyAlgorithm.algorithm");
+ key_algo = egg_asn1_read_oid (asn, "privateKeyAlgorithm.algorithm");
if (!key_algo)
goto done;
else if (key_algo == OID_PKIX1_RSA)
@@ -562,11 +562,11 @@
goto done;
}
- keydata = gck_data_asn1_read_content (asn, data, n_data, "privateKey", &n_keydata);
+ keydata = egg_asn1_read_content (asn, data, n_data, "privateKey", &n_keydata);
if (!keydata)
goto done;
- params = gck_data_asn1_read_element (asn, data, n_data, "privateKeyAlgorithm.parameters",
+ params = egg_asn1_read_element (asn, data, n_data, "privateKeyAlgorithm.parameters",
&n_params);
ret = GCK_DATA_SUCCESS;
@@ -620,18 +620,18 @@
ret = GCK_DATA_UNRECOGNIZED;
- asn = gck_data_asn1_decode ("PKIX1.pkcs-8-EncryptedPrivateKeyInfo", data, n_data);
+ asn = egg_asn1_decode ("PKIX1.pkcs-8-EncryptedPrivateKeyInfo", data, n_data);
if (!asn)
goto done;
ret = GCK_DATA_FAILURE;
/* Figure out the type of encryption */
- scheme = gck_data_asn1_read_oid (asn, "encryptionAlgorithm.algorithm");
+ scheme = egg_asn1_read_oid (asn, "encryptionAlgorithm.algorithm");
if (!scheme)
goto done;
- params = gck_data_asn1_read_element (asn, data, n_data, "encryptionAlgorithm.parameters", &n_params);
+ params = egg_asn1_read_element (asn, data, n_data, "encryptionAlgorithm.parameters", &n_params);
if (!params)
goto done;
@@ -647,7 +647,7 @@
goto done;
}
- crypted = gck_data_asn1_read_value (asn, "encryptedData", &n_crypted, gkr_secure_realloc);
+ crypted = egg_asn1_read_value (asn, "encryptedData", &n_crypted, egg_secure_realloc);
if (!crypted)
goto done;
@@ -661,7 +661,7 @@
}
/* Unpad the DER data */
- l = gck_data_asn1_element_length (crypted, n_crypted);
+ l = egg_asn1_element_length (crypted, n_crypted);
if (l <= 0 || l > n_crypted) {
ret = GCK_DATA_LOCKED;
goto done;
@@ -670,7 +670,7 @@
/* Try to parse the resulting key */
ret = gck_data_der_read_private_pkcs8_plain (crypted, n_crypted, s_key);
- gkr_secure_free (crypted);
+ egg_secure_free (crypted);
crypted = NULL;
/* If unrecognized we assume bad password */
@@ -682,7 +682,7 @@
gcry_cipher_close (cih);
if (asn)
asn1_delete_structure (&asn);
- gkr_secure_free (crypted);
+ egg_secure_free (crypted);
return ret;
}
@@ -710,7 +710,7 @@
n = e = NULL;
- res = asn1_create_element (gck_data_asn1_get_pk_asn1type (),
+ res = asn1_create_element (egg_asn1_get_pk_asn1type (),
"PK.RSAPublicKey", &asn);
g_return_val_if_fail (res == ASN1_SUCCESS, NULL);
@@ -722,7 +722,7 @@
!gck_data_asn1_write_mpi (asn, "publicExponent", e))
goto done;
- result = gck_data_asn1_encode (asn, "", len, NULL);
+ result = egg_asn1_encode (asn, "", len, NULL);
done:
if (asn)
@@ -743,7 +743,7 @@
n = e = d = p = q = u = e1 = e2 = tmp = NULL;
- res = asn1_create_element (gck_data_asn1_get_pk_asn1type (),
+ res = asn1_create_element (egg_asn1_get_pk_asn1type (),
"PK.RSAPrivateKey", &asn);
g_return_val_if_fail (res == ASN1_SUCCESS, NULL);
@@ -778,10 +778,10 @@
goto done;
/* Write out the version */
- if (!gck_data_asn1_write_uint (asn, "version", 0))
+ if (!egg_asn1_write_uint (asn, "version", 0))
goto done;
- result = gck_data_asn1_encode (asn, "", n_key, NULL);
+ result = egg_asn1_encode (asn, "", n_key, NULL);
done:
if (asn)
@@ -810,7 +810,7 @@
p = q = g = y = NULL;
- res = asn1_create_element (gck_data_asn1_get_pk_asn1type (),
+ res = asn1_create_element (egg_asn1_get_pk_asn1type (),
"PK.DSAPublicKey", &asn);
g_return_val_if_fail (res == ASN1_SUCCESS, NULL);
@@ -826,10 +826,10 @@
!gck_data_asn1_write_mpi (asn, "Y", y))
goto done;
- if (!gck_data_asn1_write_uint (asn, "version", 0))
+ if (!egg_asn1_write_uint (asn, "version", 0))
goto done;
- result = gck_data_asn1_encode (asn, "", len, NULL);
+ result = egg_asn1_encode (asn, "", len, NULL);
done:
if (asn)
@@ -852,7 +852,7 @@
x = NULL;
- res = asn1_create_element (gck_data_asn1_get_pk_asn1type (),
+ res = asn1_create_element (egg_asn1_get_pk_asn1type (),
"PK.DSAPrivatePart", &asn);
g_return_val_if_fail (res == ASN1_SUCCESS, NULL);
@@ -862,7 +862,7 @@
if (!gck_data_asn1_write_mpi (asn, "", x))
goto done;
- result = gck_data_asn1_encode (asn, "", n_key, NULL);
+ result = egg_asn1_encode (asn, "", n_key, NULL);
done:
if (asn)
@@ -882,7 +882,7 @@
p = q = g = NULL;
- res = asn1_create_element (gck_data_asn1_get_pk_asn1type (),
+ res = asn1_create_element (egg_asn1_get_pk_asn1type (),
"PK.DSAParameters", &asn);
g_return_val_if_fail (res == ASN1_SUCCESS, NULL);
@@ -896,7 +896,7 @@
!gck_data_asn1_write_mpi (asn, "g", g))
goto done;
- result = gck_data_asn1_encode (asn, "", n_params, NULL);
+ result = egg_asn1_encode (asn, "", n_params, NULL);
done:
if (asn)
@@ -918,7 +918,7 @@
p = q = g = y = x = NULL;
- res = asn1_create_element (gck_data_asn1_get_pk_asn1type (),
+ res = asn1_create_element (egg_asn1_get_pk_asn1type (),
"PK.DSAPrivateKey", &asn);
g_return_val_if_fail (res == ASN1_SUCCESS, NULL);
@@ -936,10 +936,10 @@
!gck_data_asn1_write_mpi (asn, "priv", x))
goto done;
- if (!gck_data_asn1_write_uint (asn, "version", 0))
+ if (!egg_asn1_write_uint (asn, "version", 0))
goto done;
- result = gck_data_asn1_encode (asn, "", len, NULL);
+ result = egg_asn1_encode (asn, "", len, NULL);
done:
if (asn)
@@ -1018,7 +1018,7 @@
GCRYCTL_TEST_ALGO, NULL, 0), NULL);
/* The encryption algorithm */
- if(!gck_data_asn1_write_oid (asn, "encryptionAlgorithm.algorithm",
+ if(!egg_asn1_write_oid (asn, "encryptionAlgorithm.algorithm",
OID_PKCS12_PBE_3DES_SHA1))
g_return_val_if_reached (NULL);
@@ -1037,17 +1037,17 @@
g_return_val_if_reached (NULL);
/* Now write out the parameters */
- res = asn1_create_element (gck_data_asn1_get_pkix_asn1type (),
+ res = asn1_create_element (egg_asn1_get_pkix_asn1type (),
"PKIX1.pkcs-12-PbeParams", &asn1_params);
g_return_val_if_fail (res == ASN1_SUCCESS, NULL);
- if (!gck_data_asn1_write_value (asn1_params, "salt", salt, sizeof (salt)))
+ if (!egg_asn1_write_value (asn1_params, "salt", salt, sizeof (salt)))
g_return_val_if_reached (NULL);
- if (!gck_data_asn1_write_uint (asn1_params, "iterations", iterations))
+ if (!egg_asn1_write_uint (asn1_params, "iterations", iterations))
g_return_val_if_reached (NULL);
- portion = gck_data_asn1_encode (asn1_params, "", &n_portion, NULL);
+ portion = egg_asn1_encode (asn1_params, "", &n_portion, NULL);
g_return_val_if_fail (portion, NULL);
- if (!gck_data_asn1_write_value (asn, "encryptionAlgorithm.parameters", portion, n_portion))
+ if (!egg_asn1_write_value (asn, "encryptionAlgorithm.parameters", portion, n_portion))
g_return_val_if_reached (NULL);
g_free (portion);
@@ -1083,12 +1083,12 @@
g_return_val_if_reached (NULL);
g_return_val_if_fail (is_priv == TRUE, NULL);
- res = asn1_create_element (gck_data_asn1_get_pkix_asn1type (),
+ res = asn1_create_element (egg_asn1_get_pkix_asn1type (),
"PKIX1.pkcs-8-PrivateKeyInfo", &asn);
g_return_val_if_fail (res == ASN1_SUCCESS, NULL);
/* Write out the version */
- if (!gck_data_asn1_write_uint (asn, "version", 1))
+ if (!egg_asn1_write_uint (asn, "version", 1))
g_return_val_if_reached (NULL);
/* Per algorithm differences */
@@ -1115,24 +1115,24 @@
};
/* Write out the algorithm */
- if (!gck_data_asn1_write_oid (asn, "privateKeyAlgorithm.algorithm", oid))
+ if (!egg_asn1_write_oid (asn, "privateKeyAlgorithm.algorithm", oid))
g_return_val_if_reached (NULL);
/* Write out the parameters */
- if (!gck_data_asn1_write_value (asn, "privateKeyAlgorithm.parameters", params, n_params))
+ if (!egg_asn1_write_value (asn, "privateKeyAlgorithm.parameters", params, n_params))
g_return_val_if_reached (NULL);
- gkr_secure_free (params);
+ egg_secure_free (params);
/* Write out the key portion */
- if (!gck_data_asn1_write_value (asn, "privateKey", key, n_key))
+ if (!egg_asn1_write_value (asn, "privateKey", key, n_key))
g_return_val_if_reached (NULL);
- gkr_secure_free (key);
+ egg_secure_free (key);
/* Add an empty attributes field */
- if (!gck_data_asn1_write_value (asn, "attributes", NULL, 0))
+ if (!egg_asn1_write_value (asn, "attributes", NULL, 0))
g_return_val_if_reached (NULL);
- data = gck_data_asn1_encode (asn, "", n_data, NULL);
+ data = egg_asn1_encode (asn, "", n_data, NULL);
g_return_val_if_fail (data, NULL);
asn1_delete_structure (&asn);
@@ -1154,7 +1154,7 @@
/* Encode the key in normal pkcs8 fashion */
key = gck_data_der_write_private_pkcs8_plain (skey, &n_key);
- res = asn1_create_element (gck_data_asn1_get_pkix_asn1type (),
+ res = asn1_create_element (egg_asn1_get_pkix_asn1type (),
"PKIX1.pkcs-8-EncryptedPrivateKeyInfo", &asn);
g_return_val_if_fail (res == ASN1_SUCCESS, NULL);
@@ -1184,7 +1184,7 @@
res = asn1_write_value (asn, "encryptedData", key, n_key);
g_return_val_if_fail (res == ASN1_SUCCESS, NULL);
- data = gck_data_asn1_encode (asn, "", n_data, NULL);
+ data = egg_asn1_encode (asn, "", n_data, NULL);
g_return_val_if_fail (data, NULL);
asn1_delete_structure (&asn);
@@ -1199,7 +1199,7 @@
GckDataResult
gck_data_der_read_certificate (const guchar *data, gsize n_data, ASN1_TYPE *asn1)
{
- *asn1 = gck_data_asn1_decode ("PKIX1.Certificate", data, n_data);
+ *asn1 = egg_asn1_decode ("PKIX1.Certificate", data, n_data);
if (!*asn1)
return GCK_DATA_UNRECOGNIZED;
@@ -1214,21 +1214,21 @@
ASN1_TYPE asn;
guint value;
- asn = gck_data_asn1_decode ("PKIX1.BasicConstraints", data, n_data);
+ asn = egg_asn1_decode ("PKIX1.BasicConstraints", data, n_data);
if (!asn)
goto done;
ret = GCK_DATA_FAILURE;
if (path_len) {
- if (!gck_data_asn1_read_uint (asn, "pathLenConstraint", &value))
+ if (!egg_asn1_read_uint (asn, "pathLenConstraint", &value))
*path_len = -1;
else
*path_len = value;
}
if (is_ca) {
- if (!gck_data_asn1_read_boolean (asn, "cA", is_ca))
+ if (!egg_asn1_read_boolean (asn, "cA", is_ca))
*is_ca = FALSE;
}
@@ -1254,7 +1254,7 @@
guchar buf[4];
int res, len;
- asn = gck_data_asn1_decode ("PKIX1.KeyUsage", data, n_data);
+ asn = egg_asn1_decode ("PKIX1.KeyUsage", data, n_data);
if (!asn)
goto done;
@@ -1285,7 +1285,7 @@
GQuark oid;
int i;
- asn = gck_data_asn1_decode ("PKIX1.ExtKeyUsageSyntax", data, n_data);
+ asn = egg_asn1_decode ("PKIX1.ExtKeyUsageSyntax", data, n_data);
if (!asn)
goto done;
@@ -1294,7 +1294,7 @@
array = g_array_new (TRUE, TRUE, sizeof (GQuark));
for (i = 0; TRUE; ++i) {
part = g_strdup_printf ("?%d", i + 1);
- oid = gck_data_asn1_read_oid (asn, part);
+ oid = egg_asn1_read_oid (asn, part);
g_free (part);
if (!oid)
@@ -1320,7 +1320,7 @@
g_return_val_if_fail (asn1, NULL);
g_return_val_if_fail (n_data, NULL);
- return gck_data_asn1_encode (asn1, "", n_data, NULL);
+ return egg_asn1_encode (asn1, "", n_data, NULL);
}
/* -----------------------------------------------------------------------------
@@ -1419,16 +1419,16 @@
gcry_md_test_algo (hash_algo) != 0)
goto done;
- asn = gck_data_asn1_decode ("PKIX1.pkcs-5-PBE-params", data, n_data);
+ asn = egg_asn1_decode ("PKIX1.pkcs-5-PBE-params", data, n_data);
if (!asn)
goto done;
ret = GCK_DATA_FAILURE;
- salt = gck_data_asn1_read_content (asn, data, n_data, "salt", &n_salt);
+ salt = egg_asn1_read_content (asn, data, n_data, "salt", &n_salt);
if (!salt)
goto done;
- if (!gck_data_asn1_read_uint (asn, "iterationCount", &iterations))
+ if (!egg_asn1_read_uint (asn, "iterationCount", &iterations))
iterations = 1;
n_key = gcry_cipher_get_algo_keylen (cipher_algo);
@@ -1472,14 +1472,14 @@
g_assert (data);
- asn = gck_data_asn1_decode ("PKIX1.pkcs-5-rc2-CBC-params", data, n_data);
+ asn = egg_asn1_decode ("PKIX1.pkcs-5-rc2-CBC-params", data, n_data);
if (!asn)
return GCK_DATA_UNRECOGNIZED;
- if (!gck_data_asn1_read_uint (asn, "rc2ParameterVersion", &version))
+ if (!egg_asn1_read_uint (asn, "rc2ParameterVersion", &version))
return GCK_DATA_FAILURE;
- iv = gck_data_asn1_read_content (asn, data, n_data, "iv", &n_iv);
+ iv = egg_asn1_read_content (asn, data, n_data, "iv", &n_iv);
asn1_delete_structure (&asn);
if (!iv)
@@ -1505,13 +1505,13 @@
g_assert (data);
- asn = gck_data_asn1_decode ("PKIX1.pkcs-5-des-EDE3-CBC-params", data, n_data);
+ asn = egg_asn1_decode ("PKIX1.pkcs-5-des-EDE3-CBC-params", data, n_data);
if (!asn)
- asn = gck_data_asn1_decode ("PKIX1.pkcs-5-des-CBC-params", data, n_data);
+ asn = egg_asn1_decode ("PKIX1.pkcs-5-des-CBC-params", data, n_data);
if (!asn)
return GCK_DATA_UNRECOGNIZED;
- iv = gck_data_asn1_read_content (asn, data, n_data, "", &n_iv);
+ iv = egg_asn1_read_content (asn, data, n_data, "", &n_iv);
asn1_delete_structure (&asn);
if (!iv)
@@ -1544,15 +1544,15 @@
ret = GCK_DATA_UNRECOGNIZED;
- asn = gck_data_asn1_decode ("PKIX1.pkcs-5-PBKDF2-params", data, n_data);
+ asn = egg_asn1_decode ("PKIX1.pkcs-5-PBKDF2-params", data, n_data);
if (!asn)
goto done;
ret = GCK_DATA_FAILURE;
- if (!gck_data_asn1_read_uint (asn, "iterationCount", &iterations))
+ if (!egg_asn1_read_uint (asn, "iterationCount", &iterations))
iterations = 1;
- salt = gck_data_asn1_read_content (asn, data, n_data, "salt.specified", &n_salt);
+ salt = egg_asn1_read_content (asn, data, n_data, "salt.specified", &n_salt);
if (!salt)
goto done;
@@ -1597,7 +1597,7 @@
*cih = NULL;
ret = GCK_DATA_UNRECOGNIZED;
- asn = gck_data_asn1_decode ("PKIX1.pkcs-5-PBES2-params", data, n_data);
+ asn = egg_asn1_decode ("PKIX1.pkcs-5-PBES2-params", data, n_data);
if (!asn)
goto done;
@@ -1605,7 +1605,7 @@
algo = mode = 0;
/* Read in all the encryption type */
- enc_oid = gck_data_asn1_read_oid (asn, "encryptionScheme.algorithm");
+ enc_oid = egg_asn1_read_oid (asn, "encryptionScheme.algorithm");
if (!enc_oid)
goto done;
if (enc_oid == OID_DES_EDE3_CBC)
@@ -1656,7 +1656,7 @@
}
/* Read out the key creation paramaters */
- key_deriv_algo = gck_data_asn1_read_oid (asn, "keyDerivationFunc.algorithm");
+ key_deriv_algo = egg_asn1_read_oid (asn, "keyDerivationFunc.algorithm");
if (!key_deriv_algo)
goto done;
if (key_deriv_algo != OID_PBKDF2) {
@@ -1709,16 +1709,16 @@
if (gcry_cipher_algo_info (cipher_algo, GCRYCTL_TEST_ALGO, NULL, 0) != 0)
goto done;
- asn = gck_data_asn1_decode ("PKIX1.pkcs-12-PbeParams", data, n_data);
+ asn = egg_asn1_decode ("PKIX1.pkcs-12-PbeParams", data, n_data);
if (!asn)
goto done;
ret = GCK_DATA_FAILURE;
- salt = gck_data_asn1_read_content (asn, data, n_data, "salt", &n_salt);
+ salt = egg_asn1_read_content (asn, data, n_data, "salt", &n_salt);
if (!salt)
goto done;
- if (!gck_data_asn1_read_uint (asn, "iterations", &iterations))
+ if (!egg_asn1_read_uint (asn, "iterations", &iterations))
goto done;
n_block = gcry_cipher_get_algo_blklen (cipher_algo);
Modified: trunk/pkcs11/gck/gck-data-file.c
==============================================================================
--- trunk/pkcs11/gck/gck-data-file.c (original)
+++ trunk/pkcs11/gck/gck-data-file.c Sat Jan 17 23:27:10 2009
@@ -28,8 +28,8 @@
#include "gck-marshal.h"
#include "gck-util.h"
-#include "common/gkr-buffer.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-buffer.h"
+#include "egg/egg-secure-memory.h"
#include <glib/gstdio.h>
@@ -69,15 +69,15 @@
typedef struct _UnknownBlock {
guint type;
- GkrBuffer buffer;
+ EggBuffer buffer;
} UnknownBlock;
G_DEFINE_TYPE (GckDataFile, gck_data_file, G_TYPE_OBJECT);
-#define PUBLIC_ALLOC (GkrBufferAllocator)g_realloc
-#define PRIVATE_ALLOC (GkrBufferAllocator)gkr_secure_realloc
+#define PUBLIC_ALLOC (EggBufferAllocator)g_realloc
+#define PRIVATE_ALLOC (EggBufferAllocator)egg_secure_realloc
-typedef GckDataResult (*BlockFunc) (guint block, GkrBuffer *buffer, GckLogin *login, gpointer user_data);
+typedef GckDataResult (*BlockFunc) (guint block, EggBuffer *buffer, GckLogin *login, gpointer user_data);
#define FILE_HEADER ((const guchar*)"Gnome Keyring Store 2\n\r\0")
#define FILE_HEADER_LEN 24
@@ -181,7 +181,7 @@
{
gchar header[FILE_HEADER_LEN];
GckDataResult res;
- GkrBuffer buffer;
+ EggBuffer buffer;
guint32 block;
guint32 length;
gsize offset;
@@ -199,13 +199,13 @@
return FALSE;
}
- gkr_buffer_init_full (&buffer, 1024, (GkrBufferAllocator)g_realloc);
+ egg_buffer_init_full (&buffer, 1024, (EggBufferAllocator)g_realloc);
res = GCK_DATA_SUCCESS;
for (;;) {
- gkr_buffer_reset (&buffer);
- gkr_buffer_resize (&buffer, 8);
+ egg_buffer_reset (&buffer);
+ egg_buffer_resize (&buffer, 8);
offset = 0;
/* Read in a set of bytes */
@@ -215,8 +215,8 @@
}
/* Decode it as the number of bytes in the next section */
- if (!gkr_buffer_get_uint32 (&buffer, offset, &offset, &length) ||
- !gkr_buffer_get_uint32 (&buffer, offset, &offset, &block) ||
+ if (!egg_buffer_get_uint32 (&buffer, offset, &offset, &length) ||
+ !egg_buffer_get_uint32 (&buffer, offset, &offset, &block) ||
length < 8) {
res = GCK_DATA_SUCCESS;
g_message ("invalid block size or length in store file");
@@ -224,7 +224,7 @@
}
/* Read in that amount of bytes */
- gkr_buffer_resize (&buffer, length - 8);
+ egg_buffer_resize (&buffer, length - 8);
if (!read_all_bytes (file, buffer.buf, length - 8)) {
res = GCK_DATA_FAILURE;
break;
@@ -235,27 +235,27 @@
break;
}
- gkr_buffer_uninit (&buffer);
+ egg_buffer_uninit (&buffer);
return res;
}
static gboolean
-write_file_block (int file, guint block, GkrBuffer *buffer)
+write_file_block (int file, guint block, EggBuffer *buffer)
{
- GkrBuffer header;
+ EggBuffer header;
gboolean ret;
g_assert (file != -1);
g_assert (buffer);
/* Write out the 8 bytes of header */
- gkr_buffer_init_full (&header, 8, (GkrBufferAllocator)g_realloc);
- gkr_buffer_add_uint32 (&header, buffer->len + 8);
- gkr_buffer_add_uint32 (&header, block);
- g_assert (!gkr_buffer_has_error (&header));
+ egg_buffer_init_full (&header, 8, (EggBufferAllocator)g_realloc);
+ egg_buffer_add_uint32 (&header, buffer->len + 8);
+ egg_buffer_add_uint32 (&header, block);
+ g_assert (!egg_buffer_has_error (&header));
g_assert (header.len == 8);
ret = write_all_bytes (file, header.buf, header.len);
- gkr_buffer_uninit (&header);
+ egg_buffer_uninit (&header);
if (ret != TRUE)
return FALSE;
@@ -265,7 +265,7 @@
}
static gboolean
-hash_buffer (GkrBuffer *buffer)
+hash_buffer (EggBuffer *buffer)
{
const gchar *salgo;
gsize length;
@@ -275,7 +275,7 @@
/* The length needs to be the first thing in the buffer */
g_assert (buffer->len > 4);
- g_assert (gkr_buffer_decode_uint32 (buffer->buf) == buffer->len);
+ g_assert (egg_buffer_decode_uint32 (buffer->buf) == buffer->len);
length = buffer->len;
@@ -285,8 +285,8 @@
n_hash = gcry_md_get_algo_dlen (algo);
g_return_val_if_fail (n_hash > 0, FALSE);
- gkr_buffer_add_string (buffer, salgo);
- hash = gkr_buffer_add_byte_array_empty (buffer, n_hash);
+ egg_buffer_add_string (buffer, salgo);
+ hash = egg_buffer_add_byte_array_empty (buffer, n_hash);
g_return_val_if_fail (hash, FALSE);
gcry_md_hash_buffer (algo, hash, buffer->buf, length);
@@ -294,7 +294,7 @@
}
static gboolean
-validate_buffer (GkrBuffer *buffer, gsize *offset)
+validate_buffer (EggBuffer *buffer, gsize *offset)
{
const guchar *hash;
gchar *salgo, *check;
@@ -307,8 +307,8 @@
*offset = 0;
- if (!gkr_buffer_get_uint32 (buffer, *offset, offset, &length) ||
- !gkr_buffer_get_string (buffer, length, &hash_offset, &salgo, PUBLIC_ALLOC))
+ if (!egg_buffer_get_uint32 (buffer, *offset, offset, &length) ||
+ !egg_buffer_get_string (buffer, length, &hash_offset, &salgo, PUBLIC_ALLOC))
return FALSE;
algo = gcry_md_map_name (salgo);
@@ -319,7 +319,7 @@
}
g_free (salgo);
- if (!gkr_buffer_get_byte_array (buffer, hash_offset, &hash_offset, &hash, &n_hash))
+ if (!egg_buffer_get_byte_array (buffer, hash_offset, &hash_offset, &hash, &n_hash))
return FALSE;
if (n_hash != gcry_md_get_algo_dlen (algo)) {
@@ -388,7 +388,7 @@
}
static gboolean
-encrypt_buffer (GkrBuffer *input, GckLogin *login, GkrBuffer *output)
+encrypt_buffer (EggBuffer *input, GckLogin *login, EggBuffer *output)
{
gcry_cipher_hd_t cipher;
gcry_error_t gcry;
@@ -416,18 +416,18 @@
/* Write out crypto algorithm */
salgo = gcry_cipher_algo_name (calgo);
g_return_val_if_fail (salgo, FALSE);
- gkr_buffer_add_string (output, salgo);
+ egg_buffer_add_string (output, salgo);
/* Write out the hash algorithm */
salgo = gcry_md_algo_name (halgo);
g_return_val_if_fail (halgo, FALSE);
- gkr_buffer_add_string (output, salgo);
+ egg_buffer_add_string (output, salgo);
/* Write out the iterations */
- gkr_buffer_add_uint32 (output, iterations);
+ egg_buffer_add_uint32 (output, iterations);
/* And write out the salt */
- gkr_buffer_add_byte_array (output, salt, sizeof (salt));
+ egg_buffer_add_byte_array (output, salt, sizeof (salt));
/* Okay now use the above info to create our cipher context */
if (!create_cipher (login, calgo, halgo, salt, sizeof (salt), iterations, &cipher))
@@ -439,10 +439,10 @@
/* Pad the buffer to a multiple of block length */
while (input->len % n_block != 0)
- gkr_buffer_add_byte (input, 0);
+ egg_buffer_add_byte (input, 0);
/* Now reserve space for it in the output block, and encrypt */
- dest = gkr_buffer_add_byte_array_empty (output, input->len);
+ dest = egg_buffer_add_byte_array_empty (output, input->len);
g_return_val_if_fail (dest, FALSE);
gcry = gcry_cipher_encrypt (cipher, dest, input->len, input->buf, input->len);
@@ -454,7 +454,7 @@
}
static gboolean
-decrypt_buffer (GkrBuffer *input, gsize *offset, GckLogin *login, GkrBuffer *output)
+decrypt_buffer (EggBuffer *input, gsize *offset, GckLogin *login, EggBuffer *output)
{
gcry_cipher_hd_t cipher;
gcry_error_t gcry;
@@ -470,7 +470,7 @@
g_assert (login);
/* Read in and interpret the cipher algorithm */
- if (!gkr_buffer_get_string (input, *offset, offset, &salgo, NULL))
+ if (!egg_buffer_get_string (input, *offset, offset, &salgo, NULL))
return FALSE;
calgo = gcry_cipher_map_name (salgo);
if (!calgo) {
@@ -481,7 +481,7 @@
g_free (salgo);
/* Read in and interpret the hash algorithm */
- if (!gkr_buffer_get_string (input, *offset, offset, &salgo, NULL))
+ if (!egg_buffer_get_string (input, *offset, offset, &salgo, NULL))
return FALSE;
halgo = gcry_md_map_name (salgo);
if (!halgo) {
@@ -492,9 +492,9 @@
g_free (salgo);
/* Read in the iterations, salt, and encrypted data */
- if (!gkr_buffer_get_uint32 (input, *offset, offset, &iterations) ||
- !gkr_buffer_get_byte_array (input, *offset, offset, &salt, &n_salt) ||
- !gkr_buffer_get_byte_array (input, *offset, offset, &data, &n_data))
+ if (!egg_buffer_get_uint32 (input, *offset, offset, &iterations) ||
+ !egg_buffer_get_byte_array (input, *offset, offset, &salt, &n_salt) ||
+ !egg_buffer_get_byte_array (input, *offset, offset, &data, &n_data))
return FALSE;
/* Significant block sizes */
@@ -512,8 +512,8 @@
return FALSE;
/* Now reserve space for it in the output block, and encrypt */
- gkr_buffer_reset (output);
- gkr_buffer_resize (output, n_data);
+ egg_buffer_reset (output);
+ egg_buffer_resize (output, n_data);
gcry = gcry_cipher_decrypt (cipher, output->buf, output->len, data, n_data);
g_return_val_if_fail (!gcry, FALSE);
@@ -529,7 +529,7 @@
static GckDataResult
update_entries_from_block (GckDataFile *self, guint section, GHashTable *entries,
- GkrBuffer *buffer, gsize *offset)
+ EggBuffer *buffer, gsize *offset)
{
GHashTable *attributes;
const gchar *identifier;
@@ -550,13 +550,13 @@
g_assert (offset);
/* The number of entries */
- if (!gkr_buffer_get_uint32 (buffer, *offset, offset, &n_entries))
+ if (!egg_buffer_get_uint32 (buffer, *offset, offset, &n_entries))
return GCK_DATA_FAILURE;
for (i = 0; i < n_entries; ++i) {
/* The attributes */
- if (!gkr_buffer_get_string (buffer, *offset, offset, &str, (GkrBufferAllocator)g_realloc))
+ if (!egg_buffer_get_string (buffer, *offset, offset, &str, (EggBufferAllocator)g_realloc))
return GCK_DATA_FAILURE;
/* Make sure we have this one */
@@ -578,12 +578,12 @@
identifier = key;
attributes = value;
- if (!gkr_buffer_get_uint32 (buffer, *offset, offset, &n_attrs))
+ if (!egg_buffer_get_uint32 (buffer, *offset, offset, &n_attrs))
return GCK_DATA_FAILURE;
for (j = 0; j < n_attrs; ++j) {
- if (!gkr_buffer_get_uint64 (buffer, *offset, offset, &type) ||
- !gkr_buffer_get_byte_array (buffer, *offset, offset, &data, &n_data))
+ if (!egg_buffer_get_uint64 (buffer, *offset, offset, &type) ||
+ !egg_buffer_get_byte_array (buffer, *offset, offset, &data, &n_data))
return GCK_DATA_FAILURE;
attr.type = type;
@@ -607,7 +607,7 @@
}
static GckDataResult
-update_from_public_block (GckDataFile *self, GkrBuffer *buffer)
+update_from_public_block (GckDataFile *self, EggBuffer *buffer)
{
gsize offset = 0;
@@ -625,9 +625,9 @@
}
static GckDataResult
-update_from_private_block (GckDataFile *self, GkrBuffer *buffer, GckLogin *login)
+update_from_private_block (GckDataFile *self, EggBuffer *buffer, GckLogin *login)
{
- GkrBuffer custom;
+ EggBuffer custom;
GckDataResult res;
const gchar *password;
gsize n_password;
@@ -647,12 +647,12 @@
}
offset = 0;
- gkr_buffer_init_full (&custom, 1024, gkr_secure_realloc);
+ egg_buffer_init_full (&custom, 1024, egg_secure_realloc);
/* Decrypt the buffer */
password = gck_login_get_password (login, &n_password);
if (!decrypt_buffer (buffer, &offset, login, &custom)) {
- gkr_buffer_uninit (&custom);
+ egg_buffer_uninit (&custom);
return GCK_DATA_FAILURE;
}
@@ -660,7 +660,7 @@
/* Validate the buffer hash, failure is usually a bad password */
if (!validate_buffer (&custom, &offset)) {
- gkr_buffer_uninit (&custom);
+ egg_buffer_uninit (&custom);
return GCK_DATA_LOCKED;
}
@@ -670,7 +670,7 @@
res = update_entries_from_block (self, GCK_DATA_FILE_SECTION_PRIVATE,
self->privates, &custom, &offset);
- gkr_buffer_uninit (&custom);
+ egg_buffer_uninit (&custom);
return res;
}
@@ -707,7 +707,7 @@
}
static GckDataResult
-update_from_index_block (GckDataFile *self, GkrBuffer *buffer)
+update_from_index_block (GckDataFile *self, EggBuffer *buffer)
{
gchar *identifier;
gsize offset;
@@ -722,17 +722,17 @@
offset = 0;
/* The number of entries */
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &count))
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &count))
return FALSE;
for (i = 0; i < count; ++i) {
/* The identifier */
- if (!gkr_buffer_get_string (buffer, offset, &offset, &identifier, (GkrBufferAllocator)g_realloc))
+ if (!egg_buffer_get_string (buffer, offset, &offset, &identifier, (EggBufferAllocator)g_realloc))
break;
/* The section */
- if (!gkr_buffer_get_uint32 (buffer, offset, &offset, &value)) {
+ if (!egg_buffer_get_uint32 (buffer, offset, &offset, &value)) {
g_free (identifier);
break;
}
@@ -758,7 +758,7 @@
}
static GckDataResult
-update_from_any_block (guint block, GkrBuffer *buffer, GckLogin *login, gpointer user_data)
+update_from_any_block (guint block, EggBuffer *buffer, GckLogin *login, gpointer user_data)
{
UnknownBlock *unknown;
GckDataFile *self;
@@ -786,8 +786,8 @@
if (res == GCK_DATA_UNRECOGNIZED) {
unknown = g_slice_new0 (UnknownBlock);
unknown->type = block;
- gkr_buffer_init_full (&unknown->buffer, buffer->len, PUBLIC_ALLOC);
- gkr_buffer_append (&unknown->buffer, buffer->buf, buffer->len);
+ egg_buffer_init_full (&unknown->buffer, buffer->len, PUBLIC_ALLOC);
+ egg_buffer_append (&unknown->buffer, buffer->buf, buffer->len);
self->unknowns = g_list_prepend (self->unknowns, unknown);
res = GCK_DATA_SUCCESS;
}
@@ -799,26 +799,26 @@
write_each_attribute (gpointer key, gpointer value, gpointer data)
{
CK_ATTRIBUTE_PTR attr = value;
- GkrBuffer *buffer = data;
- gkr_buffer_add_uint64 (buffer, attr->type);
+ EggBuffer *buffer = data;
+ egg_buffer_add_uint64 (buffer, attr->type);
g_assert (attr->ulValueLen != (gulong)-1);
- gkr_buffer_add_byte_array (buffer, attr->pValue, attr->ulValueLen);
+ egg_buffer_add_byte_array (buffer, attr->pValue, attr->ulValueLen);
}
static void
write_each_entry (gpointer key, gpointer value, gpointer data)
{
- GkrBuffer *buffer = data;
+ EggBuffer *buffer = data;
const gchar *unique = key;
GHashTable *attributes = value;
- gkr_buffer_add_string (buffer, unique);
- gkr_buffer_add_uint32 (buffer, g_hash_table_size (attributes));
+ egg_buffer_add_string (buffer, unique);
+ egg_buffer_add_uint32 (buffer, g_hash_table_size (attributes));
g_hash_table_foreach (attributes, write_each_attribute, buffer);
}
static GckDataResult
-write_entries_to_block (GckDataFile *self, GHashTable *entries, GkrBuffer *buffer)
+write_entries_to_block (GckDataFile *self, GHashTable *entries, EggBuffer *buffer)
{
gsize offset;
@@ -828,18 +828,18 @@
/* Reserve space for the length */
offset = buffer->len;
- gkr_buffer_add_uint32 (buffer, 0);
+ egg_buffer_add_uint32 (buffer, 0);
/* The number of attributes we'll be encountering */
- gkr_buffer_add_uint32 (buffer, g_hash_table_size (entries));
+ egg_buffer_add_uint32 (buffer, g_hash_table_size (entries));
/* Fill in the attributes */
g_hash_table_foreach (entries, write_each_entry, buffer);
- g_return_val_if_fail (!gkr_buffer_has_error (buffer), GCK_DATA_FAILURE);
+ g_return_val_if_fail (!egg_buffer_has_error (buffer), GCK_DATA_FAILURE);
/* Fill in the length */
- gkr_buffer_set_uint32 (buffer, offset, buffer->len);
+ egg_buffer_set_uint32 (buffer, offset, buffer->len);
/* Hash the entire dealio */
if (!hash_buffer (buffer))
@@ -849,9 +849,9 @@
}
static GckDataResult
-write_private_to_block (GckDataFile *self, GkrBuffer *buffer, GckLogin *login)
+write_private_to_block (GckDataFile *self, EggBuffer *buffer, GckLogin *login)
{
- GkrBuffer secure;
+ EggBuffer secure;
GckDataResult res;
g_assert (GCK_IS_DATA_FILE (self));
@@ -871,18 +871,18 @@
return GCK_DATA_LOCKED;
}
- gkr_buffer_init_full (&secure, 1024, PRIVATE_ALLOC);
+ egg_buffer_init_full (&secure, 1024, PRIVATE_ALLOC);
res = write_entries_to_block (self, self->privates, &secure);
if (res == GCK_DATA_SUCCESS)
res = encrypt_buffer (&secure, login, buffer);
- gkr_buffer_uninit (&secure);
+ egg_buffer_uninit (&secure);
return res;
}
static GckDataResult
-write_public_to_block (GckDataFile *self, GkrBuffer *buffer)
+write_public_to_block (GckDataFile *self, EggBuffer *buffer)
{
g_assert (GCK_IS_DATA_FILE (self));
g_assert (buffer);
@@ -893,23 +893,23 @@
static void
write_each_index_identifier (gpointer key, gpointer value, gpointer data)
{
- gkr_buffer_add_string (data, key);
- gkr_buffer_add_uint32 (data, GPOINTER_TO_UINT (value));
+ egg_buffer_add_string (data, key);
+ egg_buffer_add_uint32 (data, GPOINTER_TO_UINT (value));
}
static GckDataResult
-write_index_to_block (GckDataFile *self, GkrBuffer *buffer)
+write_index_to_block (GckDataFile *self, EggBuffer *buffer)
{
g_assert (GCK_IS_DATA_FILE (self));
g_assert (buffer);
/* The number of entries */
- gkr_buffer_add_uint32 (buffer, g_hash_table_size (self->identifiers));
+ egg_buffer_add_uint32 (buffer, g_hash_table_size (self->identifiers));
/* Now write out all the entries */
g_hash_table_foreach (self->identifiers, write_each_index_identifier, buffer);
- return gkr_buffer_has_error (buffer) ? GCK_DATA_FAILURE : GCK_DATA_SUCCESS;
+ return egg_buffer_has_error (buffer) ? GCK_DATA_FAILURE : GCK_DATA_SUCCESS;
}
static GckDataResult
@@ -950,7 +950,7 @@
for (l = list; l; l = g_list_next (l)) {
unknown = l->data;
g_assert (unknown);
- gkr_buffer_uninit (&unknown->buffer);
+ egg_buffer_uninit (&unknown->buffer);
g_slice_free (UnknownBlock, unknown);
}
@@ -1160,7 +1160,7 @@
GList *unknowns, *unk;
UnknownBlock *block;
GckDataResult res;
- GkrBuffer buffer;
+ EggBuffer buffer;
guint type;
gint i;
@@ -1173,7 +1173,7 @@
unknowns = g_list_copy (self->unknowns);
unknowns = g_list_sort (unknowns, sort_unknowns_by_type);
- gkr_buffer_init_full (&buffer, 8192, PUBLIC_ALLOC);
+ egg_buffer_init_full (&buffer, 8192, PUBLIC_ALLOC);
/*
* All blocks are written in sorted order by their block
@@ -1199,7 +1199,7 @@
break;
/* Prepare the block of this type */
- gkr_buffer_reset (&buffer);
+ egg_buffer_reset (&buffer);
switch (type) {
case FILE_BLOCK_INDEX:
res = write_index_to_block (self, &buffer);
@@ -1230,7 +1230,7 @@
}
g_list_free (unknowns);
- gkr_buffer_uninit (&buffer);
+ egg_buffer_uninit (&buffer);
return res;
}
Modified: trunk/pkcs11/gck/gck-login.c
==============================================================================
--- trunk/pkcs11/gck/gck-login.c (original)
+++ trunk/pkcs11/gck/gck-login.c Sat Jan 17 23:27:10 2009
@@ -23,7 +23,7 @@
#include "gck-login.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include <string.h>
@@ -50,7 +50,7 @@
{
GckLogin *self = GCK_LOGIN (obj);
- gkr_secure_strfree (self->password);
+ egg_secure_strfree (self->password);
self->password = NULL;
self->n_password = 0;
@@ -112,10 +112,10 @@
if (pin) {
if (n_pin == (CK_ULONG)-1) {
- login->password = gkr_secure_strdup ((const gchar*)pin);
+ login->password = egg_secure_strdup ((const gchar*)pin);
login->n_password = strlen (login->password);
} else {
- login->password = gkr_secure_alloc (n_pin + 1);
+ login->password = egg_secure_alloc (n_pin + 1);
memcpy (login->password, pin, n_pin);
login->n_password = n_pin;
}
Modified: trunk/pkcs11/gck/tests/Makefile.am
==============================================================================
--- trunk/pkcs11/gck/tests/Makefile.am (original)
+++ trunk/pkcs11/gck/tests/Makefile.am Sat Jan 17 23:27:10 2009
@@ -24,8 +24,7 @@
UNIT_LIBS = \
$(top_builddir)/pkcs11/gck/libgck.la \
- $(top_builddir)/common/libgkr-common-buffer.la \
- $(top_builddir)/common/libgkr-common-secure.la
+ $(top_builddir)/egg/libegg.la
EXTRA_DIST = \
test.asn \
Modified: trunk/pkcs11/gck/tests/unit-test-data-asn1.c
==============================================================================
--- trunk/pkcs11/gck/tests/unit-test-data-asn1.c (original)
+++ trunk/pkcs11/gck/tests/unit-test-data-asn1.c Sat Jan 17 23:27:10 2009
@@ -1,5 +1,5 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* unit-test-pkix-parser.c: Test PKIX parser
+/* unit-test-data-asn1.c: Test ASN.1 routines
Copyright (C) 2007 Stefan Walter
@@ -57,7 +57,7 @@
data_cert = test_read_testdata ("test-certificate-1.der", &n_data_cert);
/* We'll be catching this error later */
- pkix = gck_data_asn1_get_pkix_asn1type ();
+ pkix = egg_asn1_get_pkix_asn1type ();
if (!pkix) return;
res = asn1_create_element (pkix, "PKIX1.Certificate", &asn1_cert);
@@ -75,17 +75,6 @@
data_cert = NULL;
}
-DEFINE_TEST(asn1_types)
-{
- ASN1_TYPE asn;
-
- asn = gck_data_asn1_get_pk_asn1type ();
- g_assert ("pk asn type is null" && asn != NULL);
-
- asn = gck_data_asn1_get_pkix_asn1type ();
- g_assert ("pkix asn type is null" && asn != NULL);
-}
-
DEFINE_TEST(asn1_integers)
{
ASN1_TYPE asn;
@@ -93,21 +82,11 @@
guchar *data;
gsize n_data;
gboolean ret;
- guint val;
int res;
res = asn1_create_element (asn1_test, "TEST.TestIntegers", &asn);
g_assert ("asn test structure is null" && asn != NULL);
- ret = gck_data_asn1_write_uint (asn, "uint1", 35);
- g_assert ("couldn't write integer" && ret);
-
- ret = gck_data_asn1_write_uint (asn, "uint2", 23456);
- g_assert ("couldn't write integer" && ret);
-
- ret = gck_data_asn1_write_uint (asn, "uint3", 209384022);
- g_assert ("couldn't write integer" && ret);
-
/* Make a random number */
mpi = gcry_mpi_new (512);
g_return_if_fail (mpi);
@@ -117,7 +96,7 @@
ret = gck_data_asn1_write_mpi (asn, "mpi", mpi);
/* Now encode the whole caboodle */
- data = gck_data_asn1_encode (asn, "", &n_data, NULL);
+ data = egg_asn1_encode (asn, "", &n_data, NULL);
g_assert ("encoding asn1 didn't work" && data != NULL);
asn1_delete_structure (&asn);
@@ -129,303 +108,8 @@
res = asn1_der_decoding (&asn, data, n_data, NULL);
g_assert ("decoding asn didn't work" && res == ASN1_SUCCESS);
- /* And get out the values */
- ret = gck_data_asn1_read_uint (asn, "uint1", &val);
- g_assert ("couldn't read integer from asn1" && ret);
- g_assert_cmpuint (val, ==, 35);
-
- ret = gck_data_asn1_read_uint (asn, "uint2", &val);
- g_assert ("couldn't read integer from asn1" && ret);
- g_assert_cmpuint (val, ==, 23456);
-
- ret = gck_data_asn1_read_uint (asn, "uint3", &val);
- g_assert ("couldn't read integer from asn1" && ret);
- g_assert_cmpuint (val, ==, 209384022);
-
ret = gck_data_asn1_read_mpi (asn, "mpi", &mpt);
g_assert ("couldn't read mpi from asn1" && ret);
g_assert ("mpi returned is null" && mpt != NULL);
g_assert ("mpi is wrong number" && gcry_mpi_cmp (mpi, mpt) == 0);
}
-
-DEFINE_TEST(boolean)
-{
- ASN1_TYPE asn = NULL;
- gboolean value, ret;
- int res;
-
- res = asn1_create_element (asn1_test, "TEST.TestData", &asn);
- g_assert ("asn test structure is null" && asn != NULL);
-
- res = asn1_write_value (asn, "boolean", "TRUE", 4);
- g_assert (res == ASN1_SUCCESS);
-
- ret = gck_data_asn1_read_boolean (asn, "boolean", &value);
- g_assert (ret);
- g_assert (value == TRUE);
-
- res = asn1_write_value (asn, "boolean", "FALSE", 5);
- g_assert (res == ASN1_SUCCESS);
-
- ret = gck_data_asn1_read_boolean (asn, "boolean", &value);
- g_assert (ret);
- g_assert (value == FALSE);
-
- ret = gck_data_asn1_read_boolean (asn, "nonExistant", &value);
- g_assert (!ret);
-
- asn1_delete_structure (&asn);
-}
-
-DEFINE_TEST(write_value)
-{
- ASN1_TYPE asn = NULL;
- guchar *data;
- gsize n_data;
- int res;
-
- res = asn1_create_element (asn1_test, "TEST.TestData", &asn);
- g_assert ("asn test structure is null" && asn != NULL);
-
- if (!gck_data_asn1_write_value (asn, "data", (const guchar*)"SOME DATA", 9))
- g_assert_not_reached ();
-
- data = gck_data_asn1_read_value (asn, "data", &n_data, NULL);
- g_assert (data != NULL);
- g_assert_cmpuint (n_data, ==, 9);
- g_assert (memcmp (data, "SOME DATA", 9) == 0);
- g_free (data);
-
- asn1_delete_structure (&asn);
-}
-
-DEFINE_TEST(element_length_content)
-{
- ASN1_TYPE asn = NULL;
- guchar buffer[1024];
- const guchar *content;
- gsize n_content;
- gint length;
- int res;
-
- res = asn1_create_element (asn1_test, "TEST.TestData", &asn);
- g_assert ("asn test structure is null" && asn != NULL);
-
- res = asn1_write_value (asn, "data", "SOME DATA", 9);
- g_assert (res == ASN1_SUCCESS);
-
- length = 1024;
- res = asn1_der_coding (asn, "", buffer, &length, NULL);
- g_assert (res == ASN1_SUCCESS);
-
- /* Now the real test */
- length = gck_data_asn1_element_length (buffer, 1024);
- g_assert_cmpint (length, ==, 13);
-
- content = gck_data_asn1_element_content (buffer, length, &n_content);
- g_assert (content);
- g_assert_cmpuint (n_content, ==, 11);
-
- content = gck_data_asn1_element_content (content, n_content, &n_content);
- g_assert (content);
- g_assert_cmpuint (n_content, ==, 9);
- g_assert (memcmp (content, "SOME DATA", 9) == 0);
-
- asn1_delete_structure (&asn);
-}
-
-DEFINE_TEST(read_element)
-{
- ASN1_TYPE asn = NULL;
- guchar buffer[1024];
- const guchar *data;
- gsize n_data;
- gint length;
- int res;
-
- res = asn1_create_element (asn1_test, "TEST.TestData", &asn);
- g_assert ("asn test structure is null" && asn != NULL);
-
- res = asn1_write_value (asn, "data", "SOME DATA", 9);
- g_assert (res == ASN1_SUCCESS);
-
- length = 1024;
- res = asn1_der_coding (asn, "", buffer, &length, NULL);
- g_assert (res == ASN1_SUCCESS);
-
- /* Now the real test */
- data = gck_data_asn1_read_element (asn, buffer, length, "data", &n_data);
- g_assert (data != NULL);
- g_assert_cmpint (n_data, ==, 11);
-
- data = gck_data_asn1_read_content (asn, buffer, length, "data", &n_data);
- g_assert (data);
- g_assert_cmpuint (n_data, ==, 9);
- g_assert (memcmp (data, "SOME DATA", 9) == 0);
-
- /* Invalid should return null for both those */
- data = gck_data_asn1_read_element (asn, buffer, length, "nonExistant", &n_data);
- g_assert (data == NULL);
- data = gck_data_asn1_read_content (asn, buffer, length, "nonExistant", &n_data);
- g_assert (data == NULL);
-
- asn1_delete_structure (&asn);
-}
-
-DEFINE_TEST(oid)
-{
- ASN1_TYPE asn = NULL;
- GQuark oid, check;
- int res;
-
- res = asn1_create_element (asn1_test, "TEST.TestData", &asn);
- g_assert ("asn test structure is null" && asn != NULL);
-
- res = asn1_write_value (asn, "data", "SOME DATA", 9);
- g_assert (res == ASN1_SUCCESS);
-
- /* No such element, should return 0 */
- oid = gck_data_asn1_read_oid (asn, "nonExistant");
- g_assert (oid == 0);
-
- /* No quark of this has been defined, so should return an invalid OID */
- oid = gck_data_asn1_read_oid (asn, "data");
- g_assert (oid != 0);
- g_assert_cmpstr (g_quark_to_string (oid), !=, "SOME DATA");
-
- /* Now a quark has been defined */
- check = g_quark_from_static_string ("SOME DATA");
- oid = gck_data_asn1_read_oid (asn, "data");
- g_assert (check == oid);
- g_assert_cmpstr (g_quark_to_string (oid), ==, "SOME DATA");
-
- /* Write a different OID */
- if (!gck_data_asn1_write_oid (asn, "data", g_quark_from_static_string ("ANOTHER")))
- g_assert_not_reached ();
-
- oid = gck_data_asn1_read_oid (asn, "data");
- g_assert (oid);
- g_assert_cmpstr (g_quark_to_string (oid), ==, "ANOTHER");
-
- asn1_delete_structure (&asn);
-}
-
-typedef struct _TimeTestData {
- gchar *value;
- time_t ref;
-} TimeTestData;
-
-static const TimeTestData generalized_time_test_data[] = {
- { "20070725130528Z", 1185368728 },
- { "20070725130528.2134Z", 1185368728 },
- { "20070725140528-0100", 1185368728 },
- { "20070725040528+0900", 1185368728 },
- { "20070725013528+1130", 1185368728 },
- { "20070725Z", 1185321600 },
- { "20070725+0000", 1185321600 },
- { NULL, 0 }
-};
-
-static const TimeTestData utc_time_test_data[] = {
- /* Test the Y2K style wrap arounds */
- { "070725130528Z", 1185368728 }, /* The year 2007 */
- { "020725130528Z", 1027602328 }, /* The year 2002 */
- { "970725130528Z", 869835928 }, /* The year 1997 */
- { "370725130528Z", 2132139928 }, /* The year 2037 */
-
- /* Test the time zones and other formats */
- { "070725130528.2134Z", 1185368728 },
- { "070725140528-0100", 1185368728 },
- { "070725040528+0900", 1185368728 },
- { "070725013528+1130", 1185368728 },
- { "070725Z", 1185321600 },
- { "070725+0000", 1185321600 },
-
- { NULL, 0 }
-};
-
-DEFINE_TEST(general_time)
-{
- time_t when;
- const TimeTestData *data;
-
- for (data = generalized_time_test_data; data->value; ++data) {
- when = gck_data_asn1_parse_general_time (data->value);
- if (data->ref != when) {
- printf ("%s", data->value);
- printf ("%s != ", ctime (&when));
- printf ("%s\n", ctime (&data->ref));
- fflush (stdout);
- }
-
- g_assert ("decoded time doesn't match reference" && data->ref == when);
- }
-}
-
-DEFINE_TEST(utc_time)
-{
- time_t when;
- const TimeTestData *data;
-
- for (data = utc_time_test_data; data->value; ++data) {
- when = gck_data_asn1_parse_utc_time (data->value);
- if (data->ref != when) {
- printf ("%s", data->value);
- printf ("%s != ", ctime (&when));
- printf ("%s\n", ctime (&data->ref));
- fflush (stdout);
- }
-
- g_assert ("decoded time doesn't match reference" && data->ref == when);
- }
-}
-
-DEFINE_TEST(read_time)
-{
- time_t time;
-
- if (!gck_data_asn1_read_time (asn1_cert, "tbsCertificate.validity.notBefore", &time))
- g_assert_not_reached ();
- g_assert_cmpint (time, ==, 820454400);
-}
-
-DEFINE_TEST(read_dn)
-{
- gchar *dn;
-
- dn = gck_data_asn1_read_dn (asn1_cert, "tbsCertificate.issuer.rdnSequence");
- g_assert (dn != NULL);
- g_assert_cmpstr (dn, ==, "C=ZA, ST=Western Cape, L=Cape Town, O=Thawte Consulting, OU=Certification Services Division, CN=Thawte Personal Premium CA, EMAIL=personal-premium thawte com");
-
- g_free (dn);
-
- dn = gck_data_asn1_read_dn (asn1_cert, "tbsCertificate.nonExistant");
- g_assert (dn == NULL);
-}
-
-DEFINE_TEST(read_dn_part)
-{
- gchar *value;
-
- value = gck_data_asn1_read_dn_part (asn1_cert, "tbsCertificate.issuer.rdnSequence", "CN");
- g_assert (value != NULL);
- g_assert_cmpstr (value, ==, "Thawte Personal Premium CA");
- g_free (value);
-
- value = gck_data_asn1_read_dn_part (asn1_cert, "tbsCertificate.issuer.rdnSequence", "2.5.4.8");
- g_assert (value != NULL);
- g_assert_cmpstr (value, ==, "Western Cape");
- g_free (value);
-
- value = gck_data_asn1_read_dn_part (asn1_cert, "tbsCertificate.nonExistant", "CN");
- g_assert (value == NULL);
-
- value = gck_data_asn1_read_dn_part (asn1_cert, "tbsCertificate.issuer.rdnSequence", "DC");
- g_assert (value == NULL);
-
- value = gck_data_asn1_read_dn_part (asn1_cert, "tbsCertificate.issuer.rdnSequence", "0.0.0.0");
- g_assert (value == NULL);
-
- value = gck_data_asn1_read_dn_part (asn1_cert, "tbsCertificate.issuer.rdnSequence", "2.5.4.9");
- g_assert (value == NULL);
-}
Modified: trunk/pkcs11/gck/tests/unit-test-data-der.c
==============================================================================
--- trunk/pkcs11/gck/tests/unit-test-data-der.c (original)
+++ trunk/pkcs11/gck/tests/unit-test-data-der.c Sat Jan 17 23:27:10 2009
@@ -105,7 +105,7 @@
DEFINE_SETUP(preload)
{
certificate_data = test_read_testdata ("test-certificate-1.der", &n_certificate_data);
- certificate = gck_data_asn1_decode ("PKIX1.Certificate", certificate_data, n_certificate_data);
+ certificate = egg_asn1_decode ("PKIX1.Certificate", certificate_data, n_certificate_data);
g_assert (certificate);
}
@@ -221,7 +221,7 @@
gcry_sexp_t sexp, match;
gcry_error_t gcry;
- data = gck_data_asn1_read_element (certificate, certificate_data, n_certificate_data, "tbsCertificate.subjectPublicKeyInfo", &n_data);
+ data = egg_asn1_read_element (certificate, certificate_data, n_certificate_data, "tbsCertificate.subjectPublicKeyInfo", &n_data);
g_assert (data);
res = gck_data_der_read_public_key_info (data, n_data, &sexp);
@@ -272,7 +272,7 @@
gint path_len;
GckDataResult res;
- extension = gck_data_asn1_read_content (certificate, certificate_data, n_certificate_data, "tbsCertificate.extensions.?1.extnValue", &n_extension);
+ extension = egg_asn1_read_content (certificate, certificate_data, n_certificate_data, "tbsCertificate.extensions.?1.extnValue", &n_extension);
g_assert (extension);
res = gck_data_der_read_basic_constraints (extension, n_extension, &is_ca, &path_len);
Modified: trunk/pkcs11/roots-store/Makefile.am
==============================================================================
--- trunk/pkcs11/roots-store/Makefile.am (original)
+++ trunk/pkcs11/roots-store/Makefile.am Sat Jan 17 23:27:10 2009
@@ -37,8 +37,8 @@
gck_roots_store_standalone_la_LIBADD = \
libgck-roots-store.la \
$(top_builddir)/pkcs11/gck/libgck.la \
- $(top_builddir)/common/libgkr-common-buffer.la \
- $(top_builddir)/common/libgkr-common-secure.la \
+ $(top_builddir)/egg/libegg-buffer.la \
+ $(top_builddir)/egg/libegg-secure.la \
$(GOBJECT_LIBS) \
$(GTHREAD_LIBS) \
$(GLIB_LIBS) \
Modified: trunk/pkcs11/roots-store/gck-roots-standalone.c
==============================================================================
--- trunk/pkcs11/roots-store/gck-roots-standalone.c (original)
+++ trunk/pkcs11/roots-store/gck-roots-standalone.c Sat Jan 17 23:27:10 2009
@@ -27,7 +27,7 @@
#include "gck/gck-crypto.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include <glib-object.h>
@@ -35,11 +35,11 @@
/* Module callbacks for secure memory */
static GStaticMutex memory_mutex = G_STATIC_MUTEX_INIT;
-void gkr_memory_lock (void)
+void egg_memory_lock (void)
{ g_static_mutex_lock (&memory_mutex); }
-void gkr_memory_unlock (void)
+void egg_memory_unlock (void)
{ g_static_mutex_unlock (&memory_mutex); }
-void* gkr_memory_fallback (void *p, unsigned long sz)
+void* egg_memory_fallback (void *p, unsigned long sz)
{ return g_realloc (p, sz); }
CK_RV
Modified: trunk/pkcs11/rpc-layer/Makefile.am
==============================================================================
--- trunk/pkcs11/rpc-layer/Makefile.am (original)
+++ trunk/pkcs11/rpc-layer/Makefile.am Sat Jan 17 23:27:10 2009
@@ -44,8 +44,8 @@
gck-rpc-util.c
gnome_keyring_pkcs11_la_LIBADD = \
- $(top_builddir)/common/libgkr-common-buffer.la \
- $(top_builddir)/common/libgkr-common-creds.la
+ $(top_builddir)/egg/libegg-buffer.la \
+ $(top_builddir)/egg/libegg-creds.la
gnome_keyring_pkcs11_la_LDFLAGS = \
-module -avoid-version \
Modified: trunk/pkcs11/rpc-layer/gck-rpc-dispatch.c
==============================================================================
--- trunk/pkcs11/rpc-layer/gck-rpc-dispatch.c (original)
+++ trunk/pkcs11/rpc-layer/gck-rpc-dispatch.c Sat Jan 17 23:27:10 2009
@@ -29,7 +29,7 @@
#include "pkcs11/pkcs11.h"
#include "pkcs11/pkcs11g.h"
-#include "common/gkr-unix-credentials.h"
+#include "egg/egg-unix-credentials.h"
#include <sys/types.h>
#include <sys/param.h>
@@ -89,8 +89,8 @@
{
assert (cs);
- cs->req = gck_rpc_message_new ((GkrBufferAllocator)realloc);
- cs->resp = gck_rpc_message_new ((GkrBufferAllocator)realloc);
+ cs->req = gck_rpc_message_new ((EggBufferAllocator)realloc);
+ cs->resp = gck_rpc_message_new ((EggBufferAllocator)realloc);
if (!cs->req || !cs->resp) {
gck_rpc_message_free (cs->req);
gck_rpc_message_free (cs->resp);
@@ -179,7 +179,7 @@
assert (!msg->signature || gck_rpc_message_verify_part (msg, "fy"));
/* The number of ulongs there's room for on the other end */
- if (!gkr_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &length))
+ if (!egg_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &length))
return PARSE_ERROR;
*n_buffer = length;
@@ -212,7 +212,7 @@
assert (!msg->signature || gck_rpc_message_verify_part (msg, "ay"));
/* Read out the byte which says whether data is present or not */
- if (!gkr_buffer_get_byte (&msg->buffer, msg->parsed, &msg->parsed, &valid))
+ if (!egg_buffer_get_byte (&msg->buffer, msg->parsed, &msg->parsed, &valid))
return PARSE_ERROR;
if (!valid) {
@@ -222,7 +222,7 @@
}
/* Point our arguments into the buffer */
- if (!gkr_buffer_get_byte_array (&msg->buffer, msg->parsed, &msg->parsed,
+ if (!egg_buffer_get_byte_array (&msg->buffer, msg->parsed, &msg->parsed,
&data, &n_data))
return PARSE_ERROR;
@@ -275,7 +275,7 @@
assert (!msg->signature || gck_rpc_message_verify_part (msg, "fu"));
/* The number of ulongs there's room for on the other end */
- if (!gkr_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &length))
+ if (!egg_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &length))
return PARSE_ERROR;
*n_buffer = length;
@@ -338,7 +338,7 @@
assert (!msg->signature || gck_rpc_message_verify_part (msg, "fA"));
/* Read the number of attributes */
- if (!gkr_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &n_attrs))
+ if (!egg_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &n_attrs))
return PARSE_ERROR;
/* Allocate memory for the attribute structures */
@@ -350,13 +350,13 @@
for (i = 0; i < n_attrs; ++i) {
/* The attribute type */
- if (!gkr_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &value))
+ if (!egg_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &value))
return PARSE_ERROR;
attrs[i].type = value;
/* The number of bytes to allocate */
- if (!gkr_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &value))
+ if (!egg_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &value))
return PARSE_ERROR;
if (value == 0) {
@@ -396,7 +396,7 @@
assert (!msg->signature || gck_rpc_message_verify_part (msg, "aA"));
/* Read the number of attributes */
- if (!gkr_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &n_attrs))
+ if (!egg_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &n_attrs))
return PARSE_ERROR;
/* Allocate memory for the attribute structures */
@@ -408,19 +408,19 @@
for (i = 0; i < n_attrs; ++i) {
/* The attribute type */
- if (!gkr_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &value))
+ if (!egg_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &value))
return PARSE_ERROR;
attrs[i].type = value;
/* Whether this one is valid or not */
- if (!gkr_buffer_get_byte (&msg->buffer, msg->parsed, &msg->parsed, &valid))
+ if (!egg_buffer_get_byte (&msg->buffer, msg->parsed, &msg->parsed, &valid))
return PARSE_ERROR;
if (valid) {
- if (!gkr_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &value))
+ if (!egg_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &value))
return PARSE_ERROR;
- if (!gkr_buffer_get_byte_array (&msg->buffer, msg->parsed, &msg->parsed, &data, &n_data))
+ if (!egg_buffer_get_byte_array (&msg->buffer, msg->parsed, &msg->parsed, &data, &n_data))
return PARSE_ERROR;
if (data != NULL && n_data != value) {
@@ -486,7 +486,7 @@
/* Check that we're supposed to have this at this point */
assert (!msg->signature || gck_rpc_message_verify_part (msg, "z"));
- if (!gkr_buffer_get_byte_array (&msg->buffer, msg->parsed, &msg->parsed, &data, &n_data))
+ if (!egg_buffer_get_byte_array (&msg->buffer, msg->parsed, &msg->parsed, &data, &n_data))
return PARSE_ERROR;
/* Allocate a block of memory for it */
@@ -517,11 +517,11 @@
assert (!msg->signature || gck_rpc_message_verify_part (msg, "M"));
/* The mechanism type */
- if (!gkr_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &value))
+ if (!egg_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &value))
return PARSE_ERROR;
/* The mechanism data */
- if (!gkr_buffer_get_byte_array (&msg->buffer, msg->parsed, &msg->parsed, &data, &n_data))
+ if (!egg_buffer_get_byte_array (&msg->buffer, msg->parsed, &msg->parsed, &data, &n_data))
return PARSE_ERROR;
mech->mechanism = value;
@@ -2084,7 +2084,7 @@
assert (sock != -1);
- if (!gkr_unix_credentials_read (sock, &pid, &uid) < 0) {
+ if (!egg_unix_credentials_read (sock, &pid, &uid) < 0) {
gck_rpc_warn ("couldn't read socket credentials");
return;
}
@@ -2108,15 +2108,15 @@
break;
/* Calculate the number of bytes */
- len = gkr_buffer_decode_uint32 (buf);
+ len = egg_buffer_decode_uint32 (buf);
if (len >= 0x0FFFFFFF) {
gck_rpc_warn ("invalid message size from module: %u bytes", len);
break;
}
/* Allocate memory */
- gkr_buffer_reserve (&cs.req->buffer, cs.req->buffer.len + len);
- if (gkr_buffer_has_error (&cs.req->buffer)) {
+ egg_buffer_reserve (&cs.req->buffer, cs.req->buffer.len + len);
+ if (egg_buffer_has_error (&cs.req->buffer)) {
gck_rpc_warn ("error allocating buffer for message");
break;
}
@@ -2125,7 +2125,7 @@
if (!read_all (sock, cs.req->buffer.buf, len))
break;
- gkr_buffer_add_empty (&cs.req->buffer, len);
+ egg_buffer_add_empty (&cs.req->buffer, len);
if (!gck_rpc_message_parse (cs.req, GCK_RPC_REQUEST))
break;
@@ -2135,7 +2135,7 @@
break;
/* .. send back response length, and then response data */
- gkr_buffer_encode_uint32 (buf, cs.resp->buffer.len);
+ egg_buffer_encode_uint32 (buf, cs.resp->buffer.len);
if(!write_all (sock, buf, 4) ||
!write_all (sock, cs.resp->buffer.buf, cs.resp->buffer.len))
break;
Modified: trunk/pkcs11/rpc-layer/gck-rpc-message.c
==============================================================================
--- trunk/pkcs11/rpc-layer/gck-rpc-message.c (original)
+++ trunk/pkcs11/rpc-layer/gck-rpc-message.c Sat Jan 17 23:27:10 2009
@@ -35,7 +35,7 @@
#endif
GckRpcMessage*
-gck_rpc_message_new (GkrBufferAllocator allocator)
+gck_rpc_message_new (EggBufferAllocator allocator)
{
GckRpcMessage *msg;
@@ -46,7 +46,7 @@
return NULL;
memset (msg, 0, sizeof (*msg));
- if (!gkr_buffer_init_full (&msg->buffer, 64, allocator)) {
+ if (!egg_buffer_init_full (&msg->buffer, 64, allocator)) {
(allocator) (msg, 0); /* Frees allocation */
return NULL;
}
@@ -59,12 +59,12 @@
void
gck_rpc_message_free (GckRpcMessage *msg)
{
- GkrBufferAllocator allocator;
+ EggBufferAllocator allocator;
if (msg) {
assert (msg->buffer.allocator);
allocator = msg->buffer.allocator;
- gkr_buffer_uninit (&msg->buffer);
+ egg_buffer_uninit (&msg->buffer);
/* frees data buffer */
(allocator) (msg, 0);
@@ -82,7 +82,7 @@
msg->sigverify = NULL;
msg->parsed = 0;
- gkr_buffer_reset (&msg->buffer);
+ egg_buffer_reset (&msg->buffer);
}
int
@@ -113,14 +113,14 @@
msg->call_type = type;
/* Encode the two of them */
- gkr_buffer_add_uint32 (&msg->buffer, call_id);
+ egg_buffer_add_uint32 (&msg->buffer, call_id);
if (msg->signature) {
len = strlen (msg->signature);
- gkr_buffer_add_byte_array (&msg->buffer, (unsigned char*)msg->signature, len);
+ egg_buffer_add_byte_array (&msg->buffer, (unsigned char*)msg->signature, len);
}
msg->parsed = 0;
- return !gkr_buffer_has_error (&msg->buffer);
+ return !egg_buffer_has_error (&msg->buffer);
}
int
@@ -133,7 +133,7 @@
msg->parsed = 0;
/* Pull out the call identifier */
- if (!gkr_buffer_get_uint32 (&msg->buffer, msg->parsed, &(msg->parsed), &call_id)) {
+ if (!egg_buffer_get_uint32 (&msg->buffer, msg->parsed, &(msg->parsed), &call_id)) {
gck_rpc_warn ("invalid message: couldn't read call identifier");
return 0;
}
@@ -166,7 +166,7 @@
msg->sigverify = msg->signature;
/* Verify the incoming signature */
- if (!gkr_buffer_get_byte_array (&msg->buffer, msg->parsed, &(msg->parsed), &val, &len)) {
+ if (!egg_buffer_get_byte_array (&msg->buffer, msg->parsed, &(msg->parsed), &val, &len)) {
gck_rpc_warn ("invalid message: couldn't read signature");
return 0;
}
@@ -185,8 +185,8 @@
assert (m1 && m2);
/* Any errors and messages are never equal */
- if (gkr_buffer_has_error (&m1->buffer) ||
- gkr_buffer_has_error (&m2->buffer))
+ if (egg_buffer_has_error (&m1->buffer) ||
+ egg_buffer_has_error (&m2->buffer))
return 0;
/* Calls and signatures must be identical */
@@ -202,7 +202,7 @@
}
/* Data in buffer must be identical */
- return gkr_buffer_equal (&m1->buffer, &m2->buffer);
+ return egg_buffer_equal (&m1->buffer, &m2->buffer);
}
int
@@ -234,19 +234,19 @@
assert (!msg->signature || gck_rpc_message_verify_part (msg, "fA"));
/* Write the number of items */
- gkr_buffer_add_uint32 (&msg->buffer, num);
+ egg_buffer_add_uint32 (&msg->buffer, num);
for (i = 0; i < num; ++i) {
attr = &(arr[i]);
/* The attribute type */
- gkr_buffer_add_uint32 (&msg->buffer, attr->type);
+ egg_buffer_add_uint32 (&msg->buffer, attr->type);
/* And the attribute buffer length */
- gkr_buffer_add_uint32 (&msg->buffer, attr->pValue ? attr->ulValueLen : 0);
+ egg_buffer_add_uint32 (&msg->buffer, attr->pValue ? attr->ulValueLen : 0);
}
- return !gkr_buffer_has_error (&msg->buffer);
+ return !egg_buffer_has_error (&msg->buffer);
}
int
@@ -264,26 +264,26 @@
assert (!msg->signature || gck_rpc_message_verify_part (msg, "aA"));
/* Write the number of items */
- gkr_buffer_add_uint32 (&msg->buffer, num);
+ egg_buffer_add_uint32 (&msg->buffer, num);
for (i = 0; i < num; ++i) {
attr = &(arr[i]);
/* The attribute type */
- gkr_buffer_add_uint32 (&msg->buffer, attr->type);
+ egg_buffer_add_uint32 (&msg->buffer, attr->type);
/* Write out the attribute validity */
validity = (((CK_LONG)attr->ulValueLen) == -1) ? 0 : 1;
- gkr_buffer_add_byte (&msg->buffer, validity);
+ egg_buffer_add_byte (&msg->buffer, validity);
/* The attribute length and value */
if (validity) {
- gkr_buffer_add_uint32 (&msg->buffer, attr->ulValueLen);
- gkr_buffer_add_byte_array (&msg->buffer, attr->pValue, attr->ulValueLen);
+ egg_buffer_add_uint32 (&msg->buffer, attr->ulValueLen);
+ egg_buffer_add_byte_array (&msg->buffer, attr->pValue, attr->ulValueLen);
}
}
- return !gkr_buffer_has_error (&msg->buffer);
+ return !egg_buffer_has_error (&msg->buffer);
}
int
@@ -293,7 +293,7 @@
/* Make sure this is in the right order */
assert (!msg->signature || gck_rpc_message_verify_part (msg, "y"));
- return gkr_buffer_get_byte (&msg->buffer, msg->parsed, &msg->parsed, val);
+ return egg_buffer_get_byte (&msg->buffer, msg->parsed, &msg->parsed, val);
}
int
@@ -303,7 +303,7 @@
/* Make sure this is in the right order */
assert (!msg->signature || gck_rpc_message_verify_part (msg, "y"));
- return gkr_buffer_add_byte (&msg->buffer, val);
+ return egg_buffer_add_byte (&msg->buffer, val);
}
int
@@ -315,7 +315,7 @@
/* Make sure this is in the right order */
assert (!msg->signature || gck_rpc_message_verify_part (msg, "u"));
- if (!gkr_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &v))
+ if (!egg_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &v))
return 0;
if (val)
*val = v;
@@ -329,7 +329,7 @@
/* Make sure this is in the rigth order */
assert (!msg->signature || gck_rpc_message_verify_part (msg, "u"));
- return gkr_buffer_add_uint32 (&msg->buffer, val);
+ return egg_buffer_add_uint32 (&msg->buffer, val);
}
int
@@ -339,7 +339,7 @@
/* Make sure this is in the right order */
assert (!msg->signature || gck_rpc_message_verify_part (msg, "fy"));
- return gkr_buffer_add_uint32 (&msg->buffer, count);
+ return egg_buffer_add_uint32 (&msg->buffer, count);
}
int
@@ -352,14 +352,14 @@
/* No array, no data, just length */
if (!arr) {
- gkr_buffer_add_byte (&msg->buffer, 0);
- gkr_buffer_add_uint32 (&msg->buffer, num);
+ egg_buffer_add_byte (&msg->buffer, 0);
+ egg_buffer_add_uint32 (&msg->buffer, num);
} else {
- gkr_buffer_add_byte (&msg->buffer, 1);
- gkr_buffer_add_byte_array (&msg->buffer, arr, num);
+ egg_buffer_add_byte (&msg->buffer, 1);
+ egg_buffer_add_byte_array (&msg->buffer, arr, num);
}
- return !gkr_buffer_has_error (&msg->buffer);
+ return !egg_buffer_has_error (&msg->buffer);
}
int
@@ -369,7 +369,7 @@
/* Make sure this is in the right order */
assert (!msg->signature || gck_rpc_message_verify_part (msg, "fu"));
- return gkr_buffer_add_uint32 (&msg->buffer, count);
+ return egg_buffer_add_uint32 (&msg->buffer, count);
}
int
@@ -383,16 +383,16 @@
assert (!msg->signature || gck_rpc_message_verify_part (msg, "au"));
/* We send a byte which determines whether there's actual data present or not */
- gkr_buffer_add_byte (&msg->buffer, array ? 1 : 0);
- gkr_buffer_add_uint32 (&msg->buffer, n_array);
+ egg_buffer_add_byte (&msg->buffer, array ? 1 : 0);
+ egg_buffer_add_uint32 (&msg->buffer, n_array);
/* Now send the data if valid */
if (array) {
for (i = 0; i < n_array; ++i)
- gkr_buffer_add_uint32 (&msg->buffer, array[i]);
+ egg_buffer_add_uint32 (&msg->buffer, array[i]);
}
- return !gkr_buffer_has_error (&msg->buffer);
+ return !egg_buffer_has_error (&msg->buffer);
}
int
@@ -404,8 +404,8 @@
/* Check that we're supposed to have this at this point */
assert (!msg->signature || gck_rpc_message_verify_part (msg, "v"));
- return gkr_buffer_get_byte (&msg->buffer, msg->parsed, &msg->parsed, &version->major) &&
- gkr_buffer_get_byte (&msg->buffer, msg->parsed, &msg->parsed, &version->minor);
+ return egg_buffer_get_byte (&msg->buffer, msg->parsed, &msg->parsed, &version->major) &&
+ egg_buffer_get_byte (&msg->buffer, msg->parsed, &msg->parsed, &version->minor);
}
int
@@ -417,10 +417,10 @@
/* Check that we're supposed to have this at this point */
assert (!msg->signature || gck_rpc_message_verify_part (msg, "v"));
- gkr_buffer_add_byte (&msg->buffer, version->major);
- gkr_buffer_add_byte (&msg->buffer, version->minor);
+ egg_buffer_add_byte (&msg->buffer, version->major);
+ egg_buffer_add_byte (&msg->buffer, version->minor);
- return !gkr_buffer_has_error (&msg->buffer);
+ return !egg_buffer_has_error (&msg->buffer);
}
int
@@ -435,7 +435,7 @@
assert (!msg->signature || gck_rpc_message_verify_part (msg, "s"));
- if (!gkr_buffer_get_byte_array (&msg->buffer, msg->parsed, &msg->parsed, &data, &n_data))
+ if (!egg_buffer_get_byte_array (&msg->buffer, msg->parsed, &msg->parsed, &data, &n_data))
return 0;
if (n_data != length) {
@@ -456,7 +456,7 @@
assert (!msg->signature || gck_rpc_message_verify_part (msg, "s"));
- return gkr_buffer_add_byte_array (&msg->buffer, buffer, length);
+ return egg_buffer_add_byte_array (&msg->buffer, buffer, length);
}
int
@@ -467,5 +467,5 @@
assert (!msg->signature || gck_rpc_message_verify_part (msg, "z"));
- return gkr_buffer_add_string (&msg->buffer, (const char*)string);
+ return egg_buffer_add_string (&msg->buffer, (const char*)string);
}
Modified: trunk/pkcs11/rpc-layer/gck-rpc-module.c
==============================================================================
--- trunk/pkcs11/rpc-layer/gck-rpc-module.c (original)
+++ trunk/pkcs11/rpc-layer/gck-rpc-module.c Sat Jan 17 23:27:10 2009
@@ -28,7 +28,7 @@
#include "pkcs11/pkcs11.h"
-#include "common/gkr-unix-credentials.h"
+#include "egg/egg-unix-credentials.h"
#include <sys/types.h>
#include <sys/param.h>
@@ -251,7 +251,7 @@
return CKR_DEVICE_ERROR;
}
- if (gkr_unix_credentials_write (sock) < 0) {
+ if (egg_unix_credentials_write (sock) < 0) {
close (sock);
warning (("couldn't send socket credentials: %s", strerror (errno)));
return CKR_DEVICE_ERROR;
@@ -482,7 +482,7 @@
cs->req = cs->resp = NULL;
/* Send the number of bytes, and then the data */
- gkr_buffer_encode_uint32 (buf, req->buffer.len);
+ egg_buffer_encode_uint32 (buf, req->buffer.len);
ret = call_write (cs, buf, 4);
if (ret != CKR_OK)
goto cleanup;
@@ -494,8 +494,8 @@
ret = call_read (cs, buf, 4);
if (ret != CKR_OK)
goto cleanup;
- len = gkr_buffer_decode_uint32 (buf);
- if (!gkr_buffer_reserve (&resp->buffer, len + resp->buffer.len)) {
+ len = egg_buffer_decode_uint32 (buf);
+ if (!egg_buffer_reserve (&resp->buffer, len + resp->buffer.len)) {
warning (("couldn't allocate %u byte response area: out of memory", len));
ret = CKR_HOST_MEMORY;
goto cleanup;
@@ -504,7 +504,7 @@
if (ret != CKR_OK)
goto cleanup;
- gkr_buffer_add_empty (&resp->buffer, len);
+ egg_buffer_add_empty (&resp->buffer, len);
if (!gck_rpc_message_parse (resp, GCK_RPC_RESPONSE))
goto cleanup;
@@ -648,7 +648,7 @@
assert (!msg->signature || gck_rpc_message_verify_part (msg, "aAu"));
/* Get the number of items. We need this value to be correct */
- if (!gkr_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &num))
+ if (!egg_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &num))
return PARSE_ERROR;
if (len != num) {
@@ -670,17 +670,17 @@
for (i = 0; i < num; ++i) {
/* The attribute type */
- gkr_buffer_get_uint32 (&msg->buffer, msg->parsed,
+ egg_buffer_get_uint32 (&msg->buffer, msg->parsed,
&msg->parsed, &type);
/* Attribute validity */
- gkr_buffer_get_byte (&msg->buffer, msg->parsed,
+ egg_buffer_get_byte (&msg->buffer, msg->parsed,
&msg->parsed, &validity);
/* And the data itself */
if (validity) {
- if (gkr_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &value) &&
- gkr_buffer_get_byte_array (&msg->buffer, msg->parsed, &msg->parsed, &attrval, &attrlen)) {
+ if (egg_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &value) &&
+ egg_buffer_get_byte_array (&msg->buffer, msg->parsed, &msg->parsed, &attrval, &attrlen)) {
if (attrval && value != attrlen) {
warning (("attribute length does not match attribute data"));
return PARSE_ERROR;
@@ -690,7 +690,7 @@
}
/* Don't act on this data unless no errors */
- if (gkr_buffer_has_error (&msg->buffer))
+ if (egg_buffer_has_error (&msg->buffer))
break;
/* Try and stuff it in the output data */
@@ -728,11 +728,11 @@
}
}
- if (gkr_buffer_has_error (&msg->buffer))
+ if (egg_buffer_has_error (&msg->buffer))
return PARSE_ERROR;
/* Read in the code that goes along with these attributes */
- if (!gkr_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &num))
+ if (!egg_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &num))
return PARSE_ERROR;
return (CK_RV)num;
@@ -753,12 +753,12 @@
assert (!msg->signature || gck_rpc_message_verify_part (msg, "ay"));
/* A single byte which determines whether valid or not */
- if (!gkr_buffer_get_byte (&msg->buffer, msg->parsed, &msg->parsed, &valid))
+ if (!egg_buffer_get_byte (&msg->buffer, msg->parsed, &msg->parsed, &valid))
return PARSE_ERROR;
/* If not valid, then just the length is encoded, this can signify CKR_BUFFER_TOO_SMALL */
if (!valid) {
- if (!gkr_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &vlen))
+ if (!egg_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &vlen))
return PARSE_ERROR;
*len = vlen;
@@ -770,7 +770,7 @@
}
/* Get the actual bytes */
- if (!gkr_buffer_get_byte_array (&msg->buffer, msg->parsed, &msg->parsed, &val, &vlen))
+ if (!egg_buffer_get_byte_array (&msg->buffer, msg->parsed, &msg->parsed, &val, &vlen))
return PARSE_ERROR;
*len = vlen;
@@ -801,11 +801,11 @@
assert (!msg->signature || gck_rpc_message_verify_part (msg, "au"));
/* A single byte which determines whether valid or not */
- if (!gkr_buffer_get_byte (&msg->buffer, msg->parsed, &msg->parsed, &valid))
+ if (!egg_buffer_get_byte (&msg->buffer, msg->parsed, &msg->parsed, &valid))
return PARSE_ERROR;
/* Get the number of items. */
- if (!gkr_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &num))
+ if (!egg_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &num))
return PARSE_ERROR;
*len = num;
@@ -823,12 +823,12 @@
/* We need to go ahead and read everything in all cases */
for (i = 0; i < num; ++i) {
- gkr_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &val);
+ egg_buffer_get_uint32 (&msg->buffer, msg->parsed, &msg->parsed, &val);
if (arr)
arr[i] = val;
}
- return gkr_buffer_has_error (&msg->buffer) ? PARSE_ERROR : CKR_OK;
+ return egg_buffer_has_error (&msg->buffer) ? PARSE_ERROR : CKR_OK;
}
static CK_RV
@@ -841,7 +841,7 @@
assert (!msg->signature || gck_rpc_message_verify_part (msg, "M"));
/* The mechanism type */
- gkr_buffer_add_uint32 (&msg->buffer, mech->mechanism);
+ egg_buffer_add_uint32 (&msg->buffer, mech->mechanism);
/*
* PKCS#11 mechanism parameters are not easy to serialize. They're
@@ -856,14 +856,14 @@
*/
if (gck_rpc_mechanism_has_no_parameters (mech->mechanism))
- gkr_buffer_add_byte_array (&msg->buffer, NULL, 0);
+ egg_buffer_add_byte_array (&msg->buffer, NULL, 0);
else if (gck_rpc_mechanism_has_sane_parameters (mech->mechanism))
- gkr_buffer_add_byte_array (&msg->buffer, mech->pParameter,
+ egg_buffer_add_byte_array (&msg->buffer, mech->pParameter,
mech->ulParameterLen);
else
return CKR_MECHANISM_INVALID;
- return gkr_buffer_has_error (&msg->buffer) ? CKR_HOST_MEMORY : CKR_OK;
+ return egg_buffer_has_error (&msg->buffer) ? CKR_HOST_MEMORY : CKR_OK;
}
static CK_RV
Modified: trunk/pkcs11/rpc-layer/gck-rpc-private.h
==============================================================================
--- trunk/pkcs11/rpc-layer/gck-rpc-private.h (original)
+++ trunk/pkcs11/rpc-layer/gck-rpc-private.h Sat Jan 17 23:27:10 2009
@@ -29,7 +29,7 @@
#include <stdlib.h>
#include <stdarg.h>
-#include "common/gkr-buffer.h"
+#include "egg/egg-buffer.h"
#include "pkcs11/pkcs11.h"
@@ -227,13 +227,13 @@
int call_id;
GckRpcMessageType call_type;
const char *signature;
- GkrBuffer buffer;
+ EggBuffer buffer;
size_t parsed;
const char *sigverify;
} GckRpcMessage;
-GckRpcMessage* gck_rpc_message_new (GkrBufferAllocator allocator);
+GckRpcMessage* gck_rpc_message_new (EggBufferAllocator allocator);
void gck_rpc_message_free (GckRpcMessage *msg);
@@ -244,7 +244,7 @@
#define gck_rpc_message_is_verified(msg) (!(msg)->sigverify || (msg)->sigverify[0] == 0)
-#define gck_rpc_message_buffer_error(msg) (gkr_buffer_has_error(&(msg)->buffer))
+#define gck_rpc_message_buffer_error(msg) (egg_buffer_has_error(&(msg)->buffer))
int gck_rpc_message_prep (GckRpcMessage *msg,
int call_id,
Modified: trunk/pkcs11/ssh-agent/Makefile.am
==============================================================================
--- trunk/pkcs11/ssh-agent/Makefile.am (original)
+++ trunk/pkcs11/ssh-agent/Makefile.am Sat Jan 17 23:27:10 2009
@@ -31,8 +31,8 @@
gck_ssh_agent_standalone_LDADD = \
libgck-ssh-agent.la \
$(top_builddir)/gp11/libgp11.la \
- $(top_builddir)/common/libgkr-common-buffer.la \
- $(top_builddir)/common/libgkr-common-secure.la \
+ $(top_builddir)/egg/libegg-buffer.la \
+ $(top_builddir)/egg/libegg-secure.la \
$(GOBJECT_LIBS) \
$(GTHREAD_LIBS) \
$(LIBGCRYPT_LIBS) \
Modified: trunk/pkcs11/ssh-agent/gck-ssh-agent-ops.c
==============================================================================
--- trunk/pkcs11/ssh-agent/gck-ssh-agent-ops.c (original)
+++ trunk/pkcs11/ssh-agent/gck-ssh-agent-ops.c Sat Jan 17 23:27:10 2009
@@ -26,7 +26,7 @@
#include "gp11/gp11.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include <glib.h>
@@ -535,7 +535,7 @@
gulong algo;
gsize offset;
- if (!gkr_buffer_get_string (call->req, 5, &offset, &stype, (GkrBufferAllocator)g_realloc))
+ if (!egg_buffer_get_string (call->req, 5, &offset, &stype, (EggBufferAllocator)g_realloc))
return FALSE;
algo = gck_ssh_agent_proto_keytype_to_algo (stype);
@@ -546,7 +546,7 @@
}
g_free (stype);
- priv = gp11_attributes_new_full ((GP11Allocator)gkr_secure_realloc);
+ priv = gp11_attributes_new_full ((GP11Allocator)egg_secure_realloc);
pub = gp11_attributes_new_full (g_realloc);
switch (algo) {
@@ -572,7 +572,7 @@
/* TODO: Blinding? See ssh-agent.c */
/* Get the comment */
- if (!gkr_buffer_get_string (call->req, offset, &offset, &comment, (GkrBufferAllocator)g_realloc)) {
+ if (!egg_buffer_get_string (call->req, offset, &offset, &comment, (EggBufferAllocator)g_realloc)) {
gp11_attributes_unref (pub);
gp11_attributes_unref (priv);
return FALSE;
@@ -597,7 +597,7 @@
gp11_attributes_unref (priv);
gp11_attributes_unref (pub);
- gkr_buffer_add_byte (call->resp, ret ? GCK_SSH_RES_SUCCESS : GCK_SSH_RES_FAILURE);
+ egg_buffer_add_byte (call->resp, ret ? GCK_SSH_RES_SUCCESS : GCK_SSH_RES_FAILURE);
return TRUE;
}
@@ -610,10 +610,10 @@
gsize offset = 5;
guint32 unused;
- if (!gkr_buffer_get_uint32 (call->req, offset, &offset, &unused))
+ if (!egg_buffer_get_uint32 (call->req, offset, &offset, &unused))
return FALSE;
- priv = gp11_attributes_new_full ((GP11Allocator)gkr_secure_realloc);
+ priv = gp11_attributes_new_full ((GP11Allocator)egg_secure_realloc);
pub = gp11_attributes_new_full (g_realloc);
if (!gck_ssh_agent_proto_read_pair_v1 (call->req, &offset, priv, pub)) {
@@ -641,7 +641,7 @@
gp11_attributes_unref (priv);
gp11_attributes_unref (pub);
- gkr_buffer_add_byte (call->resp, ret ? GCK_SSH_RES_SUCCESS : GCK_SSH_RES_FAILURE);
+ egg_buffer_add_byte (call->resp, ret ? GCK_SSH_RES_SUCCESS : GCK_SSH_RES_FAILURE);
return TRUE;
}
@@ -660,12 +660,12 @@
load_identity_v2_attributes, &all_attrs,
CKA_CLASS, GP11_ULONG, CKO_PUBLIC_KEY,
GP11_INVALID)) {
- gkr_buffer_add_byte (call->resp, GCK_SSH_RES_FAILURE);
+ egg_buffer_add_byte (call->resp, GCK_SSH_RES_FAILURE);
return TRUE;
}
- gkr_buffer_add_byte (call->resp, GCK_SSH_RES_IDENTITIES_ANSWER);
- gkr_buffer_add_uint32 (call->resp, g_list_length (all_attrs));
+ egg_buffer_add_byte (call->resp, GCK_SSH_RES_IDENTITIES_ANSWER);
+ egg_buffer_add_uint32 (call->resp, g_list_length (all_attrs));
for (l = all_attrs; l; l = g_list_next (l)) {
@@ -677,16 +677,16 @@
/* Add a space for the key blob length */
blobpos = call->resp->len;
- gkr_buffer_add_uint32 (call->resp, 0);
+ egg_buffer_add_uint32 (call->resp, 0);
/* Write out the key */
gck_ssh_agent_proto_write_public (call->resp, attrs);
/* Write back the blob length */
- gkr_buffer_set_uint32 (call->resp, blobpos, (call->resp->len - blobpos) - 4);
+ egg_buffer_set_uint32 (call->resp, blobpos, (call->resp->len - blobpos) - 4);
/* And now a per key comment */
- gkr_buffer_add_string (call->resp, comment ? comment : "");
+ egg_buffer_add_string (call->resp, comment ? comment : "");
g_free (comment);
gp11_attributes_unref (attrs);
@@ -712,12 +712,12 @@
CKA_TOKEN, GP11_BOOLEAN, FALSE,
CKA_LABEL, GP11_STRING, V1_LABEL,
GP11_INVALID)) {
- gkr_buffer_add_byte (call->resp, GCK_SSH_RES_FAILURE);
+ egg_buffer_add_byte (call->resp, GCK_SSH_RES_FAILURE);
return TRUE;
}
- gkr_buffer_add_byte (call->resp, GCK_SSH_RES_RSA_IDENTITIES_ANSWER);
- gkr_buffer_add_uint32 (call->resp, g_list_length (all_attrs));
+ egg_buffer_add_byte (call->resp, GCK_SSH_RES_RSA_IDENTITIES_ANSWER);
+ egg_buffer_add_uint32 (call->resp, g_list_length (all_attrs));
for (l = all_attrs; l; l = g_list_next (l)) {
@@ -727,7 +727,7 @@
gck_ssh_agent_proto_write_public_v1 (call->resp, attrs);
/* And now a per key comment */
- gkr_buffer_add_string (call->resp, "Public Key");
+ egg_buffer_add_string (call->resp, "Public Key");
gp11_attributes_unref (attrs);
}
@@ -829,7 +829,7 @@
offset = 5;
/* The key packet size */
- if (!gkr_buffer_get_uint32 (call->req, offset, &offset, &sz))
+ if (!egg_buffer_get_uint32 (call->req, offset, &offset, &sz))
return FALSE;
/* The key itself */
@@ -845,8 +845,8 @@
else
g_return_val_if_reached (FALSE);
- if (!gkr_buffer_get_byte_array (call->req, offset, &offset, &data, &n_data) ||
- !gkr_buffer_get_uint32 (call->req, offset, &offset, &flags)) {
+ if (!egg_buffer_get_byte_array (call->req, offset, &offset, &data, &n_data) ||
+ !egg_buffer_get_uint32 (call->req, offset, &offset, &flags)) {
gp11_attributes_unref (attrs);
return FALSE;
}
@@ -856,7 +856,7 @@
gp11_attributes_unref (attrs);
if (!key) {
- gkr_buffer_add_byte (call->resp, GCK_SSH_RES_FAILURE);
+ egg_buffer_add_byte (call->resp, GCK_SSH_RES_FAILURE);
return TRUE;
}
@@ -886,19 +886,19 @@
if (error->code != CKR_FUNCTION_CANCELED)
g_message ("signing of the data failed: %s", error->message);
g_clear_error (&error);
- gkr_buffer_add_byte (call->resp, GCK_SSH_RES_FAILURE);
+ egg_buffer_add_byte (call->resp, GCK_SSH_RES_FAILURE);
return TRUE;
}
- gkr_buffer_add_byte (call->resp, GCK_SSH_RES_SIGN_RESPONSE);
+ egg_buffer_add_byte (call->resp, GCK_SSH_RES_SIGN_RESPONSE);
/* Add a space for the sig blob length */
blobpos = call->resp->len;
- gkr_buffer_add_uint32 (call->resp, 0);
+ egg_buffer_add_uint32 (call->resp, 0);
salgo = gck_ssh_agent_proto_algo_to_keytype (algo);
g_assert (salgo);
- gkr_buffer_add_string (call->resp, salgo);
+ egg_buffer_add_string (call->resp, salgo);
switch (algo) {
case CKK_RSA:
@@ -917,7 +917,7 @@
g_return_val_if_fail (ret, FALSE);
/* Write back the blob length */
- gkr_buffer_set_uint32 (call->resp, blobpos, (call->resp->len - blobpos) - 4);
+ egg_buffer_set_uint32 (call->resp, blobpos, (call->resp->len - blobpos) - 4);
return TRUE;
}
@@ -955,21 +955,21 @@
/* Only protocol 1.1 is supported */
if (call->req->len <= offset) {
gp11_attributes_unref (attrs);
- gkr_buffer_add_byte (call->resp, GCK_SSH_RES_FAILURE);
+ egg_buffer_add_byte (call->resp, GCK_SSH_RES_FAILURE);
return TRUE;
}
/* Read out the session id, raw, unbounded */
for (i = 0; i < 16; ++i) {
- gkr_buffer_get_byte (call->req, offset, &offset, &b);
+ egg_buffer_get_byte (call->req, offset, &offset, &b);
session_id[i] = b;
}
/* And the response type */
- gkr_buffer_get_uint32 (call->req, offset, &offset, &resp_type);
+ egg_buffer_get_uint32 (call->req, offset, &offset, &resp_type);
/* Did parsing fail? */
- if (gkr_buffer_has_error (call->req) || data == NULL) {
+ if (egg_buffer_has_error (call->req) || data == NULL) {
gp11_attributes_unref (attrs);
return FALSE;
}
@@ -977,7 +977,7 @@
/* Not supported request type */
if (resp_type != 1) {
gp11_attributes_unref (attrs);
- gkr_buffer_add_byte (call->resp, GCK_SSH_RES_FAILURE);
+ egg_buffer_add_byte (call->resp, GCK_SSH_RES_FAILURE);
return TRUE;
}
@@ -987,7 +987,7 @@
/* Didn't find a key? */
if (key == NULL) {
- gkr_buffer_add_byte (call->resp, GCK_SSH_RES_FAILURE);
+ egg_buffer_add_byte (call->resp, GCK_SSH_RES_FAILURE);
return TRUE;
}
@@ -1003,7 +1003,7 @@
if (error->code != CKR_FUNCTION_CANCELED)
g_message ("decryption of the data failed: %s", error->message);
g_clear_error (&error);
- gkr_buffer_add_byte (call->resp, GCK_SSH_RES_FAILURE);
+ egg_buffer_add_byte (call->resp, GCK_SSH_RES_FAILURE);
return TRUE;
}
@@ -1014,8 +1014,8 @@
n_hash = sizeof (hash);
g_checksum_get_digest (checksum, hash, &n_hash);
- gkr_buffer_add_byte (call->resp, GCK_SSH_RES_RSA_RESPONSE);
- gkr_buffer_append (call->resp, hash, n_hash);
+ egg_buffer_add_byte (call->resp, GCK_SSH_RES_RSA_RESPONSE);
+ egg_buffer_append (call->resp, hash, n_hash);
g_free (result);
return TRUE;
@@ -1033,7 +1033,7 @@
offset = 5;
/* The key packet size */
- if (!gkr_buffer_get_uint32 (call->req, offset, &offset, &sz))
+ if (!egg_buffer_get_uint32 (call->req, offset, &offset, &sz))
return FALSE;
/* The public key itself */
@@ -1063,7 +1063,7 @@
/* TODO: Implement locking of other keys */
- gkr_buffer_add_byte (call->resp, GCK_SSH_RES_SUCCESS);
+ egg_buffer_add_byte (call->resp, GCK_SSH_RES_SUCCESS);
return TRUE;
}
@@ -1102,7 +1102,7 @@
gck_ssh_agent_checkin_main_session (session);
- gkr_buffer_add_byte (call->resp, GCK_SSH_RES_SUCCESS);
+ egg_buffer_add_byte (call->resp, GCK_SSH_RES_SUCCESS);
return TRUE;
}
@@ -1136,7 +1136,7 @@
/* TODO: Go through all open tokens and lock private SSH keys */
- gkr_buffer_add_byte (call->resp, GCK_SSH_RES_SUCCESS);
+ egg_buffer_add_byte (call->resp, GCK_SSH_RES_SUCCESS);
return TRUE;
}
@@ -1169,21 +1169,21 @@
gck_ssh_agent_checkin_main_session (session);
- gkr_buffer_add_byte (call->resp, GCK_SSH_RES_SUCCESS);
+ egg_buffer_add_byte (call->resp, GCK_SSH_RES_SUCCESS);
return TRUE;
}
static gboolean
op_not_implemented_success (GckSshAgentCall *call)
{
- gkr_buffer_add_byte (call->resp, GCK_SSH_RES_SUCCESS);
+ egg_buffer_add_byte (call->resp, GCK_SSH_RES_SUCCESS);
return TRUE;
}
static gboolean
op_not_implemented_failure (GckSshAgentCall *call)
{
- gkr_buffer_add_byte (call->resp, GCK_SSH_RES_FAILURE);
+ egg_buffer_add_byte (call->resp, GCK_SSH_RES_FAILURE);
return TRUE;
}
Modified: trunk/pkcs11/ssh-agent/gck-ssh-agent-private.h
==============================================================================
--- trunk/pkcs11/ssh-agent/gck-ssh-agent-private.h (original)
+++ trunk/pkcs11/ssh-agent/gck-ssh-agent-private.h Sat Jan 17 23:27:10 2009
@@ -23,7 +23,7 @@
#ifndef GKRSSHPRIVATE_H_
#define GKRSSHPRIVATE_H_
-#include "common/gkr-buffer.h"
+#include "egg/egg-buffer.h"
#include "pkcs11/pkcs11.h"
@@ -34,8 +34,8 @@
typedef struct _GckSshAgentCall {
int sock;
GP11Module *module;
- GkrBuffer *req;
- GkrBuffer *resp;
+ EggBuffer *req;
+ EggBuffer *resp;
} GckSshAgentCall;
/* -----------------------------------------------------------------------------
@@ -105,75 +105,75 @@
const gchar* gck_ssh_agent_proto_algo_to_keytype (gulong algo);
-gboolean gck_ssh_agent_proto_read_mpi (GkrBuffer *req,
+gboolean gck_ssh_agent_proto_read_mpi (EggBuffer *req,
gsize *offset,
GP11Attributes *attrs,
CK_ATTRIBUTE_TYPE type);
-gboolean gck_ssh_agent_proto_read_mpi_v1 (GkrBuffer *req,
+gboolean gck_ssh_agent_proto_read_mpi_v1 (EggBuffer *req,
gsize *offset,
GP11Attributes *attrs,
CK_ATTRIBUTE_TYPE type);
-const guchar* gck_ssh_agent_proto_read_challenge_v1 (GkrBuffer *req,
+const guchar* gck_ssh_agent_proto_read_challenge_v1 (EggBuffer *req,
gsize *offset,
gsize *n_challenge);
-gboolean gck_ssh_agent_proto_write_mpi (GkrBuffer *resp,
+gboolean gck_ssh_agent_proto_write_mpi (EggBuffer *resp,
GP11Attribute *attr);
-gboolean gck_ssh_agent_proto_write_mpi_v1 (GkrBuffer *resp,
+gboolean gck_ssh_agent_proto_write_mpi_v1 (EggBuffer *resp,
GP11Attribute *attr);
-gboolean gck_ssh_agent_proto_read_public (GkrBuffer *req,
+gboolean gck_ssh_agent_proto_read_public (EggBuffer *req,
gsize *offset,
GP11Attributes *attrs,
gulong *algo);
-gboolean gck_ssh_agent_proto_read_public_rsa (GkrBuffer *req,
+gboolean gck_ssh_agent_proto_read_public_rsa (EggBuffer *req,
gsize *offset,
GP11Attributes *attrs);
-gboolean gck_ssh_agent_proto_read_public_dsa (GkrBuffer *req,
+gboolean gck_ssh_agent_proto_read_public_dsa (EggBuffer *req,
gsize *offset,
GP11Attributes *attrs);
-gboolean gck_ssh_agent_proto_read_public_v1 (GkrBuffer *req,
+gboolean gck_ssh_agent_proto_read_public_v1 (EggBuffer *req,
gsize *offset,
GP11Attributes *attrs);
-gboolean gck_ssh_agent_proto_read_pair_rsa (GkrBuffer *req,
+gboolean gck_ssh_agent_proto_read_pair_rsa (EggBuffer *req,
gsize *offset,
GP11Attributes *priv_attrs,
GP11Attributes *pub_attrs);
-gboolean gck_ssh_agent_proto_read_pair_dsa (GkrBuffer *req,
+gboolean gck_ssh_agent_proto_read_pair_dsa (EggBuffer *req,
gsize *offset,
GP11Attributes *priv_attrs,
GP11Attributes *pub_attrs);
-gboolean gck_ssh_agent_proto_read_pair_v1 (GkrBuffer *req,
+gboolean gck_ssh_agent_proto_read_pair_v1 (EggBuffer *req,
gsize *offset,
GP11Attributes *priv_attrs,
GP11Attributes *pub_attrs);
-gboolean gck_ssh_agent_proto_write_public (GkrBuffer *resp,
+gboolean gck_ssh_agent_proto_write_public (EggBuffer *resp,
GP11Attributes *attrs);
-gboolean gck_ssh_agent_proto_write_public_rsa (GkrBuffer *resp,
+gboolean gck_ssh_agent_proto_write_public_rsa (EggBuffer *resp,
GP11Attributes *attrs);
-gboolean gck_ssh_agent_proto_write_public_dsa (GkrBuffer *resp,
+gboolean gck_ssh_agent_proto_write_public_dsa (EggBuffer *resp,
GP11Attributes *attrs);
-gboolean gck_ssh_agent_proto_write_public_v1 (GkrBuffer *resp,
+gboolean gck_ssh_agent_proto_write_public_v1 (EggBuffer *resp,
GP11Attributes *attrs);
-gboolean gck_ssh_agent_proto_write_signature_rsa (GkrBuffer *resp,
+gboolean gck_ssh_agent_proto_write_signature_rsa (EggBuffer *resp,
CK_BYTE_PTR signature,
CK_ULONG n_signature);
-gboolean gck_ssh_agent_proto_write_signature_dsa (GkrBuffer *resp,
+gboolean gck_ssh_agent_proto_write_signature_dsa (EggBuffer *resp,
CK_BYTE_PTR signature,
CK_ULONG n_signature);
Modified: trunk/pkcs11/ssh-agent/gck-ssh-agent-proto.c
==============================================================================
--- trunk/pkcs11/ssh-agent/gck-ssh-agent-proto.c (original)
+++ trunk/pkcs11/ssh-agent/gck-ssh-agent-proto.c Sat Jan 17 23:27:10 2009
@@ -24,7 +24,7 @@
#include "gck-ssh-agent-private.h"
-#include "common/gkr-buffer.h"
+#include "egg/egg-buffer.h"
#include <gp11/gp11.h>
@@ -54,13 +54,13 @@
}
gboolean
-gck_ssh_agent_proto_read_mpi (GkrBuffer *req, gsize *offset, GP11Attributes *attrs,
+gck_ssh_agent_proto_read_mpi (EggBuffer *req, gsize *offset, GP11Attributes *attrs,
CK_ATTRIBUTE_TYPE type)
{
const guchar *data;
gsize len;
- if (!gkr_buffer_get_byte_array (req, *offset, offset, &data, &len))
+ if (!egg_buffer_get_byte_array (req, *offset, offset, &data, &len))
return FALSE;
/* Convert to unsigned format */
@@ -74,7 +74,7 @@
}
gboolean
-gck_ssh_agent_proto_read_mpi_v1 (GkrBuffer *req, gsize *offset, GP11Attributes *attrs,
+gck_ssh_agent_proto_read_mpi_v1 (EggBuffer *req, gsize *offset, GP11Attributes *attrs,
CK_ATTRIBUTE_TYPE type)
{
const guchar *data;
@@ -82,7 +82,7 @@
guint16 bits;
/* Get the number of bits */
- if (!gkr_buffer_get_uint16 (req, *offset, offset, &bits))
+ if (!egg_buffer_get_uint16 (req, *offset, offset, &bits))
return FALSE;
/* Figure out the number of binary bytes following */
@@ -101,7 +101,7 @@
}
gboolean
-gck_ssh_agent_proto_write_mpi (GkrBuffer *resp, GP11Attribute *attr)
+gck_ssh_agent_proto_write_mpi (EggBuffer *resp, GP11Attribute *attr)
{
guchar *data;
gsize n_extra;
@@ -114,7 +114,7 @@
if (attr->length && (attr->value[0] & 0x80))
++n_extra;
- data = gkr_buffer_add_byte_array_empty (resp, attr->length + n_extra);
+ data = egg_buffer_add_byte_array_empty (resp, attr->length + n_extra);
if (data == NULL)
return FALSE;
@@ -124,16 +124,16 @@
}
gboolean
-gck_ssh_agent_proto_write_mpi_v1 (GkrBuffer *resp, GP11Attribute *attr)
+gck_ssh_agent_proto_write_mpi_v1 (EggBuffer *resp, GP11Attribute *attr)
{
guchar *data;
g_return_val_if_fail (attr->length * 8 < G_MAXUSHORT, FALSE);
- if (!gkr_buffer_add_uint16 (resp, attr->length * 8))
+ if (!egg_buffer_add_uint16 (resp, attr->length * 8))
return FALSE;
- data = gkr_buffer_add_empty (resp, attr->length);
+ data = egg_buffer_add_empty (resp, attr->length);
if (data == NULL)
return FALSE;
memcpy (data, attr->value, attr->length);
@@ -141,14 +141,14 @@
}
const guchar*
-gck_ssh_agent_proto_read_challenge_v1 (GkrBuffer *req, gsize *offset, gsize *n_challenge)
+gck_ssh_agent_proto_read_challenge_v1 (EggBuffer *req, gsize *offset, gsize *n_challenge)
{
const guchar *data;
gsize bytes;
guint16 bits;
/* Get the number of bits */
- if (!gkr_buffer_get_uint16 (req, *offset, offset, &bits))
+ if (!egg_buffer_get_uint16 (req, *offset, offset, &bits))
return FALSE;
/* Figure out the number of binary bytes following */
@@ -166,7 +166,7 @@
}
gboolean
-gck_ssh_agent_proto_read_public (GkrBuffer *req, gsize *offset, GP11Attributes* attrs, gulong *algo)
+gck_ssh_agent_proto_read_public (EggBuffer *req, gsize *offset, GP11Attributes* attrs, gulong *algo)
{
gboolean ret;
gchar *stype;
@@ -176,7 +176,7 @@
g_assert (offset);
/* The string algorithm */
- if (!gkr_buffer_get_string (req, *offset, offset, &stype, (GkrBufferAllocator)g_realloc))
+ if (!egg_buffer_get_string (req, *offset, offset, &stype, (EggBufferAllocator)g_realloc))
return FALSE;
alg = gck_ssh_agent_proto_keytype_to_algo (stype);
@@ -210,7 +210,7 @@
}
gboolean
-gck_ssh_agent_proto_read_pair_rsa (GkrBuffer *req, gsize *offset,
+gck_ssh_agent_proto_read_pair_rsa (EggBuffer *req, gsize *offset,
GP11Attributes *priv_attrs, GP11Attributes *pub_attrs)
{
GP11Attribute *attr;
@@ -244,7 +244,7 @@
}
gboolean
-gck_ssh_agent_proto_read_pair_v1 (GkrBuffer *req, gsize *offset,
+gck_ssh_agent_proto_read_pair_v1 (EggBuffer *req, gsize *offset,
GP11Attributes *priv_attrs, GP11Attributes *pub_attrs)
{
GP11Attribute *attr;
@@ -278,7 +278,7 @@
}
gboolean
-gck_ssh_agent_proto_read_public_rsa (GkrBuffer *req, gsize *offset, GP11Attributes *attrs)
+gck_ssh_agent_proto_read_public_rsa (EggBuffer *req, gsize *offset, GP11Attributes *attrs)
{
g_assert (req);
g_assert (offset);
@@ -296,7 +296,7 @@
}
gboolean
-gck_ssh_agent_proto_read_public_v1 (GkrBuffer *req, gsize *offset, GP11Attributes *attrs)
+gck_ssh_agent_proto_read_public_v1 (EggBuffer *req, gsize *offset, GP11Attributes *attrs)
{
guint32 bits;
@@ -304,7 +304,7 @@
g_assert (offset);
g_assert (attrs);
- if (!gkr_buffer_get_uint32 (req, *offset, offset, &bits))
+ if (!egg_buffer_get_uint32 (req, *offset, offset, &bits))
return FALSE;
if (!gck_ssh_agent_proto_read_mpi_v1 (req, offset, attrs, CKA_PUBLIC_EXPONENT) ||
@@ -319,7 +319,7 @@
}
gboolean
-gck_ssh_agent_proto_read_pair_dsa (GkrBuffer *req, gsize *offset,
+gck_ssh_agent_proto_read_pair_dsa (EggBuffer *req, gsize *offset,
GP11Attributes *priv_attrs, GP11Attributes *pub_attrs)
{
GP11Attribute *attr;
@@ -354,7 +354,7 @@
}
gboolean
-gck_ssh_agent_proto_read_public_dsa (GkrBuffer *req, gsize *offset, GP11Attributes *attrs)
+gck_ssh_agent_proto_read_public_dsa (EggBuffer *req, gsize *offset, GP11Attributes *attrs)
{
g_assert (req);
g_assert (offset);
@@ -374,7 +374,7 @@
}
gboolean
-gck_ssh_agent_proto_write_public (GkrBuffer *resp, GP11Attributes *attrs)
+gck_ssh_agent_proto_write_public (EggBuffer *resp, GP11Attributes *attrs)
{
gboolean ret = FALSE;
const gchar *salgo;
@@ -388,7 +388,7 @@
salgo = gck_ssh_agent_proto_algo_to_keytype (algo);
g_assert (salgo);
- gkr_buffer_add_string (resp, salgo);
+ egg_buffer_add_string (resp, salgo);
switch (algo) {
case CKK_RSA:
@@ -408,7 +408,7 @@
}
gboolean
-gck_ssh_agent_proto_write_public_rsa (GkrBuffer *resp, GP11Attributes *attrs)
+gck_ssh_agent_proto_write_public_rsa (EggBuffer *resp, GP11Attributes *attrs)
{
GP11Attribute *attr;
@@ -431,7 +431,7 @@
}
gboolean
-gck_ssh_agent_proto_write_public_dsa (GkrBuffer *resp, GP11Attributes *attrs)
+gck_ssh_agent_proto_write_public_dsa (EggBuffer *resp, GP11Attributes *attrs)
{
GP11Attribute *attr;
@@ -466,7 +466,7 @@
}
gboolean
-gck_ssh_agent_proto_write_public_v1 (GkrBuffer *resp, GP11Attributes *attrs)
+gck_ssh_agent_proto_write_public_v1 (EggBuffer *resp, GP11Attributes *attrs)
{
GP11Attribute *attr;
gulong bits;
@@ -479,7 +479,7 @@
/* Write out the number of bits of the key */
if (!gp11_attributes_find_ulong (attrs, CKA_MODULUS_BITS, &bits))
g_return_val_if_reached (FALSE);
- gkr_buffer_add_uint32 (resp, bits);
+ egg_buffer_add_uint32 (resp, bits);
/* Write out the exponent */
attr = gp11_attributes_find (attrs, CKA_PUBLIC_EXPONENT);
@@ -499,15 +499,15 @@
}
gboolean
-gck_ssh_agent_proto_write_signature_rsa (GkrBuffer *resp, CK_BYTE_PTR signature, CK_ULONG n_signature)
+gck_ssh_agent_proto_write_signature_rsa (EggBuffer *resp, CK_BYTE_PTR signature, CK_ULONG n_signature)
{
- return gkr_buffer_add_byte_array (resp, signature, n_signature);
+ return egg_buffer_add_byte_array (resp, signature, n_signature);
}
gboolean
-gck_ssh_agent_proto_write_signature_dsa (GkrBuffer *resp, CK_BYTE_PTR signature, CK_ULONG n_signature)
+gck_ssh_agent_proto_write_signature_dsa (EggBuffer *resp, CK_BYTE_PTR signature, CK_ULONG n_signature)
{
g_return_val_if_fail (n_signature == 40, FALSE);
- return gkr_buffer_add_byte_array (resp, signature, n_signature);
+ return egg_buffer_add_byte_array (resp, signature, n_signature);
}
Modified: trunk/pkcs11/ssh-agent/gck-ssh-agent-standalone.c
==============================================================================
--- trunk/pkcs11/ssh-agent/gck-ssh-agent-standalone.c (original)
+++ trunk/pkcs11/ssh-agent/gck-ssh-agent-standalone.c Sat Jan 17 23:27:10 2009
@@ -25,7 +25,7 @@
#include "gck-ssh-agent.h"
#include "gck-ssh-agent-private.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "gp11/gp11.h"
@@ -38,13 +38,13 @@
G_LOCK_DEFINE_STATIC (memory_mutex);
-void gkr_memory_lock (void)
+void egg_memory_lock (void)
{ G_LOCK (memory_mutex); }
-void gkr_memory_unlock (void)
+void egg_memory_unlock (void)
{ G_UNLOCK (memory_mutex); }
-void* gkr_memory_fallback (void *p, unsigned long sz)
+void* egg_memory_fallback (void *p, unsigned long sz)
{ return g_realloc (p, sz); }
static gboolean
Modified: trunk/pkcs11/ssh-agent/gck-ssh-agent.c
==============================================================================
--- trunk/pkcs11/ssh-agent/gck-ssh-agent.c (original)
+++ trunk/pkcs11/ssh-agent/gck-ssh-agent.c Sat Jan 17 23:27:10 2009
@@ -36,8 +36,8 @@
#include "gck-ssh-agent.h"
#include "gck-ssh-agent-private.h"
-#include "common/gkr-buffer.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-buffer.h"
+#include "egg/egg-secure-memory.h"
#ifndef HAVE_SOCKLEN_T
#define socklen_t int
@@ -105,17 +105,17 @@
fd = call->sock;
- gkr_buffer_resize (call->req, 4);
+ egg_buffer_resize (call->req, 4);
if (!read_all (fd, call->req->buf, 4))
return FALSE;
- if (!gkr_buffer_get_uint32 (call->req, 0, NULL, &packet_size) ||
+ if (!egg_buffer_get_uint32 (call->req, 0, NULL, &packet_size) ||
packet_size < 1) {
g_warning ("invalid packet size from client");
return FALSE;
}
- gkr_buffer_resize (call->req, packet_size + 4);
+ egg_buffer_resize (call->req, packet_size + 4);
if (!read_all (fd, call->req->buf + 4, packet_size))
return FALSE;
@@ -127,8 +127,8 @@
{
gint *socket = data;
GckSshAgentCall call;
- GkrBuffer req;
- GkrBuffer resp;
+ EggBuffer req;
+ EggBuffer resp;
guchar op;
g_assert (GP11_IS_MODULE (pkcs11_module));
@@ -137,33 +137,33 @@
call.sock = g_atomic_int_get (socket);
g_assert (call.sock != -1);
- gkr_buffer_init_full (&req, 128, gkr_secure_realloc);
- gkr_buffer_init_full (&resp, 128, (GkrBufferAllocator)g_realloc);
+ egg_buffer_init_full (&req, 128, egg_secure_realloc);
+ egg_buffer_init_full (&resp, 128, (EggBufferAllocator)g_realloc);
call.req = &req;
call.resp = &resp;
call.module = g_object_ref (pkcs11_module);
for (;;) {
- gkr_buffer_reset (call.req);
+ egg_buffer_reset (call.req);
/* 1. Read in the request */
if (!read_packet_with_size (&call))
break;
/* 2. Now decode the operation */
- if (!gkr_buffer_get_byte (call.req, 4, NULL, &op))
+ if (!egg_buffer_get_byte (call.req, 4, NULL, &op))
break;
if (op >= GCK_SSH_OP_MAX)
break;
g_assert (gck_ssh_agent_operations[op]);
/* 3. Execute the right operation */
- gkr_buffer_reset (call.resp);
- gkr_buffer_add_uint32 (call.resp, 0);
+ egg_buffer_reset (call.resp);
+ egg_buffer_add_uint32 (call.resp, 0);
if (!(gck_ssh_agent_operations[op]) (&call))
break;
- if (!gkr_buffer_set_uint32 (call.resp, 0, call.resp->len - 4))
+ if (!egg_buffer_set_uint32 (call.resp, 0, call.resp->len - 4))
break;
/* 4. Write the reply back out */
@@ -171,8 +171,8 @@
break;
}
- gkr_buffer_uninit (&req);
- gkr_buffer_uninit (&resp);
+ egg_buffer_uninit (&req);
+ egg_buffer_uninit (&resp);
g_object_unref (call.module);
close (call.sock);
Modified: trunk/pkcs11/ssh-store/Makefile.am
==============================================================================
--- trunk/pkcs11/ssh-store/Makefile.am (original)
+++ trunk/pkcs11/ssh-store/Makefile.am Sat Jan 17 23:27:10 2009
@@ -39,8 +39,7 @@
gck_ssh_store_standalone_la_LIBADD = \
libgck-ssh-store.la \
$(top_builddir)/pkcs11/gck/libgck.la \
- $(top_builddir)/common/libgkr-common-buffer.la \
- $(top_builddir)/common/libgkr-common-secure.la \
+ $(top_builddir)/egg/libegg.la \
$(GOBJECT_LIBS) \
$(GTHREAD_LIBS) \
$(GLIB_LIBS) \
Modified: trunk/pkcs11/ssh-store/gck-ssh-openssh.c
==============================================================================
--- trunk/pkcs11/ssh-store/gck-ssh-openssh.c (original)
+++ trunk/pkcs11/ssh-store/gck-ssh-openssh.c Sat Jan 17 23:27:10 2009
@@ -7,7 +7,7 @@
#include "gck/gck-data-pem.h"
#include "gck/gck-data-types.h"
-#include "common/gkr-buffer.h"
+#include "egg/egg-buffer.h"
typedef struct _ParsePrivate {
gcry_sexp_t sexp;
@@ -33,13 +33,13 @@
}
static gboolean
-read_mpi (GkrBuffer *req, gsize *offset, gcry_mpi_t *mpi)
+read_mpi (EggBuffer *req, gsize *offset, gcry_mpi_t *mpi)
{
const guchar *data;
gsize len;
gcry_error_t gcry;
- if (!gkr_buffer_get_byte_array (req, *offset, offset, &data, &len))
+ if (!egg_buffer_get_byte_array (req, *offset, offset, &data, &len))
return FALSE;
gcry = gcry_mpi_scan (mpi, GCRYMPI_FMT_USG, data, len, NULL);
@@ -58,7 +58,7 @@
" (y %m)))"
static gboolean
-read_public_dsa (GkrBuffer *req, gsize *offset, gcry_sexp_t *sexp)
+read_public_dsa (EggBuffer *req, gsize *offset, gcry_sexp_t *sexp)
{
gcry_mpi_t p, q, g, y;
int gcry;
@@ -90,7 +90,7 @@
" (e %m)))"
static gboolean
-read_public_rsa (GkrBuffer *req, gsize *offset, gcry_sexp_t *sexp)
+read_public_rsa (EggBuffer *req, gsize *offset, gcry_sexp_t *sexp)
{
gcry_mpi_t n, e;
int gcry;
@@ -112,14 +112,14 @@
}
static gboolean
-read_public (GkrBuffer *req, gsize *offset, gcry_sexp_t *key, int *algo)
+read_public (EggBuffer *req, gsize *offset, gcry_sexp_t *key, int *algo)
{
gboolean ret;
gchar *stype;
int alg;
/* The string algorithm */
- if (!gkr_buffer_get_string (req, *offset, offset, &stype, (GkrBufferAllocator)g_realloc))
+ if (!egg_buffer_get_string (req, *offset, offset, &stype, (EggBufferAllocator)g_realloc))
return FALSE;
alg = keytype_to_algo (stype);
@@ -171,7 +171,7 @@
g_assert (decrypted);
/* Unpad the DER data */
- length = gck_data_asn1_element_length (decrypted, n_decrypted);
+ length = egg_asn1_element_length (decrypted, n_decrypted);
if (length > 0)
n_decrypted = length;
@@ -233,7 +233,7 @@
gck_ssh_openssh_parse_public_key (const guchar *data, gsize n_data,
gcry_sexp_t *sexp, gchar **comment)
{
- GkrBuffer buf;
+ EggBuffer buf;
const guchar *at;
guchar *decoded;
gsize n_decoded;
@@ -307,7 +307,7 @@
n_decoded = g_base64_decode_step ((gchar*)data, n_data, decoded, &state, &save);
/* Parse the actual key */
- gkr_buffer_init_static (&buf, decoded, n_decoded);
+ egg_buffer_init_static (&buf, decoded, n_decoded);
offset = 0;
ret = read_public (&buf, &offset, sexp, NULL);
g_free (decoded);
Modified: trunk/pkcs11/ssh-store/gck-ssh-standalone.c
==============================================================================
--- trunk/pkcs11/ssh-store/gck-ssh-standalone.c (original)
+++ trunk/pkcs11/ssh-store/gck-ssh-standalone.c Sat Jan 17 23:27:10 2009
@@ -27,7 +27,7 @@
#include "gck/gck-crypto.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "pkcs11/pkcs11.h"
@@ -35,11 +35,11 @@
/* Module callbacks for secure memory */
static GStaticMutex memory_mutex = G_STATIC_MUTEX_INIT;
-void gkr_memory_lock (void)
+void egg_memory_lock (void)
{ g_static_mutex_lock (&memory_mutex); }
-void gkr_memory_unlock (void)
+void egg_memory_unlock (void)
{ g_static_mutex_unlock (&memory_mutex); }
-void* gkr_memory_fallback (void *p, unsigned long sz)
+void* egg_memory_fallback (void *p, unsigned long sz)
{ return g_realloc (p, sz); }
CK_RV
Modified: trunk/pkcs11/ssh-store/tests/Makefile.am
==============================================================================
--- trunk/pkcs11/ssh-store/tests/Makefile.am (original)
+++ trunk/pkcs11/ssh-store/tests/Makefile.am Sat Jan 17 23:27:10 2009
@@ -6,8 +6,7 @@
UNIT_LIBS = \
$(top_builddir)/pkcs11/ssh-store/libgck-ssh-store.la \
$(top_builddir)/pkcs11/gck/libgck.la \
- $(top_builddir)/common/libgkr-common-buffer.la \
- $(top_builddir)/common/libgkr-common-secure.la
+ $(top_builddir)/egg/libegg.la
include $(top_srcdir)/tests/gtest.make
Modified: trunk/pkcs11/user-store/Makefile.am
==============================================================================
--- trunk/pkcs11/user-store/Makefile.am (original)
+++ trunk/pkcs11/user-store/Makefile.am Sat Jan 17 23:27:10 2009
@@ -39,8 +39,7 @@
gck_user_store_standalone_la_LIBADD = \
libgck-user-store.la \
$(top_builddir)/pkcs11/gck/libgck.la \
- $(top_builddir)/common/libgkr-common-buffer.la \
- $(top_builddir)/common/libgkr-common-secure.la \
+ $(top_builddir)/egg/libegg.la \
$(GOBJECT_LIBS) \
$(GTHREAD_LIBS) \
$(GLIB_LIBS) \
Modified: trunk/pkcs11/user-store/gck-user-standalone.c
==============================================================================
--- trunk/pkcs11/user-store/gck-user-standalone.c (original)
+++ trunk/pkcs11/user-store/gck-user-standalone.c Sat Jan 17 23:27:10 2009
@@ -27,7 +27,7 @@
#include "gck/gck-crypto.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
#include "pkcs11/pkcs11.h"
@@ -35,11 +35,11 @@
/* Module callbacks for secure memory */
static GStaticMutex memory_mutex = G_STATIC_MUTEX_INIT;
-void gkr_memory_lock (void)
+void egg_memory_lock (void)
{ g_static_mutex_lock (&memory_mutex); }
-void gkr_memory_unlock (void)
+void egg_memory_unlock (void)
{ g_static_mutex_unlock (&memory_mutex); }
-void* gkr_memory_fallback (void *p, unsigned long sz)
+void* egg_memory_fallback (void *p, unsigned long sz)
{ return g_realloc (p, sz); }
CK_RV
Modified: trunk/pkcs11/user-store/gck-user-storage.c
==============================================================================
--- trunk/pkcs11/user-store/gck-user-storage.c (original)
+++ trunk/pkcs11/user-store/gck-user-storage.c Sat Jan 17 23:27:10 2009
@@ -138,10 +138,10 @@
g_assert (subject);
g_assert (n_subject);
- asn = gck_data_asn1_decode ("PKIX1.Name", subject, n_subject);
+ asn = egg_asn1_decode ("PKIX1.Name", subject, n_subject);
g_return_val_if_fail (asn, NULL);
- name = gck_data_asn1_read_dn_part (asn, "rdnSequence", "CN");
+ name = egg_asn1_read_dn_part (asn, "rdnSequence", "CN");
asn1_delete_structure (&asn);
return name;
Modified: trunk/tests/gtest-helpers.c
==============================================================================
--- trunk/tests/gtest-helpers.c (original)
+++ trunk/tests/gtest-helpers.c Sat Jan 17 23:27:10 2009
@@ -33,22 +33,22 @@
#include "gtest-helpers.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
static GStaticMutex memory_mutex = G_STATIC_MUTEX_INIT;
static const gchar *test_path = NULL;
-void gkr_memory_lock (void)
+void egg_memory_lock (void)
{
g_static_mutex_lock (&memory_mutex);
}
-void gkr_memory_unlock (void)
+void egg_memory_unlock (void)
{
g_static_mutex_unlock (&memory_mutex);
}
-void* gkr_memory_fallback (void *p, unsigned long sz)
+void* egg_memory_fallback (void *p, unsigned long sz)
{
return g_realloc (p, sz);
}
Modified: trunk/tests/test-helpers.c
==============================================================================
--- trunk/tests/test-helpers.c (original)
+++ trunk/tests/test-helpers.c Sat Jan 17 23:27:10 2009
@@ -10,20 +10,20 @@
#include "test-helpers.h"
-#include "common/gkr-secure-memory.h"
+#include "egg/egg-secure-memory.h"
static GStaticMutex memory_mutex = G_STATIC_MUTEX_INIT;
-void gkr_memory_lock (void)
+void egg_memory_lock (void)
{
g_static_mutex_lock (&memory_mutex);
}
-void gkr_memory_unlock (void)
+void egg_memory_unlock (void)
{
g_static_mutex_unlock (&memory_mutex);
}
-void* gkr_memory_fallback (void *p, unsigned long sz)
+void* egg_memory_fallback (void *p, unsigned long sz)
{
return g_realloc (p, sz);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]