Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/openssl/openssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steuer <patrick.steuer@de.ibm.com>2019-11-03 02:32:04 +0300
committerPatrick Steuer <patrick.steuer@de.ibm.com>2019-11-05 15:53:04 +0300
commit677c4a012a7e72b5f2dd239639034f01fad850bf (patch)
tree092195e1966385aab5aa66297dd2cef0ec911ac3 /include/internal
parent6376c229c44a355248db17e9f0bb2e4567a16d0d (diff)
s390x assembly pack: process x25519 and x448 non-canonical values
...in constant time. Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10339)
Diffstat (limited to 'include/internal')
-rw-r--r--include/internal/constant_time.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/internal/constant_time.h b/include/internal/constant_time.h
index d98dae9545..dc75e31df1 100644
--- a/include/internal/constant_time.h
+++ b/include/internal/constant_time.h
@@ -353,6 +353,34 @@ static ossl_inline void constant_time_cond_swap_64(uint64_t mask, uint64_t *a,
}
/*
+ * mask must be 0xFF or 0x00.
+ * "constant time" is per len.
+ *
+ * if (mask) {
+ * unsigned char tmp[len];
+ *
+ * memcpy(tmp, a, len);
+ * memcpy(a, b);
+ * memcpy(b, tmp);
+ * }
+ */
+static ossl_inline void constant_time_cond_swap_buff(unsigned char mask,
+ unsigned char *a,
+ unsigned char *b,
+ size_t len)
+{
+ size_t i;
+ unsigned char tmp;
+
+ for (i = 0; i < len; i++) {
+ tmp = a[i] ^ b[i];
+ tmp &= mask;
+ a[i] ^= tmp;
+ b[i] ^= tmp;
+ }
+}
+
+/*
* table is a two dimensional array of bytes. Each row has rowsize elements.
* Copies row number idx into out. rowsize and numrows are not considered
* private.