X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/bac41a7b9a0a9254fa30f8bb6e6038ab71a483e2..ce0ac947b4708d0bc1c7e6789b3e1f3bfc80d6e9:/cdsa/cdsa_utilities/cssmcred.cpp diff --git a/cdsa/cdsa_utilities/cssmcred.cpp b/cdsa/cdsa_utilities/cssmcred.cpp index d65d5371..781e47d6 100644 --- a/cdsa/cdsa_utilities/cssmcred.cpp +++ b/cdsa/cdsa_utilities/cssmcred.cpp @@ -38,6 +38,27 @@ const AccessCredentials &AccessCredentials::null = #endif +// +// Scan a SampleGroup for samples with a given CSSM_SAMPLE_TYPE. +// Collect all matching samples into a list (which is cleared to begin with). +// Return true if any were found, false if none. +// Throw if any of the samples are obviously malformed. +// +bool SampleGroup::collect(CSSM_SAMPLE_TYPE sampleType, list &matches) const +{ + for (uint32 n = 0; n < length(); n++) { + TypedList sample = (*this)[n]; + sample.checkProper(); + if (sample.type() == sampleType) { + sample.snip(); // skip sample type + matches.push_back(sample); + } + } + return !matches.empty(); +} + + + // // AutoCredentials self-constructing credentials structure //