summaryrefslogtreecommitdiff
path: root/render/glyph.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2008-09-23 09:22:07 -0700
committerKeith Packard <keithp@keithp.com>2008-09-23 09:22:07 -0700
commita39377cbcbd3091095efbeab25bec18ae520147e (patch)
tree2c2e8fa9adaa87e014db79c86b89784082a9fbf7 /render/glyph.c
parent10a9bac0257b381367cedff395b40425d584bf59 (diff)
Revert "Render: Use built-in SHA1 library"
This reverts commit d3bd31fddff7894f89ba80a3cdddff49aff08db8. X.org should not be providing a custom SHA1 implementation.
Diffstat (limited to 'render/glyph.c')
-rw-r--r--render/glyph.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/render/glyph.c b/render/glyph.c
index 949e02340..849e65fce 100644
--- a/render/glyph.c
+++ b/render/glyph.c
@@ -26,7 +26,13 @@
#include <dix-config.h>
#endif
-#include "sha1.h"
+#ifdef HAVE_SHA1_IN_LIBMD /* Use libmd for SHA1 */
+# include <sha1.h>
+#else /* Use OpenSSL's libcrypto */
+# include <stddef.h> /* buggy openssl/sha.h wants size_t */
+# include <openssl/sha.h>
+#endif
+
#include "misc.h"
#include "scrnintstr.h"
#include "os.h"
@@ -192,12 +198,33 @@ HashGlyph (xGlyphInfo *gi,
unsigned long size,
unsigned char sha1[20])
{
+#ifdef HAVE_SHA1_IN_LIBMD /* Use libmd for SHA1 */
SHA1_CTX ctx;
SHA1Init (&ctx);
SHA1Update (&ctx, gi, sizeof (xGlyphInfo));
SHA1Update (&ctx, bits, size);
SHA1Final (sha1, &ctx);
+#else /* Use OpenSSL's libcrypto */
+ SHA_CTX ctx;
+ int success;
+
+ success = SHA1_Init (&ctx);
+ if (! success)
+ return BadAlloc;
+
+ success = SHA1_Update (&ctx, gi, sizeof (xGlyphInfo));
+ if (! success)
+ return BadAlloc;
+
+ success = SHA1_Update (&ctx, bits, size);
+ if (! success)
+ return BadAlloc;
+
+ success = SHA1_Final (sha1, &ctx);
+ if (! success)
+ return BadAlloc;
+#endif
return Success;
}