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/asn1/a_utctm.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/asn1/a_utctm.c')
-rw-r--r-- | src/lib/libcrypto/asn1/a_utctm.c | 70 |
1 files changed, 9 insertions, 61 deletions
diff --git a/src/lib/libcrypto/asn1/a_utctm.c b/src/lib/libcrypto/asn1/a_utctm.c index d381c9e0d1..ed2d827db2 100644 --- a/src/lib/libcrypto/asn1/a_utctm.c +++ b/src/lib/libcrypto/asn1/a_utctm.c | |||
@@ -58,20 +58,11 @@ | |||
58 | 58 | ||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include <time.h> | 60 | #include <time.h> |
61 | #ifdef VMS | ||
62 | #include <descrip.h> | ||
63 | #include <lnmdef.h> | ||
64 | #include <starlet.h> | ||
65 | #endif | ||
66 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
62 | #include "o_time.h" | ||
67 | #include <openssl/asn1.h> | 63 | #include <openssl/asn1.h> |
68 | 64 | ||
69 | ASN1_UTCTIME *ASN1_UTCTIME_new(void) | 65 | #if 0 |
70 | { return M_ASN1_UTCTIME_new(); } | ||
71 | |||
72 | void ASN1_UTCTIME_free(ASN1_UTCTIME *x) | ||
73 | { M_ASN1_UTCTIME_free(x); } | ||
74 | |||
75 | int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a, unsigned char **pp) | 66 | int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a, unsigned char **pp) |
76 | { | 67 | { |
77 | #ifndef CHARSET_EBCDIC | 68 | #ifndef CHARSET_EBCDIC |
@@ -119,6 +110,8 @@ err: | |||
119 | return(NULL); | 110 | return(NULL); |
120 | } | 111 | } |
121 | 112 | ||
113 | #endif | ||
114 | |||
122 | int ASN1_UTCTIME_check(ASN1_UTCTIME *d) | 115 | int ASN1_UTCTIME_check(ASN1_UTCTIME *d) |
123 | { | 116 | { |
124 | static int min[8]={ 0, 1, 1, 0, 0, 0, 0, 0}; | 117 | static int min[8]={ 0, 1, 1, 0, 0, 0, 0, 0}; |
@@ -182,6 +175,7 @@ int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, char *str) | |||
182 | { | 175 | { |
183 | ASN1_STRING_set((ASN1_STRING *)s, | 176 | ASN1_STRING_set((ASN1_STRING *)s, |
184 | (unsigned char *)str,t.length); | 177 | (unsigned char *)str,t.length); |
178 | s->type = V_ASN1_UTCTIME; | ||
185 | } | 179 | } |
186 | return(1); | 180 | return(1); |
187 | } | 181 | } |
@@ -193,59 +187,17 @@ ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t) | |||
193 | { | 187 | { |
194 | char *p; | 188 | char *p; |
195 | struct tm *ts; | 189 | struct tm *ts; |
196 | #if defined(THREADS) && !defined(WIN32) && !defined(__CYGWIN32__) | ||
197 | |||
198 | struct tm data; | 190 | struct tm data; |
199 | #endif | ||
200 | 191 | ||
201 | if (s == NULL) | 192 | if (s == NULL) |
202 | s=M_ASN1_UTCTIME_new(); | 193 | s=M_ASN1_UTCTIME_new(); |
203 | if (s == NULL) | 194 | if (s == NULL) |
204 | return(NULL); | 195 | return(NULL); |
205 | 196 | ||
206 | #if defined(THREADS) && !defined(WIN32) && !defined(__CYGWIN32__) | 197 | ts=OPENSSL_gmtime(&t, &data); |
207 | gmtime_r(&t,&data); /* should return &data, but doesn't on some systems, so we don't even look at the return value */ | ||
208 | ts=&data; | ||
209 | #else | ||
210 | ts=gmtime(&t); | ||
211 | #endif | ||
212 | #ifdef VMS | ||
213 | if (ts == NULL) | 198 | if (ts == NULL) |
214 | { | 199 | return(NULL); |
215 | static $DESCRIPTOR(tabnam,"LNM$DCL_LOGICAL"); | 200 | |
216 | static $DESCRIPTOR(lognam,"SYS$TIMEZONE_DIFFERENTIAL"); | ||
217 | char result[256]; | ||
218 | unsigned int reslen = 0; | ||
219 | struct { | ||
220 | short buflen; | ||
221 | short code; | ||
222 | void *bufaddr; | ||
223 | unsigned int *reslen; | ||
224 | } itemlist[] = { | ||
225 | { 0, LNM$_STRING, 0, 0 }, | ||
226 | { 0, 0, 0, 0 }, | ||
227 | }; | ||
228 | int status; | ||
229 | |||
230 | /* Get the value for SYS$TIMEZONE_DIFFERENTIAL */ | ||
231 | itemlist[0].buflen = sizeof(result); | ||
232 | itemlist[0].bufaddr = result; | ||
233 | itemlist[0].reslen = &reslen; | ||
234 | status = sys$trnlnm(0, &tabnam, &lognam, 0, itemlist); | ||
235 | if (!(status & 1)) | ||
236 | return NULL; | ||
237 | result[reslen] = '\0'; | ||
238 | |||
239 | /* Get the numerical value of the equivalence string */ | ||
240 | status = atoi(result); | ||
241 | |||
242 | /* and use it to move time to GMT */ | ||
243 | t -= status; | ||
244 | |||
245 | /* then convert the result to the time structure */ | ||
246 | ts=(struct tm *)localtime(&t); | ||
247 | } | ||
248 | #endif | ||
249 | p=(char *)s->data; | 201 | p=(char *)s->data; |
250 | if ((p == NULL) || (s->length < 14)) | 202 | if ((p == NULL) || (s->length < 14)) |
251 | { | 203 | { |
@@ -286,11 +238,7 @@ int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t) | |||
286 | 238 | ||
287 | t -= offset*60; /* FIXME: may overflow in extreme cases */ | 239 | t -= offset*60; /* FIXME: may overflow in extreme cases */ |
288 | 240 | ||
289 | #if defined(THREADS) && !defined(WIN32) && !defined(__CYGWIN32__) | 241 | { struct tm data; tm = OPENSSL_gmtime(&t, &data); } |
290 | { struct tm data; gmtime_r(&t, &data); tm = &data; } | ||
291 | #else | ||
292 | tm = gmtime(&t); | ||
293 | #endif | ||
294 | 242 | ||
295 | #define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1 | 243 | #define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1 |
296 | year = g2(s->data); | 244 | year = g2(s->data); |