1/* 2 * Copyright (c) 2004-2008 Apple Inc. All Rights Reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24/* 25 * DotMacTpUtils.h 26 */ 27 28#ifndef _DOT_MAC_TP_UTILS_H_ 29#define _DOT_MAC_TP_UTILS_H_ 30 31#include <Security/cssmtype.h> 32#include <Security/x509defs.h> 33#include <security_asn1/SecNssCoder.h> 34#include "dotMacTpRpcGlue.h" 35 36#ifdef __cplusplus 37extern "C" { 38#endif 39 40/* 41 * Given an array of name/value pairs, cook up a CSSM_X509_NAME in specified 42 * SecNssCoder's address space. 43 */ 44void dotMacTpbuildX509Name( 45 SecNssCoder &coder, 46 uint32 numTypeValuePairs, // size of typeValuePairs[] 47 CSSM_X509_TYPE_VALUE_PAIR_PTR typeValuePairs, 48 CSSM_X509_NAME &x509Name); 49 50/* Convert a reference key to a raw key. */ 51void dotMacRefKeyToRaw( 52 CSSM_CSP_HANDLE cspHand, 53 const CSSM_KEY *refKey, 54 CSSM_KEY_PTR rawKey); // RETURNED 55 56/* Fetch components of a hostname string. */ 57void dotMacTokenizeHostName( 58 const CSSM_DATA &inName, // UTF8, no NULL 59 CSSM_DATA &outName, // RETURNED 60 CSSM_DATA &outDomain); // RETURNED 61 62/* Fetch components of a username string. */ 63void dotMacTokenizeUserName( 64 const CSSM_DATA &inName, // UTF8, no NULL 65 CSSM_DATA &outName, // RETURNED 66 CSSM_DATA &outDomain); // RETURNED 67 68/* 69 * Encode/decode ReferenceIdentitifiers for queued requests. 70 * We PEM encode/decode here to keep things orthogonal, since returned 71 * certs and URLs are also in PEM or at least UTF8 format. 72 */ 73OSStatus dotMacEncodeRefId( 74 const CSSM_DATA &userName, // UTF8, no NULL 75 const CSSM_DATA &domainName, // UTF8, no NULL 76 DotMacCertTypeTag signType, 77 SecNssCoder &coder, // results mallocd in this address space 78 CSSM_DATA &refId); // RETURNED, PEM encoded 79 80OSStatus dotMacDecodeRefId( 81 SecNssCoder &coder, // results mallocd in this address space 82 const CSSM_DATA &refId, // PEM encoded 83 CSSM_DATA &userName, // RETURNED, UTF8, no NULL 84 CSSM_DATA &domainName, // RETURNED, UTF8, no NULL 85 DotMacCertTypeTag *signType); // RETURNED 86 87/* fetch cert via HTTP */ 88CSSM_RETURN dotMacTpCertFetch( 89 const CSSM_DATA &userName, // UTF8, no NULL 90 const CSSM_DATA &domainName, // UTF8, no NULL 91 DotMacCertTypeTag signType, 92 Allocator &alloc, // results mallocd here 93 CSSM_DATA &result); // RETURNED 94 95#ifdef __cplusplus 96} 97#endif 98 99#endif /* _DOT_MAC_TP_UTILS_H_ */ 100 101