]> git.pld-linux.org Git - packages/xorg-xserver-server.git/blame - xorg-xserver-server-builtin-SHA1.patch
up to 1.20.11 (fixes CVE-2021-3472)
[packages/xorg-xserver-server.git] / xorg-xserver-server-builtin-SHA1.patch
CommitLineData
fc866b7f
AM
1diff -urN xorg-server-1.17.0.org/configure.ac xorg-server-1.17.0/configure.ac
2--- xorg-server-1.17.0.org/configure.ac 2015-02-02 07:40:17.000000000 +0100
3+++ xorg-server-1.17.0/configure.ac 2015-02-04 19:34:23.458568095 +0100
4@@ -1544,7 +1544,7 @@
5
6 if test "x$SPECIAL_DTRACE_OBJECTS" = "xyes" ; then
7 DIX_LIB='$(top_builddir)/dix/dix.O'
8- OS_LIB='$(top_builddir)/os/os.O $(SHA1_LIBS) $(DLOPEN_LIBS) $(LIBUNWIND_LIBS)'
9+ OS_LIB='$(top_builddir)/os/os.O $(DLOPEN_LIBS) $(LIBUNWIND_LIBS)'
10 else
11 DIX_LIB='$(top_builddir)/dix/libdix.la'
12 OS_LIB='$(top_builddir)/os/libos.la'
13@@ -1566,124 +1566,6 @@
14 MIEXT_SYNC_LIB='$(top_builddir)/miext/sync/libsync.la'
15 CORE_INCS='-I$(top_srcdir)/include -I$(top_builddir)/include'
16
17-# SHA1 hashing
18-AC_ARG_WITH([sha1],
19- [AS_HELP_STRING([--with-sha1=libc|libmd|libnettle|libgcrypt|libcrypto|libsha1|CommonCrypto|CryptoAPI],
20- [choose SHA1 implementation])])
21-AC_CHECK_FUNC([SHA1Init], [HAVE_SHA1_IN_LIBC=yes])
22-if test "x$with_sha1" = x && test "x$HAVE_SHA1_IN_LIBC" = xyes; then
23- with_sha1=libc
24-fi
25-if test "x$with_sha1" = xlibc && test "x$HAVE_SHA1_IN_LIBC" != xyes; then
26- AC_MSG_ERROR([libc requested but not found])
27-fi
28-if test "x$with_sha1" = xlibc; then
29- AC_DEFINE([HAVE_SHA1_IN_LIBC], [1],
30- [Use libc SHA1 functions])
31- SHA1_LIBS=""
32-fi
33-AC_CHECK_FUNC([CC_SHA1_Init], [HAVE_SHA1_IN_COMMONCRYPTO=yes])
34-if test "x$with_sha1" = x && test "x$HAVE_SHA1_IN_COMMONCRYPTO" = xyes; then
35- with_sha1=CommonCrypto
36-fi
37-if test "x$with_sha1" = xCommonCrypto && test "x$HAVE_SHA1_IN_COMMONCRYPTO" != xyes; then
38- AC_MSG_ERROR([CommonCrypto requested but not found])
39-fi
40-if test "x$with_sha1" = xCommonCrypto; then
41- AC_DEFINE([HAVE_SHA1_IN_COMMONCRYPTO], [1],
42- [Use CommonCrypto SHA1 functions])
43- SHA1_LIBS=""
44-fi
45-dnl stdcall functions cannot be tested with AC_CHECK_LIB
46-AC_CHECK_HEADER([wincrypt.h], [HAVE_SHA1_IN_CRYPTOAPI=yes], [], [#include <windows.h>])
47-if test "x$with_sha1" = x && test "x$HAVE_SHA1_IN_CRYPTOAPI" = xyes; then
48- with_sha1=CryptoAPI
49-fi
50-if test "x$with_sha1" = xCryptoAPI && test "x$HAVE_SHA1_IN_CRYPTOAPI" != xyes; then
51- AC_MSG_ERROR([CryptoAPI requested but not found])
52-fi
53-if test "x$with_sha1" = xCryptoAPI; then
54- AC_DEFINE([HAVE_SHA1_IN_CRYPTOAPI], [1],
55- [Use CryptoAPI SHA1 functions])
56- SHA1_LIBS=""
57-fi
58-AC_CHECK_LIB([md], [SHA1Init], [HAVE_LIBMD=yes])
59-if test "x$with_sha1" = x && test "x$HAVE_LIBMD" = xyes; then
60- with_sha1=libmd
61-fi
62-if test "x$with_sha1" = xlibmd && test "x$HAVE_LIBMD" != xyes; then
63- AC_MSG_ERROR([libmd requested but not found])
64-fi
65-if test "x$with_sha1" = xlibmd; then
66- AC_DEFINE([HAVE_SHA1_IN_LIBMD], [1],
67- [Use libmd SHA1 functions])
68- SHA1_LIBS=-lmd
69-fi
70-PKG_CHECK_MODULES([LIBSHA1], [libsha1], [HAVE_LIBSHA1=yes], [HAVE_LIBSHA1=no])
71-if test "x$with_sha1" = x && test "x$HAVE_LIBSHA1" = xyes; then
72- with_sha1=libsha1
73-fi
74-if test "x$with_sha1" = xlibsha1 && test "x$HAVE_LIBSHA1" != xyes; then
75- AC_MSG_ERROR([libsha1 requested but not found])
76-fi
77-if test "x$with_sha1" = xlibsha1; then
78- AC_DEFINE([HAVE_SHA1_IN_LIBSHA1], [1],
79- [Use libsha1 for SHA1])
80- SHA1_LIBS=-lsha1
81-fi
82-AC_CHECK_LIB([nettle], [nettle_sha1_init], [HAVE_LIBNETTLE=yes])
83-if test "x$with_sha1" = x && test "x$HAVE_LIBNETTLE" = xyes; then
84- with_sha1=libnettle
85-fi
86-if test "x$with_sha1" = xlibnettle && test "x$HAVE_LIBNETTLE" != xyes; then
87- AC_MSG_ERROR([libnettle requested but not found])
88-fi
89-if test "x$with_sha1" = xlibnettle; then
90- AC_DEFINE([HAVE_SHA1_IN_LIBNETTLE], [1],
91- [Use libnettle SHA1 functions])
92- SHA1_LIBS=-lnettle
93-fi
94-AC_CHECK_LIB([gcrypt], [gcry_md_open], [HAVE_LIBGCRYPT=yes])
95-if test "x$with_sha1" = x && test "x$HAVE_LIBGCRYPT" = xyes; then
96- with_sha1=libgcrypt
97-fi
98-if test "x$with_sha1" = xlibgcrypt && test "x$HAVE_LIBGCRYPT" != xyes; then
99- AC_MSG_ERROR([libgcrypt requested but not found])
100-fi
101-if test "x$with_sha1" = xlibgcrypt; then
102- AC_DEFINE([HAVE_SHA1_IN_LIBGCRYPT], [1],
103- [Use libgcrypt SHA1 functions])
104- SHA1_LIBS=-lgcrypt
105-fi
106-# We don't need all of the OpenSSL libraries, just libcrypto
107-AC_CHECK_LIB([crypto], [SHA1_Init], [HAVE_LIBCRYPTO=yes])
108-PKG_CHECK_MODULES([OPENSSL], [openssl], [HAVE_OPENSSL_PKC=yes],
109- [HAVE_OPENSSL_PKC=no])
110-if test "x$HAVE_LIBCRYPTO" = xyes || test "x$HAVE_OPENSSL_PKC" = xyes; then
111- if test "x$with_sha1" = x; then
112- with_sha1=libcrypto
113- fi
114-else
115- if test "x$with_sha1" = xlibcrypto; then
116- AC_MSG_ERROR([OpenSSL libcrypto requested but not found])
117- fi
118-fi
119-if test "x$with_sha1" = xlibcrypto; then
120- if test "x$HAVE_LIBCRYPTO" = xyes; then
121- SHA1_LIBS=-lcrypto
122- else
123- SHA1_LIBS="$OPENSSL_LIBS"
124- SHA1_CFLAGS="$OPENSSL_CFLAGS"
125- fi
126-fi
127-AC_MSG_CHECKING([for SHA1 implementation])
128-if test "x$with_sha1" = x; then
129- AC_MSG_ERROR([No suitable SHA1 implementation found])
130-fi
131-AC_MSG_RESULT([$with_sha1])
132-AC_SUBST(SHA1_LIBS)
133-AC_SUBST(SHA1_CFLAGS)
134-
135 PKG_CHECK_MODULES([XSERVERCFLAGS], [$REQUIRED_MODULES $REQUIRED_LIBS])
136 PKG_CHECK_MODULES([XSERVERLIBS], [$REQUIRED_LIBS])
137
138diff -urN xorg-server-1.17.0.org/include/dix-config.h.in xorg-server-1.17.0/include/dix-config.h.in
139--- xorg-server-1.17.0.org/include/dix-config.h.in 2014-10-09 14:15:31.000000000 +0200
140+++ xorg-server-1.17.0/include/dix-config.h.in 2015-02-04 19:34:23.455234679 +0100
141@@ -152,27 +152,6 @@
a4642760
JP
142 /* Define to 1 if you have the `arc4random_buf' function. */
143 #undef HAVE_ARC4RANDOM_BUF
be68129d
JR
144
145-/* Define to use libc SHA1 functions */
146-#undef HAVE_SHA1_IN_LIBC
147-
148-/* Define to use CommonCrypto SHA1 functions */
149-#undef HAVE_SHA1_IN_COMMONCRYPTO
150-
c113a98d
AM
151-/* Define to use CryptoAPI SHA1 functions */
152-#undef HAVE_SHA1_IN_CRYPTOAPI
153-
be68129d
JR
154-/* Define to use libmd SHA1 functions */
155-#undef HAVE_SHA1_IN_LIBMD
156-
157-/* Define to use libgcrypt SHA1 functions */
158-#undef HAVE_SHA1_IN_LIBGCRYPT
159-
c39080c6
AM
160-/* Define to use libnettle SHA1 functions */
161-#undef HAVE_SHA1_IN_LIBNETTLE
162-
be68129d
JR
163-/* Define to use libsha1 for SHA1 */
164-#undef HAVE_SHA1_IN_LIBSHA1
165-
166 /* Define to 1 if you have the `shmctl64' function. */
167 #undef HAVE_SHMCTL64
168
fc866b7f
AM
169diff -urN xorg-server-1.17.0.org/os/Makefile.am xorg-server-1.17.0/os/Makefile.am
170--- xorg-server-1.17.0.org/os/Makefile.am 2013-11-12 00:15:00.000000000 +0100
171+++ xorg-server-1.17.0/os/Makefile.am 2015-02-04 19:34:23.455234679 +0100
172@@ -21,7 +21,6 @@
a4642760 173 ospoll.h \
fc866b7f 174 utils.c \
be68129d
JR
175 xdmauth.c \
176- xsha1.c \
177 xstrans.c \
178 xprintf.c \
179 $(XORG_SRCS)
fc866b7f
AM
180diff -urN xorg-server-1.17.0.org/os/xsha1.c xorg-server-1.17.0/os/xsha1.c
181--- xorg-server-1.17.0.org/os/xsha1.c 2015-01-18 00:42:52.000000000 +0100
182+++ xorg-server-1.17.0/os/xsha1.c 2015-02-04 19:34:23.455234679 +0100
183@@ -23,270 +23,3 @@
184 * DEALINGS IN THE SOFTWARE.
185 */
186
be68129d
JR
187-#ifdef HAVE_DIX_CONFIG_H
188-#include <dix-config.h>
189-#endif
190-
191-#include "os.h"
192-#include "xsha1.h"
193-
194-#if defined(HAVE_SHA1_IN_LIBMD) /* Use libmd for SHA1 */ \
5ef960ab 195- || defined(HAVE_SHA1_IN_LIBC) /* Use libc for SHA1 */
be68129d 196-
5ef960ab 197-#include <sha1.h>
be68129d 198-
5ef960ab
AM
199-void *
200-x_sha1_init(void)
be68129d 201-{
156d8c26 202- SHA1_CTX *ctx = malloc(sizeof(*ctx));
5ef960ab 203-
be68129d
JR
204- if (!ctx)
205- return NULL;
206- SHA1Init(ctx);
207- return ctx;
208-}
209-
5ef960ab
AM
210-int
211-x_sha1_update(void *ctx, void *data, int size)
be68129d
JR
212-{
213- SHA1_CTX *sha1_ctx = ctx;
5ef960ab 214-
be68129d
JR
215- SHA1Update(sha1_ctx, data, size);
216- return 1;
217-}
218-
5ef960ab
AM
219-int
220-x_sha1_final(void *ctx, unsigned char result[20])
be68129d
JR
221-{
222- SHA1_CTX *sha1_ctx = ctx;
5ef960ab 223-
be68129d 224- SHA1Final(result, sha1_ctx);
156d8c26 225- free(sha1_ctx);
be68129d
JR
226- return 1;
227-}
228-
5ef960ab 229-#elif defined(HAVE_SHA1_IN_COMMONCRYPTO) /* Use CommonCrypto for SHA1 */
be68129d
JR
230-
231-#include <CommonCrypto/CommonDigest.h>
232-
5ef960ab
AM
233-void *
234-x_sha1_init(void)
be68129d 235-{
156d8c26 236- CC_SHA1_CTX *ctx = malloc(sizeof(*ctx));
5ef960ab 237-
be68129d
JR
238- if (!ctx)
239- return NULL;
240- CC_SHA1_Init(ctx);
241- return ctx;
242-}
243-
5ef960ab
AM
244-int
245-x_sha1_update(void *ctx, void *data, int size)
be68129d
JR
246-{
247- CC_SHA1_CTX *sha1_ctx = ctx;
5ef960ab 248-
be68129d
JR
249- CC_SHA1_Update(sha1_ctx, data, size);
250- return 1;
251-}
252-
5ef960ab
AM
253-int
254-x_sha1_final(void *ctx, unsigned char result[20])
be68129d
JR
255-{
256- CC_SHA1_CTX *sha1_ctx = ctx;
5ef960ab 257-
be68129d 258- CC_SHA1_Final(result, sha1_ctx);
156d8c26 259- free(sha1_ctx);
be68129d
JR
260- return 1;
261-}
262-
c113a98d
AM
263-#elif defined(HAVE_SHA1_IN_CRYPTOAPI) /* Use CryptoAPI for SHA1 */
264-
265-#define WIN32_LEAN_AND_MEAN
266-#include <X11/Xwindows.h>
267-#include <wincrypt.h>
268-
269-static HCRYPTPROV hProv;
270-
271-void *
272-x_sha1_init(void)
273-{
274- HCRYPTHASH *ctx = malloc(sizeof(*ctx));
275-
276- if (!ctx)
277- return NULL;
278- CryptAcquireContext(&hProv, NULL, MS_DEF_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
279- CryptCreateHash(hProv, CALG_SHA1, 0, 0, ctx);
280- return ctx;
281-}
282-
283-int
284-x_sha1_update(void *ctx, void *data, int size)
285-{
286- HCRYPTHASH *hHash = ctx;
287-
288- CryptHashData(*hHash, data, size, 0);
289- return 1;
290-}
291-
292-int
293-x_sha1_final(void *ctx, unsigned char result[20])
294-{
295- HCRYPTHASH *hHash = ctx;
296- DWORD len = 20;
297-
298- CryptGetHashParam(*hHash, HP_HASHVAL, result, &len, 0);
299- CryptDestroyHash(*hHash);
300- CryptReleaseContext(hProv, 0);
301- free(ctx);
302- return 1;
303-}
304-
c39080c6
AM
305-#elif defined(HAVE_SHA1_IN_LIBNETTLE) /* Use libnettle for SHA1 */
306-
307-#include <nettle/sha.h>
308-
309-void *
310-x_sha1_init(void)
311-{
312- struct sha1_ctx *ctx = malloc(sizeof(*ctx));
313-
314- if (!ctx)
315- return NULL;
316- sha1_init(ctx);
317- return ctx;
318-}
319-
320-int
321-x_sha1_update(void *ctx, void *data, int size)
322-{
323- sha1_update(ctx, size, data);
324- return 1;
325-}
326-
327-int
328-x_sha1_final(void *ctx, unsigned char result[20])
329-{
330- sha1_digest(ctx, 20, result);
331- free(ctx);
332- return 1;
333-}
334-
5ef960ab 335-#elif defined(HAVE_SHA1_IN_LIBGCRYPT) /* Use libgcrypt for SHA1 */
be68129d 336-
5ef960ab 337-#include <gcrypt.h>
be68129d 338-
5ef960ab
AM
339-void *
340-x_sha1_init(void)
be68129d
JR
341-{
342- static int init;
343- gcry_md_hd_t h;
344- gcry_error_t err;
345-
346- if (!init) {
347- if (!gcry_check_version(NULL))
348- return NULL;
349- gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
350- gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
351- init = 1;
352- }
353-
354- err = gcry_md_open(&h, GCRY_MD_SHA1, 0);
355- if (err)
356- return NULL;
357- return h;
358-}
359-
5ef960ab
AM
360-int
361-x_sha1_update(void *ctx, void *data, int size)
be68129d
JR
362-{
363- gcry_md_hd_t h = ctx;
5ef960ab 364-
be68129d
JR
365- gcry_md_write(h, data, size);
366- return 1;
367-}
368-
5ef960ab
AM
369-int
370-x_sha1_final(void *ctx, unsigned char result[20])
be68129d
JR
371-{
372- gcry_md_hd_t h = ctx;
5ef960ab 373-
be68129d
JR
374- memcpy(result, gcry_md_read(h, GCRY_MD_SHA1), 20);
375- gcry_md_close(h);
376- return 1;
377-}
378-
5ef960ab 379-#elif defined(HAVE_SHA1_IN_LIBSHA1) /* Use libsha1 */
be68129d 380-
5ef960ab 381-#include <libsha1.h>
be68129d 382-
5ef960ab
AM
383-void *
384-x_sha1_init(void)
be68129d 385-{
156d8c26 386- sha1_ctx *ctx = malloc(sizeof(*ctx));
5ef960ab
AM
387-
388- if (!ctx)
be68129d
JR
389- return NULL;
390- sha1_begin(ctx);
391- return ctx;
392-}
393-
5ef960ab
AM
394-int
395-x_sha1_update(void *ctx, void *data, int size)
be68129d
JR
396-{
397- sha1_hash(data, size, ctx);
398- return 1;
399-}
400-
5ef960ab
AM
401-int
402-x_sha1_final(void *ctx, unsigned char result[20])
be68129d
JR
403-{
404- sha1_end(result, ctx);
156d8c26 405- free(ctx);
be68129d
JR
406- return 1;
407-}
408-
5ef960ab 409-#else /* Use OpenSSL's libcrypto */
be68129d 410-
5ef960ab
AM
411-#include <stddef.h> /* buggy openssl/sha.h wants size_t */
412-#include <openssl/sha.h>
be68129d 413-
5ef960ab
AM
414-void *
415-x_sha1_init(void)
be68129d
JR
416-{
417- int ret;
156d8c26 418- SHA_CTX *ctx = malloc(sizeof(*ctx));
5ef960ab 419-
be68129d
JR
420- if (!ctx)
421- return NULL;
422- ret = SHA1_Init(ctx);
423- if (!ret) {
156d8c26 424- free(ctx);
be68129d
JR
425- return NULL;
426- }
427- return ctx;
428-}
429-
5ef960ab
AM
430-int
431-x_sha1_update(void *ctx, void *data, int size)
be68129d
JR
432-{
433- int ret;
434- SHA_CTX *sha_ctx = ctx;
5ef960ab 435-
be68129d
JR
436- ret = SHA1_Update(sha_ctx, data, size);
437- if (!ret)
156d8c26 438- free(sha_ctx);
be68129d
JR
439- return ret;
440-}
441-
5ef960ab
AM
442-int
443-x_sha1_final(void *ctx, unsigned char result[20])
be68129d
JR
444-{
445- int ret;
446- SHA_CTX *sha_ctx = ctx;
5ef960ab 447-
be68129d 448- ret = SHA1_Final(result, sha_ctx);
156d8c26 449- free(sha_ctx);
be68129d
JR
450- return ret;
451-}
452-
453-#endif
fc866b7f
AM
454diff -urN xorg-server-1.17.0.org/render/glyph.c xorg-server-1.17.0/render/glyph.c
455--- xorg-server-1.17.0.org/render/glyph.c 2015-01-18 00:42:52.000000000 +0100
456+++ xorg-server-1.17.0/render/glyph.c 2015-02-04 19:34:23.458568095 +0100
be68129d
JR
457@@ -26,8 +26,7 @@
458 #include <dix-config.h>
459 #endif
460
461-#include "xsha1.h"
462-
463+#include "sha1.h"
464 #include "misc.h"
465 #include "scrnintstr.h"
466 #include "os.h"
fc866b7f 467@@ -165,21 +164,13 @@
5ef960ab
AM
468 HashGlyph(xGlyphInfo * gi,
469 CARD8 *bits, unsigned long size, unsigned char sha1[20])
be68129d
JR
470 {
471- void *ctx = x_sha1_init();
472- int success;
5ef960ab
AM
473+ SHA1_CTX ctx;
474
be68129d 475- if (!ctx)
5ef960ab
AM
476- return BadAlloc;
477+ SHA1Init (&ctx);
478+ SHA1Update (&ctx, gi, sizeof (xGlyphInfo));
479+ SHA1Update (&ctx, bits, size);
480+ SHA1Final (sha1, &ctx);
481
be68129d
JR
482- success = x_sha1_update(ctx, gi, sizeof(xGlyphInfo));
483- if (!success)
5ef960ab 484- return BadAlloc;
be68129d
JR
485- success = x_sha1_update(ctx, bits, size);
486- if (!success)
5ef960ab 487- return BadAlloc;
be68129d
JR
488- success = x_sha1_final(ctx, sha1);
489- if (!success)
5ef960ab 490- return BadAlloc;
be68129d
JR
491 return Success;
492 }
493
fc866b7f
AM
494diff -urN xorg-server-1.17.0.org/render/Makefile.am xorg-server-1.17.0/render/Makefile.am
495--- xorg-server-1.17.0.org/render/Makefile.am 2013-06-18 18:03:42.000000000 +0200
496+++ xorg-server-1.17.0/render/Makefile.am 2015-02-04 19:34:23.455234679 +0100
497@@ -13,8 +13,11 @@
498 mitrap.c \
499 mitri.c \
500 picture.c \
501+ sha1.c \
502 render.c
503
504 if XORG
505 sdk_HEADERS = picture.h mipict.h glyphstr.h picturestr.h
506 endif
507+
508+EXTRA_DIST = sha1.h
509diff -urN xorg-server-1.17.0.org/render/sha1.c xorg-server-1.17.0/render/sha1.c
510--- xorg-server-1.17.0.org/render/sha1.c 1970-01-01 01:00:00.000000000 +0100
511+++ xorg-server-1.17.0/render/sha1.c 2015-02-04 19:34:23.458568095 +0100
be68129d
JR
512@@ -0,0 +1,173 @@
513+/*
514+ * SHA-1 in C
515+ * By Steve Reid <steve@edmweb.com>
516+ * 100% Public Domain
517+ *
518+ * Test Vectors (from FIPS PUB 180-1)
519+ * "abc"
520+ * A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
521+ * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
522+ * 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
523+ * A million repetitions of "a"
524+ * 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
525+ */
526+
527+#include <sys/param.h>
528+#include <string.h>
529+#include <sha1.h>
530+
531+#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
532+
533+/*
534+ * blk0() and blk() perform the initial expand.
535+ * I got the idea of expanding during the round function from SSLeay
536+ */
537+#if BYTE_ORDER == LITTLE_ENDIAN
538+# define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
539+ |(rol(block->l[i],8)&0x00FF00FF))
540+#else
541+# define blk0(i) block->l[i]
542+#endif
543+#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
544+ ^block->l[(i+2)&15]^block->l[i&15],1))
545+
546+/*
547+ * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1
548+ */
549+#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
550+#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
551+#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
552+#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
553+#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
554+
555+/*
556+ * Hash a single 512-bit block. This is the core of the algorithm.
557+ */
558+void
559+SHA1Transform(uint32_t state[5], const uint8_t buffer[SHA1_BLOCK_LENGTH])
560+{
561+ uint32_t a, b, c, d, e;
562+ uint8_t workspace[SHA1_BLOCK_LENGTH];
563+ typedef union {
564+ uint8_t c[64];
565+ uint32_t l[16];
566+ } CHAR64LONG16;
567+ CHAR64LONG16 *block = (CHAR64LONG16 *)workspace;
568+
569+ (void)memcpy(block, buffer, SHA1_BLOCK_LENGTH);
570+
571+ /* Copy context->state[] to working vars */
572+ a = state[0];
573+ b = state[1];
574+ c = state[2];
575+ d = state[3];
576+ e = state[4];
577+
578+ /* 4 rounds of 20 operations each. Loop unrolled. */
579+ 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);
580+ 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);
581+ 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);
582+ 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);
583+ 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);
584+ 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);
585+ 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);
586+ 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);
587+ 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);
588+ 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);
589+ 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);
590+ 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);
591+ 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);
592+ 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);
593+ 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);
594+ 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);
595+ 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);
596+ 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);
597+ 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);
598+ 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);
599+
600+ /* Add the working vars back into context.state[] */
601+ state[0] += a;
602+ state[1] += b;
603+ state[2] += c;
604+ state[3] += d;
605+ state[4] += e;
606+
607+ /* Wipe variables */
608+ a = b = c = d = e = 0;
609+}
610+
611+
612+/*
613+ * SHA1Init - Initialize new context
614+ */
615+void
616+SHA1Init(SHA1_CTX *context)
617+{
618+
619+ /* SHA1 initialization constants */
620+ context->count = 0;
621+ context->state[0] = 0x67452301;
622+ context->state[1] = 0xEFCDAB89;
623+ context->state[2] = 0x98BADCFE;
624+ context->state[3] = 0x10325476;
625+ context->state[4] = 0xC3D2E1F0;
626+}
627+
628+
629+/*
630+ * Run your data through this.
631+ */
632+void
633+SHA1Update(SHA1_CTX *context, const uint8_t *data, size_t len)
634+{
635+ size_t i, j;
636+
637+ j = (size_t)((context->count >> 3) & 63);
638+ context->count += (len << 3);
639+ if ((j + len) > 63) {
640+ (void)memcpy(&context->buffer[j], data, (i = 64-j));
641+ SHA1Transform(context->state, context->buffer);
642+ for ( ; i + 63 < len; i += 64)
643+ SHA1Transform(context->state, (uint8_t *)&data[i]);
644+ j = 0;
645+ } else {
646+ i = 0;
647+ }
648+ (void)memcpy(&context->buffer[j], &data[i], len - i);
649+}
650+
651+
652+/*
653+ * Add padding and return the message digest.
654+ */
655+void
656+SHA1Pad(SHA1_CTX *context)
657+{
658+ uint8_t finalcount[8];
659+ uint i;
660+
661+ for (i = 0; i < 8; i++) {
662+ finalcount[i] = (uint8_t)((context->count >>
663+ ((7 - (i & 7)) * 8)) & 255); /* Endian independent */
664+ }
665+ SHA1Update(context, (uint8_t *)"\200", 1);
666+ while ((context->count & 504) != 448)
667+ SHA1Update(context, (uint8_t *)"\0", 1);
668+ SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
669+}
670+
671+void
672+SHA1Final(uint8_t digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context)
673+{
674+ uint i;
675+
676+ SHA1Pad(context);
677+ if (digest) {
678+ for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
679+ digest[i] = (uint8_t)
680+ ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
681+ }
682+ memset(context, 0, sizeof(*context));
683+ }
684+}
685+
fc866b7f
AM
686diff -urN xorg-server-1.17.0.org/render/sha1.h xorg-server-1.17.0/render/sha1.h
687--- xorg-server-1.17.0.org/render/sha1.h 1970-01-01 01:00:00.000000000 +0100
688+++ xorg-server-1.17.0/render/sha1.h 2015-02-04 19:34:23.458568095 +0100
be68129d
JR
689@@ -0,0 +1,63 @@
690+/*
691+ * SHA-1 in C
692+ * By Steve Reid <steve@edmweb.com>
693+ * 100% Public Domain
694+ */
695+
696+#ifndef _SHA1_H
697+#define _SHA1_H
698+
699+#include <stdint.h>
700+#include <stddef.h>
701+#include <unistd.h>
702+
703+
704+#define SHA1_BLOCK_LENGTH 64
705+#define SHA1_DIGEST_LENGTH 20
706+#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
707+
708+typedef struct {
709+ uint32_t state[5];
710+ uint64_t count;
711+ uint8_t buffer[SHA1_BLOCK_LENGTH];
712+} SHA1_CTX;
713+
714+#include <sys/cdefs.h>
715+
716+__BEGIN_DECLS
717+void SHA1Init(SHA1_CTX *);
718+void SHA1Pad(SHA1_CTX *);
719+void SHA1Transform(uint32_t [5], const uint8_t [SHA1_BLOCK_LENGTH])
720+ __attribute__((__bounded__(__minbytes__,1,5)))
721+ __attribute__((__bounded__(__minbytes__,2,SHA1_BLOCK_LENGTH)));
722+void SHA1Update(SHA1_CTX *, const uint8_t *, size_t)
723+ __attribute__((__bounded__(__string__,2,3)));
724+void SHA1Final(uint8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *)
725+ __attribute__((__bounded__(__minbytes__,1,SHA1_DIGEST_LENGTH)));
726+char *SHA1End(SHA1_CTX *, char *)
727+ __attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
728+char *SHA1File(const char *, char *)
729+ __attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
730+char *SHA1FileChunk(const char *, char *, off_t, off_t)
731+ __attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
732+char *SHA1Data(const uint8_t *, size_t, char *)
733+ __attribute__((__bounded__(__string__,1,2)))
734+ __attribute__((__bounded__(__minbytes__,3,SHA1_DIGEST_STRING_LENGTH)));
735+__END_DECLS
736+
737+#define HTONDIGEST(x) do { \
738+ x[0] = htonl(x[0]); \
739+ x[1] = htonl(x[1]); \
740+ x[2] = htonl(x[2]); \
741+ x[3] = htonl(x[3]); \
742+ x[4] = htonl(x[4]); } while (0)
743+
744+#define NTOHDIGEST(x) do { \
745+ x[0] = ntohl(x[0]); \
746+ x[1] = ntohl(x[1]); \
747+ x[2] = ntohl(x[2]); \
748+ x[3] = ntohl(x[3]); \
749+ x[4] = ntohl(x[4]); } while (0)
750+
751+#endif /* _SHA1_H */
752+
This page took 0.226842 seconds and 4 git commands to generate.