2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
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
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.
20 // acl_threshold - Threshold-based group ACL subjects.
22 // This subject type implements threshold (k of n) subjects as per CSSM standard.
23 // Subsubjects are stored and evaluated in the order received. Any subsubject
24 // is presented with all subsamples of the corresponding threshold sample, but
25 // not any other samples possibly present in the credentials. Subsubject evaluation
26 // stops as soon as the threshold is satisfied, or as soon as it becomes numerically
27 // impossible to satisfy the threshold with future matches.
28 // Note that this subject will reject out of hand any threshold sample that
29 // contains more than <n> subsamples. This defeats "sample stuffing" attacks
30 // where the attacker provides thousands of samples in the hope that some may
31 // match by accident. It will however accept threshold samples with fewer than
32 // <n> subsamples, as long as there are at least <k> subsamples.
34 #ifndef _ACL_THRESHOLD
35 #define _ACL_THRESHOLD
37 #include <Security/cssmacl.h>
40 #ifdef _CPP_ACL_THRESHOLD
47 class ThresholdAclSubject
: public SimpleAclSubject
{
48 typedef ObjectAcl::AclSubjectPointer AclSubjectPointer
;
49 typedef vector
<AclSubjectPointer
> AclSubjectVector
;
51 bool validate(const AclValidationContext
&baseCtx
, const TypedList
&sample
) const;
52 CssmList
toList(CssmAllocator
&alloc
) const;
54 ThresholdAclSubject(uint32 n
, uint32 k
, const AclSubjectVector
&subSubjects
);
56 void exportBlob(Writer::Counter
&pub
, Writer::Counter
&priv
);
57 void exportBlob(Writer
&pub
, Writer
&priv
);
59 IFDUMP(void debugDump() const);
61 class Maker
: public AclSubject::Maker
{
63 Maker() : AclSubject::Maker(CSSM_ACL_SUBJECT_TYPE_THRESHOLD
) { }
64 ThresholdAclSubject
*make(const TypedList
&list
) const;
65 ThresholdAclSubject
*make(Version
, Reader
&pub
, Reader
&priv
) const;
69 uint32 minimumNeeded
; // number of matches needed
70 uint32 totalSubjects
; // number of subSubjects
71 AclSubjectVector elements
; // sub-subject vector
73 template <class Action
>
74 void ThresholdAclSubject::exportBlobForm(Action
&pub
, Action
&priv
);
77 } // end namespace Security
79 #ifdef _CPP_ACL_THRESHOLD
83 #endif //_ACL_THRESHOLD