/*
- * Copyright (c) 2006-2007 Apple Inc. All Rights Reserved.
+ * Copyright (c) 2006-2012 Apple Inc. All Rights Reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
//
#include "requirement.h"
#include "reqinterp.h"
+#include "codesigning_dtrace.h"
#include <security_utilities/errors.h>
#include <security_utilities/unix++.h>
#include <security_utilities/logging.h>
"host",
"guest",
"designated",
- "library"
+ "library",
+ "plugin",
};
//
void Requirement::validate(const Requirement::Context &ctx, OSStatus failure /* = errSecCSReqFailed */) const
{
+ if (!this->validates(ctx, failure))
+ MacOSError::throwMe(failure);
+}
+
+bool Requirement::validates(const Requirement::Context &ctx, OSStatus failure /* = errSecCSReqFailed */) const
+{
+ CODESIGN_EVAL_REQINT_START((void*)this, this->length());
switch (kind()) {
case exprForm:
- if (!Requirement::Interpreter(this, &ctx).evaluate())
- MacOSError::throwMe(failure);
- return;
+ if (Requirement::Interpreter(this, &ctx).evaluate()) {
+ CODESIGN_EVAL_REQINT_END(this, 0);
+ return true;
+ } else {
+ CODESIGN_EVAL_REQINT_END(this, failure);
+ return false;
+ }
default:
- secdebug("reqval", "unrecognized requirement kind %d", kind());
+ CODESIGN_EVAL_REQINT_END(this, errSecCSReqUnsupported);
MacOSError::throwMe(errSecCSReqUnsupported);
}
}
if (certs) {
if (ix < 0)
ix += certCount();
+ if (ix >= CFArrayGetCount(certs))
+ return NULL;
if (CFTypeRef element = CFArrayGetValueAtIndex(certs, ix))
return SecCertificateRef(element);
}
#endif //TEST_APPLE_ANCHOR
-
//
// Debug dump support
//