~ubuntu-branches/ubuntu/maverick/gnome-keyring/maverick

« back to all changes in this revision

Viewing changes to pkcs11/gkm/gkm-data-asn1.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2010-09-01 12:54:04 UTC
  • mfrom: (1.1.64 upstream)
  • Revision ID: james.westby@ubuntu.com-20100901125404-3d96lh3oo4karbv3
Tags: 2.92.92.is.2.31.91-0ubuntu1
* New upstream release
* debian/control:
  - Drop build-depends on libgconf2-dev
  - Build-depend on dh-autoreconf, gnome-common
* debian/rules:
  - Use autoreconf.mk
* debian/gnome-keyring.install:
  - No longer provides a gconf schema
* debian/libgcr0.symbols:
  - Updated
* debian/patches/90_git_pam_headers.patch:
  - Fix incorrect PAM header check
* debian/patches/05_login_unlock_string.patch:
* debian/patches/90_git_keyring_encoding.patch:
  - Applied upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 
2
/* gkr-pkix-asn1.c - ASN.1 helper routines
 
3
 
 
4
   Copyright (C) 2007 Stefan Walter
 
5
 
 
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.
 
10
 
 
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.
 
15
 
 
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.
 
20
 
 
21
   Author: Stef Walter <stef@memberwebs.com>
 
22
*/
 
23
 
 
24
#include "config.h"
 
25
 
 
26
#include "gkm-data-asn1.h"
 
27
 
 
28
#include "egg/egg-asn1x.h"
 
29
 
 
30
gboolean
 
31
gkm_data_asn1_read_mpi (GNode *asn, gcry_mpi_t *mpi)
 
32
{
 
33
        gcry_error_t gcry;
 
34
        gsize sz;
 
35
        const guchar *buf;
 
36
 
 
37
        g_return_val_if_fail (asn, FALSE);
 
38
        g_return_val_if_fail (mpi, FALSE);
 
39
 
 
40
        buf = egg_asn1x_get_raw_value (asn, &sz);
 
41
        if (!buf)
 
42
                return FALSE;
 
43
 
 
44
        /* Automatically stores in secure memory if DER data is secure */
 
45
        gcry = gcry_mpi_scan (mpi, GCRYMPI_FMT_STD, buf, sz, &sz);
 
46
        if (gcry != 0)
 
47
                return FALSE;
 
48
 
 
49
        return TRUE;
 
50
}
 
51
 
 
52
gboolean
 
53
gkm_data_asn1_write_mpi (GNode *asn, gcry_mpi_t mpi)
 
54
{
 
55
        gcry_error_t gcry;
 
56
        gsize len;
 
57
        guchar *buf;
 
58
 
 
59
        g_return_val_if_fail (asn, FALSE);
 
60
        g_return_val_if_fail (mpi, FALSE);
 
61
 
 
62
        /* Get the size */
 
63
        gcry = gcry_mpi_print (GCRYMPI_FMT_STD, NULL, 0, &len, mpi);
 
64
        g_return_val_if_fail (gcry == 0, FALSE);
 
65
        g_return_val_if_fail (len > 0, FALSE);
 
66
 
 
67
        buf = gcry_calloc_secure (len, 1);
 
68
 
 
69
        gcry = gcry_mpi_print (GCRYMPI_FMT_STD, buf, len, &len, mpi);
 
70
        g_return_val_if_fail (gcry == 0, FALSE);
 
71
 
 
72
        return egg_asn1x_set_integer_as_raw (asn, buf, len, gcry_free);
 
73
}