4
* Copyright (C) 2008 Stefan Walter
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as
8
* published by the Free Software Foundation; either version 2.1 of
9
* the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24
#include "gck-attributes.h"
25
#include "gck-null-mechanism.h"
26
#include "gck-null-key.h"
27
#include "gck-session.h"
30
#include "pkcs11/pkcs11.h"
31
#include "pkcs11/pkcs11i.h"
37
G_DEFINE_TYPE (GckNullKey, gck_null_key, GCK_TYPE_SECRET_KEY);
39
/* -----------------------------------------------------------------------------
44
factory_create_null_key (GckSession *session, GckTransaction *transaction,
45
CK_ATTRIBUTE_PTR attrs, CK_ULONG n_attrs)
50
manager = gck_manager_for_template (attrs, n_attrs, session);
51
key = g_object_new (GCK_TYPE_NULL_KEY,
52
"module", gck_session_get_module (session),
56
gck_session_complete_object_creation (session, transaction, GCK_OBJECT (key),
57
TRUE, attrs, n_attrs);
58
return GCK_OBJECT (key);
61
/* -----------------------------------------------------------------------------
66
gck_null_key_real_get_attribute (GckObject *base, GckSession *session, CK_ATTRIBUTE *attr)
71
return gck_attribute_set_ulong (attr, CKK_G_NULL);
75
return gck_attribute_set_bool (attr, CK_TRUE);
78
return gck_attribute_set_empty (attr);
81
return gck_attribute_set_ulong (attr, 0);
84
return gck_attribute_set_data (attr, "\0\0\0", 3);
86
case CKA_ALLOWED_MECHANISMS:
87
return gck_attribute_set_data (attr, (CK_VOID_PTR)GCK_NULL_MECHANISMS,
88
sizeof (GCK_NULL_MECHANISMS));
91
return GCK_OBJECT_CLASS (gck_null_key_parent_class)->get_attribute (base, session, attr);
95
gck_null_key_init (GckNullKey *self)
101
gck_null_key_class_init (GckNullKeyClass *klass)
103
GckObjectClass *gck_class = GCK_OBJECT_CLASS (klass);
105
gck_null_key_parent_class = g_type_class_peek_parent (klass);
106
gck_class->get_attribute = gck_null_key_real_get_attribute;
109
/* -----------------------------------------------------------------------------
114
gck_null_key_get_factory (void)
116
static CK_OBJECT_CLASS klass = CKO_SECRET_KEY;
117
static CK_KEY_TYPE type = CKK_G_NULL;
119
static CK_ATTRIBUTE attributes[] = {
120
{ CKA_CLASS, &klass, sizeof (klass) },
121
{ CKA_KEY_TYPE, &type, sizeof (type) }
124
static GckFactory factory = {
126
G_N_ELEMENTS (attributes),
127
factory_create_null_key