Skip to content

Commit

Permalink
Make SSL handshakes much faster
Browse files Browse the repository at this point in the history
This change boosts SSL handshake performance from 2,627 to ~10,000 per
second which is the same level of performance as NGINX at establishing
secure connections. That's impressive if we consider that redbean is a
forking frontend application server. This was accomplished by:

  1. Enabling either SSL session caching or SSL tickets. We choose to
     use tickets since they reduce network round trips too and that's
     a more important metric than wrk'ing localhost.

  2. Fixing mbedtls_mpi_sub_abs() which is the most frequently called
     function. It's called about 12,000 times during an SSL handshake
     since it's the basis of most arithmetic operations like addition
     and for some strange reason it was designed to make two needless
     copies in addition to calling malloc and free. That's now fixed.

  3. Improving TLS output buffering during the SSL handshake only, so
     that only a single is write and read system call is needed until
     blocking on the ping pong.

redbean will now do a better job wiping sensitive memory from a child
process as soon as it's not needed. The nice thing about fork is it's
much faster than reverse proxying so the goal is to use the different
address spaces along with setuid() to minimize the risk that a server
key will be compromised in the event that application code is hacked.
  • Loading branch information
jart committed Jul 12, 2021
1 parent 8c4cce0 commit f3e28aa
Show file tree
Hide file tree
Showing 103 changed files with 1,309 additions and 1,084 deletions.
37 changes: 28 additions & 9 deletions libc/calls/sigenter-xnu.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "libc/calls/internal.h"
#include "libc/calls/struct/siginfo.h"
#include "libc/calls/ucontext.h"
#include "libc/intrin/repstosb.h"
#include "libc/str/str.h"

/**
Expand Down Expand Up @@ -401,7 +402,14 @@ noasan static void xnuthreadstate2linux(
mc->fs = xnuss->__fs;
mc->eflags = xnuss->__rflags;
uc->uc_flags = xnuss->__rflags;
memcpy(&mc->r8, &xnuss->__r8, 8 * sizeof(int64_t));
mc->r8 = xnuss->__r8;
mc->r9 = xnuss->__r9;
mc->r10 = xnuss->__r10;
mc->r11 = xnuss->__r11;
mc->r12 = xnuss->__r12;
mc->r13 = xnuss->__r13;
mc->r14 = xnuss->__r14;
mc->r15 = xnuss->__r15;
}

noasan static void linuxthreadstate2xnu(
Expand All @@ -420,7 +428,21 @@ noasan static void linuxthreadstate2xnu(
xnuss->__fs = mc->fs;
xnuss->__rflags = mc->eflags;
xnuss->__rflags = uc->uc_flags;
memcpy(&xnuss->__r8, &mc->r8, 8 * sizeof(int64_t));
xnuss->__r8 = mc->r8;
xnuss->__r9 = mc->r9;
xnuss->__r10 = mc->r10;
xnuss->__r11 = mc->r11;
xnuss->__r12 = mc->r12;
xnuss->__r13 = mc->r13;
xnuss->__r14 = mc->r14;
xnuss->__r15 = mc->r15;
}

noasan static void CopyFpXmmRegs(void *d, const void *s) {
size_t i;
for (i = 0; i < (8 + 16) * 16; i += 16) {
__builtin_memcpy((char *)d + i, (const char *)s + i, 16);
}
}

noasan static void xnussefpustate2linux(
Expand All @@ -433,8 +455,7 @@ noasan static void xnussefpustate2linux(
fs->rdp = xnufs->__fpu_dp;
fs->mxcsr = xnufs->__fpu_mxcsr;
fs->mxcr_mask = xnufs->__fpu_mxcsrmask;
/* copy st0-st7 as well as xmm0-xmm15 */
memcpy(fs->st, &xnufs->__fpu_stmm0, (8 + 16) * sizeof(uint128_t));
CopyFpXmmRegs(fs->st, &xnufs->__fpu_stmm0);
}

noasan static void linuxssefpustate2xnu(
Expand All @@ -447,8 +468,7 @@ noasan static void linuxssefpustate2xnu(
xnufs->__fpu_dp = fs->rdp;
xnufs->__fpu_mxcsr = fs->mxcsr;
xnufs->__fpu_mxcsrmask = fs->mxcr_mask;
/* copy st0-st7 as well as xmm0-xmm15 */
memcpy(&xnufs->__fpu_stmm0, fs->st, (8 + 16) * sizeof(uint128_t));
CopyFpXmmRegs(&xnufs->__fpu_stmm0, fs->st);
}

noasan void __sigenter_xnu(void *fn, int infostyle, int sig,
Expand All @@ -462,10 +482,9 @@ noasan void __sigenter_xnu(void *fn, int infostyle, int sig,
} g;
rva = __sighandrvas[sig & (NSIG - 1)];
if (rva >= kSigactionMinRva) {
memset(&g, 0, sizeof(g));
repstosb(&g, 0, sizeof(g));
if (xnuctx) {
memcpy(&g.uc.uc_sigmask, &xnuctx->uc_sigmask,
MIN(sizeof(g.uc.uc_sigmask), sizeof(xnuctx->uc_sigmask)));
g.uc.uc_sigmask.__bits[0] = xnuctx->uc_sigmask;
g.uc.uc_stack.ss_sp = xnuctx->uc_stack.ss_sp;
g.uc.uc_stack.ss_flags = xnuctx->uc_stack.ss_flags;
g.uc.uc_stack.ss_size = xnuctx->uc_stack.ss_size;
Expand Down
2 changes: 1 addition & 1 deletion libc/intrin/mpsadbw.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ void(mpsadbw)(uint16_t c[8], const uint8_t b[16], const uint8_t a[16],
r[i] += ABS(b[(control & 4) + i + j] - a[(control & 3) * 4 + j]);
}
}
memcpy(c, r, 16);
__builtin_memcpy(c, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pabsb.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ void(pabsb)(uint8_t a[16], const int8_t b[16]) {
for (i = 0; i < 16; ++i) {
r[i] = ABS(b[i]);
}
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pabsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ void(pabsd)(uint32_t a[4], const int32_t b[4]) {
for (i = 0; i < 4; ++i) {
r[i] = b[i] >= 0 ? b[i] : -(uint32_t)b[i];
}
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pabsw.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ void(pabsw)(uint16_t a[8], const int16_t b[8]) {
for (i = 0; i < 8; ++i) {
r[i] = ABS(b[i]);
}
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/packsswb.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ void(packsswb)(int8_t a[16], const int16_t b[8], const int16_t c[8]) {
int8_t r[16];
for (i = 0; i < 8; ++i) r[i + 0] = MIN(INT8_MAX, MAX(INT8_MIN, b[i]));
for (i = 0; i < 8; ++i) r[i + 8] = MIN(INT8_MAX, MAX(INT8_MIN, c[i]));
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/packusdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ void(packusdw)(uint16_t a[8], const int32_t b[4], const int32_t c[4]) {
uint16_t r[8];
for (i = 0; i < 4; ++i) r[i + 0] = MIN(UINT16_MAX, MAX(UINT16_MIN, b[i]));
for (i = 0; i < 4; ++i) r[i + 4] = MIN(UINT16_MAX, MAX(UINT16_MIN, c[i]));
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/packuswb.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ void(packuswb)(uint8_t a[16], const int16_t b[8], const int16_t c[8]) {
uint8_t r[16];
for (i = 0; i < 8; ++i) r[i + 0] = MIN(UINT8_MAX, MAX(UINT8_MIN, b[i]));
for (i = 0; i < 8; ++i) r[i + 8] = MIN(UINT8_MAX, MAX(UINT8_MIN, c[i]));
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/paddb.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ void(paddb)(int8_t a[16], const int8_t b[16], const int8_t c[16]) {
unsigned i;
int8_t r[16];
for (i = 0; i < 16; ++i) r[i] = b[i] + c[i];
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/paddd.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ void(paddd)(uint32_t a[4], const uint32_t b[4], const uint32_t c[4]) {
for (i = 0; i < 4; ++i) {
r[i] = b[i] + c[i];
}
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/paddq.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ void(paddq)(uint64_t a[2], const uint64_t b[2], const uint64_t c[2]) {
unsigned i;
uint64_t r[2];
for (i = 0; i < 2; ++i) r[i] = b[i] + c[i];
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/paddsb.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ void(paddsb)(int8_t a[16], const int8_t b[16], const int8_t c[16]) {
for (i = 0; i < 16; ++i) {
r[i] = MIN(INT8_MAX, MAX(INT8_MIN, b[i] + c[i]));
}
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/paddsw.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ void(paddsw)(int16_t a[8], const int16_t b[8], const int16_t c[8]) {
for (i = 0; i < 8; ++i) {
r[i] = MIN(SHRT_MAX, MAX(SHRT_MIN, b[i] + c[i]));
}
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/paddusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ void(paddusb)(uint8_t a[16], const uint8_t b[16], const uint8_t c[16]) {
for (i = 0; i < 16; ++i) {
r[i] = MIN(UINT8_MAX, b[i] + c[i]);
}
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/paddusw.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ void(paddusw)(uint16_t a[8], const uint16_t b[8], const uint16_t c[8]) {
for (i = 0; i < 8; ++i) {
r[i] = MIN(UINT16_MAX, b[i] + c[i]);
}
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/paddw.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ void(paddw)(int16_t a[8], const int16_t b[8], const int16_t c[8]) {
for (i = 0; i < 8; ++i) {
r[i] = b[i] + c[i];
}
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
8 changes: 4 additions & 4 deletions libc/intrin/palignr.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
*/
void(palignr)(void *c, const void *b, const void *a, unsigned long i) {
char t[48];
memcpy(t, a, 16);
memcpy(t + 16, b, 16);
memset(t + 32, 0, 16);
memcpy(c, t + MIN(i, 32), 16);
__builtin_memcpy(t, a, 16);
__builtin_memcpy(t + 16, b, 16);
__builtin_memset(t + 32, 0, 16);
__builtin_memcpy(c, t + MIN(i, 32), 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pavgb.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ void(pavgb)(uint8_t a[16], const uint8_t b[16], const uint8_t c[16]) {
for (i = 0; i < 16; ++i) {
r[i] = (b[i] + c[i] + 1) >> 1;
}
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pavgw.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ void(pavgw)(uint16_t a[8], const uint16_t b[8], const uint16_t c[8]) {
for (i = 0; i < 8; ++i) {
r[i] = (b[i] + c[i] + 1) >> 1;
}
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pcmpeqb.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ void(pcmpeqb)(uint8_t a[16], const uint8_t b[16], const uint8_t c[16]) {
unsigned i;
uint8_t r[16];
for (i = 0; i < 16; ++i) r[i] = -(b[i] == c[i]);
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pcmpeqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ void(pcmpeqd)(int32_t a[4], const int32_t b[4], const int32_t c[4]) {
unsigned i;
int32_t r[4];
for (i = 0; i < 4; ++i) r[i] = -(b[i] == c[i]);
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pcmpeqw.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ void(pcmpeqw)(int16_t a[8], const int16_t b[8], const int16_t c[8]) {
unsigned i;
int16_t r[8];
for (i = 0; i < 8; ++i) r[i] = -(b[i] == c[i]);
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pcmpgtb.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ void(pcmpgtb)(int8_t a[16], const int8_t b[16], const int8_t c[16]) {
unsigned i;
int8_t r[16];
for (i = 0; i < 16; ++i) r[i] = -(b[i] > c[i]);
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pcmpgtd.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ void(pcmpgtd)(int32_t a[4], const int32_t b[4], const int32_t c[4]) {
unsigned i;
int32_t r[4];
for (i = 0; i < 4; ++i) r[i] = -(b[i] > c[i]);
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pcmpgtw.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ void(pcmpgtw)(int16_t a[8], const int16_t b[8], const int16_t c[8]) {
unsigned i;
int16_t r[8];
for (i = 0; i < 8; ++i) r[i] = -(b[i] > c[i]);
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/phaddd.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ void(phaddd)(uint32_t a[4], const uint32_t b[4], const uint32_t c[4]) {
t[1] = b[2] + b[3];
t[2] = c[0] + c[1];
t[3] = c[2] + c[3];
memcpy(a, t, sizeof(t));
__builtin_memcpy(a, t, sizeof(t));
}
2 changes: 1 addition & 1 deletion libc/intrin/phaddw.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ void(phaddw)(int16_t a[8], const int16_t b[8], const int16_t c[8]) {
t[5] = c[2] + c[3];
t[6] = c[4] + c[5];
t[7] = c[6] + c[7];
memcpy(a, t, sizeof(t));
__builtin_memcpy(a, t, sizeof(t));
}
2 changes: 1 addition & 1 deletion libc/intrin/phsubd.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ void(phsubd)(uint32_t a[4], const uint32_t b[4], const uint32_t c[4]) {
t[1] = b[2] - b[3];
t[2] = c[0] - c[1];
t[3] = c[2] - c[3];
memcpy(a, t, sizeof(t));
__builtin_memcpy(a, t, sizeof(t));
}
2 changes: 1 addition & 1 deletion libc/intrin/phsubw.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ void(phsubw)(int16_t a[8], const int16_t b[8], const int16_t c[8]) {
t[5] = c[2] - c[3];
t[6] = c[4] - c[5];
t[7] = c[6] - c[7];
memcpy(a, t, sizeof(t));
__builtin_memcpy(a, t, sizeof(t));
}
2 changes: 1 addition & 1 deletion libc/intrin/pmaxsw.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ void(pmaxsw)(int16_t a[8], const int16_t b[8], const int16_t c[8]) {
for (i = 0; i < 8; ++i) {
r[i] = MAX(b[i], c[i]);
}
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pminsw.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ void(pminsw)(int16_t a[8], const int16_t b[8], const int16_t c[8]) {
for (i = 0; i < 8; ++i) {
r[i] = MIN(b[i], c[i]);
}
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pmulhrsw.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ void(pmulhrsw)(int16_t a[8], const int16_t b[8], const int16_t c[8]) {
unsigned i;
int16_t r[8];
for (i = 0; i < 8; ++i) r[i] = (((b[i] * c[i]) >> 14) + 1) >> 1;
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pmulhuw.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ void(pmulhuw)(uint16_t a[8], const uint16_t b[8], const uint16_t c[8]) {
x >>= 16;
r[i] = x;
}
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pmulhw.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ void(pmulhw)(int16_t a[8], const int16_t b[8], const int16_t c[8]) {
for (i = 0; i < 8; ++i) {
r[i] = ((b[i] * c[i]) & 0xffff0000) >> 16;
}
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pmulld.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ void(pmulld)(uint32_t a[4], const uint32_t b[4], const uint32_t c[4]) {
for (i = 0; i < 4; ++i) {
r[i] = b[i] * c[i];
}
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pmullw.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ void(pmullw)(int16_t a[8], const int16_t b[8], const int16_t c[8]) {
for (i = 0; i < 8; ++i) {
r[i] = b[i] * c[i];
}
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pshufb.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ void(pshufb)(uint8_t a[16], const uint8_t b[16], const uint8_t c[16]) {
unsigned i;
uint8_t r[16];
for (i = 0; i < 16; ++i) r[i] = (c[i] & 0x80) ? 0 : b[c[i] & 0x0F];
memcpy(a, r, 16);
__builtin_memcpy(a, r, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pshufd.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ void(pshufd)(int32_t b[4], const int32_t a[4], uint8_t m) {
t[1] = a[(m & 0b00001100) >> 2];
t[2] = a[(m & 0b00110000) >> 4];
t[3] = a[(m & 0b11000000) >> 6];
memcpy(b, t, 16);
__builtin_memcpy(b, t, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pslld.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ void(pslld)(uint32_t a[4], const uint32_t b[4], unsigned char c) {
a[i] = b[i] << c;
}
} else {
memset(a, 0, 16);
__builtin_memset(a, 0, 16);
}
}
2 changes: 1 addition & 1 deletion libc/intrin/pslldq.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ void(pslldq)(uint8_t b[16], const uint8_t a[16], unsigned long n) {
if (n > 16) n = 16;
for (i = 0; i < n; ++i) t[i] = 0;
for (i = 0; i < 16 - n; ++i) t[n + i] = a[i];
memcpy(b, t, 16);
__builtin_memcpy(b, t, 16);
}
2 changes: 1 addition & 1 deletion libc/intrin/pslldv.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ void(pslldv)(uint32_t a[4], const uint32_t b[4], const uint64_t c[2]) {
a[i] = b[i] << c[0];
}
} else {
memset(a, 0, 16);
__builtin_memset(a, 0, 16);
}
}
2 changes: 1 addition & 1 deletion libc/intrin/psllq.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ void(psllq)(uint64_t a[2], const uint64_t b[2], unsigned char c) {
a[i] = b[i] << c;
}
} else {
memset(a, 0, 16);
__builtin_memset(a, 0, 16);
}
}
2 changes: 1 addition & 1 deletion libc/intrin/psllqv.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ void(psllqv)(uint64_t a[2], const uint64_t b[2], const uint64_t c[2]) {
a[i] = b[i] << c[0];
}
} else {
memset(a, 0, 16);
__builtin_memset(a, 0, 16);
}
}
2 changes: 1 addition & 1 deletion libc/intrin/psllw.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ void(psllw)(uint16_t a[8], const uint16_t b[8], unsigned char c) {
a[i] = b[i] << c;
}
} else {
memset(a, 0, 16);
__builtin_memset(a, 0, 16);
}
}
2 changes: 1 addition & 1 deletion libc/intrin/psllwv.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ void(psllwv)(uint16_t a[8], const uint16_t b[8], const uint64_t c[2]) {
a[i] = b[i] << c[0];
}
} else {
memset(a, 0, 16);
__builtin_memset(a, 0, 16);
}
}
Loading

2 comments on commit f3e28aa

@szakharchenko
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you intend to upstream the mbedtls_mpi_sub_abs changes by any chance, or at least get them reviewed?

@jart
Copy link
Owner Author

@jart jart commented on f3e28aa Jul 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@szakharchenko If the MbedTLS authors want any of the changes I've made then they'll have them. I made further changes to subtraction in 398f0c1 PTAL

Please sign in to comment.