/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /* * test_policychecker.c * * Test Policy Checking *
*/
#include"testutil.h" #include"testutil_nss.h"
#define PKIX_TEST_MAX_CERTS 10
staticvoid *plContext = NULL;
staticvoid
printUsage(char *testname)
{ char *fmt = "USAGE: %s testname" " [ENE|EE] \"{OID[:OID]*}\" [A|E|P] cert [cert]*\n" "(The quotes are needed around the OID argument for dbx.)\n" "(The optional arg A indicates initialAnyPolicyInhibit.)\n" "(The optional arg E indicates initialExplicitPolicy.)\n" "(The optional arg P indicates initialPolicyMappingInhibit.)\n";
printf(fmt, testname);
}
staticvoid
printUsageMax(PKIX_UInt32 numCerts)
{
printf("\nUSAGE ERROR: number of certs %d exceed maximum %d\n",
numCerts, PKIX_TEST_MAX_CERTS);
}
/* * There may or may not be quotes around the initial-policy-set * string. If they are omitted, dbx will strip off the curly braces. * If they are included, dbx will strip off the quotes, but if you * are running directly from a script, without dbx, the quotes will * not be stripped. We need to be able to handle both cases.
*/ if (*p == '"') {
p++;
}
/* scan to the end of policyString */ while (!validString) { /* scan to the end of the current OID string */
c = *oid; while ((c != '\0') && (c != ':') && (c != '}')) {
c = *++oid;
}
if ((c != ':') || (c != '}')) {
*oid = '\0'; /* store a null terminator */
PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_OID_Create(p, &plOID, plContext));
PKIX_TEST_DECREF_BC(plOID);
plOID = NULL; if (c == '}') { /* * Any exit but this one means * we were given a badly-formed string.
*/
validString = PKIX_TRUE;
}
p = ++oid;
}
}
cleanup: if (!validString) {
PKIX_TEST_DECREF_AC(plOID);
PKIX_TEST_DECREF_AC(policySet);
policySet = NULL;
}
PKIX_TEST_RETURN();
return (policySet);
}
/* * FUNCTION: treeToStringHelper * This function obtains the string representation of a PolicyNode * Tree and compares it to the expected value. * PARAMETERS: * "parent" - a PolicyNode, the root of a PolicyNodeTree; * must be non-NULL. * "expected" - the desired string. * THREAD SAFETY: * Thread Safe * * Multiple threads can safely call this function without worrying * about conflicts, even if they're operating on the same object. * RETURNS: * Nothing.
*/ staticvoid
treeToStringHelper(PKIX_PolicyNode *parent, char *expected)
{
PKIX_PL_String *stringRep = NULL; char *actual = NULL;
PKIX_TEST_STD_VARS();
subTest("testNistTest1: Creating the cert chain"); /* * Create a chain, but don't include the first certName. * That's the anchor, and is supplied separately from * the chain.
*/
certNames[0] = intermediateCert;
certNames[1] = endEntityCert;
chain = createCertChainPlus(dirName, certNames, certs, PKIX_TEST_NUM_CERTS, plContext);
subTest("testNistTest2: Creating the cert chain"); /* * Create a chain, but don't include the first certName. * That's the anchor, and is supplied separately from * the chain.
*/
certNames[0] = intermediateCert;
certNames[1] = endEntityCert;
chain = createCertChainPlus(dirName, certNames, certs, PKIX_TEST_NUM_CERTS, plContext);
/* * Perform hard-coded tests if no command line args. * If command line args are provided, they must be: * arg[1]: test name * arg[2]: "ENE" or "EE", for "expect no error" or "expect error" * arg[3]: directory for certificates * arg[4]: user-initial-policy-set, consisting of braces * containing zero or more OID sequences, separated by commas * arg[5]: (optional) "E", indicating initialExplicitPolicy * arg[firstCert]: the path and filename of the trust anchor certificate * arg[firstCert+1..(n-1)]: successive certificates in the chain * arg[n]: the end entity certificate * * Example: test_policychecker test1EE ENE * {2.5.29.32.0,2.5.29.32.3.6} Anchor CA EndEntity
*/
/* * Create a chain, but don't include the first certName. * That's the anchor, and is supplied separately from * the chain.
*/ for (i = 0; i < chainLength; i++) {
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.