Project

General

Profile

API » History » Version 10

Felix Tiede, 12/08/2013 10:10 PM
Documented version 2.0 API.

1 1 Felix Tiede
h1. Public API
2
3
The real code is documented, of course. See header files in source:src.
4
For a history of how it was created, see ticket #34.
5
6
Regardless of the files the API is split into, in C++ it looks like this:
7
<pre><code class="cplusplus">namespace Kca
8
{
9
namespace OpenSSL
10
{
11
  enum Digest {
12
    RIPEMD160,
13
    SHA1,
14
    SHA256,
15
    SHA384,
16
    SHA512,
17 10 Felix Tiede
  }; /* End enum Digest */
18 1 Felix Tiede
19
  enum RevocationReason {
20
    Unspecified,
21
    KeyCompromise,
22
    CACompromise,
23
    AffilitionChanged,
24
    Superseded,
25
    CessationOfOperation,
26
    CertificateHold,
27
    RemoveFromCRL = 8
28 10 Felix Tiede
  }; /* End enum RevocationReason */
29 1 Felix Tiede
30
31 6 Felix Tiede
  class OpenSSLException : public std::exception
32
  {
33
    public:
34
      ~OpenSSLException() throw();
35 1 Felix Tiede
36 5 Felix Tiede
      const char * what() const throw();
37 10 Felix Tiede
      const char * where() const throw();
38 1 Felix Tiede
39 6 Felix Tiede
    protected:
40 10 Felix Tiede
      OpenSSLException(const QString&, const char* = NULL, int = 0) throw();
41
      OpenSSLException(const OpenSSLException&) throw();
42
  }; /* End class OpenSSLException */
43 1 Felix Tiede
44
45
  class SigningException : public std::exception
46
  {
47
    public:
48
      enum Operation {
49
        SignCsr,
50
        SignCrl,
51 10 Felix Tiede
      }; /* End enum Operation */
52 1 Felix Tiede
53
      enum Failure {
54
        NoCACertificate,
55
        KeyMismatch,
56
        SerialConstraint,
57
        TimeConstraint,
58
        ExtensionError,
59
        ObjectError,
60 10 Felix Tiede
      }; /* End enum Failure */
61 1 Felix Tiede
62
      ~SigningException() throw();
63
64 10 Felix Tiede
      Operation operation() const throw();
65
      Failure failure() const throw();
66 9 Felix Tiede
      const char * what() const throw();
67 10 Felix Tiede
      const char * where() const throw();
68 1 Felix Tiede
69 9 Felix Tiede
    protected:
70 10 Felix Tiede
      SigningException(Operation, Failure, const QString&, const char* = NULL, int = 0) throw();
71
      SigningException(const SigningException&) throw();
72 1 Felix Tiede
73 10 Felix Tiede
      void setFailure(Failure) throw();
74
      void setMessage(const QString&) throw();
75
  }; /* End class SigningException */
76 6 Felix Tiede
77 1 Felix Tiede
78 6 Felix Tiede
  class Extension {
79 1 Felix Tiede
    public:
80 6 Felix Tiede
      struct ObjectID {
81 1 Felix Tiede
        QString oid;
82
        QString shortName;
83
        QString longName;
84 10 Felix Tiede
      }; /* End struct ObjectID */
85 1 Felix Tiede
86 10 Felix Tiede
      Extension(const ObjectID&, const QString&,
87
                bool = false, bool = false);
88 6 Felix Tiede
      ~Extension();
89
90
      const ObjectID oid() const;
91
92
      const QString value() const;
93 10 Felix Tiede
      void setValue(const QString&);
94 6 Felix Tiede
95
      bool critical() const;
96 10 Felix Tiede
      void setCritical(bool);
97 1 Felix Tiede
98
      bool replace() const;
99 10 Felix Tiede
      void setReplace(bool);
100 1 Felix Tiede
101 10 Felix Tiede
      bool operator==(const Extension&) const;
102
      Extension& operator=(const Extension&);
103 6 Felix Tiede
104 1 Felix Tiede
    protected:
105 10 Felix Tiede
      Extension(const QString&, const QString&,
106
                bool = false, bool = false);
107
      Extension(int, const QString&,
108
                bool = false, bool = false);
109
      Extension(const X509_EXTENSION*);
110
      X509_EXTENSION* handle(X509V3_CTX* = NULL) const;
111
  }; /* End class Extension */
112 1 Felix Tiede
  typedef QList< Extension > ExtensionList;
113
114
  struct CRLEntry {
115
    quint64 serial;
116
    RevocationReason reason;
117
    QDateTime timestamp;
118 10 Felix Tiede
  }; /* End struct CRLEntry */
119 1 Felix Tiede
  typedef QList< CRLEntry > CRL;
120
121
  QString version();
122
  QString build_information();
123
124
  quint64 random();
125
126
  ExtensionList emailCertExtensions();
127
128
129 10 Felix Tiede
  class Key : public QSslKey
130
  {
131
    public:
132
      Key(const QSslKey& = QSslKey());
133
      Key(const Key&);
134
      ~Key();
135 1 Felix Tiede
136 10 Felix Tiede
      operator=(const Key&);
137 1 Felix Tiede
138 10 Felix Tiede
      static const Key generateKeyPair(int = 2048, QSsl::KeyAlgorithm = QSsl::Rsa);
139
140
    protected:
141
      EVP_PKEY* handle() const;
142
  }; /* End class Key */
143
144
145
  class Request
146
  {
147
    public:
148
      Request(const QByteArray& = QByteArray(), QSsl::EncodingFormat = QSsl::Pem);
149
      Request(const Request&)
150
      ~Request();
151
152
      bool isNull() const;
153
154
      QByteArray subject() const;
155
156
      ExtensionList extensions() const;
157
158
      QByteArray toDer() const;
159
      QByteArray toPem() const;
160
161
      QByteArray version() const;
162
163
      bool operator!=(const Request&) const;
164
      bool operator==(const Request&) const;
165
166
      Request& operator=(const Request&);
167
168
      static Request generate(const Key&, const QByteArray&,
169
                              const ExtensionList& = ExtensionList(),
170
                              Digest = SHA256);
171
172
    protected:
173
      X509_REQ* handle() const;
174
  }; /* End class Request */
175
176
177 1 Felix Tiede
  class Certificate : public QSslCertificate
178
  {
179
    public:
180
      struct SignatureDetails {
181
        quint64 serial;
182
        Digest digest;
183
        QDateTime effectiveDate;
184
        QDateTime expiryDate;
185 10 Felix Tiede
      }; /* End struct SignatureDetails */
186 1 Felix Tiede
187 10 Felix Tiede
      Certificate(const QSslCertificate& = QSslCertificate());
188
      Certificate(const Certificate&);
189 1 Felix Tiede
190 10 Felix Tiede
      Certificate(const Key&, const QString&,
191
                  const SignatureDetails&, const ExtensionList&);
192
193
      ~Certificate();
194
195 1 Felix Tiede
      bool isCA() const;
196 10 Felix Tiede
      bool keyMatch(const Key&) const;
197 1 Felix Tiede
198 10 Felix Tiede
      ExtensionList extensions() const;
199 1 Felix Tiede
200 10 Felix Tiede
      const Certificate sign(const Request&, const Key&,
201
                             const SignatureDetails&,
202
                             const ExtensionList&) const;
203 1 Felix Tiede
204 10 Felix Tiede
      const QByteArray sign(const CRL&, const Key&,
205
                            const SignatureDetails&,
206
                            const ExtensionList&, QSsl::EncodingFormat = QSsl::Der) const;
207
  }; /* End class Certificate */
208
209
}; /* End namespace OpenSSL */
210
}; /* End namespace Kca */</code></pre>