]> git.saurik.com Git - apple/security.git/blob - cdsa/cdsa_utilities/SampleGroup.h
Security-54.1.tar.gz
[apple/security.git] / cdsa / cdsa_utilities / SampleGroup.h
1 /*
2 * Copyright (c) 2000-2001 Apple Computer, 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 // SampleGroup.h
20 //
21 // a class interface to the CSSM_SAMPLEGROUP structure
22 //
23 // Here are the relevant structures:
24 //
25 // typedef struct cssm_samplegroup {
26 // uint32 NumberOfSamples;
27 // const CSSM_SAMPLE *Samples;
28 // } CSSM_SAMPLEGROUP, *CSSM_SAMPLEGROUP_PTR;
29 //
30 // typedef struct cssm_sample {
31 // CSSM_LIST TypedSample;
32 // const CSSM_SUBSERVICE_UID *Verifier;
33 // } CSSM_SAMPLE, *CSSM_SAMPLE_PTR;
34 //
35 // typedef struct cssm_list {
36 // CSSM_LIST_TYPE ListType; /* type of this list */
37 // CSSM_LIST_ELEMENT_PTR Head; /* head of the list */
38 // CSSM_LIST_ELEMENT_PTR Tail; /* tail of the list */
39 // } CSSM_LIST, *CSSM_LIST_PTR;
40 //
41 // typedef uint32 CSSM_LIST_TYPE, *CSSM_LIST_TYPE_PTR;
42 // enum {
43 // CSSM_LIST_TYPE_UNKNOWN = 0,
44 // CSSM_LIST_TYPE_CUSTOM = 1,
45 // CSSM_LIST_TYPE_SEXPR = 2
46 // };
47 //
48 // typedef struct cssm_list_element {
49 // struct cssm_list_element *NextElement; /* next list element */
50 // CSSM_WORDID_TYPE WordID; /* integer identifier associated */
51 // /* with a Word value */
52 // CSSM_LIST_ELEMENT_TYPE ElementType;
53 // union {
54 // CSSM_LIST Sublist; /* sublist */
55 // CSSM_DATA Word; /* a byte-string */
56 // } Element;
57 // } CSSM_LIST_ELEMENT;
58 //
59
60
61 #ifndef __SAMPLEGROUP__
62 #define __SAMPLEGROUP__
63
64 #include <cdsa/cssmtype.h>
65 #include <cdsa_utilities/utilities.h>
66 #include <cdsa_utilities/cssm_adt_utils.h>
67
68 #ifdef _CPP_UTILITIES
69 #pragma export on
70 #endif
71
72
73 class CssmSample : public PodWrapper<CssmSample, CSSM_SAMPLE> {
74 public:
75 CssmSample();
76 CssmSample( CSSM_LIST &list, CSSM_SUBSERVICE_UID *verifier);
77 ~CssmSample();
78
79 CssmSample* operator = (CssmSample& sample);
80
81 void SetSubserviceUID( CSSM_SUBSERVICE_UID *verifier ) { Verifier = verifier; }
82 void SetList( CSSM_LIST *list ) { TypedSample.ListType = list->ListType; TypedSample.Head = list->Head; TypedSample.Tail = list->Tail; }
83
84 // CSSM_SAMPLE_TYPE_PASSWORD = CSSM_WORDID_PASSWORD,
85 CSSM_RETURN AddPasswordImmediate( char* password, CSSM_SUBSERVICE_UID *optionalVerifier ); // provide password without callback or reply to callback
86 CSSM_RETURN AddPasswordCallback( ); // triggers a callback that will acquire the password
87
88 // CSSM_SAMPLE_TYPE_HASHED_PASSWORD = CSSM_WORDID_HASHED_PASSWORD,
89 CSSM_RETURN AddHashedPassword( char* password, CSSM_SUBSERVICE_UID *optionalVerifier ); // this is always in reply to a callback
90
91 // CSSM_SAMPLE_TYPE_PROTECTED_PASSWORD = CSSM_WORDID_PROTECTED_PASSWORD,
92 CSSM_RETURN AddProtectedPasword(CSSM_SUBSERVICE_UID *optionalVerifier); // this always provokes a callback, Verifier is optional
93
94 // CSSM_SAMPLE_TYPE_PROMPTED_PASSWORD = CSSM_WORDID_PROMPTED_PASSWORD,
95 CSSM_RETURN AddPromptedPassword( char* promptedPassword, CSSM_SUBSERVICE_UID *optionalVerifier ); // this is always in reply to a callback
96
97 // CSSM_SAMPLE_TYPE_SIGNED_NONCE = CSSM_WORDID_SIGNED_NONCE,
98 CSSM_RETURN AddSignedNonceForCallback( CSSM_SUBSERVICE_UID *requiredVerifier );
99 CSSM_RETURN AddSignedNonceReply( CSSM_DATA_PTR signedNonce, CSSM_SUBSERVICE_UID *requiredVerifier ); // used to reply to the callback for a signed nonce
100
101 // CSSM_SAMPLE_TYPE_SIGNED_SECRET = CSSM_WORDID_SIGNED_SECRET,
102 CSSM_RETURN AddSignedSecretForCallback( CSSM_SUBSERVICE_UID *requiredVerifier ); // will provoke a callback to fill in the actual signed secret
103 CSSM_RETURN AddSignedSecretImmediate( CSSM_DATA_PTR signedSecret, CSSM_SUBSERVICE_UID *requiredVerifier ); // use as the original request or as a response to a callback
104
105 // CSSM_SAMPLE_TYPE_BIOMETRIC = CSSM_WORDID_BIOMETRIC,
106 CSSM_RETURN AddBiometricCallback( CSSM_SUBSERVICE_UID *requiredVerifier );
107 CSSM_RETURN AddBiometricImmediate( CSSM_DATA_PTR biometricData, CSSM_SUBSERVICE_UID *requiredVerifier ); // reply to callback or provide sample without callback
108
109 // CSSM_SAMPLE_TYPE_PROTECTED_BIOMETRIC = CSSM_WORDID_PROTECTED_BIOMETRIC,
110 CSSM_RETURN AddProtectedBiometric( CSSM_SUBSERVICE_UID *requiredVerifier ); // request for a callback for biometric data
111
112 // CSSM_SAMPLE_TYPE_PROMPTED_BIOMETRIC = CSSM_WORDID_PROMPTED_BIOMETRIC,
113 CSSM_RETURN AddPromptedBiometric( CSSM_DATA_PTR biometricData, CSSM_SUBSERVICE_UID *requiredVerifier ); // reply to callback only
114
115 // CSSM_SAMPLE_TYPE_THRESHOLD = CSSM_WORDID_THRESHOLD
116 CSSM_RETURN AddThreshold();
117
118 };
119
120 class CssmSampleGroup : public PodWrapper<CssmSampleGroup, CSSM_SAMPLEGROUP>
121 {
122 public:
123 CssmSampleGroup();
124 CssmSampleGroup( uint32 sampleCount, CSSM_SAMPLE *samples );
125 ~CssmSampleGroup();
126
127 CSSM_RETURN AddSample(CSSM_SAMPLE* sample);
128
129 CSSM_SAMPLE* GetIthSample(uint32 sampleIndex);
130
131 uint32 GetSampleCount() { return NumberOfSamples; }
132
133
134 private:
135 };
136
137 #ifdef _CPP_UTILITIES
138 #pragma export off
139 #endif
140
141 #endif // __SAMPLEGROUP__