Mercurial > projects > dstep
view dstep/security/SecureTransport.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | 07194b026fa4 |
children |
line wrap: on
line source
/** * Copyright: Copyright (c) 2009 Jacob Carlborg. * Authors: Jacob Carlborg * Version: Initial created: Jul 22, 2009 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) */ module dstep.security.SecureTransport; import dstep.corefoundation.CFArray; import dstep.corefoundation.CFBase; import dstep.coreservices.carboncore.MacTypes : OSStatus; import dstep.security.CipherSuite; struct SSLContext; alias SSLContext* SSLContextRef; alias void* SSLConnectionRef; extern (C) { alias OSStatus function (SSLConnectionRef connection, /*const*/ void *data,size_t* dataLength) SSLWriteFunc; alias OSStatus function (SSLConnectionRef connection, void* data, size_t dataLength) SSLReadFunc; } enum SSLProtocol { kSSLProtocolUnknown, kSSLProtocol2, kSSLProtocol3, kSSLProtocol3Only, kTLSProtocol1, kTLSProtocol1Only, kSSLProtocolAll } enum SSLSessionState { kSSLIdle, kSSLHandshake, kSSLConnected, kSSLClosed, kSSLAborted } enum SSLClientCertificateState { kSSLClientCertNone, kSSLClientCertRequested, kSSLClientCertSent, kSSLClientCertRejected } enum { errSSLProtocol = -9800, errSSLNegotiation = -9801, errSSLFatalAlert = -9802, errSSLWouldBlock = -9803, errSSLSessionNotFound = -9804, errSSLClosedGraceful = -9805, errSSLClosedAbort = -9806, errSSLXCertChainInvalid = -9807, errSSLBadCert = -9808, errSSLCrypto = -9809, errSSLInternal = -9810, errSSLModuleAttach = -9811, errSSLUnknownRootCert = -9812, errSSLNoRootCert = -9813, errSSLCertExpired = -9814, errSSLCertNotYetValid = -9815, errSSLClosedNoNotify = -9816, errSSLBufferOverflow = -9817, errSSLBadCipherSuite = -9818, errSSLPeerUnexpectedMsg = -9819, errSSLPeerBadRecordMac = -9820, errSSLPeerDecryptionFail = -9821, errSSLPeerRecordOverflow = -9822, errSSLPeerDecompressFail = -9823, errSSLPeerHandshakeFail = -9824, errSSLPeerBadCert = -9825, errSSLPeerUnsupportedCert = -9826, errSSLPeerCertRevoked = -9827, errSSLPeerCertExpired = -9828, errSSLPeerCertUnknown = -9829, errSSLIllegalParam = -9830, errSSLPeerUnknownCA = -9831, errSSLPeerAccessDenied = -9832, errSSLPeerDecodeError = -9833, errSSLPeerDecryptError = -9834, errSSLPeerExportRestriction = -9835, errSSLPeerProtocolVersion = -9836, errSSLPeerInsufficientSecurity = -9837, errSSLPeerInternalError = -9838, errSSLPeerUserCancelled = -9839, errSSLPeerNoRenegotiation = -9840, errSSLHostNameMismatch = -9843, errSSLConnectionRefused = -9844, errSSLDecryptionFail = -9845, errSSLBadRecordMac = -9846, errSSLRecordOverflow = -9847, errSSLBadConfiguration = -9848, errSSLLast = -9849 } enum { kNeverAuthenticate, kAlwaysAuthenticate, kTryAuthenticate } extern (C) { int SSLNewContext (ubyte isServer, SSLContextRef* contextPtr); int SSLDisposeContext (SSLContextRef context); int SSLGetSessionState (SSLContextRef context, SSLSessionState* state); int SSLSetIOFuncs (SSLContextRef context, SSLReadFunc read, SSLWriteFunc write); int SSLSetProtocolVersionEnabled (SSLContextRef context, int protocol, ubyte enable); int SSLGetProtocolVersionEnabled (SSLContextRef context, int protocol, char* enable); int SSLSetProtocolVersion (SSLContextRef context, int version_); int SSLGetProtocolVersion (SSLContextRef context, SSLProtocol* protocol); int SSLSetCertificate (SSLContextRef context, CFArrayRef certRefs); int SSLSetConnection (SSLContextRef context, SSLConnectionRef connection); int SSLGetConnection (SSLContextRef context, SSLConnectionRef* connection); int SSLSetPeerDomainName (SSLContextRef context, char* peerName, uint peerNameLen); int SSLGetPeerDomainNameLength (SSLContextRef context, size_t* peerNameLen); int SSLGetPeerDomainName (SSLContextRef context, char* peerName, size_t* peerNameLen); int SSLGetNegotiatedProtocolVersion (SSLContextRef context, SSLProtocol* protocol); int SSLGetNumberSupportedCiphers (SSLContextRef context, size_t* numCiphers); int SSLGetSupportedCiphers (SSLContextRef context, SSLCipherSuite* ciphers, size_t* numCiphers); int SSLSetEnabledCiphers (SSLContextRef context, SSLCipherSuite* ciphers, uint numCiphers); int SSLGetNumberEnabledCiphers (SSLContextRef context, size_t* numCiphers); int SSLGetEnabledCiphers (SSLContextRef context, SSLCipherSuite* ciphers, size_t* numCiphers); int SSLSetEnableCertVerify (SSLContextRef context, ubyte enableVerify); int SSLGetEnableCertVerify (SSLContextRef context, char* enableVerify); int SSLSetAllowsExpiredCerts (SSLContextRef context, ubyte allowsExpired); int SSLGetAllowsExpiredCerts (SSLContextRef context, char* allowsExpired); int SSLSetAllowsExpiredRoots (SSLContextRef context, ubyte allowsExpired); int SSLGetAllowsExpiredRoots (SSLContextRef context, char* allowsExpired); int SSLSetAllowsAnyRoot (SSLContextRef context, ubyte anyRoot); int SSLGetAllowsAnyRoot (SSLContextRef context, char* anyRoot); int SSLSetTrustedRoots (SSLContextRef context, CFArrayRef trustedRoots, ubyte replaceExisting); int SSLGetTrustedRoots (SSLContextRef context, CFArrayRef* trustedRoots); int SSLCopyTrustedRoots (SSLContextRef context, CFArrayRef* trustedRoots); int SSLGetPeerCertificates (SSLContextRef context, CFArrayRef* certs); int SSLCopyPeerCertificates (SSLContextRef context, CFArrayRef* certs); int SSLSetPeerID (SSLContextRef context, void* peerID, uint peerIDLen); int SSLGetPeerID (SSLContextRef context, void** peerID, size_t* peerIDLen); int SSLGetNegotiatedCipher (SSLContextRef context, SSLCipherSuite* cipherSuite); int SSLSetEncryptionCertificate (SSLContextRef context, CFArrayRef certRefs); int SSLSetClientSideAuthenticate (SSLContextRef context, int auth); int SSLAddDistinguishedName (SSLContextRef context, void* derDN, uint derDNLen); int SSLSetCertificateAuthorities (SSLContextRef context, CFTypeRef certificateOrArray, ubyte replaceExisting); int SSLCopyCertificateAuthorities (SSLContextRef context, CFArrayRef* certificates); int SSLCopyDistinguishedNames (SSLContextRef context, CFArrayRef* names); int SSLGetClientCertificateState (SSLContextRef context, SSLClientCertificateState* clientState); int SSLSetDiffieHellmanParams (SSLContextRef context, void* dhParams, uint dhParamsLen); int SSLGetDiffieHellmanParams (SSLContextRef context, void** dhParams, size_t* dhParamsLen); int SSLSetRsaBlinding (SSLContextRef context, ubyte blinding); int SSLGetRsaBlinding (SSLContextRef context, char* blinding); int SSLHandshake (SSLContextRef context); int SSLWrite (SSLContextRef context, void* data, uint dataLength, size_t* processed); int SSLRead (SSLContextRef context, void* data, uint dataLength, size_t* processed); int SSLGetBufferedReadSize (SSLContextRef context, size_t* bufSize); int SSLClose (SSLContextRef context); }