1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2
/* gkr-pkix-asn1.c - ASN.1 helper routines
4
Copyright (C) 2007 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>
26
#include "gkm-data-asn1.h"
28
#include "egg/egg-asn1x.h"
31
gkm_data_asn1_read_mpi (GNode *asn, gcry_mpi_t *mpi)
37
g_return_val_if_fail (asn, FALSE);
38
g_return_val_if_fail (mpi, FALSE);
40
buf = egg_asn1x_get_raw_value (asn, &sz);
44
/* Automatically stores in secure memory if DER data is secure */
45
gcry = gcry_mpi_scan (mpi, GCRYMPI_FMT_STD, buf, sz, &sz);
53
gkm_data_asn1_write_mpi (GNode *asn, gcry_mpi_t mpi)
59
g_return_val_if_fail (asn, FALSE);
60
g_return_val_if_fail (mpi, FALSE);
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);
67
buf = gcry_calloc_secure (len, 1);
69
gcry = gcry_mpi_print (GCRYMPI_FMT_STD, buf, len, &len, mpi);
70
g_return_val_if_fail (gcry == 0, FALSE);
72
return egg_asn1x_set_integer_as_raw (asn, buf, len, gcry_free);