diff dstep/security/SecKeychain.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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dstep/security/SecKeychain.d	Sat Aug 01 15:03:28 2009 +0200
@@ -0,0 +1,228 @@
+/**
+ * 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.SecKeychain;
+
+import dstep.corefoundation.CFArray;
+import dstep.corefoundation.CFBase;
+import dstep.objc.bridge.TypeEncoding;
+import dstep.security.SecBase;
+import dstep.security.cssmapple;
+import dstep.security.cssmtype;
+
+alias uint SecAuthenticationType;
+alias uint SecProtocolType;
+alias uint SecKeychainEvent;
+alias uint SecKeychainEventMask;
+
+extern (C)
+{
+	alias int function (uint, SecKeychainCallbackInfo*, void*) SecKeychainCallback;
+}
+
+// This is needed otherwise the enums will fail compiling with gdc
+version (GNU)
+{
+	private
+	{
+		const __kSecProtocolTypeFTP = getOSType!("ftp ");
+		const __kSecProtocolTypeFTPAccount = getOSType!("ftpa");
+		const __kSecProtocolTypeHTTP = getOSType!("http");
+		const __kSecProtocolTypeIRC = getOSType!("irc ");
+		const __kSecProtocolTypeNNTP = getOSType!("nntp");
+		const __kSecProtocolTypePOP3 = getOSType!("pop3");
+		const __kSecProtocolTypeSMTP = getOSType!("smtp");
+		const __kSecProtocolTypeSOCKS = getOSType!("sox ");
+		const __kSecProtocolTypeIMAP = getOSType!("imap");
+		const __kSecProtocolTypeLDAP = getOSType!("ldap");
+		const __kSecProtocolTypeAppleTalk = getOSType!("atlk");
+		const __kSecProtocolTypeAFP = getOSType!("afp ");
+		const __kSecProtocolTypeTelnet = getOSType!("teln");
+		const __kSecProtocolTypeSSH = getOSType!("ssh ");
+		const __kSecProtocolTypeFTPS = getOSType!("ftps");
+		const __kSecProtocolTypeHTTPS = getOSType!("htps");
+		const __kSecProtocolTypeHTTPProxy = getOSType!("htpx");
+		const __kSecProtocolTypeHTTPSProxy = getOSType!("htsx");
+		const __kSecProtocolTypeFTPProxy = getOSType!("ftpx");
+		const __kSecProtocolTypeCIFS = getOSType!("cifs");
+		const __kSecProtocolTypeSMB = getOSType!("smb ");
+		const __kSecProtocolTypeRTSP = getOSType!("rtsp");
+		const __kSecProtocolTypeRTSPProxy = getOSType!("rtsx");
+		const __kSecProtocolTypeDAAP = getOSType!("daap");
+		const __kSecProtocolTypeEPPC = getOSType!("eppc");
+		const __kSecProtocolTypeIPP = getOSType!("ipp ");
+		const __kSecProtocolTypeNNTPS = getOSType!("ntps");
+		const __kSecProtocolTypeLDAPS = getOSType!("ldps");
+		const __kSecProtocolTypeTelnetS = getOSType!("tels");
+		const __kSecProtocolTypeIMAPS = getOSType!("imps");
+		const __kSecProtocolTypeIRCS = getOSType!("ircs");
+		const __kSecProtocolTypePOP3S = getOSType!("pops");
+		const __kSecProtocolTypeCVSpserver = getOSType!("cvsp");
+		const __kSecProtocolTypeSVN = getOSType!("svn ");
+		const __kSecAuthenticationTypeNTLM = ((getOSType!("ntlm") >> 24) | ((getOSType!("ntlm") >> 8) & 0xff00) | ((getOSType!("ntlm") << 8) & 0xff0000) | (getOSType!("ntlm") & 0xff) << 24);
+		const __kSecAuthenticationTypeMSN = ((getOSType!("msna") >> 24) | ((getOSType!("msna") >> 8) & 0xff00) | ((getOSType!("msna") << 8) & 0xff0000) | (getOSType!("msna") & 0xff) << 24);
+		const __kSecAuthenticationTypeDPA = ((getOSType!("dpaa") >> 24) | ((getOSType!("dpaa") >> 8) & 0xff00) | ((getOSType!("dpaa") << 8) & 0xff0000) | (getOSType!("dpaa") & 0xff) << 24);
+		const __kSecAuthenticationTypeRPA = ((getOSType!("rpaa") >> 24) | ((getOSType!("rpaa") >> 8) & 0xff00) | ((getOSType!("rpaa") << 8) & 0xff0000) | (getOSType!("rpaa") & 0xff) << 24);
+		const __kSecAuthenticationTypeHTTPBasic = ((getOSType!("http") >> 24) | ((getOSType!("http") >> 8) & 0xff00) | ((getOSType!("http") << 8) & 0xff0000) | (getOSType!("http") & 0xff) << 24);
+		const __kSecAuthenticationTypeHTTPDigest = ((getOSType!("httd") >> 24) | ((getOSType!("httd") >> 8) & 0xff00) | ((getOSType!("httd") << 8) & 0xff0000) | (getOSType!("httd") & 0xff) << 24);
+		const __kSecAuthenticationTypeHTMLForm = ((getOSType!("form") >> 24) | ((getOSType!("form") >> 8) & 0xff00) | ((getOSType!("form") << 8) & 0xff0000) | (getOSType!("form") & 0xff) << 24);
+		const __kSecAuthenticationTypeDefault = ((getOSType!("dflt") >> 24) | ((getOSType!("dflt") >> 8) & 0xff00) | ((getOSType!("dflt") << 8) & 0xff0000) | (getOSType!("dflt") & 0xff) << 24);
+		const __kSecAuthenticationTypeAny = ((0 >> 24) | ((0 >> 8) & 0xff00) | ((0 << 8) & 0xff0000) | (0 & 0xff) << 24);
+	}
+}
+
+enum
+{
+	kSecUnlockStateStatus = 1,
+	kSecReadPermStatus = 2,
+	kSecWritePermStatus = 4
+}
+
+enum
+{
+	kSecAuthenticationTypeNTLM = ((getOSType!("ntlm") >> 24) | ((getOSType!("ntlm") >> 8) & 0xff00) | ((getOSType!("ntlm") << 8) & 0xff0000) | (getOSType!("ntlm") & 0xff) << 24),
+	kSecAuthenticationTypeMSN = ((getOSType!("msna") >> 24) | ((getOSType!("msna") >> 8) & 0xff00) | ((getOSType!("msna") << 8) & 0xff0000) | (getOSType!("msna") & 0xff) << 24),
+	kSecAuthenticationTypeDPA = ((getOSType!("dpaa") >> 24) | ((getOSType!("dpaa") >> 8) & 0xff00) | ((getOSType!("dpaa") << 8) & 0xff0000) | (getOSType!("dpaa") & 0xff) << 24),
+	kSecAuthenticationTypeRPA = ((getOSType!("rpaa") >> 24) | ((getOSType!("rpaa") >> 8) & 0xff00) | ((getOSType!("rpaa") << 8) & 0xff0000) | (getOSType!("rpaa") & 0xff) << 24),
+	kSecAuthenticationTypeHTTPBasic = ((getOSType!("http") >> 24) | ((getOSType!("http") >> 8) & 0xff00) | ((getOSType!("http") << 8) & 0xff0000) | (getOSType!("http") & 0xff) << 24),
+	kSecAuthenticationTypeHTTPDigest = ((getOSType!("httd") >> 24) | ((getOSType!("httd") >> 8) & 0xff00) | ((getOSType!("httd") << 8) & 0xff0000) | (getOSType!("httd") & 0xff) << 24),
+	kSecAuthenticationTypeHTMLForm = ((getOSType!("form") >> 24) | ((getOSType!("form") >> 8) & 0xff00) | ((getOSType!("form") << 8) & 0xff0000) | (getOSType!("form") & 0xff) << 24),
+	kSecAuthenticationTypeDefault = ((getOSType!("dflt") >> 24) | ((getOSType!("dflt") >> 8) & 0xff00) | ((getOSType!("dflt") << 8) & 0xff0000) | (getOSType!("dflt") & 0xff) << 24),
+	kSecAuthenticationTypeAny = ((0 >> 24) | ((0 >> 8) & 0xff00) | ((0 << 8) & 0xff0000) | (0 & 0xff) << 24)
+}
+
+enum
+{
+	kSecProtocolTypeFTP = getOSType!("ftp "),
+	kSecProtocolTypeFTPAccount = getOSType!("ftpa"),
+	kSecProtocolTypeHTTP = getOSType!("http"),
+	kSecProtocolTypeIRC = getOSType!("irc "),
+	kSecProtocolTypeNNTP = getOSType!("nntp"),
+	kSecProtocolTypePOP3 = getOSType!("pop3"),
+	kSecProtocolTypeSMTP = getOSType!("smtp"),
+	kSecProtocolTypeSOCKS = getOSType!("sox "),
+	kSecProtocolTypeIMAP = getOSType!("imap"),
+	kSecProtocolTypeLDAP = getOSType!("ldap"),
+	kSecProtocolTypeAppleTalk = getOSType!("atlk"),
+	kSecProtocolTypeAFP = getOSType!("afp "),
+	kSecProtocolTypeTelnet = getOSType!("teln"),
+	kSecProtocolTypeSSH = getOSType!("ssh "),
+	kSecProtocolTypeFTPS = getOSType!("ftps"),
+	kSecProtocolTypeHTTPS = getOSType!("htps"),
+	kSecProtocolTypeHTTPProxy = getOSType!("htpx"),
+	kSecProtocolTypeHTTPSProxy = getOSType!("htsx"),
+	kSecProtocolTypeFTPProxy = getOSType!("ftpx"),
+	kSecProtocolTypeCIFS = getOSType!("cifs"),
+	kSecProtocolTypeSMB = getOSType!("smb "),
+	kSecProtocolTypeRTSP = getOSType!("rtsp"),
+	kSecProtocolTypeRTSPProxy = getOSType!("rtsx"),
+	kSecProtocolTypeDAAP = getOSType!("daap"),
+	kSecProtocolTypeEPPC = getOSType!("eppc"),
+	kSecProtocolTypeIPP = getOSType!("ipp "),
+	kSecProtocolTypeNNTPS = getOSType!("ntps"),
+	kSecProtocolTypeLDAPS = getOSType!("ldps"),
+	kSecProtocolTypeTelnetS = getOSType!("tels"),
+	kSecProtocolTypeIMAPS = getOSType!("imps"),
+	kSecProtocolTypeIRCS = getOSType!("ircs"),
+	kSecProtocolTypePOP3S = getOSType!("pops"),
+	kSecProtocolTypeCVSpserver = getOSType!("cvsp"),
+	kSecProtocolTypeSVN = getOSType!("svn "),
+	kSecProtocolTypeAny = 0
+}
+
+enum
+{
+	kSecLockEvent = 1,
+	kSecUnlockEvent = 2,
+	kSecAddEvent = 3,
+	kSecDeleteEvent = 4,
+	kSecUpdateEvent = 5,
+	kSecPasswordChangedEvent = 6,
+	kSecDefaultChangedEvent = 9,
+	kSecDataAccessEvent = 10,
+	kSecKeychainListChangedEvent = 11,
+	kSecTrustSettingsChangedEvent = 12
+}
+
+enum
+{
+	kSecLockEventMask = 1 << kSecLockEvent,
+	kSecUnlockEventMask = 1 << kSecUnlockEvent,
+	kSecAddEventMask = 1 << kSecAddEvent,
+	kSecDeleteEventMask = 1 << kSecDeleteEvent,
+	kSecUpdateEventMask = 1 << kSecUpdateEvent,
+	kSecPasswordChangedEventMask = 1 << kSecPasswordChangedEvent,
+	kSecDefaultChangedEventMask = 1 << kSecDefaultChangedEvent,
+	kSecDataAccessEventMask = 1 << kSecDataAccessEvent,
+	kSecKeychainListChangedMask = 1 << kSecKeychainListChangedEvent,
+	kSecTrustSettingsChangedEventMask = 1 << kSecTrustSettingsChangedEvent,
+	kSecEveryEventMask = 0xffffffff
+}
+
+enum SecPreferencesDomain
+{
+	kSecPreferencesDomainUser,
+	kSecPreferencesDomainSystem,
+	kSecPreferencesDomainCommon,
+	kSecPreferencesDomainDynamic
+}
+
+struct SecKeychainSettings
+{
+	uint version_;
+	ubyte lockOnSleep;
+	ubyte useLockInterval;
+	uint lockInterval;
+}
+
+
+struct SecKeychainCallbackInfo
+{
+	uint version_;
+	SecKeychainItemRef item;
+	SecKeychainRef keychain;
+	int pid;
+}
+
+extern (C)
+{
+	uint SecKeychainGetTypeID ();
+	int SecKeychainGetVersion (uint* returnVers);
+	int SecKeychainOpen (char* pathName, SecKeychainRef* keychain);
+	int SecKeychainCreate (char* pathName, uint passwordLength, void* password, ubyte promptUser, SecAccessRef initialAccess, SecKeychainRef* keychain);
+	int SecKeychainDelete (SecKeychainRef keychainOrArray);
+	int SecKeychainSetSettings (SecKeychainRef keychain, SecKeychainSettings* newSettings);
+	int SecKeychainCopySettings (SecKeychainRef keychain, SecKeychainSettings* outSettings);
+	int SecKeychainUnlock (SecKeychainRef keychain, uint passwordLength, void* password, ubyte usePassword);
+	int SecKeychainLock (SecKeychainRef keychain);
+	int SecKeychainLockAll ();
+	int SecKeychainCopyDefault (SecKeychainRef* keychain);
+	int SecKeychainSetDefault (SecKeychainRef keychain);
+	int SecKeychainCopySearchList (CFArrayRef* searchList);
+	int SecKeychainSetSearchList (CFArrayRef searchList);
+	int SecKeychainCopyDomainDefault (int domain, SecKeychainRef* keychain);
+	int SecKeychainSetDomainDefault (int domain, SecKeychainRef keychain);
+	int SecKeychainCopyDomainSearchList (int domain, CFArrayRef* searchList);
+	int SecKeychainSetDomainSearchList (int domain, CFArrayRef searchList);
+	int SecKeychainSetPreferenceDomain (int domain);
+	int SecKeychainGetPreferenceDomain (SecPreferencesDomain* domain);
+	int SecKeychainGetStatus (SecKeychainRef keychain, SecKeychainStatus* keychainStatus);
+	int SecKeychainGetPath (SecKeychainRef keychain, uint* ioPathLength, char* pathName);
+	int SecKeychainAttributeInfoForItemID (SecKeychainRef keychain, uint itemID, SecKeychainAttributeInfo** info);
+	int SecKeychainFreeAttributeInfo (SecKeychainAttributeInfo* info);
+	int SecKeychainAddCallback (SecKeychainCallback callbackFunction, uint eventMask, void* userContext);
+	int SecKeychainRemoveCallback (SecKeychainCallback callbackFunction);
+	int SecKeychainAddInternetPassword (SecKeychainRef keychain, uint serverNameLength, char* serverName, uint securityDomainLength, char* securityDomain, uint accountNameLength, char* accountName, uint pathLength, char* path, ushort port, uint protocol, uint authenticationType, uint passwordLength, void* passwordData, SecKeychainItemRef* itemRef);
+	int SecKeychainFindInternetPassword (CFTypeRef keychainOrArray, uint serverNameLength, char* serverName, uint securityDomainLength, char* securityDomain, uint accountNameLength, char* accountName, uint pathLength, char* path, ushort port, uint protocol, uint authenticationType, uint* passwordLength, void** passwordData, SecKeychainItemRef* itemRef);
+	int SecKeychainAddGenericPassword (SecKeychainRef keychain, uint serviceNameLength, char* serviceName, uint accountNameLength, char* accountName, uint passwordLength, void* passwordData, SecKeychainItemRef* itemRef);
+	int SecKeychainFindGenericPassword (CFTypeRef keychainOrArray, uint serviceNameLength, char* serviceName, uint accountNameLength, char* accountName, uint* passwordLength, void** passwordData, SecKeychainItemRef* itemRef);
+	int SecKeychainSetUserInteractionAllowed (ubyte state);
+	int SecKeychainGetUserInteractionAllowed (char* state);
+	int SecKeychainGetCSPHandle (SecKeychainRef keychain, CSSM_CSP_HANDLE* cspHandle);
+	int SecKeychainGetDLDBHandle (SecKeychainRef keychain, CSSM_DL_DB_HANDLE* dldbHandle);
+	int SecKeychainCopyAccess (SecKeychainRef keychain, SecAccessRef* access);
+	int SecKeychainSetAccess (SecKeychainRef keychain, SecAccessRef access);
+}
\ No newline at end of file