diff options
Diffstat (limited to 'src/lib/libcrypto/x509/x509cset.c')
-rw-r--r-- | src/lib/libcrypto/x509/x509cset.c | 89 |
1 files changed, 51 insertions, 38 deletions
diff --git a/src/lib/libcrypto/x509/x509cset.c b/src/lib/libcrypto/x509/x509cset.c index bb39cf4e04..ee405d6e9f 100644 --- a/src/lib/libcrypto/x509/x509cset.c +++ b/src/lib/libcrypto/x509/x509cset.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -63,98 +63,111 @@ | |||
63 | #include <openssl/evp.h> | 63 | #include <openssl/evp.h> |
64 | #include <openssl/x509.h> | 64 | #include <openssl/x509.h> |
65 | 65 | ||
66 | int X509_CRL_set_version(X509_CRL *x, long version) | 66 | int |
67 | X509_CRL_set_version(X509_CRL *x, long version) | ||
67 | { | 68 | { |
68 | if (x == NULL) return(0); | 69 | if (x == NULL) |
70 | return (0); | ||
69 | if (x->crl->version == NULL) { | 71 | if (x->crl->version == NULL) { |
70 | if ((x->crl->version=M_ASN1_INTEGER_new()) == NULL) | 72 | if ((x->crl->version = M_ASN1_INTEGER_new()) == NULL) |
71 | return(0); | 73 | return (0); |
72 | } | 74 | } |
73 | return(ASN1_INTEGER_set(x->crl->version,version)); | 75 | return (ASN1_INTEGER_set(x->crl->version, version)); |
74 | } | 76 | } |
75 | 77 | ||
76 | int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name) | 78 | int |
79 | X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name) | ||
77 | { | 80 | { |
78 | if ((x == NULL) || (x->crl == NULL)) return(0); | 81 | if ((x == NULL) || (x->crl == NULL)) |
79 | return(X509_NAME_set(&x->crl->issuer,name)); | 82 | return (0); |
83 | return (X509_NAME_set(&x->crl->issuer, name)); | ||
80 | } | 84 | } |
81 | 85 | ||
82 | 86 | int | |
83 | int X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm) | 87 | X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm) |
84 | { | 88 | { |
85 | ASN1_TIME *in; | 89 | ASN1_TIME *in; |
86 | 90 | ||
87 | if (x == NULL) return(0); | 91 | if (x == NULL) |
88 | in=x->crl->lastUpdate; | 92 | return (0); |
93 | in = x->crl->lastUpdate; | ||
89 | if (in != tm) { | 94 | if (in != tm) { |
90 | in=M_ASN1_TIME_dup(tm); | 95 | in = M_ASN1_TIME_dup(tm); |
91 | if (in != NULL) { | 96 | if (in != NULL) { |
92 | M_ASN1_TIME_free(x->crl->lastUpdate); | 97 | M_ASN1_TIME_free(x->crl->lastUpdate); |
93 | x->crl->lastUpdate=in; | 98 | x->crl->lastUpdate = in; |
94 | } | 99 | } |
95 | } | 100 | } |
96 | return(in != NULL); | 101 | return (in != NULL); |
97 | } | 102 | } |
98 | 103 | ||
99 | int X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm) | 104 | int |
105 | X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm) | ||
100 | { | 106 | { |
101 | ASN1_TIME *in; | 107 | ASN1_TIME *in; |
102 | 108 | ||
103 | if (x == NULL) return(0); | 109 | if (x == NULL) |
104 | in=x->crl->nextUpdate; | 110 | return (0); |
111 | in = x->crl->nextUpdate; | ||
105 | if (in != tm) { | 112 | if (in != tm) { |
106 | in=M_ASN1_TIME_dup(tm); | 113 | in = M_ASN1_TIME_dup(tm); |
107 | if (in != NULL) { | 114 | if (in != NULL) { |
108 | M_ASN1_TIME_free(x->crl->nextUpdate); | 115 | M_ASN1_TIME_free(x->crl->nextUpdate); |
109 | x->crl->nextUpdate=in; | 116 | x->crl->nextUpdate = in; |
110 | } | 117 | } |
111 | } | 118 | } |
112 | return(in != NULL); | 119 | return (in != NULL); |
113 | } | 120 | } |
114 | 121 | ||
115 | int X509_CRL_sort(X509_CRL *c) | 122 | int |
123 | X509_CRL_sort(X509_CRL *c) | ||
116 | { | 124 | { |
117 | int i; | 125 | int i; |
118 | X509_REVOKED *r; | 126 | X509_REVOKED *r; |
127 | |||
119 | /* sort the data so it will be written in serial | 128 | /* sort the data so it will be written in serial |
120 | * number order */ | 129 | * number order */ |
121 | sk_X509_REVOKED_sort(c->crl->revoked); | 130 | sk_X509_REVOKED_sort(c->crl->revoked); |
122 | for (i=0; i<sk_X509_REVOKED_num(c->crl->revoked); i++) { | 131 | for (i = 0; i < sk_X509_REVOKED_num(c->crl->revoked); i++) { |
123 | r=sk_X509_REVOKED_value(c->crl->revoked,i); | 132 | r = sk_X509_REVOKED_value(c->crl->revoked, i); |
124 | r->sequence=i; | 133 | r->sequence = i; |
125 | } | 134 | } |
126 | c->crl->enc.modified = 1; | 135 | c->crl->enc.modified = 1; |
127 | return 1; | 136 | return 1; |
128 | } | 137 | } |
129 | 138 | ||
130 | int X509_REVOKED_set_revocationDate(X509_REVOKED *x, ASN1_TIME *tm) | 139 | int |
140 | X509_REVOKED_set_revocationDate(X509_REVOKED *x, ASN1_TIME *tm) | ||
131 | { | 141 | { |
132 | ASN1_TIME *in; | 142 | ASN1_TIME *in; |
133 | 143 | ||
134 | if (x == NULL) return(0); | 144 | if (x == NULL) |
135 | in=x->revocationDate; | 145 | return (0); |
146 | in = x->revocationDate; | ||
136 | if (in != tm) { | 147 | if (in != tm) { |
137 | in=M_ASN1_TIME_dup(tm); | 148 | in = M_ASN1_TIME_dup(tm); |
138 | if (in != NULL) { | 149 | if (in != NULL) { |
139 | M_ASN1_TIME_free(x->revocationDate); | 150 | M_ASN1_TIME_free(x->revocationDate); |
140 | x->revocationDate=in; | 151 | x->revocationDate = in; |
141 | } | 152 | } |
142 | } | 153 | } |
143 | return(in != NULL); | 154 | return (in != NULL); |
144 | } | 155 | } |
145 | 156 | ||
146 | int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial) | 157 | int |
158 | X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial) | ||
147 | { | 159 | { |
148 | ASN1_INTEGER *in; | 160 | ASN1_INTEGER *in; |
149 | 161 | ||
150 | if (x == NULL) return(0); | 162 | if (x == NULL) |
151 | in=x->serialNumber; | 163 | return (0); |
164 | in = x->serialNumber; | ||
152 | if (in != serial) { | 165 | if (in != serial) { |
153 | in=M_ASN1_INTEGER_dup(serial); | 166 | in = M_ASN1_INTEGER_dup(serial); |
154 | if (in != NULL) { | 167 | if (in != NULL) { |
155 | M_ASN1_INTEGER_free(x->serialNumber); | 168 | M_ASN1_INTEGER_free(x->serialNumber); |
156 | x->serialNumber=in; | 169 | x->serialNumber = in; |
157 | } | 170 | } |
158 | } | 171 | } |
159 | return(in != NULL); | 172 | return (in != NULL); |
160 | } | 173 | } |