Deleted Added
full compact
verify_extra_test.c (1.1.1.2) verify_extra_test.c (1.1.1.1)
1/*
1/*
2 * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
2 * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#include <stdio.h>

--- 121 unchanged lines hidden (view full) ---

132 BIO_free(bio);
133 sk_X509_pop_free(untrusted, X509_free);
134 X509_STORE_free(store);
135 if (ret != 1)
136 ERR_print_errors_fp(stderr);
137 return ret;
138}
139
3 *
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#include <stdio.h>

--- 121 unchanged lines hidden (view full) ---

132 BIO_free(bio);
133 sk_X509_pop_free(untrusted, X509_free);
134 X509_STORE_free(store);
135 if (ret != 1)
136 ERR_print_errors_fp(stderr);
137 return ret;
138}
139
140static int test_store_ctx(const char *bad_f)
141{
142 X509_STORE_CTX *sctx = NULL;
143 X509 *x = NULL;
144 BIO *bio = NULL;
145 int testresult = 0, ret;
146
147 bio = BIO_new_file(bad_f, "r");
148 if (bio == NULL)
149 goto err;
150
151 x = PEM_read_bio_X509(bio, NULL, 0, NULL);
152 if (x == NULL)
153 goto err;
154
155 sctx = X509_STORE_CTX_new();
156 if (sctx == NULL)
157 goto err;
158
159 if (!X509_STORE_CTX_init(sctx, NULL, x, NULL))
160 goto err;
161
162 /* Verifying a cert where we have no trusted certs should fail */
163 ret = X509_verify_cert(sctx);
164
165 if (ret == 0) {
166 /* This is the result we were expecting: Test passed */
167 testresult = 1;
168 }
169
170 err:
171 X509_STORE_CTX_free(sctx);
172 X509_free(x);
173 BIO_free(bio);
174 return testresult;
175}
176
177int main(int argc, char **argv)
178{
179 CRYPTO_set_mem_debug(1);
180 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
181
182 if (argc != 4) {
183 fprintf(stderr, "usage: verify_extra_test roots.pem untrusted.pem bad.pem\n");
184 return 1;
185 }
186
187 if (!test_alt_chains_cert_forgery(argv[1], argv[2], argv[3])) {
188 fprintf(stderr, "Test alt chains cert forgery failed\n");
189 return 1;
190 }
191
140int main(int argc, char **argv)
141{
142 CRYPTO_set_mem_debug(1);
143 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
144
145 if (argc != 4) {
146 fprintf(stderr, "usage: verify_extra_test roots.pem untrusted.pem bad.pem\n");
147 return 1;
148 }
149
150 if (!test_alt_chains_cert_forgery(argv[1], argv[2], argv[3])) {
151 fprintf(stderr, "Test alt chains cert forgery failed\n");
152 return 1;
153 }
154
192 if (!test_store_ctx(argv[3])) {
193 fprintf(stderr, "Test X509_STORE_CTX failed\n");
194 return 1;
195 }
196
197#ifndef OPENSSL_NO_CRYPTO_MDEBUG
198 if (CRYPTO_mem_leaks_fp(stderr) <= 0)
199 return 1;
200#endif
201
202 printf("PASS\n");
203 return 0;
204}
155#ifndef OPENSSL_NO_CRYPTO_MDEBUG
156 if (CRYPTO_mem_leaks_fp(stderr) <= 0)
157 return 1;
158#endif
159
160 printf("PASS\n");
161 return 0;
162}