diff options
author | beck <> | 2002-05-15 02:29:21 +0000 |
---|---|---|
committer | beck <> | 2002-05-15 02:29:21 +0000 |
commit | b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch) | |
tree | fa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libcrypto/x509/x509_trs.c | |
parent | e471e1ea98d673597b182ea85f29e30c97cd08b5 (diff) | |
download | openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2 openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip |
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'src/lib/libcrypto/x509/x509_trs.c')
-rw-r--r-- | src/lib/libcrypto/x509/x509_trs.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/lib/libcrypto/x509/x509_trs.c b/src/lib/libcrypto/x509/x509_trs.c index 86b3b79dcc..17d69ac005 100644 --- a/src/lib/libcrypto/x509/x509_trs.c +++ b/src/lib/libcrypto/x509/x509_trs.c | |||
@@ -66,6 +66,7 @@ static int tr_cmp(const X509_TRUST * const *a, | |||
66 | static void trtable_free(X509_TRUST *p); | 66 | static void trtable_free(X509_TRUST *p); |
67 | 67 | ||
68 | static int trust_1oidany(X509_TRUST *trust, X509 *x, int flags); | 68 | static int trust_1oidany(X509_TRUST *trust, X509 *x, int flags); |
69 | static int trust_1oid(X509_TRUST *trust, X509 *x, int flags); | ||
69 | static int trust_compat(X509_TRUST *trust, X509 *x, int flags); | 70 | static int trust_compat(X509_TRUST *trust, X509 *x, int flags); |
70 | 71 | ||
71 | static int obj_trust(int id, X509 *x, int flags); | 72 | static int obj_trust(int id, X509 *x, int flags); |
@@ -79,8 +80,10 @@ static int (*default_trust)(int id, X509 *x, int flags) = obj_trust; | |||
79 | static X509_TRUST trstandard[] = { | 80 | static X509_TRUST trstandard[] = { |
80 | {X509_TRUST_COMPAT, 0, trust_compat, "compatible", 0, NULL}, | 81 | {X509_TRUST_COMPAT, 0, trust_compat, "compatible", 0, NULL}, |
81 | {X509_TRUST_SSL_CLIENT, 0, trust_1oidany, "SSL Client", NID_client_auth, NULL}, | 82 | {X509_TRUST_SSL_CLIENT, 0, trust_1oidany, "SSL Client", NID_client_auth, NULL}, |
82 | {X509_TRUST_SSL_SERVER, 0, trust_1oidany, "SSL Client", NID_server_auth, NULL}, | 83 | {X509_TRUST_SSL_SERVER, 0, trust_1oidany, "SSL Server", NID_server_auth, NULL}, |
83 | {X509_TRUST_EMAIL, 0, trust_1oidany, "S/MIME email", NID_email_protect, NULL}, | 84 | {X509_TRUST_EMAIL, 0, trust_1oidany, "S/MIME email", NID_email_protect, NULL}, |
85 | {X509_TRUST_OCSP_SIGN, 0, trust_1oid, "OCSP responder", NID_OCSP_sign, NULL}, | ||
86 | {X509_TRUST_OCSP_REQUEST, 0, trust_1oid, "OCSP request", NID_ad_OCSP, NULL} | ||
84 | }; | 87 | }; |
85 | 88 | ||
86 | #define X509_TRUST_COUNT (sizeof(trstandard)/sizeof(X509_TRUST)) | 89 | #define X509_TRUST_COUNT (sizeof(trstandard)/sizeof(X509_TRUST)) |
@@ -97,10 +100,10 @@ static int tr_cmp(const X509_TRUST * const *a, | |||
97 | 100 | ||
98 | int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int) | 101 | int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int) |
99 | { | 102 | { |
100 | int (*oldtrust)(int , X509 *, int); | 103 | int (*oldtrust)(int , X509 *, int); |
101 | oldtrust = default_trust; | 104 | oldtrust = default_trust; |
102 | default_trust = trust; | 105 | default_trust = trust; |
103 | return oldtrust; | 106 | return oldtrust; |
104 | } | 107 | } |
105 | 108 | ||
106 | 109 | ||
@@ -141,6 +144,16 @@ int X509_TRUST_get_by_id(int id) | |||
141 | return idx + X509_TRUST_COUNT; | 144 | return idx + X509_TRUST_COUNT; |
142 | } | 145 | } |
143 | 146 | ||
147 | int X509_TRUST_set(int *t, int trust) | ||
148 | { | ||
149 | if(X509_TRUST_get_by_id(trust) == -1) { | ||
150 | X509err(X509_F_X509_TRUST_SET, X509_R_INVALID_TRUST); | ||
151 | return 0; | ||
152 | } | ||
153 | *t = trust; | ||
154 | return 1; | ||
155 | } | ||
156 | |||
144 | int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int), | 157 | int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int), |
145 | char *name, int arg1, void *arg2) | 158 | char *name, int arg1, void *arg2) |
146 | { | 159 | { |
@@ -236,6 +249,12 @@ static int trust_1oidany(X509_TRUST *trust, X509 *x, int flags) | |||
236 | return trust_compat(trust, x, flags); | 249 | return trust_compat(trust, x, flags); |
237 | } | 250 | } |
238 | 251 | ||
252 | static int trust_1oid(X509_TRUST *trust, X509 *x, int flags) | ||
253 | { | ||
254 | if(x->aux) return obj_trust(trust->arg1, x, flags); | ||
255 | return X509_TRUST_UNTRUSTED; | ||
256 | } | ||
257 | |||
239 | static int trust_compat(X509_TRUST *trust, X509 *x, int flags) | 258 | static int trust_compat(X509_TRUST *trust, X509 *x, int flags) |
240 | { | 259 | { |
241 | X509_check_purpose(x, -1, 0); | 260 | X509_check_purpose(x, -1, 0); |