API » History » Version 4
Felix Tiede, 02/18/2013 06:58 AM
Modified API for X509Extension constructor.
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 | }; |
||
18 | |||
19 | enum RevocationReason { |
||
20 | Unspecified, |
||
21 | KeyCompromise, |
||
22 | CACompromise, |
||
23 | AffilitionChanged, |
||
24 | Superseded, |
||
25 | CessationOfOperation, |
||
26 | CertificateHold, |
||
27 | RemoveFromCRL = 8 |
||
28 | }; |
||
29 | |||
30 | 4 | Felix Tiede | class X509Extension { |
31 | 1 | Felix Tiede | bool replace; |
32 | bool critical; |
||
33 | QString name; |
||
34 | QString value; |
||
35 | 4 | Felix Tiede | |
36 | X509Extension(const QString& name, const QString& value, |
||
37 | bool critical=false, bool replace=false); |
||
38 | 1 | Felix Tiede | }; |
39 | typedef QList< X509Extension > ExtensionList; |
||
40 | |||
41 | struct CRLEntry { |
||
42 | quint64 serial; |
||
43 | RevocationReason reason; |
||
44 | QDateTime timestamp; |
||
45 | }; |
||
46 | typedef QList< CRLEntry > CRL; |
||
47 | |||
48 | 2 | Felix Tiede | QString version(); |
49 | QString build_information(); |
||
50 | |||
51 | 3 | Felix Tiede | quint64 random(); |
52 | 1 | Felix Tiede | const QSslKey generateKeyPair(const unsigned int length = 2048); |
53 | const QByteArray generateRequest(const QSslKey& key, |
||
54 | const QString& subject, |
||
55 | const ExtensionList& extensions); |
||
56 | |||
57 | ExtensionList emailCertExtensions(); |
||
58 | |||
59 | QString requestSubject(const QByteArray& request); |
||
60 | ExtensionList requestExtensions(const QByteArray& request); |
||
61 | |||
62 | |||
63 | class SigningException : public std::exception |
||
64 | { |
||
65 | public: |
||
66 | enum Operation { |
||
67 | SignCsr, |
||
68 | SignCrl, |
||
69 | }; |
||
70 | |||
71 | enum Failure { |
||
72 | NoCACertificate, |
||
73 | KeyMismatch, |
||
74 | TimeConstraint, |
||
75 | ExtensionError, |
||
76 | ObjectError, |
||
77 | }; |
||
78 | |||
79 | ~SigningException() throw(); |
||
80 | |||
81 | const Operation operation() const throw(); |
||
82 | const Failure failure() const throw(); |
||
83 | const QString description() const throw(); |
||
84 | |||
85 | protected: |
||
86 | SigningException(Operation operation, Failure failure, const QString& description) throw(); |
||
87 | |||
88 | void setFailure(Failure failure) throw(); |
||
89 | void setDescription(const QString& description) throw(); |
||
90 | }; |
||
91 | |||
92 | |||
93 | class Certificate : public QSslCertificate |
||
94 | { |
||
95 | public: |
||
96 | struct SignatureDetails { |
||
97 | quint64 serial; |
||
98 | Digest digest; |
||
99 | QDateTime effectiveDate; |
||
100 | QDateTime expiryDate; |
||
101 | }; |
||
102 | |||
103 | Certificate(const QSslKey& key, const QString& subject, |
||
104 | const SignatureDetails& details, const ExtensionList& extensions) throw(SigningException); |
||
105 | |||
106 | bool isCA() const; |
||
107 | bool keyMatch(const QSslKey& key) const; |
||
108 | |||
109 | const QSslCertificate sign(const QByteArray& request, const QSslKey& signingKey, |
||
110 | const SignatureDetails& details, |
||
111 | const ExtensionList& extensions) const throw(SigningException); |
||
112 | |||
113 | const QByteArray sign(const CRL& crl, const QSslKey& signingKey, |
||
114 | const SignatureDetails& details, |
||
115 | const ExtensionList& extensions) const throw(SigningException); |
||
116 | }; |
||
117 | |||
118 | }; |
||
119 | };</code></pre> |