aboutsummaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/CMakeLists.txt7
-rw-r--r--crypto/Makefile.am6
-rw-r--r--crypto/Makefile.am.elf-mips1
-rw-r--r--crypto/Makefile.am.elf-mips6412
-rw-r--r--crypto/arch/mips/crypto_arch.h18
-rw-r--r--crypto/bn/arch/mips/bn_arch.h19
-rw-r--r--crypto/compat/ftruncate.c17
-rw-r--r--crypto/compat/getdelim.c20
-rw-r--r--crypto/compat/getprogname_windows.c3
-rw-r--r--crypto/compat/posix_win.c13
-rw-r--r--crypto/compat/syslog_r.c11
11 files changed, 86 insertions, 41 deletions
diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt
index d566182..0698ab4 100644
--- a/crypto/CMakeLists.txt
+++ b/crypto/CMakeLists.txt
@@ -22,8 +22,9 @@ if(HOST_ASM_ELF_AARCH64)
22 ASM_AARCH64_ELF_SRC 22 ASM_AARCH64_ELF_SRC
23 sha/sha1_aarch64_ce.S 23 sha/sha1_aarch64_ce.S
24 sha/sha256_aarch64_ce.S 24 sha/sha256_aarch64_ce.S
25 sha/sha256_aarch64_ce.S 25 sha/sha512_aarch64_ce.S
26 ) 26 )
27 add_definitions(-DLIBRESSL_USE_SHA_ASSEMBLY)
27 set(CRYPTO_SRC ${CRYPTO_SRC} ${ASM_AARCH64_ELF_SRC}) 28 set(CRYPTO_SRC ${CRYPTO_SRC} ${ASM_AARCH64_ELF_SRC})
28endif() 29endif()
29 30
@@ -636,10 +637,6 @@ if(NOT HAVE_FREEZERO)
636 set(COMPAT_SRC ${COMPAT_SRC} compat/freezero.c) 637 set(COMPAT_SRC ${COMPAT_SRC} compat/freezero.c)
637endif() 638endif()
638 639
639if(NOT HAVE_FTRUNCATE)
640 set(COMPAT_SRC ${COMPAT_SRC} compat/ftruncate.c)
641endif()
642
643if(NOT HAVE_GETDELIM) 640if(NOT HAVE_GETDELIM)
644 set(COMPAT_SRC ${COMPAT_SRC} compat/getdelim.c) 641 set(COMPAT_SRC ${COMPAT_SRC} compat/getdelim.c)
645endif() 642endif()
diff --git a/crypto/Makefile.am b/crypto/Makefile.am
index f703e33..a4a717d 100644
--- a/crypto/Makefile.am
+++ b/crypto/Makefile.am
@@ -148,10 +148,6 @@ if !HAVE_FREEZERO
148libcompat_la_SOURCES += compat/freezero.c 148libcompat_la_SOURCES += compat/freezero.c
149endif 149endif
150 150
151if !HAVE_FTRUNCATE
152libcompat_la_SOURCES += compat/ftruncate.c
153endif
154
155if !HAVE_GETDELIM 151if !HAVE_GETDELIM
156libcompat_la_SOURCES += compat/getdelim.c 152libcompat_la_SOURCES += compat/getdelim.c
157endif 153endif
@@ -216,6 +212,7 @@ include Makefile.am.mingw64-x86_64
216if !HOST_ASM_ELF_AARCH64 212if !HOST_ASM_ELF_AARCH64
217if !HOST_ASM_ELF_MIPS 213if !HOST_ASM_ELF_MIPS
218if !HOST_ASM_ELF_MIPS64 214if !HOST_ASM_ELF_MIPS64
215if !HOST_ASM_ELF_RISCV64
219if !HOST_ASM_ELF_X86_64 216if !HOST_ASM_ELF_X86_64
220if !HOST_ASM_MACOSX_X86_64 217if !HOST_ASM_MACOSX_X86_64
221if !HOST_ASM_MASM_X86_64 218if !HOST_ASM_MASM_X86_64
@@ -228,6 +225,7 @@ endif
228endif 225endif
229endif 226endif
230endif 227endif
228endif
231 229
232if HOST_AARCH64 230if HOST_AARCH64
233if HOST_DARWIN 231if HOST_DARWIN
diff --git a/crypto/Makefile.am.elf-mips b/crypto/Makefile.am.elf-mips
index 2276991..682fb5e 100644
--- a/crypto/Makefile.am.elf-mips
+++ b/crypto/Makefile.am.elf-mips
@@ -2,7 +2,6 @@ ASM_MIPS_ELF = aes/aes-mips.S
2ASM_MIPS_ELF += bn/bn-mips.S 2ASM_MIPS_ELF += bn/bn-mips.S
3ASM_MIPS_ELF += bn/mont-mips.S 3ASM_MIPS_ELF += bn/mont-mips.S
4ASM_MIPS_ELF += sha/sha1-mips.S 4ASM_MIPS_ELF += sha/sha1-mips.S
5ASM_MIPS_ELF += sha/sha512-mips.S
6ASM_MIPS_ELF += sha/sha256-mips.S 5ASM_MIPS_ELF += sha/sha256-mips.S
7 6
8EXTRA_DIST += $(ASM_MIPS_ELF) 7EXTRA_DIST += $(ASM_MIPS_ELF)
diff --git a/crypto/Makefile.am.elf-mips64 b/crypto/Makefile.am.elf-mips64
index c6727b3..7269d6e 100644
--- a/crypto/Makefile.am.elf-mips64
+++ b/crypto/Makefile.am.elf-mips64
@@ -1,9 +1,9 @@
1ASM_MIPS64_ELF = aes/aes-mips.S 1ASM_MIPS64_ELF = aes/aes-mips64.S
2ASM_MIPS64_ELF += bn/bn-mips.S 2ASM_MIPS64_ELF += bn/bn-mips64.S
3ASM_MIPS64_ELF += bn/mont-mips.S 3ASM_MIPS64_ELF += bn/mont-mips64.S
4ASM_MIPS64_ELF += sha/sha1-mips.S 4ASM_MIPS64_ELF += sha/sha1-mips64.S
5ASM_MIPS64_ELF += sha/sha512-mips.S 5ASM_MIPS64_ELF += sha/sha512-mips64.S
6ASM_MIPS64_ELF += sha/sha256-mips.S 6ASM_MIPS64_ELF += sha/sha256-mips64.S
7 7
8EXTRA_DIST += $(ASM_MIPS64_ELF) 8EXTRA_DIST += $(ASM_MIPS64_ELF)
9 9
diff --git a/crypto/arch/mips/crypto_arch.h b/crypto/arch/mips/crypto_arch.h
index 274879c..2407503 100644
--- a/crypto/arch/mips/crypto_arch.h
+++ b/crypto/arch/mips/crypto_arch.h
@@ -18,4 +18,22 @@
18#ifndef HEADER_CRYPTO_ARCH_H 18#ifndef HEADER_CRYPTO_ARCH_H
19#define HEADER_CRYPTO_ARCH_H 19#define HEADER_CRYPTO_ARCH_H
20 20
21#ifndef OPENSSL_NO_ASM
22
23#ifdef LIBRESSL_USE_AES_ASSEMBLY
24#define HAVE_AES_SET_ENCRYPT_KEY_INTERNAL
25#define HAVE_AES_SET_DECRYPT_KEY_INTERNAL
26#define HAVE_AES_ENCRYPT_INTERNAL
27#define HAVE_AES_DECRYPT_INTERNAL
28#endif
29
30#ifdef LIBRESSL_USE_SHA_ASSEMBLY
31#define HAVE_SHA1_BLOCK_DATA_ORDER
32#define HAVE_SHA1_BLOCK_GENERIC
33#define HAVE_SHA256_BLOCK_DATA_ORDER
34#define HAVE_SHA256_BLOCK_GENERIC
35#endif
36
37#endif
38
21#endif 39#endif
diff --git a/crypto/bn/arch/mips/bn_arch.h b/crypto/bn/arch/mips/bn_arch.h
index 4d6571f..a14b83b 100644
--- a/crypto/bn/arch/mips/bn_arch.h
+++ b/crypto/bn/arch/mips/bn_arch.h
@@ -20,5 +20,24 @@
20 20
21#ifndef OPENSSL_NO_ASM 21#ifndef OPENSSL_NO_ASM
22 22
23#ifdef LIBRESSL_USE_BN_ASSEMBLY
24
25#define HAVE_BN_ADD_WORDS
26
27#define HAVE_BN_DIV_WORDS
28#define HAVE_BN_DIV_3_WORDS
29
30#define HAVE_BN_MUL_COMBA4
31#define HAVE_BN_MUL_COMBA8
32#define HAVE_BN_MULW_ADD_WORDS
33#define HAVE_BN_MULW_WORDS
34
35#define HAVE_BN_SQR_COMBA4
36#define HAVE_BN_SQR_COMBA8
37
38#define HAVE_BN_SUB_WORDS
39
40#endif
41
23#endif 42#endif
24#endif 43#endif
diff --git a/crypto/compat/ftruncate.c b/crypto/compat/ftruncate.c
deleted file mode 100644
index e825e50..0000000
--- a/crypto/compat/ftruncate.c
+++ /dev/null
@@ -1,17 +0,0 @@
1/*
2 * Public domain
3 *
4 * Kinichiro Inoguchi <inoguchi@openbsd.org>
5 */
6
7#ifdef _WIN32
8
9#include <unistd.h>
10
11int
12ftruncate(int fd, off_t length)
13{
14 return _chsize(fd, length);
15}
16
17#endif
diff --git a/crypto/compat/getdelim.c b/crypto/compat/getdelim.c
index caec3f2..bf4889f 100644
--- a/crypto/compat/getdelim.c
+++ b/crypto/compat/getdelim.c
@@ -27,6 +27,8 @@
27 * POSSIBILITY OF SUCH DAMAGE. 27 * POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30#include <errno.h>
31#include <stdint.h>
30#include <stdio.h> 32#include <stdio.h>
31#include <stdlib.h> 33#include <stdlib.h>
32 34
@@ -35,13 +37,16 @@
35ssize_t 37ssize_t
36getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp) 38getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
37{ 39{
38 char *ptr, *eptr; 40 char *ptr, *eptr, *nbuf;
41 size_t nbufsiz;
39 42
40 43
41 if (*buf == NULL || *bufsiz == 0) { 44 if (*buf == NULL || *bufsiz < 2) {
42 *bufsiz = BUFSIZ; 45 nbufsiz = BUFSIZ;
43 if ((*buf = malloc(*bufsiz)) == NULL) 46 if ((nbuf = realloc(*buf, nbufsiz)) == NULL)
44 return -1; 47 return -1;
48 *buf = nbuf;
49 *bufsiz = nbufsiz;
45 } 50 }
46 51
47 for (ptr = *buf, eptr = *buf + *bufsiz;;) { 52 for (ptr = *buf, eptr = *buf + *bufsiz;;) {
@@ -62,9 +67,12 @@ getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
62 return ptr - *buf; 67 return ptr - *buf;
63 } 68 }
64 if (ptr + 2 >= eptr) { 69 if (ptr + 2 >= eptr) {
65 char *nbuf;
66 size_t nbufsiz = *bufsiz * 2;
67 ssize_t d = ptr - *buf; 70 ssize_t d = ptr - *buf;
71 if (*bufsiz > SIZE_MAX / 2) {
72 errno = EOVERFLOW;
73 return -1;
74 }
75 nbufsiz = *bufsiz * 2;
68 if ((nbuf = realloc(*buf, nbufsiz)) == NULL) 76 if ((nbuf = realloc(*buf, nbufsiz)) == NULL)
69 return -1; 77 return -1;
70 *buf = nbuf; 78 *buf = nbuf;
diff --git a/crypto/compat/getprogname_windows.c b/crypto/compat/getprogname_windows.c
index eb04ec0..9de3cab 100644
--- a/crypto/compat/getprogname_windows.c
+++ b/crypto/compat/getprogname_windows.c
@@ -7,7 +7,8 @@ getprogname(void)
7{ 7{
8 static char progname[MAX_PATH + 1]; 8 static char progname[MAX_PATH + 1];
9 DWORD length = GetModuleFileName(NULL, progname, sizeof (progname) - 1); 9 DWORD length = GetModuleFileName(NULL, progname, sizeof (progname) - 1);
10 if (length < 0) 10 if (length == 0)
11 return "?"; 11 return "?";
12 progname[length] = '\0';
12 return progname; 13 return progname;
13} 14}
diff --git a/crypto/compat/posix_win.c b/crypto/compat/posix_win.c
index bc0fa36..14b79f5 100644
--- a/crypto/compat/posix_win.c
+++ b/crypto/compat/posix_win.c
@@ -68,6 +68,14 @@ libressl_fstat(int fd, struct stat *statbuf)
68 return fstat(get_real_fd(fd), statbuf); 68 return fstat(get_real_fd(fd), statbuf);
69} 69}
70 70
71#ifndef HAVE_FTRUNCATE
72int
73ftruncate(int fd, off_t length)
74{
75 return _chsize(get_real_fd(fd), length);
76}
77#endif
78
71int 79int
72posix_open(const char *path, ...) 80posix_open(const char *path, ...)
73{ 81{
@@ -178,6 +186,9 @@ wsa_errno(int err)
178 case WSAETIMEDOUT: 186 case WSAETIMEDOUT:
179 errno = EPIPE; 187 errno = EPIPE;
180 break; 188 break;
189 default:
190 errno = EIO;
191 break;
181 } 192 }
182 return -1; 193 return -1;
183} 194}
@@ -292,7 +303,7 @@ int gettimeofday(struct timeval *tp, void *tzp)
292 time = ((uint64_t)file_time.dwLowDateTime); 303 time = ((uint64_t)file_time.dwLowDateTime);
293 time += ((uint64_t)file_time.dwHighDateTime) << 32; 304 time += ((uint64_t)file_time.dwHighDateTime) << 32;
294 305
295 tp->tv_sec = (long long)((time - EPOCH) / 10000000L); 306 tp->tv_sec = (long)((time - EPOCH) / 10000000L);
296 tp->tv_usec = (long)(system_time.wMilliseconds * 1000); 307 tp->tv_usec = (long)(system_time.wMilliseconds * 1000);
297 return 0; 308 return 0;
298} 309}
diff --git a/crypto/compat/syslog_r.c b/crypto/compat/syslog_r.c
index d68169d..30841c1 100644
--- a/crypto/compat/syslog_r.c
+++ b/crypto/compat/syslog_r.c
@@ -1,3 +1,5 @@
1#include <stdio.h>
2#include <stdlib.h>
1#include <syslog.h> 3#include <syslog.h>
2 4
3void 5void
@@ -14,6 +16,15 @@ void
14vsyslog_r(int pri, struct syslog_data *data, const char *fmt, va_list ap) 16vsyslog_r(int pri, struct syslog_data *data, const char *fmt, va_list ap)
15{ 17{
16#ifdef HAVE_SYSLOG 18#ifdef HAVE_SYSLOG
19#ifdef HAVE_VSYSLOG
17 vsyslog(pri, fmt, ap); 20 vsyslog(pri, fmt, ap);
21#else
22 char *msg = NULL;
23
24 if (vasprintf(&msg, fmt, ap) == -1)
25 return;
26 syslog(pri, "%s", msg);
27 free(msg);
28#endif
18#endif 29#endif
19} 30}