From 46394bd631ee051753e91d57e9c537413dd360a6 Mon Sep 17 00:00:00 2001 From: Justin W Smith <103147162+justsmth@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:44:36 -0400 Subject: [PATCH 1/2] Quell static-analysis concern about div-by-0 (#1866) ### Issues: Addresses #1856 ### Description of changes: Clarify pkcs8 logic so it doesn't trip up static analysis. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license. --- crypto/pkcs8/pkcs8.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crypto/pkcs8/pkcs8.c b/crypto/pkcs8/pkcs8.c index 4bc337bfd6..9cea6471c4 100644 --- a/crypto/pkcs8/pkcs8.c +++ b/crypto/pkcs8/pkcs8.c @@ -167,8 +167,11 @@ int pkcs12_key_gen(const char *pass, size_t pass_len, const uint8_t *salt, for (size_t i = 0; i < S_len; i++) { I[i] = salt[i % salt_len]; } - for (size_t i = 0; i < P_len; i++) { - I[i + S_len] = pass_raw[i % pass_raw_len]; + // P_len would be 0 in this case, but static analyzers don't always see that + if(pass_raw_len > 0) { + for (size_t i = 0; i < P_len; i++) { + I[i + S_len] = pass_raw[i % pass_raw_len]; + } } while (out_len != 0) { From 9c8bd6d7b8adccdd8af4242e074633ef09b5ecdf Mon Sep 17 00:00:00 2001 From: torben-hansen <50673096+torben-hansen@users.noreply.github.com> Date: Fri, 20 Sep 2024 13:15:23 -0700 Subject: [PATCH 2/2] Update s2n-bignum subtree (#1865) The list that tracks which files from s2n-bignum are used in AWS-LC was not complete. I dunno why this pulls in +84 commits. But since it's only a license change, I'm going to simply squash. --- third_party/s2n-bignum/arm/fastmul/bignum_emontredc_8n_neon.S | 2 +- third_party/s2n-bignum/arm/fastmul/bignum_kmul_16_32_neon.S | 2 +- third_party/s2n-bignum/arm/fastmul/bignum_kmul_32_64_neon.S | 2 +- third_party/s2n-bignum/arm/fastmul/bignum_ksqr_16_32_neon.S | 2 +- third_party/s2n-bignum/arm/fastmul/bignum_ksqr_32_64_neon.S | 2 +- third_party/s2n-bignum/x86_att/curve25519/bignum_madd_n25519.S | 2 +- .../s2n-bignum/x86_att/curve25519/bignum_madd_n25519_alt.S | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/third_party/s2n-bignum/arm/fastmul/bignum_emontredc_8n_neon.S b/third_party/s2n-bignum/arm/fastmul/bignum_emontredc_8n_neon.S index 1fc7af3984..342b844dd6 100644 --- a/third_party/s2n-bignum/arm/fastmul/bignum_emontredc_8n_neon.S +++ b/third_party/s2n-bignum/arm/fastmul/bignum_emontredc_8n_neon.S @@ -1,5 +1,5 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 OR ISC +// SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT-0 // ---------------------------------------------------------------------------- // Extend Montgomery reduce in 8-digit blocks, results in input-output buffer diff --git a/third_party/s2n-bignum/arm/fastmul/bignum_kmul_16_32_neon.S b/third_party/s2n-bignum/arm/fastmul/bignum_kmul_16_32_neon.S index a3cb89bda6..70a8311fcb 100644 --- a/third_party/s2n-bignum/arm/fastmul/bignum_kmul_16_32_neon.S +++ b/third_party/s2n-bignum/arm/fastmul/bignum_kmul_16_32_neon.S @@ -1,5 +1,5 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 OR ISC +// SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT-0 // ---------------------------------------------------------------------------- // Multiply z := x * y diff --git a/third_party/s2n-bignum/arm/fastmul/bignum_kmul_32_64_neon.S b/third_party/s2n-bignum/arm/fastmul/bignum_kmul_32_64_neon.S index ce17e8fbb1..fc716cbea8 100644 --- a/third_party/s2n-bignum/arm/fastmul/bignum_kmul_32_64_neon.S +++ b/third_party/s2n-bignum/arm/fastmul/bignum_kmul_32_64_neon.S @@ -1,5 +1,5 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 OR ISC +// SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT-0 // ---------------------------------------------------------------------------- // Multiply z := x * y diff --git a/third_party/s2n-bignum/arm/fastmul/bignum_ksqr_16_32_neon.S b/third_party/s2n-bignum/arm/fastmul/bignum_ksqr_16_32_neon.S index bc7fca0691..6be2bcb384 100644 --- a/third_party/s2n-bignum/arm/fastmul/bignum_ksqr_16_32_neon.S +++ b/third_party/s2n-bignum/arm/fastmul/bignum_ksqr_16_32_neon.S @@ -1,5 +1,5 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 OR ISC +// SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT-0 // ---------------------------------------------------------------------------- // Square, z := x^2 diff --git a/third_party/s2n-bignum/arm/fastmul/bignum_ksqr_32_64_neon.S b/third_party/s2n-bignum/arm/fastmul/bignum_ksqr_32_64_neon.S index 83e611c5bc..0419764233 100644 --- a/third_party/s2n-bignum/arm/fastmul/bignum_ksqr_32_64_neon.S +++ b/third_party/s2n-bignum/arm/fastmul/bignum_ksqr_32_64_neon.S @@ -1,5 +1,5 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 OR ISC +// SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT-0 // ---------------------------------------------------------------------------- // Square, z := x^2 diff --git a/third_party/s2n-bignum/x86_att/curve25519/bignum_madd_n25519.S b/third_party/s2n-bignum/x86_att/curve25519/bignum_madd_n25519.S index 6e1e95e3f1..5ec8de2de2 100644 --- a/third_party/s2n-bignum/x86_att/curve25519/bignum_madd_n25519.S +++ b/third_party/s2n-bignum/x86_att/curve25519/bignum_madd_n25519.S @@ -1,5 +1,5 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 OR ISC +// SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT-0 // ---------------------------------------------------------------------------- // Multiply-add modulo the order of the curve25519/edwards25519 basepoint diff --git a/third_party/s2n-bignum/x86_att/curve25519/bignum_madd_n25519_alt.S b/third_party/s2n-bignum/x86_att/curve25519/bignum_madd_n25519_alt.S index 14d7c23954..f264b79c29 100644 --- a/third_party/s2n-bignum/x86_att/curve25519/bignum_madd_n25519_alt.S +++ b/third_party/s2n-bignum/x86_att/curve25519/bignum_madd_n25519_alt.S @@ -1,5 +1,5 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 OR ISC +// SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT-0 // ---------------------------------------------------------------------------- // Multiply-add modulo the order of the curve25519/edwards25519 basepoint