-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathOpenSSL-submodule-fixes-for-RISCV64-compilation.patch
143 lines (129 loc) · 6.22 KB
/
OpenSSL-submodule-fixes-for-RISCV64-compilation.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
From b7f3fefcc4d946c78c2ab0a500e969632e593723 Mon Sep 17 00:00:00 2001
From: Pete Batard <[email protected]>
Date: Mon, 27 Jan 2025 20:38:04 +0000
Subject: [PATCH] OpenSSL submodule fixes for RISCV64 compilation
---
crypto/ec/curve448/curve448.c | 2 +-
crypto/ec/curve448/point_448.h | 2 +-
crypto/ec/ec_ameth.c | 3 ++-
crypto/evp/evp_enc.c | 2 +-
providers/implementations/include/prov/ciphercommon.h | 2 +-
providers/implementations/include/prov/digestcommon.h | 2 +-
providers/implementations/macs/hmac_prov.c | 2 +-
providers/implementations/signature/ecdsa_sig.c | 2 +-
providers/implementations/signature/rsa_sig.c | 2 +-
9 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/crypto/ec/curve448/curve448.c b/crypto/ec/curve448/curve448.c
index 6928d9693c..7ddd617a73 100644
--- a/crypto/ec/curve448/curve448.c
+++ b/crypto/ec/curve448/curve448.c
@@ -509,7 +509,7 @@ struct smvt_control {
int power, addend;
};
-#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3))
+#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)) && !defined(_M_RISCV64) && !defined (__riscv)
# define NUMTRAILINGZEROS __builtin_ctz
#else
# define NUMTRAILINGZEROS numtrailingzeros
diff --git a/crypto/ec/curve448/point_448.h b/crypto/ec/curve448/point_448.h
index e67ea68044..72536c2471 100644
--- a/crypto/ec/curve448/point_448.h
+++ b/crypto/ec/curve448/point_448.h
@@ -181,7 +181,7 @@ static ossl_inline void curve448_scalar_copy(curve448_scalar_t out,
static ossl_inline void curve448_point_copy(curve448_point_t a,
const curve448_point_t b)
{
- *a = *b;
+ memcpy(a, b, sizeof(*a));
}
/*
diff --git a/crypto/ec/ec_ameth.c b/crypto/ec/ec_ameth.c
index d4348ff244..cac8672354 100644
--- a/crypto/ec/ec_ameth.c
+++ b/crypto/ec/ec_ameth.c
@@ -161,12 +161,13 @@ static int eckey_priv_decode_ex(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8,
static int eckey_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
{
- EC_KEY ec_key = *(pkey->pkey.ec);
+ EC_KEY ec_key;
unsigned char *ep = NULL;
int eplen, ptype;
void *pval;
unsigned int old_flags;
+ memcpy(&ec_key, pkey->pkey.ec, sizeof(ec_key));
if (!eckey_param2type(&ptype, &pval, &ec_key)) {
ERR_raise(ERR_LIB_EC, EC_R_DECODE_ERROR);
return 0;
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c
index 4e6f83e3d0..6cac709644 100644
--- a/crypto/evp/evp_enc.c
+++ b/crypto/evp/evp_enc.c
@@ -1423,7 +1423,7 @@ int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in)
EVP_CIPHER_CTX_reset(out);
- *out = *in;
+ memcpy(out, in, sizeof(*out));
out->algctx = NULL;
if (in->fetched_cipher != NULL && !EVP_CIPHER_up_ref(in->fetched_cipher)) {
diff --git a/providers/implementations/include/prov/ciphercommon.h b/providers/implementations/include/prov/ciphercommon.h
index aacd49707f..03c25cbb1f 100644
--- a/providers/implementations/include/prov/ciphercommon.h
+++ b/providers/implementations/include/prov/ciphercommon.h
@@ -317,7 +317,7 @@ static void name(PROV_CIPHER_CTX *dst, const PROV_CIPHER_CTX *src) \
CTX_TYPE *sctx = (CTX_TYPE *)src; \
CTX_TYPE *dctx = (CTX_TYPE *)dst; \
\
- *dctx = *sctx; \
+ memcpy(dctx, sctx, sizeof(*dctx)); \
dst->ks = &dctx->ks.ks; \
}
diff --git a/providers/implementations/include/prov/digestcommon.h b/providers/implementations/include/prov/digestcommon.h
index abdb8bb2ad..7e299501c4 100644
--- a/providers/implementations/include/prov/digestcommon.h
+++ b/providers/implementations/include/prov/digestcommon.h
@@ -67,7 +67,7 @@ static void *name##_dupctx(void *ctx) \
CTX *in = (CTX *)ctx; \
CTX *ret = ossl_prov_is_running() ? OPENSSL_malloc(sizeof(*ret)) : NULL; \
if (ret != NULL) \
- *ret = *in; \
+ memcpy(ret, in, sizeof(*ret)); \
return ret; \
} \
PROV_FUNC_DIGEST_FINAL(name, dgstsize, fin) \
diff --git a/providers/implementations/macs/hmac_prov.c b/providers/implementations/macs/hmac_prov.c
index 52ebb08b8f..4bfe4ca675 100644
--- a/providers/implementations/macs/hmac_prov.c
+++ b/providers/implementations/macs/hmac_prov.c
@@ -112,7 +112,7 @@ static void *hmac_dup(void *vsrc)
return NULL;
ctx = dst->ctx;
- *dst = *src;
+ memcpy(dst, src, sizeof(*dst));
dst->ctx = ctx;
dst->key = NULL;
memset(&dst->digest, 0, sizeof(dst->digest));
diff --git a/providers/implementations/signature/ecdsa_sig.c b/providers/implementations/signature/ecdsa_sig.c
index 865d49d100..472add01f2 100644
--- a/providers/implementations/signature/ecdsa_sig.c
+++ b/providers/implementations/signature/ecdsa_sig.c
@@ -399,7 +399,7 @@ static void *ecdsa_dupctx(void *vctx)
if (dstctx == NULL)
return NULL;
- *dstctx = *srcctx;
+ memcpy(dstctx, srcctx, sizeof(*dstctx));
dstctx->ec = NULL;
dstctx->md = NULL;
dstctx->mdctx = NULL;
diff --git a/providers/implementations/signature/rsa_sig.c b/providers/implementations/signature/rsa_sig.c
index 919ef17269..540bea8814 100644
--- a/providers/implementations/signature/rsa_sig.c
+++ b/providers/implementations/signature/rsa_sig.c
@@ -994,7 +994,7 @@ static void *rsa_dupctx(void *vprsactx)
return NULL;
}
- *dstctx = *srcctx;
+ memcpy(dstctx, srcctx, sizeof(*dstctx));
dstctx->rsa = NULL;
dstctx->md = NULL;
dstctx->mgf1_md = NULL;
--
2.45.2.windows.1