Skip to content

Commit 8aba2ef

Browse files
committed
Merge branch 'main' into fe_isnonzero_vartime
2 parents e7143af + 9cb93e0 commit 8aba2ef

39 files changed

+1355
-1080
lines changed

.github/workflows/ci.yml

+51-22
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ jobs:
151151
- i686-pc-windows-msvc
152152
- i686-unknown-linux-gnu
153153
- i686-unknown-linux-musl
154-
- powerpc-unknown-linux-gnu
155154
- riscv64gc-unknown-linux-gnu
156155
- wasm32-wasi
157156
- x86_64-pc-windows-gnu
@@ -174,10 +173,10 @@ jobs:
174173

175174
include:
176175
- target: aarch64-apple-darwin
177-
host_os: macos-13-xlarge
176+
host_os: macos-14
178177

179178
- target: aarch64-apple-ios
180-
host_os: macos-13
179+
host_os: macos-14
181180
# TODO: Run in the emulator.
182181
cargo_options: --no-run
183182

@@ -217,12 +216,44 @@ jobs:
217216
- target: i686-unknown-linux-musl
218217
host_os: ubuntu-22.04
219218

219+
- target: mips-unknown-linux-gnu
220+
mode: --release
221+
rust_channel: 1.71.0 # No prebuilt toolchain for later versions.
222+
host_os: ubuntu-22.04
223+
224+
- target: mips64el-unknown-linux-gnuabi64
225+
mode: --release
226+
rust_channel: 1.71.0 # No prebuilt toolchain for later versions.
227+
host_os: ubuntu-22.04
228+
229+
- target: mipsel-unknown-linux-gnu
230+
mode: --release
231+
rust_channel: 1.71.0 # No prebuilt toolchain for later versions.
232+
host_os: ubuntu-22.04
233+
220234
- target: powerpc-unknown-linux-gnu
235+
mode: --release
236+
rust_channel: stable
237+
host_os: ubuntu-22.04
238+
239+
- target: powerpc64-unknown-linux-gnu
240+
mode: --release
241+
rust_channel: stable
242+
host_os: ubuntu-22.04
243+
244+
- target: powerpc64le-unknown-linux-gnu
245+
mode: --release
246+
rust_channel: stable
221247
host_os: ubuntu-22.04
222248

223249
- target: riscv64gc-unknown-linux-gnu
224250
host_os: ubuntu-22.04
225251

252+
- target: s390x-unknown-linux-gnu
253+
mode: --release
254+
rust_channel: stable
255+
host_os: ubuntu-22.04
256+
226257
- target: wasm32-wasi
227258
host_os: ubuntu-22.04
228259

@@ -273,15 +304,14 @@ jobs:
273304
274305
# Check that all the needed symbol renaming was done.
275306
# TODO: Do this check on Windows too.
276-
# TODO: Check iOS too.
277-
# TODO: Do this on Apple-hosted release builds too; currently these fail with:
278-
# Unknown attribute kind (528)
279-
# (Producer: 'LLVM12.0.0-rust-1.54.0-nightly'
280-
# Reader: 'LLVM APPLE_1_1200.0.32.29_0')
281-
- if: ${{ matrix.target != 'aarch64-apple-ios' &&
282-
!contains(matrix.host_os, 'windows') &&
283-
(!contains(matrix.host_os, 'macos') || matrix.mode != '--release') }}
284-
run: mk/check-symbol-prefixes.sh --target=${{ matrix.target }}
307+
308+
- if: ${{ (matrix.target != 'aarch64-apple-ios' || matrix.rust_channel != '1.61.0') &&
309+
!contains(matrix.host_os, 'windows') }}
310+
run: rustup toolchain install --component=llvm-tools-preview ${{ matrix.rust_channel }}
311+
312+
- if: ${{ (matrix.target != 'aarch64-apple-ios' || matrix.rust_channel != '1.61.0') &&
313+
!contains(matrix.host_os, 'windows') }}
314+
run: mk/check-symbol-prefixes.sh +${{ matrix.rust_channel }} --target=${{ matrix.target }}
285315

286316
test-bench:
287317
# Don't run duplicate `push` jobs for the repo owner's PRs.
@@ -402,16 +432,14 @@ jobs:
402432
403433
# Check that all the needed symbol renaming was done.
404434
# TODO: Do this check on Windows too.
405-
# TODO: Check iOS too.
406-
# TODO: Do this on Apple-hosted release builds too; currently these fail with:
407-
# Unknown attribute kind (528)
408-
# (Producer: 'LLVM12.0.0-rust-1.54.0-nightly'
409-
# Reader: 'LLVM APPLE_1_1200.0.32.29_0')
410-
- if: ${{ matrix.target != 'aarch64-apple-ios' &&
411-
!contains(matrix.host_os, 'windows') &&
412-
(!contains(matrix.host_os, 'macos') || matrix.mode != '--release') }}
413-
run: mk/check-symbol-prefixes.sh --target=${{ matrix.target }}
414435

436+
- if: ${{ (matrix.target != 'aarch64-apple-ios' || matrix.rust_channel != '1.61.0') &&
437+
!contains(matrix.host_os, 'windows') }}
438+
run: rustup toolchain install --component=llvm-tools-preview ${{ matrix.rust_channel }}
439+
440+
- if: ${{ (matrix.target != 'aarch64-apple-ios' || matrix.rust_channel != '1.61.0') &&
441+
!contains(matrix.host_os, 'windows') }}
442+
run: mk/check-symbol-prefixes.sh +${{ matrix.rust_channel }} --target=${{ matrix.target }}
415443

416444
# The wasm32-unknown-unknown targets have a different set of feature sets and
417445
# an additional `webdriver` dimension.
@@ -465,7 +493,8 @@ jobs:
465493
466494
# Check that all the needed symbol renaming was done.
467495
# TODO: Do this check on Windows too.
468-
- run: mk/check-symbol-prefixes.sh --target=${{ matrix.target }}
496+
- run: rustup toolchain install --component=llvm-tools-preview ${{ matrix.rust_channel }}
497+
- run: mk/check-symbol-prefixes.sh +${{ matrix.rust_channel }} --target=${{ matrix.target }}
469498

470499
coverage:
471500
# Don't run duplicate `push` jobs for the repo owner's PRs.

Cargo.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repository = "https://github.com/briansmith/ring"
1414
rust-version = "1.61.0"
1515

1616
# Keep in sync with `links` below.
17-
version = "0.17.7"
17+
version = "0.17.8"
1818

1919
# Keep in sync with `version` above.
2020
#
@@ -23,7 +23,7 @@ version = "0.17.7"
2323
# build.rs uses this to derive the prefix for FFI symbols and the file names
2424
# of the FFI libraries, so it must be a valid identifier prefix and a valid
2525
# filename prefix.
26-
links = "ring_core_0_17_7"
26+
links = "ring_core_0_17_8"
2727

2828
include = [
2929
"LICENSE",
@@ -86,6 +86,7 @@ include = [
8686
"crypto/fipsmodule/modes/asm/ghash-x86.pl",
8787
"crypto/fipsmodule/modes/asm/ghash-x86_64.pl",
8888
"crypto/fipsmodule/modes/asm/ghashv8-armx.pl",
89+
"crypto/fipsmodule/modes/asm/aesv8-gcm-armv8.pl",
8990
"crypto/fipsmodule/sha/asm/sha256-armv4.pl",
9091
"crypto/fipsmodule/sha/asm/sha512-armv4.pl",
9192
"crypto/fipsmodule/sha/asm/sha512-armv8.pl",
@@ -181,7 +182,7 @@ spin = { version = "0.9.8", default-features = false, features = ["once"] }
181182
libc = { version = "0.2.148", default-features = false }
182183

183184
[target.'cfg(all(target_arch = "aarch64", target_os = "windows"))'.dependencies]
184-
windows-sys = { version = "0.48", features = ["Win32_Foundation", "Win32_System_Threading"] }
185+
windows-sys = { version = "0.52", features = ["Win32_Foundation", "Win32_System_Threading"] }
185186

186187
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
187188
wasm-bindgen-test = { version = "0.3.37", default-features = false }

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ need to be installed.
4343
Benchmarks
4444
----------
4545

46-
*ring*'s benchmarks are located in the `benches` folder of this repository. Because
46+
*ring*'s benchmarks are located in the `bench` folder of this repository. Because
4747
there is lots of platform-specific code in *ring*, and because *ring* chooses
4848
dynamically at runtime which optimized implementation of each crypto primitive
4949
to use, it is very difficult to publish a useful single set of benchmarks;

bench/aead.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,14 @@ impl aead::NonceSequence for NonceSequence {
7070
}
7171

7272
fn seal_in_place_separate_tag(c: &mut Criterion) {
73+
let mut group = c.benchmark_group("aead");
74+
7375
let rng = SystemRandom::new();
7476

7577
for &(alg_name, algorithm) in ALGORITHMS {
7678
for record_len in RECORD_LENGTHS {
77-
c.bench_with_input(
79+
group.throughput(criterion::Throughput::BytesDecimal(*record_len as _));
80+
group.bench_with_input(
7881
bench_id("seal_in_place_separate_tag", alg_name, *record_len),
7982
record_len,
8083
|b, record_len| {
@@ -97,11 +100,14 @@ fn seal_in_place_separate_tag(c: &mut Criterion) {
97100
}
98101

99102
fn open_in_place(c: &mut Criterion) {
103+
let mut group = c.benchmark_group("aead");
104+
100105
let rng = SystemRandom::new();
101106

102107
for &(alg_name, algorithm) in ALGORITHMS {
103108
for record_len in RECORD_LENGTHS {
104-
c.bench_with_input(
109+
group.throughput(criterion::Throughput::BytesDecimal(*record_len as _));
110+
group.bench_with_input(
105111
bench_id("open_in_place", alg_name, *record_len),
106112
record_len,
107113
|b, _record_len| {
@@ -140,7 +146,7 @@ fn open_in_place(c: &mut Criterion) {
140146
}
141147

142148
fn bench_id(func_name: &str, alg_name: &str, record_len: usize) -> BenchmarkId {
143-
BenchmarkId::new(format!("aead::{}::{}", alg_name, func_name), record_len)
149+
BenchmarkId::new(format!("{}::{}", alg_name, func_name), record_len)
144150
}
145151

146152
criterion_group!(aead, seal_in_place_separate_tag, open_in_place);

build.rs

+20-24
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const X86: &str = "x86";
3131
const X86_64: &str = "x86_64";
3232
const AARCH64: &str = "aarch64";
3333
const ARM: &str = "arm";
34+
const WASM32: &str = "wasm32";
3435

3536
#[rustfmt::skip]
3637
const RING_SRCS: &[(&[&str], &str)] = &[
@@ -93,6 +94,7 @@ const RING_SRCS: &[(&[&str], &str)] = &[
9394
(&[AARCH64], "crypto/fipsmodule/bn/asm/armv8-mont.pl"),
9495
(&[AARCH64], "crypto/fipsmodule/ec/asm/p256-armv8-asm.pl"),
9596
(&[AARCH64], "crypto/fipsmodule/modes/asm/ghash-neon-armv8.pl"),
97+
(&[AARCH64], "crypto/fipsmodule/modes/asm/aesv8-gcm-armv8.pl"),
9698
(&[AARCH64], SHA512_ARMV8),
9799
];
98100

@@ -111,18 +113,11 @@ fn cpp_flags(compiler: &cc::Tool) -> &'static [&'static str] {
111113
static NON_MSVC_FLAGS: &[&str] = &[
112114
"-fvisibility=hidden",
113115
"-std=c1x", // GCC 4.6 requires "c1x" instead of "c11"
114-
"-pedantic",
115116
"-Wall",
116-
"-Wextra",
117117
"-Wbad-function-cast",
118118
"-Wcast-align",
119119
"-Wcast-qual",
120120
"-Wconversion",
121-
"-Wenum-compare",
122-
"-Wfloat-equal",
123-
"-Wformat=2",
124-
"-Winline",
125-
"-Winvalid-pch",
126121
"-Wmissing-field-initializers",
127122
"-Wmissing-include-dirs",
128123
"-Wnested-externs",
@@ -133,7 +128,6 @@ fn cpp_flags(compiler: &cc::Tool) -> &'static [&'static str] {
133128
"-Wstrict-prototypes",
134129
"-Wundef",
135130
"-Wuninitialized",
136-
"-Wwrite-strings",
137131
];
138132
NON_MSVC_FLAGS
139133
} else {
@@ -162,63 +156,63 @@ fn cpp_flags(compiler: &cc::Tool) -> &'static [&'static str] {
162156
const ASM_TARGETS: &[AsmTarget] = &[
163157
AsmTarget {
164158
oss: LINUX_ABI,
165-
arch: "aarch64",
159+
arch: AARCH64,
166160
perlasm_format: "linux64",
167161
asm_extension: "S",
168162
preassemble: false,
169163
},
170164
AsmTarget {
171165
oss: LINUX_ABI,
172-
arch: "arm",
166+
arch: ARM,
173167
perlasm_format: "linux32",
174168
asm_extension: "S",
175169
preassemble: false,
176170
},
177171
AsmTarget {
178172
oss: LINUX_ABI,
179-
arch: "x86",
173+
arch: X86,
180174
perlasm_format: "elf",
181175
asm_extension: "S",
182176
preassemble: false,
183177
},
184178
AsmTarget {
185179
oss: LINUX_ABI,
186-
arch: "x86_64",
180+
arch: X86_64,
187181
perlasm_format: "elf",
188182
asm_extension: "S",
189183
preassemble: false,
190184
},
191185
AsmTarget {
192186
oss: MACOS_ABI,
193-
arch: "aarch64",
187+
arch: AARCH64,
194188
perlasm_format: "ios64",
195189
asm_extension: "S",
196190
preassemble: false,
197191
},
198192
AsmTarget {
199193
oss: MACOS_ABI,
200-
arch: "x86_64",
194+
arch: X86_64,
201195
perlasm_format: "macosx",
202196
asm_extension: "S",
203197
preassemble: false,
204198
},
205199
AsmTarget {
206200
oss: &[WINDOWS],
207-
arch: "x86",
201+
arch: X86,
208202
perlasm_format: "win32n",
209203
asm_extension: "asm",
210204
preassemble: true,
211205
},
212206
AsmTarget {
213207
oss: &[WINDOWS],
214-
arch: "x86_64",
208+
arch: X86_64,
215209
perlasm_format: "nasm",
216210
asm_extension: "asm",
217211
preassemble: true,
218212
},
219213
AsmTarget {
220214
oss: &[WINDOWS],
221-
arch: "aarch64",
215+
arch: AARCH64,
222216
perlasm_format: "win64",
223217
asm_extension: "S",
224218
preassemble: false,
@@ -264,8 +258,9 @@ const LINUX_ABI: &[&str] = &[
264258

265259
/// Operating systems that have the same ABI as macOS on every architecture
266260
/// mentioned in `ASM_TARGETS`.
267-
const MACOS_ABI: &[&str] = &["ios", "macos", "tvos"];
261+
const MACOS_ABI: &[&str] = &["ios", MACOS, "tvos"];
268262

263+
const MACOS: &str = "macos";
269264
const WINDOWS: &str = "windows";
270265

271266
/// Read an environment variable and tell Cargo that we depend on it.
@@ -588,7 +583,7 @@ fn configure_cc(c: &mut cc::Build, target: &Target, include_dir: &Path) {
588583
let _ = c.flag(f);
589584
}
590585

591-
if target.os.as_str() == "macos" {
586+
if target.os.as_str() == MACOS {
592587
// ``-gfull`` is required for Darwin's |-dead_strip|.
593588
let _ = c.flag("-gfull");
594589
} else if !compiler.is_like_msvc() {
@@ -602,8 +597,7 @@ fn configure_cc(c: &mut cc::Build, target: &Target, include_dir: &Path) {
602597
// Allow cross-compiling without a target sysroot for these targets.
603598
//
604599
// poly1305_vec.c requires <emmintrin.h> which requires <stdlib.h>.
605-
if (target.arch == "wasm32")
606-
|| (target.os == "linux" && target.is_musl && target.arch != "x86_64")
600+
if (target.arch == WASM32) || (target.os == "linux" && target.is_musl && target.arch != X86_64)
607601
{
608602
if let Ok(compiler) = c.try_get_compiler() {
609603
// TODO: Expand this to non-clang compilers in 0.17.0 if practical.
@@ -634,8 +628,8 @@ fn cc_asm(b: &cc::Build, file: &Path, out_file: &Path) -> Command {
634628

635629
fn nasm(file: &Path, arch: &str, include_dir: &Path, out_file: &Path) -> Command {
636630
let oformat = match arch {
637-
"x86_64" => "win64",
638-
"x86" => "win32",
631+
x if x == X86_64 => "win64",
632+
x if x == X86 => "win32",
639633
_ => panic!("unsupported arch: {}", arch),
640634
};
641635

@@ -742,7 +736,7 @@ fn perlasm(src_dst: &[(PathBuf, PathBuf)], asm_target: &AsmTarget) {
742736
src.to_string_lossy().into_owned(),
743737
asm_target.perlasm_format.to_owned(),
744738
];
745-
if asm_target.arch == "x86" {
739+
if asm_target.arch == X86 {
746740
args.push("-fPIC".into());
747741
args.push("-DOPENSSL_IA32_SSE2".into());
748742
}
@@ -943,6 +937,8 @@ fn prefix_all_symbols(pp: char, prefix_prefix: &str, prefix: &str) -> String {
943937
"gcm_init_avx",
944938
"gcm_init_clmul",
945939
"gcm_init_neon",
940+
"aes_gcm_enc_kernel",
941+
"aes_gcm_dec_kernel",
946942
"k25519Precomp",
947943
"limbs_mul_add_limb",
948944
"little_endian_bytes_from_scalar",

crypto/internal.h

+8
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@
132132
#include <stdalign.h>
133133
#endif
134134

135+
#if defined(__clang__) || defined(__GNUC__)
136+
#define RING_NOINLINE __attribute__((noinline))
137+
#elif defined(_MSC_VER)
138+
#define RING_NOINLINE __declspec(noinline)
139+
#else
140+
#define RING_NOINLINE
141+
#endif
142+
135143
// Some C compilers require a useless cast when dealing with arrays for the
136144
// reason explained in
137145
// https://gustedt.wordpress.com/2011/02/12/const-and-arrays/

0 commit comments

Comments
 (0)