Skip to content

Commit

Permalink
Merge branch 'main' into ml-dsa
Browse files Browse the repository at this point in the history
  • Loading branch information
fpseverino authored Nov 18, 2024
2 parents 0ac196b + b6a32eb commit 654953e
Show file tree
Hide file tree
Showing 266 changed files with 3,908 additions and 1,310 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/BUG_REPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ about: If something isn't working as expected
### New Issue Checklist

- [ ] I'm using the latest version of Swift Crypto (`main` branch)
- [ ] I read the [Contribution Guidelines](https://github.com/apple/swift-crypto/blob/master/CONTRIBUTING.md)
- [ ] I read the [Contribution Guidelines](https://github.com/apple/swift-crypto/blob/main/CONTRIBUTING.md)
- [ ] I searched for [existing GitHub issues](https://github.com/apple/swift-crypto/issues)

### Expected behavior
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/QUESTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ about: Not sure how something works or how to implement some functionality? Ask

### Question Checklist

- [ ] I'm using the latest version of Swift Crypto (master branch)
- [ ] I read the [Contribution Guidelines](https://github.com/apple/swift-crypto/blob/master/CONTRIBUTING.md)
- [ ] I'm using the latest version of Swift Crypto (main branch)
- [ ] I read the [Contribution Guidelines](https://github.com/apple/swift-crypto/blob/main/CONTRIBUTING.md)
- [ ] I searched for [existing GitHub issues](https://github.com/apple/swift-crypto/issues)

### Question Subject
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/REGRESSION.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ about: If a recent release broke a feature (Please make sure you know the last k

### New Regression Checklist

- [ ] I'm using the latest version of Swift Crypto (master branch)
- [ ] I read the [Contribution Guidelines](https://github.com/apple/swift-crypto/blob/master/CONTRIBUTING.md)
- [ ] I'm using the latest version of Swift Crypto (main branch)
- [ ] I read the [Contribution Guidelines](https://github.com/apple/swift-crypto/blob/main/CONTRIBUTING.md)
- [ ] I searched for [existing GitHub issues](https://github.com/apple/swift-crypto/issues)

### Regression Information
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Main

on:
push:
branches: [main]
schedule:
- cron: "0 8,20 * * *"

jobs:
unit-tests:
name: Unit tests
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
with:
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"

cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
41 changes: 41 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: PR

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
soundness:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
with:
license_header_check_project_name: "SwiftCrypto"
format_check_enabled: false
docs_check_enabled: false

cmake-lists:
name: Check cmake lists
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
with:
name: "Check cmake lists"
matrix_linux_command: ./scripts/check-cmake-lists.sh

unit-tests:
name: Unit tests
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
with:
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
windows_6_0_enabled: true
windows_nightly_6_0_enabled: true
windows_nightly_main_enabled: true
windows_6_0_arguments_override: "--explicit-target-dependency-import-check error"
windows_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"

cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
18 changes: 18 additions & 0 deletions .github/workflows/pull_request_label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: PR label

on:
pull_request:
types: [labeled, unlabeled, opened, reopened, synchronize]

jobs:
semver-label-check:
name: Semantic Version label check
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Check for Semantic Version label
uses: apple/swift-nio/.github/actions/pull_request_semver_label_checker@main
48 changes: 48 additions & 0 deletions .licenseignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.gitignore
**/.gitignore
.licenseignore
.unacceptablelanguageignore
.gitattributes
.git-blame-ignore-revs
.mailfilter
.mailmap
.spi.yml
.swift-format
.editorconfig
.github/*
*.md
*.txt
*.yml
*.yaml
*.json
Package.swift
**/Package.swift
Package@-*.swift
**/Package@-*.swift
Package.resolved
**/Package.resolved
Makefile
*.modulemap
**/*.modulemap
**/*.docc/*
*.xcprivacy
**/*.xcprivacy
*.symlink
**/*.symlink
Dockerfile
**/Dockerfile
Snippets/*
dev/git.commit.template
dev/update-benchmark-thresholds
*.crt
**/*.crt
*.pem
**/*.pem
*.der
**/*.der
.swiftformat
Sources/CCryptoBoringSSL/*
**/*.swift.gyb
scripts/*.patch
scripts/gyb
scripts/gyb.py
4 changes: 4 additions & 0 deletions .spi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: 1
builder:
configs:
- documentation_targets: [Crypto]
1 change: 1 addition & 0 deletions .unacceptablelanguageignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sources/CCryptoBoringSSL/*
5 changes: 0 additions & 5 deletions .xcodesamplecode.plist

This file was deleted.

6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
## See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
##
## SPDX-License-Identifier: Apache-2.0
##
Expand All @@ -31,6 +31,10 @@ endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)

set(SWIFT_CRYPTO_COMPILE_OPTIONS
-package-name com.apple.swift-crypto
)

option(BUILD_SHARED_LIBS "Build shared libraries by default" YES)

if(BUILD_SHARED_LIBS)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ components that this product depends on.
This product contains test vectors from Google's wycheproof project.

* LICENSE (Apache License 2.0):
* https://github.com/google/wycheproof/blob/master/LICENSE
* https://github.com/C2SP/wycheproof/blob/31387e2cd596587c859c611027b6a44d2e2b65ff/LICENSE
* HOMEPAGE:
* https://github.com/google/wycheproof

Expand Down
7 changes: 4 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.md for the list of SwiftCrypto project authors
// See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand All @@ -20,7 +20,7 @@
// Sources/CCryptoBoringSSL directory. The source repository is at
// https://boringssl.googlesource.com/boringssl.
//
// BoringSSL Commit: 6a2ccdcc2ed1d37a43a2183658d2ae61fd5ce208
// BoringSSL Commit: 2587c4974dbe9872451151c8e975f58567a1ce0d

import PackageDescription

Expand Down Expand Up @@ -135,7 +135,7 @@ let package = Package(
"Signatures/ECDSA.swift.gyb",
],
resources: privacyManifestResource,
swiftSettings: swiftSettings + [.define("MODULE_IS_CRYPTO")]
swiftSettings: swiftSettings
),
.target(
name: "_CryptoExtras",
Expand Down Expand Up @@ -173,6 +173,7 @@ let package = Package(
swiftSettings: swiftSettings
),
.testTarget(name: "_CryptoExtrasTests", dependencies: ["_CryptoExtras"]),
.testTarget(name: "CryptoBoringWrapperTests", dependencies: ["CryptoBoringWrapper"]),
],
cxxLanguageStandard: .cxx11
)
10 changes: 9 additions & 1 deletion Sources/CCryptoBoringSSL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
## See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
##
## SPDX-License-Identifier: Apache-2.0
##
Expand Down Expand Up @@ -165,9 +165,17 @@ add_library(CCryptoBoringSSL STATIC
"crypto/refcount.c"
"crypto/rsa_extra/rsa_asn1.c"
"crypto/rsa_extra/rsa_crypt.c"
"crypto/rsa_extra/rsa_extra.c"
"crypto/rsa_extra/rsa_print.c"
"crypto/sha/sha1.c"
"crypto/sha/sha256.c"
"crypto/sha/sha512.c"
"crypto/siphash/siphash.c"
"crypto/slhdsa/fors.c"
"crypto/slhdsa/merkle.c"
"crypto/slhdsa/slhdsa.c"
"crypto/slhdsa/thash.c"
"crypto/slhdsa/wots.c"
"crypto/spx/spx.c"
"crypto/spx/spx_address.c"
"crypto/spx/spx_fors.c"
Expand Down
6 changes: 6 additions & 0 deletions Sources/CCryptoBoringSSL/crypto/bcm_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include <CCryptoBoringSSL_base.h>

#include <stdio.h>

// Provided by libcrypto, called from BCM

#if defined(__cplusplus)
Expand Down Expand Up @@ -105,6 +107,10 @@ OPENSSL_EXPORT uint64_t CRYPTO_get_fork_generation(void);
OPENSSL_EXPORT void CRYPTO_fork_detect_force_madv_wipeonfork_for_testing(
int on);

// CRYPTO_get_stderr returns stderr. This function exists to avoid BCM needing
// a data dependency on libc.
FILE *CRYPTO_get_stderr(void);


#if defined(__cplusplus)
} // extern C
Expand Down
4 changes: 4 additions & 0 deletions Sources/CCryptoBoringSSL/crypto/bio/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,11 @@ static long conn_callback_ctrl(BIO *bio, int cmd, bio_info_cb fp) {
// convention.
OPENSSL_MSVC_PRAGMA(warning(push))
OPENSSL_MSVC_PRAGMA(warning(disable : 4191))
OPENSSL_CLANG_PRAGMA("clang diagnostic push")
OPENSSL_CLANG_PRAGMA("clang diagnostic ignored \"-Wunknown-warning-option\"")
OPENSSL_CLANG_PRAGMA("clang diagnostic ignored \"-Wcast-function-type\"")
data->info_callback = (int (*)(const struct bio_st *, int, int))fp;
OPENSSL_CLANG_PRAGMA("clang diagnostic pop")
OPENSSL_MSVC_PRAGMA(warning(pop))
break;
default:
Expand Down
1 change: 1 addition & 0 deletions Sources/CCryptoBoringSSL/crypto/cipher_extra/e_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ static int aead_tls_get_iv(const EVP_AEAD_CTX *ctx, const uint8_t **out_iv,
const AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)&ctx->state;
const size_t iv_len = EVP_CIPHER_CTX_iv_length(&tls_ctx->cipher_ctx);
if (iv_len <= 1) {
OPENSSL_PUT_ERROR(CIPHER, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
return 0;
}

Expand Down
3 changes: 3 additions & 0 deletions Sources/CCryptoBoringSSL/crypto/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <CCryptoBoringSSL_crypto.h>

#include <assert.h>
#include <stdio.h>

#include "fipsmodule/rand/internal.h"
#include "bcm_support.h"
Expand Down Expand Up @@ -186,3 +187,5 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings) {
}

void OPENSSL_cleanup(void) {}

FILE *CRYPTO_get_stderr(void) { return stderr; }
2 changes: 0 additions & 2 deletions Sources/CCryptoBoringSSL/crypto/dsa/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ struct dsa_st {
CRYPTO_EX_DATA ex_data;
};

#define OPENSSL_DSA_MAX_MODULUS_BITS 10000

// dsa_check_key performs cheap self-checks on |dsa|, and ensures it is within
// DoS bounds. It returns one on success and zero on error.
int dsa_check_key(const DSA *dsa);
Expand Down
35 changes: 35 additions & 0 deletions Sources/CCryptoBoringSSL/crypto/ec_extra/ec_asn1.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,41 @@ int i2d_ECPrivateKey(const EC_KEY *key, uint8_t **outp) {
return CBB_finish_i2d(&cbb, outp);
}

EC_GROUP *d2i_ECPKParameters(EC_GROUP **out, const uint8_t **inp, long len) {
if (len < 0) {
return NULL;
}

CBS cbs;
CBS_init(&cbs, *inp, (size_t)len);
EC_GROUP *ret = EC_KEY_parse_parameters(&cbs);
if (ret == NULL) {
return NULL;
}

if (out != NULL) {
EC_GROUP_free(*out);
*out = ret;
}
*inp = CBS_data(&cbs);
return ret;
}

int i2d_ECPKParameters(const EC_GROUP *group, uint8_t **outp) {
if (group == NULL) {
OPENSSL_PUT_ERROR(EC, ERR_R_PASSED_NULL_PARAMETER);
return -1;
}

CBB cbb;
if (!CBB_init(&cbb, 0) || //
!EC_KEY_marshal_curve_name(&cbb, group)) {
CBB_cleanup(&cbb);
return -1;
}
return CBB_finish_i2d(&cbb, outp);
}

EC_KEY *d2i_ECParameters(EC_KEY **out_key, const uint8_t **inp, long len) {
if (len < 0) {
return NULL;
Expand Down
Loading

0 comments on commit 654953e

Please sign in to comment.