1/*
2 * Copyright (c) 2000-2001,2011,2014 Apple Inc. All Rights Reserved.
3 *
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
8 * using this file.
9 *
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
16 */
17
18
19/*
20   File:      MDSAttrStrings.h
21
22   Contains:  Static tables to map attribute names to numeric values.
23
24   Copyright (c) 2001,2011,2014 Apple Inc. All Rights Reserved.
25*/
26
27#ifndef _MDS_ATTR_STRINGS_H_
28#define _MDS_ATTR_STRINGS_H_  1
29
30#include <Security/cssmtype.h>
31
32namespace Security
33{
34
35/*
36 * Each type of attribute has a name/value pair in a table of these:
37 */
38typedef struct {
39	uint32			value;
40	const char 		*name;
41} MDSNameValuePair;
42
43/*
44 * Various tables.
45 */
46
47/* attributes in Object and Common relations */
48extern const MDSNameValuePair MDSServiceNames[];		// CSSM_SERVICE_MASK
49
50/* CSP attributes */
51extern const MDSNameValuePair MDSContextTypeNames[];	// CSSM_CONTEXT_TYPE
52extern const MDSNameValuePair MDSAttributeTypeNames[];	// CSSM_ATTRIBUTE_TYPE
53extern const MDSNameValuePair MDSPaddingNames[];		// CSSM_PADDING
54extern const MDSNameValuePair MDSCspFlagsNames[];		// CSSM_CSP_FLAGS
55extern const MDSNameValuePair MDSAlgorithmNames[];		// CSSM_ALGORITHMS
56extern const MDSNameValuePair MDSEncryptModeNames[];	// CSSM_ENCRYPT_MODE
57extern const MDSNameValuePair MDSCspTypeNames[];		// CSSM_CSPTYPE
58extern const MDSNameValuePair MDSUseeTagsNames[];		// CSSM_USEE_TAG
59extern const MDSNameValuePair MDSCspReaderFlagsNames[];	// CSSM_CSP_READER_FLAGS
60extern const MDSNameValuePair MDSCspScFlagsNames[];		// CSSM_SC_FLAGS
61
62/* CL attributes */
63extern const MDSNameValuePair MDSCertTypeNames[];		// CSSM_CERT_TYPE
64extern const MDSNameValuePair MDSCrlTypeNames[];		// CSSM_CRL_TYPE
65extern const MDSNameValuePair MDSCertBundleTypeNames[];	// CSSM_CERT_BUNDLE_TYPE
66extern const MDSNameValuePair MDSCertTemplateTypeNames[];
67														// CSSM_CL_TEMPLATE_TYPE
68
69/* TP attributes */
70/* CSSM_TP_AUTHORITY_REQUEST_CERTISSUE */
71extern const MDSNameValuePair MDSTpAuthRequestNames[];
72											// CSSM_TP_AUTHORITY_REQUEST_CERTISSUE
73
74/* DL attributes */
75extern const MDSNameValuePair MDSDlTypeNames[];			// CSSM_DLTYPE
76extern const MDSNameValuePair MDSDbConjunctiveNames[];	// CSSM_DB_CONJUNCTIVE
77extern const MDSNameValuePair MDSDbOperatorNames[];		// CSSM_DB_OPERATOR
78extern const MDSNameValuePair MDSNetProtocolNames[];	// CSSM_NET_PROTOCOL
79extern const MDSNameValuePair MDSDbRetrievalModeNames[];// CSSM_DB_RETRIEVAL_MODES
80
81/* misc. */
82extern const MDSNameValuePair MDSAclSubjectTypeNames[];	// CSSM_ACL_SUBJECT_TYPE
83extern const MDSNameValuePair MDSAclAuthTagNames[];		// CSSM_ACL_AUTHORIZATION_TAG
84extern const MDSNameValuePair MDSSampleTypeNames[];		// CSSM_SAMPLE_TYPE
85extern const MDSNameValuePair MDSKrPolicyTypeNames[];	// CSSM_KR_POLICY_TYPE
86
87// extern const MDSNameValuePair MDSRecordTypeNames[];		// CSSM_DB_RECORDTYPE
88
89/*
90 * Use this function to convert a name, e.g. "CSSM_ALGCLASS_SIGNATURE", to
91 * its associated value as a uint32. Caller specifies proper lookup table
92 * as an optimization to avoid grunging thru entire CDSA namespace on every
93 * lookup.
94 *
95 * If the specified name is not found, or if no MDSNameValuePair is specified,
96 * an attempt will be made to convert the incoming string to a number as if
97 * it were an ASCII hex (starts with "0x") or decimal (starts with any other numeric
98 * string) string. If that fails, CSSMERR_CSSM_MDS_ERROR is returned.
99 *
100 * Values can be prefixed with "<<" indicating that the indicated
101 * value is to be shifted 16 bits. Cf. CL Primary Relation, {Cert,Crl}TypeFormat.
102 * This applies to both numeric and string tokens.
103 */
104CSSM_RETURN MDSAttrNameToValue(
105	const char *name,
106	const MDSNameValuePair *table,
107	uint32 &value);					// RETURNED
108
109} // end namespace Security
110
111#endif /* _MDS_ATTR_STRINGS_H_ */
112