Skip to content

Commit a4cac33

Browse files
committed
Update to Go 1.20.7 and fix memory leak
1 parent 96c76ab commit a4cac33

File tree

2 files changed

+33
-21
lines changed

2 files changed

+33
-21
lines changed

config/versions.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"github.com/golang-fips/go": "go1.20-fips-release",
3-
"github.com/golang-fips/openssl-fips": "9051f24728fe7141015889776bc44949c2b4cf1e",
4-
"github.com/golang/go": "go1.20.6"
3+
"github.com/golang-fips/openssl-fips": "b175be2ccd46683a51cba60a9a2087b09593317d",
4+
"github.com/golang/go": "go1.20.7"
55
}

patches/001-initial-openssl-for-fips.patch

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,24 +2348,24 @@ index 8734dd03c1..22a104f338 100644
23482348
} else {
23492349
testCurve = elliptic.P384()
23502350
diff --git a/src/go.mod b/src/go.mod
2351-
index 4697da201c..a3891edd78 100644
2351+
index 4697da201c..791a04b0e5 100644
23522352
--- a/src/go.mod
23532353
+++ b/src/go.mod
23542354
@@ -3,6 +3,7 @@ module std
23552355
go 1.20
23562356

23572357
require (
2358-
+ github.com/golang-fips/openssl-fips v0.0.0-20230714114059-9051f24728fe
2358+
+ github.com/golang-fips/openssl-fips v0.0.0-20230801192317-b175be2ccd46
23592359
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a
23602360
golang.org/x/net v0.4.1-0.20230214201333-88ed8ca3307d
23612361
)
23622362
diff --git a/src/go.sum b/src/go.sum
2363-
index 625f2070b3..2e984ad481 100644
2363+
index 625f2070b3..8cbd8cfb33 100644
23642364
--- a/src/go.sum
23652365
+++ b/src/go.sum
23662366
@@ -1,3 +1,5 @@
2367-
+github.com/golang-fips/openssl-fips v0.0.0-20230714114059-9051f24728fe h1:Zr44HT3VYwYIkT72fyvaqWZN+sO2Saw++e+6PaXapN0=
2368-
+github.com/golang-fips/openssl-fips v0.0.0-20230714114059-9051f24728fe/go.mod h1:V2IU8imz/VkScnIbTOrdYsZ5R88ZFypCE0LzhRJ3HsI=
2367+
+github.com/golang-fips/openssl-fips v0.0.0-20230801192317-b175be2ccd46 h1:1oaM7kpYYlqwc6sIROINgj5fUW4CGZGEBwfzIc+TnJI=
2368+
+github.com/golang-fips/openssl-fips v0.0.0-20230801192317-b175be2ccd46/go.mod h1:V2IU8imz/VkScnIbTOrdYsZ5R88ZFypCE0LzhRJ3HsI=
23692369
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a h1:diz9pEYuTIuLMJLs3rGDkeaTsNyRs6duYdFyPAxzE/U=
23702370
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
23712371
golang.org/x/net v0.4.1-0.20230214201333-88ed8ca3307d h1:KHU/KRz6+/yWyRHEC24m7T5gou5VSh62duch955ktBY=
@@ -3539,7 +3539,7 @@ index 0000000000..a900b3f9e7
35393539
+#endif
35403540
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
35413541
+DEFINEFUNC(void, CRYPTO_set_locking_callback,
3542-
+ (void (*locking_function)(int mode, int n, const char *file, int line)),
3542+
+ (void (*locking_function)(int mode, int n, const char *file, int line)),
35433543
+ (locking_function))
35443544
+#else
35453545
+static inline void
@@ -3916,11 +3916,11 @@ index 0000000000..a900b3f9e7
39163916
+DEFINEFUNC(int, ECDSA_do_verify, (const uint8_t *arg0, size_t arg1, const GO_ECDSA_SIG *arg2, GO_EC_KEY *arg3), (arg0, arg1, arg2, arg3))
39173917
+DEFINEFUNC(size_t, ECDSA_size, (const GO_EC_KEY *arg0), (arg0))
39183918
+
3919-
+DEFINEFUNCINTERNAL(int, ECDSA_sign,
3919+
+DEFINEFUNCINTERNAL(int, ECDSA_sign,
39203920
+ (int type, const unsigned char *dgst, size_t dgstlen, unsigned char *sig, unsigned int *siglen, EC_KEY *eckey),
39213921
+ (type, dgst, dgstlen, sig, siglen, eckey))
39223922
+
3923-
+DEFINEFUNCINTERNAL(int, ECDSA_verify,
3923+
+DEFINEFUNCINTERNAL(int, ECDSA_verify,
39243924
+ (int type, const unsigned char *dgst, size_t dgstlen, const unsigned char *sig, unsigned int siglen, EC_KEY *eckey),
39253925
+ (type, dgst, dgstlen, sig, siglen, eckey))
39263926
+
@@ -4131,7 +4131,7 @@ index 0000000000..a900b3f9e7
41314131
+DEFINEFUNCINTERNAL(void, RSA_get0_factors,
41324132
+ (const GO_RSA *rsa, const GO_BIGNUM **p, const GO_BIGNUM **q),
41334133
+ (rsa, p, q))
4134-
+static inline void
4134+
+static inline void
41354135
+_goboringcrypto_RSA_get0_factors(const GO_RSA *rsa, const GO_BIGNUM **p, const GO_BIGNUM **q) {
41364136
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
41374137
+ if (p)
@@ -4146,7 +4146,7 @@ index 0000000000..a900b3f9e7
41464146
+DEFINEFUNCINTERNAL(void, RSA_get0_key,
41474147
+ (const GO_RSA *rsa, const GO_BIGNUM **n, const GO_BIGNUM **e, const GO_BIGNUM **d),
41484148
+ (rsa, n, e, d))
4149-
+static inline void
4149+
+static inline void
41504150
+_goboringcrypto_RSA_get0_key(const GO_RSA *rsa, const GO_BIGNUM **n, const GO_BIGNUM **e, const GO_BIGNUM **d) {
41514151
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
41524152
+ if (n)
@@ -4281,9 +4281,9 @@ index 0000000000..a900b3f9e7
42814281
+
42824282
+static inline int
42834283
+_goboringcrypto_EVP_PKEY_CTX_set_rsa_pss_saltlen(GO_EVP_PKEY_CTX * arg0, int arg1) {
4284-
+ return _goboringcrypto_EVP_PKEY_CTX_ctrl(arg0, EVP_PKEY_RSA,
4285-
+ (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY),
4286-
+ EVP_PKEY_CTRL_RSA_PSS_SALTLEN,
4284+
+ return _goboringcrypto_EVP_PKEY_CTX_ctrl(arg0, EVP_PKEY_RSA,
4285+
+ (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY),
4286+
+ EVP_PKEY_CTRL_RSA_PSS_SALTLEN,
42874287
+ arg1, NULL);
42884288
+}
42894289
+
@@ -5246,10 +5246,10 @@ index 0000000000..714d18f1e8
52465246
+}
52475247
diff --git a/src/vendor/github.com/golang-fips/openssl-fips/openssl/openssl_evp.c b/src/vendor/github.com/golang-fips/openssl-fips/openssl/openssl_evp.c
52485248
new file mode 100644
5249-
index 0000000000..76bac5bc01
5249+
index 0000000000..24a9615108
52505250
--- /dev/null
52515251
+++ b/src/vendor/github.com/golang-fips/openssl-fips/openssl/openssl_evp.c
5252-
@@ -0,0 +1,128 @@
5252+
@@ -0,0 +1,140 @@
52535253
+// +build linux
52545254
+// +build !android
52555255
+// +build !no_openssl
@@ -5295,7 +5295,11 @@ index 0000000000..76bac5bc01
52955295
+ GO_RSA *rsa_key) {
52965296
+ int ret = 0;
52975297
+ GO_EVP_PKEY *pk = _goboringcrypto_EVP_PKEY_new();
5298-
+ _goboringcrypto_EVP_PKEY_assign_RSA(pk, rsa_key);
5298+
+ if (!pk)
5299+
+ return 0;
5300+
+
5301+
+ if (!(_goboringcrypto_EVP_PKEY_set1_RSA(pk, rsa_key)))
5302+
+ goto err;
52995303
+
53005304
+ if (!ctx && !(ctx = _goboringcrypto_EVP_PKEY_CTX_new(pk, NULL)))
53015305
+ goto err;
@@ -5315,6 +5319,8 @@ index 0000000000..76bac5bc01
53155319
+err:
53165320
+ if (ctx)
53175321
+ _goboringcrypto_EVP_PKEY_CTX_free(ctx);
5322+
+ if (pk)
5323+
+ _goboringcrypto_EVP_PKEY_free(pk);
53185324
+
53195325
+ return ret;
53205326
+}
@@ -5355,7 +5361,11 @@ index 0000000000..76bac5bc01
53555361
+ int ret = 0;
53565362
+ EVP_PKEY_CTX *ctx;
53575363
+ GO_EVP_PKEY *pk = _goboringcrypto_EVP_PKEY_new();
5358-
+ _goboringcrypto_EVP_PKEY_assign_RSA(pk, rsa_key);
5364+
+ if (!pk)
5365+
+ return 0;
5366+
+
5367+
+ if (!(_goboringcrypto_EVP_PKEY_set1_RSA(pk, rsa_key)))
5368+
+ goto err;
53595369
+
53605370
+ if (!(ctx = _goboringcrypto_EVP_PKEY_CTX_new(pk, NULL)))
53615371
+ goto err;
@@ -5375,6 +5385,8 @@ index 0000000000..76bac5bc01
53755385
+err:
53765386
+ if (ctx)
53775387
+ _goboringcrypto_EVP_PKEY_CTX_free(ctx);
5388+
+ if (pk)
5389+
+ _goboringcrypto_EVP_PKEY_free(pk);
53785390
+
53795391
+ return ret;
53805392
+}
@@ -7152,11 +7164,11 @@ index cf82f3f64f..0b55cedc91 100644
71527164

71537165
type sha512Ctx struct {
71547166
diff --git a/src/vendor/modules.txt b/src/vendor/modules.txt
7155-
index 89a7c86c41..f4f12ecee2 100644
7167+
index 89a7c86c41..ced961d73d 100644
71567168
--- a/src/vendor/modules.txt
71577169
+++ b/src/vendor/modules.txt
71587170
@@ -1,3 +1,6 @@
7159-
+# github.com/golang-fips/openssl-fips v0.0.0-20230714114059-9051f24728fe
7171+
+# github.com/golang-fips/openssl-fips v0.0.0-20230801192317-b175be2ccd46
71607172
+## explicit; go 1.18
71617173
+github.com/golang-fips/openssl-fips/openssl
71627174
# golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a

0 commit comments

Comments
 (0)