view dstep/security/SecCertificate.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.SecCertificate;

import dstep.corefoundation.CFArray;
import dstep.corefoundation.CFBase;
import dstep.corefoundation.CFDate;
import dstep.objc.bridge.TypeEncoding;
import dstep.security.SecBase;
import dstep.security.cssmtype;
import dstep.security.x509defs;

// This is needed otherwise the enums will fail compiling with gdc
version (GNU)
{
	private
	{
		const __kSecSubjectItemAttr = getOSType!("subj");
		const __kSecIssuerItemAttr = getOSType!("issu");
		const __kSecSerialNumberItemAttr = getOSType!("snbr");
		const __kSecPublicKeyHashItemAttr = getOSType!("hpky");
		const __kSecSubjectKeyIdentifierItemAttr = getOSType!("skid");
		const __kSecCertTypeItemAttr = getOSType!("ctyp");
		const __kSecCertEncodingItemAttr = getOSType!("cenc");
	}
}

enum
{
	kSecSubjectItemAttr = getOSType!("subj"),
	kSecIssuerItemAttr = getOSType!("issu"),
	kSecSerialNumberItemAttr = getOSType!("snbr"),
	kSecPublicKeyHashItemAttr = getOSType!("hpky"),
	kSecSubjectKeyIdentifierItemAttr = getOSType!("skid"),
	kSecCertTypeItemAttr = getOSType!("ctyp"),
	kSecCertEncodingItemAttr = getOSType!("cenc")
}

extern (C)
{
	uint SecCertificateGetTypeID ();
	int SecCertificateCreateFromData (CSSM_DATA* data, uint type, uint encoding, SecCertificateRef* certificate);
	int SecCertificateAddToKeychain (SecCertificateRef certificate, SecKeychainRef keychain);
	int SecCertificateGetData (SecCertificateRef certificate, CSSM_DATA_PTR data);
	int SecCertificateGetType (SecCertificateRef certificate, CSSM_CERT_TYPE* certificateType);
	int SecCertificateGetSubject (SecCertificateRef certificate, CSSM_X509_NAME** subject);
	int SecCertificateGetIssuer (SecCertificateRef certificate, CSSM_X509_NAME** issuer);
	int SecCertificateGetCLHandle (SecCertificateRef certificate, CSSM_CL_HANDLE* clHandle);
	int SecCertificateGetAlgorithmID (SecCertificateRef certificate, CSSM_X509_ALGORITHM_IDENTIFIER** algid);
	int SecCertificateCopyPublicKey (SecCertificateRef certificate, SecKeyRef* key);
	int SecCertificateCopyCommonName (SecCertificateRef certificate, CFStringRef* commonName);
	int SecCertificateCopyEmailAddresses (SecCertificateRef certificate, CFArrayRef* emailAddresses);
	int SecCertificateCopyPreference (CFStringRef name, uint keyUsage, SecCertificateRef* certificate);
	int SecCertificateSetPreference (SecCertificateRef certificate, CFStringRef name, uint keyUsage, CFDateRef date);
}