Coverage Report

Created: 2025-12-31 06:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl33/crypto/x509/x509_d2.c
Line
Count
Source
1
/*
2
 * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
3
 *
4
 * Licensed under the Apache License 2.0 (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>
11
#include "internal/cryptlib.h"
12
#include <openssl/crypto.h>
13
#include <openssl/x509.h>
14
15
int X509_STORE_set_default_paths_ex(X509_STORE *ctx, OSSL_LIB_CTX *libctx,
16
    const char *propq)
17
0
{
18
0
    X509_LOOKUP *lookup;
19
20
0
    lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file());
21
0
    if (lookup == NULL)
22
0
        return 0;
23
0
    X509_LOOKUP_load_file_ex(lookup, NULL, X509_FILETYPE_DEFAULT, libctx, propq);
24
25
0
    lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_hash_dir());
26
0
    if (lookup == NULL)
27
0
        return 0;
28
0
    X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT);
29
30
0
    lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_store());
31
0
    if (lookup == NULL)
32
0
        return 0;
33
0
    X509_LOOKUP_add_store_ex(lookup, NULL, libctx, propq);
34
35
    /* clear any errors */
36
0
    ERR_clear_error();
37
38
0
    return 1;
39
0
}
40
int X509_STORE_set_default_paths(X509_STORE *ctx)
41
0
{
42
0
    return X509_STORE_set_default_paths_ex(ctx, NULL, NULL);
43
0
}
44
45
int X509_STORE_load_file_ex(X509_STORE *ctx, const char *file,
46
    OSSL_LIB_CTX *libctx, const char *propq)
47
0
{
48
0
    X509_LOOKUP *lookup;
49
50
0
    if (file == NULL
51
0
        || (lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file())) == NULL
52
0
        || X509_LOOKUP_load_file_ex(lookup, file, X509_FILETYPE_PEM, libctx,
53
0
               propq)
54
0
            <= 0)
55
0
        return 0;
56
57
0
    return 1;
58
0
}
59
60
int X509_STORE_load_file(X509_STORE *ctx, const char *file)
61
0
{
62
0
    return X509_STORE_load_file_ex(ctx, file, NULL, NULL);
63
0
}
64
65
int X509_STORE_load_path(X509_STORE *ctx, const char *path)
66
0
{
67
0
    X509_LOOKUP *lookup;
68
69
0
    if (path == NULL
70
0
        || (lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_hash_dir())) == NULL
71
0
        || X509_LOOKUP_add_dir(lookup, path, X509_FILETYPE_PEM) <= 0)
72
0
        return 0;
73
74
0
    return 1;
75
0
}
76
77
int X509_STORE_load_store_ex(X509_STORE *ctx, const char *uri,
78
    OSSL_LIB_CTX *libctx, const char *propq)
79
0
{
80
0
    X509_LOOKUP *lookup;
81
82
0
    if (uri == NULL
83
0
        || (lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_store())) == NULL
84
0
        || X509_LOOKUP_add_store_ex(lookup, uri, libctx, propq) == 0)
85
0
        return 0;
86
87
0
    return 1;
88
0
}
89
90
int X509_STORE_load_store(X509_STORE *ctx, const char *uri)
91
0
{
92
0
    return X509_STORE_load_store_ex(ctx, uri, NULL, NULL);
93
0
}
94
95
int X509_STORE_load_locations_ex(X509_STORE *ctx, const char *file,
96
    const char *path, OSSL_LIB_CTX *libctx,
97
    const char *propq)
98
0
{
99
0
    if (file == NULL && path == NULL)
100
0
        return 0;
101
0
    if (file != NULL && !X509_STORE_load_file_ex(ctx, file, libctx, propq))
102
0
        return 0;
103
0
    if (path != NULL && !X509_STORE_load_path(ctx, path))
104
0
        return 0;
105
0
    return 1;
106
0
}
107
108
int X509_STORE_load_locations(X509_STORE *ctx, const char *file,
109
    const char *path)
110
0
{
111
0
    return X509_STORE_load_locations_ex(ctx, file, path, NULL, NULL);
112
0
}