Mercurial > projects > dstep
comparison dstep/security/SecureTransport.d @ 11:07194b026fa4
Added bindings to a couple of frameworks, new license + some other things
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sat, 01 Aug 2009 15:03:28 +0200 |
parents | |
children | 19885b43130e |
comparison
equal
deleted
inserted
replaced
10:27e00625790b | 11:07194b026fa4 |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Jul 22, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.security.SecureTransport; | |
8 | |
9 //import dstep.AvailabilityMacros; | |
10 import dstep.corefoundation.CFArray; | |
11 import dstep.corefoundation.CFBase; | |
12 import dstep.coreservices.carboncore.MacTypes : OSStatus; | |
13 import dstep.security.CipherSuite; | |
14 //import dstep.sys.types; | |
15 | |
16 struct SSLContext; | |
17 | |
18 alias SSLContext* SSLContextRef; | |
19 alias void* SSLConnectionRef; | |
20 | |
21 extern (C) | |
22 { | |
23 alias OSStatus function (SSLConnectionRef connection, /*const*/ void *data,size_t* dataLength) SSLWriteFunc; | |
24 alias OSStatus function (SSLConnectionRef connection, void* data, size_t dataLength) SSLReadFunc; | |
25 } | |
26 | |
27 enum SSLProtocol | |
28 { | |
29 kSSLProtocolUnknown, | |
30 kSSLProtocol2, | |
31 kSSLProtocol3, | |
32 kSSLProtocol3Only, | |
33 kTLSProtocol1, | |
34 kTLSProtocol1Only, | |
35 kSSLProtocolAll | |
36 } | |
37 | |
38 enum SSLSessionState | |
39 { | |
40 kSSLIdle, | |
41 kSSLHandshake, | |
42 kSSLConnected, | |
43 kSSLClosed, | |
44 kSSLAborted | |
45 } | |
46 | |
47 enum SSLClientCertificateState | |
48 { | |
49 kSSLClientCertNone, | |
50 kSSLClientCertRequested, | |
51 kSSLClientCertSent, | |
52 kSSLClientCertRejected | |
53 } | |
54 | |
55 enum | |
56 { | |
57 errSSLProtocol = -9800, | |
58 errSSLNegotiation = -9801, | |
59 errSSLFatalAlert = -9802, | |
60 errSSLWouldBlock = -9803, | |
61 errSSLSessionNotFound = -9804, | |
62 errSSLClosedGraceful = -9805, | |
63 errSSLClosedAbort = -9806, | |
64 errSSLXCertChainInvalid = -9807, | |
65 errSSLBadCert = -9808, | |
66 errSSLCrypto = -9809, | |
67 errSSLInternal = -9810, | |
68 errSSLModuleAttach = -9811, | |
69 errSSLUnknownRootCert = -9812, | |
70 errSSLNoRootCert = -9813, | |
71 errSSLCertExpired = -9814, | |
72 errSSLCertNotYetValid = -9815, | |
73 errSSLClosedNoNotify = -9816, | |
74 errSSLBufferOverflow = -9817, | |
75 errSSLBadCipherSuite = -9818, | |
76 errSSLPeerUnexpectedMsg = -9819, | |
77 errSSLPeerBadRecordMac = -9820, | |
78 errSSLPeerDecryptionFail = -9821, | |
79 errSSLPeerRecordOverflow = -9822, | |
80 errSSLPeerDecompressFail = -9823, | |
81 errSSLPeerHandshakeFail = -9824, | |
82 errSSLPeerBadCert = -9825, | |
83 errSSLPeerUnsupportedCert = -9826, | |
84 errSSLPeerCertRevoked = -9827, | |
85 errSSLPeerCertExpired = -9828, | |
86 errSSLPeerCertUnknown = -9829, | |
87 errSSLIllegalParam = -9830, | |
88 errSSLPeerUnknownCA = -9831, | |
89 errSSLPeerAccessDenied = -9832, | |
90 errSSLPeerDecodeError = -9833, | |
91 errSSLPeerDecryptError = -9834, | |
92 errSSLPeerExportRestriction = -9835, | |
93 errSSLPeerProtocolVersion = -9836, | |
94 errSSLPeerInsufficientSecurity = -9837, | |
95 errSSLPeerInternalError = -9838, | |
96 errSSLPeerUserCancelled = -9839, | |
97 errSSLPeerNoRenegotiation = -9840, | |
98 errSSLHostNameMismatch = -9843, | |
99 errSSLConnectionRefused = -9844, | |
100 errSSLDecryptionFail = -9845, | |
101 errSSLBadRecordMac = -9846, | |
102 errSSLRecordOverflow = -9847, | |
103 errSSLBadConfiguration = -9848, | |
104 errSSLLast = -9849 | |
105 } | |
106 | |
107 enum | |
108 { | |
109 kNeverAuthenticate, | |
110 kAlwaysAuthenticate, | |
111 kTryAuthenticate | |
112 } | |
113 | |
114 extern (C) | |
115 { | |
116 int SSLNewContext (ubyte isServer, SSLContextRef* contextPtr); | |
117 int SSLDisposeContext (SSLContextRef context); | |
118 int SSLGetSessionState (SSLContextRef context, SSLSessionState* state); | |
119 int SSLSetIOFuncs (SSLContextRef context, SSLReadFunc read, SSLWriteFunc write); | |
120 int SSLSetProtocolVersionEnabled (SSLContextRef context, int protocol, ubyte enable); | |
121 int SSLGetProtocolVersionEnabled (SSLContextRef context, int protocol, char* enable); | |
122 int SSLSetProtocolVersion (SSLContextRef context, int version_); | |
123 int SSLGetProtocolVersion (SSLContextRef context, SSLProtocol* protocol); | |
124 int SSLSetCertificate (SSLContextRef context, CFArrayRef certRefs); | |
125 int SSLSetConnection (SSLContextRef context, SSLConnectionRef connection); | |
126 int SSLGetConnection (SSLContextRef context, SSLConnectionRef* connection); | |
127 int SSLSetPeerDomainName (SSLContextRef context, char* peerName, uint peerNameLen); | |
128 int SSLGetPeerDomainNameLength (SSLContextRef context, size_t* peerNameLen); | |
129 int SSLGetPeerDomainName (SSLContextRef context, char* peerName, size_t* peerNameLen); | |
130 int SSLGetNegotiatedProtocolVersion (SSLContextRef context, SSLProtocol* protocol); | |
131 int SSLGetNumberSupportedCiphers (SSLContextRef context, size_t* numCiphers); | |
132 int SSLGetSupportedCiphers (SSLContextRef context, SSLCipherSuite* ciphers, size_t* numCiphers); | |
133 int SSLSetEnabledCiphers (SSLContextRef context, SSLCipherSuite* ciphers, uint numCiphers); | |
134 int SSLGetNumberEnabledCiphers (SSLContextRef context, size_t* numCiphers); | |
135 int SSLGetEnabledCiphers (SSLContextRef context, SSLCipherSuite* ciphers, size_t* numCiphers); | |
136 int SSLSetEnableCertVerify (SSLContextRef context, ubyte enableVerify); | |
137 int SSLGetEnableCertVerify (SSLContextRef context, char* enableVerify); | |
138 int SSLSetAllowsExpiredCerts (SSLContextRef context, ubyte allowsExpired); | |
139 int SSLGetAllowsExpiredCerts (SSLContextRef context, char* allowsExpired); | |
140 int SSLSetAllowsExpiredRoots (SSLContextRef context, ubyte allowsExpired); | |
141 int SSLGetAllowsExpiredRoots (SSLContextRef context, char* allowsExpired); | |
142 int SSLSetAllowsAnyRoot (SSLContextRef context, ubyte anyRoot); | |
143 int SSLGetAllowsAnyRoot (SSLContextRef context, char* anyRoot); | |
144 int SSLSetTrustedRoots (SSLContextRef context, CFArrayRef trustedRoots, ubyte replaceExisting); | |
145 int SSLGetTrustedRoots (SSLContextRef context, CFArrayRef* trustedRoots); | |
146 int SSLCopyTrustedRoots (SSLContextRef context, CFArrayRef* trustedRoots); | |
147 int SSLGetPeerCertificates (SSLContextRef context, CFArrayRef* certs); | |
148 int SSLCopyPeerCertificates (SSLContextRef context, CFArrayRef* certs); | |
149 int SSLSetPeerID (SSLContextRef context, void* peerID, uint peerIDLen); | |
150 int SSLGetPeerID (SSLContextRef context, void** peerID, size_t* peerIDLen); | |
151 int SSLGetNegotiatedCipher (SSLContextRef context, SSLCipherSuite* cipherSuite); | |
152 int SSLSetEncryptionCertificate (SSLContextRef context, CFArrayRef certRefs); | |
153 int SSLSetClientSideAuthenticate (SSLContextRef context, int auth); | |
154 int SSLAddDistinguishedName (SSLContextRef context, void* derDN, uint derDNLen); | |
155 int SSLSetCertificateAuthorities (SSLContextRef context, CFTypeRef certificateOrArray, ubyte replaceExisting); | |
156 int SSLCopyCertificateAuthorities (SSLContextRef context, CFArrayRef* certificates); | |
157 int SSLCopyDistinguishedNames (SSLContextRef context, CFArrayRef* names); | |
158 int SSLGetClientCertificateState (SSLContextRef context, SSLClientCertificateState* clientState); | |
159 int SSLSetDiffieHellmanParams (SSLContextRef context, void* dhParams, uint dhParamsLen); | |
160 int SSLGetDiffieHellmanParams (SSLContextRef context, void** dhParams, size_t* dhParamsLen); | |
161 int SSLSetRsaBlinding (SSLContextRef context, ubyte blinding); | |
162 int SSLGetRsaBlinding (SSLContextRef context, char* blinding); | |
163 int SSLHandshake (SSLContextRef context); | |
164 int SSLWrite (SSLContextRef context, void* data, uint dataLength, size_t* processed); | |
165 int SSLRead (SSLContextRef context, void* data, uint dataLength, size_t* processed); | |
166 int SSLGetBufferedReadSize (SSLContextRef context, size_t* bufSize); | |
167 int SSLClose (SSLContextRef context); | |
168 } |