~ubuntu-branches/ubuntu/natty/gnome-keyring/natty

« back to all changes in this revision

Viewing changes to pkcs11/gck/gck-data-file.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2010-02-16 19:00:06 UTC
  • mfrom: (1.1.58 upstream)
  • Revision ID: james.westby@ubuntu.com-20100216190006-cqpnic4zxlkmmi0o
Tags: 2.29.90git20100218-0ubuntu1
Updated to a git snapshot version

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
#define PUBLIC_ALLOC (EggBufferAllocator)g_realloc
79
79
#define PRIVATE_ALLOC (EggBufferAllocator)egg_secure_realloc
80
80
 
81
 
typedef GckDataResult (*BlockFunc) (guint block, EggBuffer *buffer, GckLogin *login, gpointer user_data);
 
81
typedef GckDataResult (*BlockFunc) (guint block, EggBuffer *buffer, GckSecret *login, gpointer user_data);
82
82
 
83
83
#define FILE_HEADER ((const guchar*)"Gnome Keyring Store 2\n\r\0")
84
84
#define FILE_HEADER_LEN 24
178
178
}
179
179
 
180
180
static GckDataResult
181
 
parse_file_blocks (int file, BlockFunc block_func, GckLogin *login, gpointer user_data)
 
181
parse_file_blocks (int file, BlockFunc block_func, GckSecret *login, gpointer user_data)
182
182
{
183
183
        gchar header[FILE_HEADER_LEN];
184
184
        GckDataResult res;
337
337
}
338
338
 
339
339
static gboolean
340
 
create_cipher (GckLogin *login, int calgo, int halgo, const guchar *salt, 
 
340
create_cipher (GckSecret *login, int calgo, int halgo, const guchar *salt, 
341
341
               gsize n_salt, guint iterations, gcry_cipher_hd_t *cipher)
342
342
{
343
343
        gsize n_key, n_block;
360
360
        g_return_val_if_fail (key, FALSE);
361
361
        iv = g_malloc0 (n_block);
362
362
        
363
 
        password = gck_login_get_password (login, &n_password);
 
363
        password = gck_secret_get_password (login, &n_password);
364
364
        
365
365
        if (!egg_symkey_generate_simple (calgo, halgo, password, n_password, 
366
 
                                                salt, n_salt, iterations, &key, &iv)) {
 
366
                                         salt, n_salt, iterations, &key, &iv)) {
367
367
                gcry_free (key);
368
368
                g_free (iv);
369
369
                return FALSE;
389
389
}
390
390
 
391
391
static gboolean
392
 
encrypt_buffer (EggBuffer *input, GckLogin *login, EggBuffer *output)
 
392
encrypt_buffer (EggBuffer *input, GckSecret *login, EggBuffer *output)
393
393
{
394
394
        gcry_cipher_hd_t cipher;
395
395
        gcry_error_t gcry;
455
455
}
456
456
 
457
457
static gboolean
458
 
decrypt_buffer (EggBuffer *input, gsize *offset, GckLogin *login, EggBuffer *output)
 
458
decrypt_buffer (EggBuffer *input, gsize *offset, GckSecret *login, EggBuffer *output)
459
459
{
460
460
        gcry_cipher_hd_t cipher;
461
461
        gcry_error_t gcry;
634
634
}
635
635
 
636
636
static GckDataResult
637
 
update_from_private_block (GckDataFile *self, EggBuffer *buffer, GckLogin *login)
 
637
update_from_private_block (GckDataFile *self, EggBuffer *buffer, GckSecret *login)
638
638
{
639
639
        EggBuffer custom;
640
640
        GckDataResult res;
659
659
        egg_buffer_init_full (&custom, 1024, egg_secure_realloc);
660
660
 
661
661
        /* Decrypt the buffer */
662
 
        password = gck_login_get_password (login, &n_password);
 
662
        password = gck_secret_get_password (login, &n_password);
663
663
        if (!decrypt_buffer (buffer, &offset, login, &custom)) {
664
664
                egg_buffer_uninit (&custom);
665
665
                return GCK_DATA_FAILURE;
769
769
}
770
770
 
771
771
static GckDataResult
772
 
update_from_any_block (guint block, EggBuffer *buffer, GckLogin *login, gpointer user_data)
 
772
update_from_any_block (guint block, EggBuffer *buffer, GckSecret *login, gpointer user_data)
773
773
{
774
774
        UnknownBlock *unknown;
775
775
        GckDataFile *self;
860
860
}
861
861
 
862
862
static GckDataResult
863
 
write_private_to_block (GckDataFile *self, EggBuffer *buffer, GckLogin *login)
 
863
write_private_to_block (GckDataFile *self, EggBuffer *buffer, GckSecret *login)
864
864
{
865
865
        EggBuffer secure;
866
866
        GckDataResult res;
1136
1136
}
1137
1137
 
1138
1138
GckDataResult
1139
 
gck_data_file_read_fd (GckDataFile *self, int fd, GckLogin *login)
 
1139
gck_data_file_read_fd (GckDataFile *self, int fd, GckSecret *login)
1140
1140
{
1141
1141
        GckDataResult res;
1142
1142
        
1185
1185
}
1186
1186
 
1187
1187
GckDataResult
1188
 
gck_data_file_write_fd (GckDataFile *self, int fd, GckLogin *login)
 
1188
gck_data_file_write_fd (GckDataFile *self, int fd, GckSecret *login)
1189
1189
{
1190
1190
        guint types[3] = { FILE_BLOCK_INDEX, FILE_BLOCK_PRIVATE, FILE_BLOCK_PUBLIC };
1191
1191
        GList *unknowns, *unk;