1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2
/* dump-data-file.c: Dump a gck data file
4
Copyright (C) 2009 Stefan Walter
6
The Gnome Keyring Library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Library General Public License as
8
published by the Free Software Foundation; either version 2 of the
9
License, or (at your option) any later version.
11
The Gnome Keyring Library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Library General Public License for more details.
16
You should have received a copy of the GNU Library General Public
17
License along with the Gnome Library; see the file COPYING.LIB. If not,
18
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
Boston, MA 02111-1307, USA.
21
Author: Stef Walter <stef@memberwebs.com>
24
#include "gck-crypto.h"
25
#include "gck-data-file.h"
27
#include "egg/egg-secure-memory.h"
39
void egg_memory_lock (void)
41
void egg_memory_unlock (void)
43
void* egg_memory_fallback (void *p, size_t sz)
44
{ return g_realloc (p, sz); }
46
static void G_GNUC_NORETURN
47
failure (const gchar* message, ...)
50
va_start (va, message);
51
vfprintf (stderr, message, va);
58
main(int argc, char* argv[])
60
const gchar *password;
67
gck_crypto_initialize ();
70
failure ("usage: dump-data-file filename");
72
fd = open (argv[1], O_RDONLY, 0);
74
failure ("dump-data-file: couldn't open file: %s: %s", argv[1], g_strerror (errno));
76
password = getpass ("Password: ");
77
login = gck_login_new ((guchar*)password, strlen (password));
79
file = gck_data_file_new ();
80
res = gck_data_file_read_fd (file, fd, login);
81
g_object_unref (login);
84
case GCK_DATA_FAILURE:
85
failure ("dump-data-file: failed to read file: %s", argv[1]);
87
failure ("dump-data-file: invalid password for file: %s", argv[1]);
88
case GCK_DATA_UNRECOGNIZED:
89
failure ("dump-data-file: unparseable file format: %s", argv[1]);
90
case GCK_DATA_SUCCESS:
93
g_assert_not_reached ();
96
gck_data_file_dump (file);
97
g_object_unref (file);