more tls reorganisation

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35605 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2012-09-26 15:23:24 +00:00
parent c2808eb88e
commit f05d94e9e3
6 changed files with 921 additions and 482 deletions

View file

@ -42,29 +42,10 @@
#include <gcrypt.h>
#undef id
@protocol GSTLSOwner
/* Returns the optins dictionary set for this session.
*/
- (NSDictionary*) options;
/* Returns the host this session should be connected to.
*/
- (NSHost*) remoteHost;
@end
/* This class is used to ensure that the GNUTLS system is initialised
* and thread-safe. It also provides session verification.
* and thread-safe.
*/
@interface GSTLSObject : NSObject
/* Performs verification for the supplied session and returns a GNUTLS
* error code in the event of verification failure or zero on success.<br />
* The ponter set in the session with gnutls_session_set_ptr() must be
* the owner of the session and must conform to the GSTLSOwner protocol.
*/
+ (int) verify: (gnutls_session_t)session;
@end
/* This class provides the current autogenerated Diffie Hellman parameters
@ -122,5 +103,78 @@
- (gnutls_x509_privkey_t) key;
@end
/* Declare a pointer to a function to be used for I/O
*/
typedef ssize_t (*GSTLSIOR)(gnutls_transport_ptr_t, void *, size_t);
typedef ssize_t (*GSTLSIOW)(gnutls_transport_ptr_t, const void *, size_t);
/* This class encapsulates a session to a remote system.
* Sessions are created with a direction and an options dictionary,
* defining how they will operate. The handle, pushFunc and pullFunc
* provide the I/O mechanism, and the host specifies the host that the
* session is connected to.
*/
@interface GSTLSSession : GSTLSObject
{
NSDictionary *opts;
NSHost *host;
GSTLSPrivateKey *key;
GSTLSCertificateList *list;
GSTLSDHParams *dhParams;
gnutls_certificate_credentials_t certcred;
BOOL outgoing;
BOOL active;
BOOL handshake;
BOOL setup;
@public
gnutls_session_t session;
}
+ (GSTLSSession*) sessionWithOptions: (NSDictionary*)options
direction: (BOOL)isOutgoing
transport: (void*)handle
push: (GSTLSIOW)pushFunc
pull: (GSTLSIOR)pullFunc
host: (NSHost*)remote;
- (id) initWithOptions: (NSDictionary*)options
direction: (BOOL)isOutgoing
transport: (void*)handle
push: (GSTLSIOW)pushFunc
pull: (GSTLSIOR)pullFunc
host: (NSHost*)remote;
/* Return YES if the session is active (handshake has succeeded and the
* session has not been disconnected), NO otherwise.
*/
- (BOOL) active;
/* Disconnects and closes down the session.
*/
- (void) disconnect;
/* Try to complete a handshake ... return YES if complete, NO if we need
* to try again (would have to wait for the remote end).<br />
*/
- (BOOL) handshake;
/* Read data from the session.
*/
- (NSInteger) read: (void*)buf length: (NSUInteger)len;
/** Get a report of the SSL/TLS status of the current session.
*/
- (NSString*) sessionInfo;
/* Write data to the session.
*/
- (NSInteger) write: (const void*)buf length: (NSUInteger)len;
/* For internal use to verify the remmote system's vertificate.
* Returns 0 on success, negative on failure.
*/
- (int) verify;
@end
#endif