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

« back to all changes in this revision

Viewing changes to pkcs11/gck/tests/test-module.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:
23
23
 
24
24
#include "config.h"
25
25
#include "test-module.h"
 
26
#include "run-auto-test.h"
26
27
 
27
28
/* Include all the module entry points */
28
29
#include "gck/gck-module-ep.h"
29
30
GCK_DEFINE_MODULE (test_module, GCK_TYPE_MODULE);
30
31
 
 
32
#include "gck/gck-certificate.h"
 
33
 
31
34
GckModule*
32
35
test_module_initialize_and_enter (void)
33
36
{
84
87
 
85
88
        return session;
86
89
}
 
90
 
 
91
GckObject*
 
92
test_module_object_new (GckSession *session)
 
93
{
 
94
        CK_BBOOL token = CK_FALSE;
 
95
        CK_OBJECT_CLASS klass = CKO_CERTIFICATE;
 
96
        CK_CERTIFICATE_TYPE type = CKC_X_509;
 
97
        GckObject *object;
 
98
 
 
99
        gsize n_data;
 
100
        guchar *data = test_data_read ("test-certificate-1.der", &n_data);
 
101
 
 
102
        CK_ATTRIBUTE attrs[] = {
 
103
                { CKA_TOKEN, &token, sizeof (token) },
 
104
                { CKA_CLASS, &klass, sizeof (klass) },
 
105
                { CKA_CERTIFICATE_TYPE, &type, sizeof (type) },
 
106
                { CKA_VALUE, data, n_data },
 
107
        };
 
108
 
 
109
        object = gck_session_create_object_for_factory (session, GCK_FACTORY_CERTIFICATE, NULL,
 
110
                                                      attrs, G_N_ELEMENTS (attrs));
 
111
        if (object) /* Owned by storage */
 
112
                g_object_unref (object);
 
113
        return object;
 
114
}