]> git.pld-linux.org Git - packages/xorg-xserver-server.git/blob - xorg-xserver-server-builtin-SHA1.patch
- up to 1.12.0.902; needs to be checked by nvidia users if patch6 is still needed...
[packages/xorg-xserver-server.git] / xorg-xserver-server-builtin-SHA1.patch
1 From 3fbec7d4db59bbd24a9a768182000a1d004c5bc5 Mon Sep 17 00:00:00 2001
2 From: Tiago Vignatti <tiago.vignatti@nokia.com>
3 Date: Wed, 24 Mar 2010 17:27:43 +0200
4 Subject: [PATCH] Revert "Revert "Render: Use built-in SHA1 library""
5
6 This reverts commit a39377cbcbd3091095efbeab25bec18ae520147e.
7
8 Conflicts:
9
10         configure.ac
11         include/dix-config.h.in
12         render/glyph.c
13
14
15 Ok ok ok, it's the revert of a revert! Buhhh... 
16
17 Once upon a time, back in 2007, Carl Worth was trying to boost render
18 (4c6abe1c). He prefered to use a "strong hash" to compare glyphs (19b3b1fd)
19 and used openssl library for this. Further, for the same purpose, people
20 started to set other SHA1 implementations in autoconf. And a lot of
21 alternatives appeared - six, to be precise. In the mean time, John Tapsell
22 commit a builtin implementation of SHA1. In the same day, Keith Packard
23 reverted, stating "X.org should not be providing a custom SHA1
24 implementation." (a39377cb). Now, users ended up with Xorg setting the default
25 as the openssl's one (libcrypto), which takes 88 kB of xserver's private RSS.
26 Besides that, we have a ridiculous "configure dot fucking ac stanza to work
27 out which lib to use is almost as long as sha1.c was", to quote daniels.
28
29 My simple argument against Keith's decision is simple: we can save 316 kB of
30 RSS in a standalone Xorg call. Therefore, I'm in favor to keep our own very
31 simple and shiny SHA1 implementation.
32
33 ---
34 I'm not comfortable yet to send this patch around without see if there's any
35 regressions on render or eventually get some ack from Carl.
36
37
38  configure.ac            |   89 +------------------------
39  include/dix-config.h.in |   15 ----
40  os/Makefile.am          |    1 -
41  os/xsha1.c              |  168 ---------------------------------------------
42  render/Makefile.am      |    3 +
43  render/glyph.c          |   25 ++-----
44  render/sha1.c           |  173 +++++++++++++++++++++++++++++++++++++++++++++++
45  render/sha1.h           |   63 +++++++++++++++++
46  8 files changed, 248 insertions(+), 289 deletions(-)
47  delete mode 100644 os/xsha1.c
48  create mode 100644 render/sha1.c
49  create mode 100644 render/sha1.h
50
51 diff --git a/include/dix-config.h.in b/include/dix-config.h.in
52 index 058c8fd..d6e99a5 100644
53 --- a/include/dix-config.h.in
54 +++ b/include/dix-config.h.in
55 @@ -160,21 +160,6 @@
56  /* Define to 1 if you have the <rpcsvc/dbm.h> header file. */
57  #undef HAVE_RPCSVC_DBM_H
58  
59 -/* Define to use libc SHA1 functions */
60 -#undef HAVE_SHA1_IN_LIBC
61 -
62 -/* Define to use CommonCrypto SHA1 functions */
63 -#undef HAVE_SHA1_IN_COMMONCRYPTO
64 -
65 -/* Define to use libmd SHA1 functions */
66 -#undef HAVE_SHA1_IN_LIBMD
67 -
68 -/* Define to use libgcrypt SHA1 functions */
69 -#undef HAVE_SHA1_IN_LIBGCRYPT
70 -
71 -/* Define to use libsha1 for SHA1 */
72 -#undef HAVE_SHA1_IN_LIBSHA1
73 -
74  /* Define to 1 if you have the `shmctl64' function. */
75  #undef HAVE_SHMCTL64
76  
77 diff --git a/os/Makefile.am b/os/Makefile.am
78 index 66a4a0f..b8c1636 100644
79 --- a/os/Makefile.am
80 +++ b/os/Makefile.am
81 @@ -22,7 +22,6 @@ libos_la_SOURCES =    \
82         strcasecmp.c    \
83         strcasestr.c    \
84         xdmauth.c       \
85 -       xsha1.c         \
86         xstrans.c       \
87         xprintf.c       \
88         $(XORG_SRCS)
89 --- a/os/xsha1.c        2012-03-30 04:57:28.000000000 +0200
90 +++ /dev/null   2011-06-01 08:46:43.490033582 +0200
91 @@ -1,195 +0,0 @@
92 -#ifdef HAVE_DIX_CONFIG_H
93 -#include <dix-config.h>
94 -#endif
95 -
96 -#include "os.h"
97 -#include "xsha1.h"
98 -
99 -#if defined(HAVE_SHA1_IN_LIBMD)  /* Use libmd for SHA1 */ \
100 -       || defined(HAVE_SHA1_IN_LIBC)   /* Use libc for SHA1 */
101 -
102 -#include <sha1.h>
103 -
104 -void *
105 -x_sha1_init(void)
106 -{
107 -    SHA1_CTX *ctx = malloc(sizeof(*ctx));
108 -
109 -    if (!ctx)
110 -        return NULL;
111 -    SHA1Init(ctx);
112 -    return ctx;
113 -}
114 -
115 -int
116 -x_sha1_update(void *ctx, void *data, int size)
117 -{
118 -    SHA1_CTX *sha1_ctx = ctx;
119 -
120 -    SHA1Update(sha1_ctx, data, size);
121 -    return 1;
122 -}
123 -
124 -int
125 -x_sha1_final(void *ctx, unsigned char result[20])
126 -{
127 -    SHA1_CTX *sha1_ctx = ctx;
128 -
129 -    SHA1Final(result, sha1_ctx);
130 -    free(sha1_ctx);
131 -    return 1;
132 -}
133 -
134 -#elif defined(HAVE_SHA1_IN_COMMONCRYPTO)        /* Use CommonCrypto for SHA1 */
135 -
136 -#include <CommonCrypto/CommonDigest.h>
137 -
138 -void *
139 -x_sha1_init(void)
140 -{
141 -    CC_SHA1_CTX *ctx = malloc(sizeof(*ctx));
142 -
143 -    if (!ctx)
144 -        return NULL;
145 -    CC_SHA1_Init(ctx);
146 -    return ctx;
147 -}
148 -
149 -int
150 -x_sha1_update(void *ctx, void *data, int size)
151 -{
152 -    CC_SHA1_CTX *sha1_ctx = ctx;
153 -
154 -    CC_SHA1_Update(sha1_ctx, data, size);
155 -    return 1;
156 -}
157 -
158 -int
159 -x_sha1_final(void *ctx, unsigned char result[20])
160 -{
161 -    CC_SHA1_CTX *sha1_ctx = ctx;
162 -
163 -    CC_SHA1_Final(result, sha1_ctx);
164 -    free(sha1_ctx);
165 -    return 1;
166 -}
167 -
168 -#elif defined(HAVE_SHA1_IN_LIBGCRYPT)   /* Use libgcrypt for SHA1 */
169 -
170 -#include <gcrypt.h>
171 -
172 -void *
173 -x_sha1_init(void)
174 -{
175 -    static int init;
176 -    gcry_md_hd_t h;
177 -    gcry_error_t err;
178 -
179 -    if (!init) {
180 -        if (!gcry_check_version(NULL))
181 -            return NULL;
182 -        gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
183 -        gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
184 -        init = 1;
185 -    }
186 -
187 -    err = gcry_md_open(&h, GCRY_MD_SHA1, 0);
188 -    if (err)
189 -        return NULL;
190 -    return h;
191 -}
192 -
193 -int
194 -x_sha1_update(void *ctx, void *data, int size)
195 -{
196 -    gcry_md_hd_t h = ctx;
197 -
198 -    gcry_md_write(h, data, size);
199 -    return 1;
200 -}
201 -
202 -int
203 -x_sha1_final(void *ctx, unsigned char result[20])
204 -{
205 -    gcry_md_hd_t h = ctx;
206 -
207 -    memcpy(result, gcry_md_read(h, GCRY_MD_SHA1), 20);
208 -    gcry_md_close(h);
209 -    return 1;
210 -}
211 -
212 -#elif defined(HAVE_SHA1_IN_LIBSHA1)     /* Use libsha1 */
213 -
214 -#include <libsha1.h>
215 -
216 -void *
217 -x_sha1_init(void)
218 -{
219 -    sha1_ctx *ctx = malloc(sizeof(*ctx));
220 -
221 -    if (!ctx)
222 -        return NULL;
223 -    sha1_begin(ctx);
224 -    return ctx;
225 -}
226 -
227 -int
228 -x_sha1_update(void *ctx, void *data, int size)
229 -{
230 -    sha1_hash(data, size, ctx);
231 -    return 1;
232 -}
233 -
234 -int
235 -x_sha1_final(void *ctx, unsigned char result[20])
236 -{
237 -    sha1_end(result, ctx);
238 -    free(ctx);
239 -    return 1;
240 -}
241 -
242 -#else                           /* Use OpenSSL's libcrypto */
243 -
244 -#include <stddef.h>             /* buggy openssl/sha.h wants size_t */
245 -#include <openssl/sha.h>
246 -
247 -void *
248 -x_sha1_init(void)
249 -{
250 -    int ret;
251 -    SHA_CTX *ctx = malloc(sizeof(*ctx));
252 -
253 -    if (!ctx)
254 -        return NULL;
255 -    ret = SHA1_Init(ctx);
256 -    if (!ret) {
257 -        free(ctx);
258 -        return NULL;
259 -    }
260 -    return ctx;
261 -}
262 -
263 -int
264 -x_sha1_update(void *ctx, void *data, int size)
265 -{
266 -    int ret;
267 -    SHA_CTX *sha_ctx = ctx;
268 -
269 -    ret = SHA1_Update(sha_ctx, data, size);
270 -    if (!ret)
271 -        free(sha_ctx);
272 -    return ret;
273 -}
274 -
275 -int
276 -x_sha1_final(void *ctx, unsigned char result[20])
277 -{
278 -    int ret;
279 -    SHA_CTX *sha_ctx = ctx;
280 -
281 -    ret = SHA1_Final(result, sha_ctx);
282 -    free(sha_ctx);
283 -    return ret;
284 -}
285 -
286 -#endif
287 diff --git a/render/Makefile.am b/render/Makefile.am
288 index 216c613..bb46702 100644
289 --- a/render/Makefile.am
290 +++ b/render/Makefile.am
291 @@ -13,8 +13,11 @@ librender_la_SOURCES =       \
292         mitrap.c        \
293         mitri.c         \
294         picture.c       \
295 +       sha1.c          \
296         render.c
297  
298  if XORG
299  sdk_HEADERS = picture.h mipict.h glyphstr.h picturestr.h
300  endif
301 +
302 +EXTRA_DIST = sha1.h
303 diff --git a/render/glyph.c b/render/glyph.c
304 index 0b864ad..e14530a 100644
305 --- a/render/glyph.c
306 +++ b/render/glyph.c
307 @@ -26,8 +26,7 @@
308  #include <dix-config.h>
309  #endif
310  
311 -#include "xsha1.h"
312 -
313 +#include "sha1.h"
314  #include "misc.h"
315  #include "scrnintstr.h"
316  #include "os.h"
317 @@ -167,21 +167,13 @@ int
318  HashGlyph(xGlyphInfo * gi,
319            CARD8 *bits, unsigned long size, unsigned char sha1[20])
320  {
321 -    void *ctx = x_sha1_init();
322 -    int success;
323 +    SHA1_CTX ctx;
324  
325 -    if (!ctx)
326 -        return BadAlloc;
327 +    SHA1Init (&ctx);
328 +    SHA1Update (&ctx, gi, sizeof (xGlyphInfo));
329 +    SHA1Update (&ctx, bits, size);
330 +    SHA1Final (sha1, &ctx);
331  
332 -    success = x_sha1_update(ctx, gi, sizeof(xGlyphInfo));
333 -    if (!success)
334 -        return BadAlloc;
335 -    success = x_sha1_update(ctx, bits, size);
336 -    if (!success)
337 -        return BadAlloc;
338 -    success = x_sha1_final(ctx, sha1);
339 -    if (!success)
340 -        return BadAlloc;
341      return Success;
342  }
343  
344 diff --git a/render/sha1.c b/render/sha1.c
345 new file mode 100644
346 index 0000000..820eb2a
347 --- /dev/null
348 +++ b/render/sha1.c
349 @@ -0,0 +1,173 @@
350 +/*
351 + * SHA-1 in C
352 + * By Steve Reid <steve@edmweb.com>
353 + * 100% Public Domain
354 + *
355 + * Test Vectors (from FIPS PUB 180-1)
356 + * "abc"
357 + *   A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
358 + * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
359 + *   84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
360 + * A million repetitions of "a"
361 + *   34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
362 + */
363 +
364 +#include <sys/param.h>
365 +#include <string.h>
366 +#include <sha1.h>
367 +
368 +#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
369 +
370 +/*
371 + * blk0() and blk() perform the initial expand.
372 + * I got the idea of expanding during the round function from SSLeay
373 + */
374 +#if BYTE_ORDER == LITTLE_ENDIAN
375 +# define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
376 +    |(rol(block->l[i],8)&0x00FF00FF))
377 +#else
378 +# define blk0(i) block->l[i]
379 +#endif
380 +#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
381 +    ^block->l[(i+2)&15]^block->l[i&15],1))
382 +
383 +/*
384 + * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1
385 + */
386 +#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
387 +#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
388 +#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
389 +#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
390 +#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
391 +
392 +/*
393 + * Hash a single 512-bit block. This is the core of the algorithm.
394 + */
395 +void
396 +SHA1Transform(uint32_t state[5], const uint8_t buffer[SHA1_BLOCK_LENGTH])
397 +{
398 +       uint32_t a, b, c, d, e;
399 +       uint8_t workspace[SHA1_BLOCK_LENGTH];
400 +       typedef union {
401 +               uint8_t c[64];
402 +               uint32_t l[16];
403 +       } CHAR64LONG16;
404 +       CHAR64LONG16 *block = (CHAR64LONG16 *)workspace;
405 +
406 +       (void)memcpy(block, buffer, SHA1_BLOCK_LENGTH);
407 +
408 +       /* Copy context->state[] to working vars */
409 +       a = state[0];
410 +       b = state[1];
411 +       c = state[2];
412 +       d = state[3];
413 +       e = state[4];
414 +
415 +       /* 4 rounds of 20 operations each. Loop unrolled. */
416 +       R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
417 +       R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
418 +       R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
419 +       R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
420 +       R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
421 +       R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
422 +       R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
423 +       R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
424 +       R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
425 +       R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
426 +       R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
427 +       R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
428 +       R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
429 +       R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
430 +       R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
431 +       R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
432 +       R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
433 +       R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
434 +       R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
435 +       R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
436 +
437 +       /* Add the working vars back into context.state[] */
438 +       state[0] += a;
439 +       state[1] += b;
440 +       state[2] += c;
441 +       state[3] += d;
442 +       state[4] += e;
443 +
444 +       /* Wipe variables */
445 +       a = b = c = d = e = 0;
446 +}
447 +
448 +
449 +/*
450 + * SHA1Init - Initialize new context
451 + */
452 +void
453 +SHA1Init(SHA1_CTX *context)
454 +{
455 +
456 +       /* SHA1 initialization constants */
457 +       context->count = 0;
458 +       context->state[0] = 0x67452301;
459 +       context->state[1] = 0xEFCDAB89;
460 +       context->state[2] = 0x98BADCFE;
461 +       context->state[3] = 0x10325476;
462 +       context->state[4] = 0xC3D2E1F0;
463 +}
464 +
465 +
466 +/*
467 + * Run your data through this.
468 + */
469 +void
470 +SHA1Update(SHA1_CTX *context, const uint8_t *data, size_t len)
471 +{
472 +       size_t i, j;
473 +
474 +       j = (size_t)((context->count >> 3) & 63);
475 +       context->count += (len << 3);
476 +       if ((j + len) > 63) {
477 +               (void)memcpy(&context->buffer[j], data, (i = 64-j));
478 +               SHA1Transform(context->state, context->buffer);
479 +               for ( ; i + 63 < len; i += 64)
480 +                       SHA1Transform(context->state, (uint8_t *)&data[i]);
481 +               j = 0;
482 +       } else {
483 +               i = 0;
484 +       }
485 +       (void)memcpy(&context->buffer[j], &data[i], len - i);
486 +}
487 +
488 +
489 +/*
490 + * Add padding and return the message digest.
491 + */
492 +void
493 +SHA1Pad(SHA1_CTX *context)
494 +{
495 +       uint8_t finalcount[8];
496 +       uint i;
497 +
498 +       for (i = 0; i < 8; i++) {
499 +               finalcount[i] = (uint8_t)((context->count >>
500 +                   ((7 - (i & 7)) * 8)) & 255);        /* Endian independent */
501 +       }
502 +       SHA1Update(context, (uint8_t *)"\200", 1);
503 +       while ((context->count & 504) != 448)
504 +               SHA1Update(context, (uint8_t *)"\0", 1);
505 +       SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
506 +}
507 +
508 +void
509 +SHA1Final(uint8_t digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context)
510 +{
511 +       uint i;
512 +
513 +       SHA1Pad(context);
514 +       if (digest) {
515 +               for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
516 +                       digest[i] = (uint8_t)
517 +                          ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
518 +               }
519 +               memset(context, 0, sizeof(*context));
520 +       }
521 +}
522 +
523 diff --git a/render/sha1.h b/render/sha1.h
524 new file mode 100644
525 index 0000000..ace7d97
526 --- /dev/null
527 +++ b/render/sha1.h
528 @@ -0,0 +1,63 @@
529 +/*
530 + * SHA-1 in C
531 + * By Steve Reid <steve@edmweb.com>
532 + * 100% Public Domain
533 + */
534 +
535 +#ifndef _SHA1_H
536 +#define _SHA1_H
537 +
538 +#include <stdint.h>
539 +#include <stddef.h>
540 +#include <unistd.h>
541 +
542 +
543 +#define        SHA1_BLOCK_LENGTH               64
544 +#define        SHA1_DIGEST_LENGTH              20
545 +#define        SHA1_DIGEST_STRING_LENGTH       (SHA1_DIGEST_LENGTH * 2 + 1)
546 +
547 +typedef struct {
548 +    uint32_t state[5];
549 +    uint64_t count;
550 +    uint8_t buffer[SHA1_BLOCK_LENGTH];
551 +} SHA1_CTX;
552 +
553 +#include <sys/cdefs.h>
554 +
555 +__BEGIN_DECLS
556 +void SHA1Init(SHA1_CTX *);
557 +void SHA1Pad(SHA1_CTX *);
558 +void SHA1Transform(uint32_t [5], const uint8_t [SHA1_BLOCK_LENGTH])
559 +       __attribute__((__bounded__(__minbytes__,1,5)))
560 +       __attribute__((__bounded__(__minbytes__,2,SHA1_BLOCK_LENGTH)));
561 +void SHA1Update(SHA1_CTX *, const uint8_t *, size_t)
562 +       __attribute__((__bounded__(__string__,2,3)));
563 +void SHA1Final(uint8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *)
564 +       __attribute__((__bounded__(__minbytes__,1,SHA1_DIGEST_LENGTH)));
565 +char *SHA1End(SHA1_CTX *, char *)
566 +       __attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
567 +char *SHA1File(const char *, char *)
568 +       __attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
569 +char *SHA1FileChunk(const char *, char *, off_t, off_t)
570 +       __attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
571 +char *SHA1Data(const uint8_t *, size_t, char *)
572 +       __attribute__((__bounded__(__string__,1,2)))
573 +       __attribute__((__bounded__(__minbytes__,3,SHA1_DIGEST_STRING_LENGTH)));
574 +__END_DECLS
575 +
576 +#define HTONDIGEST(x) do {                                              \
577 +        x[0] = htonl(x[0]);                                             \
578 +        x[1] = htonl(x[1]);                                             \
579 +        x[2] = htonl(x[2]);                                             \
580 +        x[3] = htonl(x[3]);                                             \
581 +        x[4] = htonl(x[4]); } while (0)
582 +
583 +#define NTOHDIGEST(x) do {                                              \
584 +        x[0] = ntohl(x[0]);                                             \
585 +        x[1] = ntohl(x[1]);                                             \
586 +        x[2] = ntohl(x[2]);                                             \
587 +        x[3] = ntohl(x[3]);                                             \
588 +        x[4] = ntohl(x[4]); } while (0)
589 +
590 +#endif /* _SHA1_H */
591 +
592 -- 
593 1.6.0.4
594
595 --- xorg-server-1.9.2.902/configure.ac.orig     2010-12-04 06:56:52.000000000 +0100
596 +++ xorg-server-1.9.2.902/configure.ac  2010-12-07 19:16:06.420296250 +0100
597 @@ -1338,7 +1338,7 @@
598  
599  if test "x$SPECIAL_DTRACE_OBJECTS" = "xyes" ; then
600    DIX_LIB='$(top_builddir)/dix/dix.O'
601 -  OS_LIB='$(top_builddir)/os/os.O $(SHA1_LIBS) $(DLOPEN_LIBS)'
602 +  OS_LIB='$(top_builddir)/os/os.O $(DLOPEN_LIBS)'
603  else
604    DIX_LIB='$(top_builddir)/dix/libdix.la'
605    OS_LIB='$(top_builddir)/os/libos.la'
606 @@ -1358,99 +1358,6 @@
607  MIEXT_SHADOW_LIB='$(top_builddir)/miext/shadow/libshadow.la'
608  CORE_INCS='-I$(top_srcdir)/include -I$(top_builddir)/include'
609  
610 -# SHA1 hashing
611 -AC_ARG_WITH([sha1],
612 -            [AS_HELP_STRING([--with-sha1=libc|libmd|libgcrypt|libcrypto|libsha1|CommonCrypto],
613 -                            [choose SHA1 implementation])])
614 -AC_CHECK_FUNC([SHA1Init], [HAVE_SHA1_IN_LIBC=yes])
615 -if test "x$with_sha1" = x && test "x$HAVE_SHA1_IN_LIBC" = xyes; then
616 -       with_sha1=libc
617 -fi
618 -if test "x$with_sha1" = xlibc && test "x$HAVE_SHA1_IN_LIBC" != xyes; then
619 -       AC_MSG_ERROR([libc requested but not found])
620 -fi
621 -if test "x$with_sha1" = xlibc; then
622 -       AC_DEFINE([HAVE_SHA1_IN_LIBC], [1],
623 -               [Use libc SHA1 functions])
624 -       SHA1_LIBS=""
625 -fi
626 -AC_CHECK_FUNC([CC_SHA1_Init], [HAVE_SHA1_IN_COMMONCRYPTO=yes])
627 -if test "x$with_sha1" = x && test "x$HAVE_SHA1_IN_COMMONCRYPTO" = xyes; then
628 -       with_sha1=CommonCrypto
629 -fi
630 -if test "x$with_sha1" = xCommonCrypto && test "x$HAVE_SHA1_IN_COMMONCRYPTO" != xyes; then
631 -       AC_MSG_ERROR([CommonCrypto requested but not found])
632 -fi
633 -if test "x$with_sha1" = xCommonCrypto; then
634 -       AC_DEFINE([HAVE_SHA1_IN_COMMONCRYPTO], [1],
635 -               [Use CommonCrypto SHA1 functions])
636 -       SHA1_LIBS=""
637 -fi
638 -AC_CHECK_LIB([md], [SHA1Init], [HAVE_LIBMD=yes])
639 -if test "x$with_sha1" = x && test "x$HAVE_LIBMD" = xyes; then
640 -       with_sha1=libmd
641 -fi
642 -if test "x$with_sha1" = xlibmd && test "x$HAVE_LIBMD" != xyes; then
643 -       AC_MSG_ERROR([libmd requested but not found])
644 -fi
645 -if test "x$with_sha1" = xlibmd; then
646 -       AC_DEFINE([HAVE_SHA1_IN_LIBMD], [1],
647 -                 [Use libmd SHA1 functions])
648 -       SHA1_LIBS=-lmd
649 -fi
650 -PKG_CHECK_MODULES([LIBSHA1], [libsha1], [HAVE_LIBSHA1=yes], [HAVE_LIBSHA1=no])
651 -if test "x$with_sha1" = x && test "x$HAVE_LIBSHA1" = xyes; then
652 -   with_sha1=libsha1
653 -fi
654 -if test "x$with_sha1" = xlibsha1 && test "x$HAVE_LIBSHA1" != xyes; then
655 -       AC_MSG_ERROR([libsha1 requested but not found])
656 -fi
657 -if test "x$with_sha1" = xlibsha1; then
658 -       AC_DEFINE([HAVE_SHA1_IN_LIBSHA1], [1],
659 -                 [Use libsha1 for SHA1])
660 -       SHA1_LIBS=-lsha1
661 -fi
662 -AC_CHECK_LIB([gcrypt], [gcry_md_open], [HAVE_LIBGCRYPT=yes])
663 -if test "x$with_sha1" = x && test "x$HAVE_LIBGCRYPT" = xyes; then
664 -       with_sha1=libgcrypt
665 -fi
666 -if test "x$with_sha1" = xlibgcrypt && test "x$HAVE_LIBGCRYPT" != xyes; then
667 -       AC_MSG_ERROR([libgcrypt requested but not found])
668 -fi
669 -if test "x$with_sha1" = xlibgcrypt; then
670 -       AC_DEFINE([HAVE_SHA1_IN_LIBGCRYPT], [1],
671 -                 [Use libgcrypt SHA1 functions])
672 -       SHA1_LIBS=-lgcrypt
673 -fi
674 -# We don't need all of the OpenSSL libraries, just libcrypto
675 -AC_CHECK_LIB([crypto], [SHA1_Init], [HAVE_LIBCRYPTO=yes])
676 -PKG_CHECK_MODULES([OPENSSL], [openssl], [HAVE_OPENSSL_PKC=yes],
677 -                  [HAVE_OPENSSL_PKC=no])
678 -if test "x$HAVE_LIBCRYPTO" = xyes || test "x$HAVE_OPENSSL_PKC" = xyes; then
679 -       if test "x$with_sha1" = x; then
680 -               with_sha1=libcrypto
681 -       fi
682 -else
683 -       if test "x$with_sha1" = xlibcrypto; then
684 -               AC_MSG_ERROR([OpenSSL libcrypto requested but not found])
685 -       fi
686 -fi
687 -if test "x$with_sha1" = xlibcrypto; then
688 -       if test "x$HAVE_LIBCRYPTO" = xyes; then
689 -               SHA1_LIBS=-lcrypto
690 -       else
691 -               SHA1_LIBS="$OPENSSL_LIBS"
692 -               SHA1_CFLAGS="$OPENSSL_CFLAGS"
693 -       fi
694 -fi
695 -AC_MSG_CHECKING([for SHA1 implementation])
696 -if test "x$with_sha1" = x; then
697 -       AC_MSG_ERROR([No suitable SHA1 implementation found])
698 -fi
699 -AC_MSG_RESULT([$with_sha1])
700 -AC_SUBST(SHA1_LIBS)
701 -AC_SUBST(SHA1_CFLAGS)
702 -
703  PKG_CHECK_MODULES([XSERVERCFLAGS], [$REQUIRED_MODULES $REQUIRED_LIBS])
704  PKG_CHECK_MODULES([XSERVERLIBS], [$REQUIRED_LIBS])
This page took 1.854636 seconds and 4 git commands to generate.