1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Original Code is the PKIX-C library.
16 * The Initial Developer of the Original Code is
17 * Sun Microsystems, Inc.
18 * Portions created by the Initial Developer are
19 * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
22 * Sun Microsystems, Inc.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 * test_authorityinfoaccess.c
40 * Test Authority InfoAccess Type
47 #include "testutil_nss.h"
49 static void *plContext = NULL;
51 int test_authorityinfoaccess(int argc, char *argv[]) {
53 PKIX_PL_Cert *cert = NULL;
54 PKIX_PL_Cert *certDiff = NULL;
55 PKIX_List *aiaList = NULL;
56 PKIX_List *siaList = NULL;
57 PKIX_PL_InfoAccess *aia = NULL;
58 PKIX_PL_InfoAccess *aiaDup = NULL;
59 PKIX_PL_InfoAccess *aiaDiff = NULL;
60 char *certPathName = NULL;
62 PKIX_UInt32 actualMinorVersion;
65 char *expectedAscii = "[method:caIssuers, location:ldap:"
66 "//betty.nist.gov/cn=CA,ou=Basic%20LDAP%20URI%20OU1,"
67 "o=Test%20Certificates,c=US?cACertificate;binary,"
68 "crossCertificatePair;binary]";
72 startTests("AuthorityInfoAccess");
74 PKIX_TEST_EXPECT_NO_ERROR(
75 PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
78 printf("Usage: %s <test-purpose> <cert> <diff-cert>\n", argv[0]);
82 certPathName = argv[3+j];
84 subTest("Creating Cert with Authority Info Access");
85 cert = createCert(dirName, certPathName, plContext);
87 certPathName = argv[4+j];
89 subTest("Creating Cert with Subject Info Access");
90 certDiff = createCert(dirName, certPathName, plContext);
92 subTest("Getting Authority Info Access");
93 PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Cert_GetAuthorityInfoAccess
94 (cert, &aiaList, plContext));
96 PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_GetLength
97 (aiaList, &size, plContext));
100 pkixTestErrorMsg = "unexpected number of AIA";
104 PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_GetItem
105 (aiaList, 0, (PKIX_PL_Object **) &aia, plContext));
107 PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_GetItem
108 (aiaList, 0, (PKIX_PL_Object **) &aiaDup, plContext));
110 subTest("Getting Subject Info Access as difference comparison");
111 PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Cert_GetSubjectInfoAccess
112 (certDiff, &siaList, plContext));
114 PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_GetLength
115 (siaList, &size, plContext));
118 pkixTestErrorMsg = "unexpected number of AIA";
122 PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_GetItem
123 (siaList, 0, (PKIX_PL_Object **) &aiaDiff, plContext));
125 subTest("Checking: Equal, Hash and ToString");
126 PKIX_TEST_EQ_HASH_TOSTR_DUP
127 (aia, aiaDup, aiaDiff, expectedAscii, InfoAccess, PKIX_FALSE);
133 PKIX_TEST_DECREF_AC(aia);
134 PKIX_TEST_DECREF_AC(aiaDup);
135 PKIX_TEST_DECREF_AC(aiaDiff);
136 PKIX_TEST_DECREF_AC(aiaList);
137 PKIX_TEST_DECREF_AC(siaList);
138 PKIX_TEST_DECREF_AC(cert);
139 PKIX_TEST_DECREF_AC(certDiff);
141 PKIX_Shutdown(plContext);
145 endTests("Authorityinfoaccess");