~ubuntu-branches/ubuntu/maverick/vmware-view-open-client/maverick

« back to all changes in this revision

Viewing changes to gtk/cryptoki.hh

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2010-06-04 17:45:04 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20100604174504-zjltuc0hdp4mv7de
Tags: 4.5.0-264434+dfsg-1
* Merging upstream version 4.5.0-264434+dfsg.
* Updating date and version header in manpage.
* Rediffing doc-pdf.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#endif
39
39
 
40
40
 
41
 
#include <boost/signal.hpp>
42
41
#include <gmodule.h>
43
42
#include <list>
44
43
#include <openssl/evp.h>
52
51
#include "util.hh"
53
52
 
54
53
 
 
54
#define CDK_CRYPTOKI_ERROR cdk::Cryptoki::GetErrorQuark()
 
55
 
 
56
 
55
57
namespace cdk {
56
58
 
57
59
 
58
60
class Cryptoki
59
61
{
60
62
public:
 
63
   enum ErrorCode {
 
64
      ERR_UNKNOWN = 1,
 
65
      ERR_INVALID_PIN,
 
66
      ERR_PIN_FINAL_TRY,
 
67
      ERR_PIN_LOCKED,
 
68
      ERR_DEVICE_REMOVED,
 
69
      ERR_SESSION_NOT_FOUND
 
70
   };
 
71
 
61
72
   Cryptoki();
62
73
   ~Cryptoki();
63
74
 
69
80
 
70
81
   bool GetHadEvent();
71
82
 
72
 
   std::list<X509 *> GetCertificates(STACK_OF(X509_NAME) *CAs);
 
83
   std::list<X509 *> GetCertificates(std::list<Util::string> &trustedIssuers);
 
84
   bool Login(const X509 *cert, const char *pin, GError **error);
73
85
   EVP_PKEY *GetPrivateKey(const X509 *cert);
74
86
 
75
87
   std::vector<Util::string> GetSlotNames();
76
88
   Util::string GetSlotName(const X509 *cert);
 
89
   Util::string GetTokenName(const X509 *cert);
77
90
 
78
91
   X509 *DupCert(X509 *cert);
79
92
   void FreeCert(X509 *cert);
82
95
 
83
96
   void CloseAllSessions();
84
97
 
85
 
   boost::signal2<const char *, const Util::string &, const X509 *> requestPin;
86
 
 
87
98
   static void FreeCertificates(std::list<X509 *> &certs);
 
99
   static GQuark GetErrorQuark();
88
100
 
89
101
private:
90
102
   class Module
94
106
      ~Module();
95
107
 
96
108
      bool Load(const Util::string &filePath);
97
 
      void GetCertificates(std::list<X509 *> &certs, STACK_OF(X509_NAME) *CAs);
 
109
      void GetCertificates(std::list<X509 *> &certs,
 
110
                           std::list<Util::string> &issuers);
98
111
      void GetSlotNames(std::set<Util::string> &slots);
99
112
      Util::string GetSlotName(CK_SLOT_ID slot);
100
113
 
127
140
 
128
141
      CK_RV Open(CK_SLOT_ID slot);
129
142
      CK_RV Logout();
130
 
      void GetCertificates(std::list<X509 *> &certs, STACK_OF(X509_NAME) *CAs);
 
143
      void GetCertificates(std::list<X509 *> &certs,
 
144
                           std::list<Util::string> &issuers);
131
145
      EVP_PKEY *GetPrivateKey(const X509 *cert);
132
146
      Util::string GetSlotName();
 
147
      Util::string GetTokenName() const { return mLabel; }
133
148
 
134
149
      bool GetIsInserted();
135
150
 
 
151
      bool Login(const X509 *cert, const char *pin, GError **error);
 
152
 
136
153
   private:
137
 
      bool Login(const X509 *cert);
138
 
 
139
154
      static const RSA_METHOD *GetRsaMethod();
140
155
      static int RsaSign(int type,
141
156
                         const unsigned char *m, unsigned int m_length,
187
202
   };
188
203
 
189
204
   std::list<Module *> mModules;
 
205
   static GQuark sErrorQuark;
190
206
};
191
207
 
192
208