Skip to content

Commit 5ebac6a

Browse files
committed
crypto: Don't compile SHA1 support when Websockets are disabled
SHA1 is not ideal, security wise. Let's make sure we don't even have it compiled when nothing depends on it, e.g. Websockets.
1 parent 9d6558a commit 5ebac6a

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

src/common/crypto.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
int hash_md5(void *out, const void *in, const size_t in_len);
1212

1313
/* Generates an SHA1 hash of 'in' and writes it to 'out', which must be 20 bytes in size. */
14+
#ifdef LIBVNCSERVER_WITH_WEBSOCKETS
1415
int hash_sha1(void *out, const void *in, const size_t in_len);
16+
#endif
1517

1618
/* Fill 'out' with 'len' random bytes. */
1719
void random_bytes(void *out, size_t len);

src/common/crypto_included.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ int hash_md5(void *out, const void *in, const size_t in_len)
3333
return 0;
3434
}
3535

36+
#ifdef LIBVNCSERVER_WITH_WEBSOCKETS
3637
int hash_sha1(void *out, const void *in, const size_t in_len)
3738
{
3839
SHA1Context sha1;
@@ -45,6 +46,7 @@ int hash_sha1(void *out, const void *in, const size_t in_len)
4546

4647
return 1;
4748
}
49+
#endif /* LIBVNCSERVER_WITH_WEBSOCKETS */
4850

4951
void random_bytes(void *out, size_t len)
5052
{

src/common/crypto_libgcrypt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ int hash_md5(void *out, const void *in, const size_t in_len)
7474
return result;
7575
}
7676

77+
#ifdef LIBVNCSERVER_WITH_WEBSOCKETS
7778
int hash_sha1(void *out, const void *in, const size_t in_len)
7879
{
7980
int result = 0;
@@ -98,6 +99,7 @@ int hash_sha1(void *out, const void *in, const size_t in_len)
9899
gcry_md_close(sha1);
99100
return result;
100101
}
102+
#endif /* LIBVNCSERVER_WITH_WEBSOCKETS */
101103

102104
void random_bytes(void *out, size_t len)
103105
{

src/common/crypto_openssl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ int hash_md5(void *out, const void *in, const size_t in_len)
5252
return 1;
5353
}
5454

55+
#ifdef LIBVNCSERVER_WITH_WEBSOCKETS
5556
int hash_sha1(void *out, const void *in, const size_t in_len)
5657
{
5758
SHA_CTX sha1;
@@ -63,6 +64,7 @@ int hash_sha1(void *out, const void *in, const size_t in_len)
6364
return 0;
6465
return 1;
6566
}
67+
#endif /* LIBVNCSERVER_WITH_WEBSOCKETS */
6668

6769
void random_bytes(void *out, size_t len)
6870
{

0 commit comments

Comments
 (0)