From 2585b42e63eef1d72b58fd76a30c671ed0b54332 Mon Sep 17 00:00:00 2001 From: Roy7Kim Date: Wed, 15 Mar 2023 13:40:11 +0900 Subject: [PATCH] Bump to rust-ring 0.16.20 --- packaging/extern.patch | 51 +++++++++++++++++++++++++++++ packaging/rust-ring.manifest | 5 +++ packaging/rust-ring.spec | 77 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 packaging/extern.patch create mode 100644 packaging/rust-ring.manifest create mode 100644 packaging/rust-ring.spec diff --git a/packaging/extern.patch b/packaging/extern.patch new file mode 100644 index 0000000..d9effc8 --- /dev/null +++ b/packaging/extern.patch @@ -0,0 +1,51 @@ +diff --git a/src/ec/suite_b.rs b/src/ec/suite_b.rs +index 9e36356..749747f 100644 +--- a/src/ec/suite_b.rs ++++ b/src/ec/suite_b.rs +@@ -191,7 +191,7 @@ fn key_pair_from_pkcs8_<'a>( + let actual_alg_id = + der::expect_tag_and_get_value(input, der::Tag::ContextSpecificConstructed0) + .map_err(|error::Unspecified| error::KeyRejected::invalid_encoding())?; +- if actual_alg_id != template.curve_oid() { ++ if actual_alg_id.as_slice_less_safe() != template.curve_oid().as_slice_less_safe() { + return Err(error::KeyRejected::wrong_algorithm()); + } + } +@@ -220,7 +220,7 @@ pub(crate) fn key_pair_from_bytes( + + let r = ec::KeyPair::derive(seed) + .map_err(|error::Unspecified| error::KeyRejected::unexpected_error())?; +- if public_key_bytes != *r.public_key().as_ref() { ++ if public_key_bytes.as_slice_less_safe() != r.public_key().as_ref() { + return Err(error::KeyRejected::inconsistent_components()); + } + +diff --git a/src/lib.rs b/src/lib.rs +index cc66d73..a421e0c 100644 +--- a/src/lib.rs ++++ b/src/lib.rs +@@ -73,6 +73,11 @@ + #![forbid(unused_results)] + #![no_std] + ++extern crate libc; ++extern crate untrusted; ++extern crate spin; ++use std::ops; ++ + #[cfg(feature = "alloc")] + extern crate alloc; + +diff --git a/src/pkcs8.rs b/src/pkcs8.rs +index c3ca499..d947aa7 100644 +--- a/src/pkcs8.rs ++++ b/src/pkcs8.rs +@@ -119,7 +119,7 @@ fn unwrap_key__<'a>( + + let actual_alg_id = der::expect_tag_and_get_value(input, der::Tag::Sequence) + .map_err(|error::Unspecified| error::KeyRejected::invalid_encoding())?; +- if actual_alg_id != alg_id { ++ if actual_alg_id.as_slice_less_safe() != alg_id.as_slice_less_safe() { + return Err(error::KeyRejected::wrong_algorithm()); + } + diff --git a/packaging/rust-ring.manifest b/packaging/rust-ring.manifest new file mode 100644 index 0000000..017d22d --- /dev/null +++ b/packaging/rust-ring.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/rust-ring.spec b/packaging/rust-ring.spec new file mode 100644 index 0000000..5e84854 --- /dev/null +++ b/packaging/rust-ring.spec @@ -0,0 +1,77 @@ +# Generated by rust2rpm 23 +%global _rpm_strip_disable 1 +%global debug_package %{nil} + +%global crate ring +%global real_crate_name ring +%global rustc_edition 2018 + +Name: rust-ring +Version: 0.16.20 +Release: 1 +Summary: Safe, fast, small crypto using Rust + +# Upstream license specification: None +License: # FIXME + +URL: https://crates.io/crates/ring +Source: %{crate}-%{version}.tar.gz +Source1: %{name}.manifest +Source2: extern.patch + +# ========================================================== +# BuildRequires +# specifies build-time dependencies for the package +# ========================================================== +BuildRequires: rust +BuildRequires: rust-libc +BuildRequires: rust-once_cell +BuildRequires: rust-spin +BuildRequires: rust-untrusted + +# ========================================================== +# dev-dependencies +# ========================================================== +# BuildRequires: rust-libc + + +%description +Safe, fast, small crypto using Rust. + +%prep +%setup -q +cp %{SOURCE1} . +%{__patch} -p1 < %{SOURCE2} + +# ========================================================== +# build section +# crate-type : dylib, proc-macro, cdylib, bin, etc. +# ========================================================== +%build + %{rustc_std_build} --crate-type=dylib \ + --crate-name=%{real_crate_name} \ + %{?rustc_edition:--edition=%{rustc_edition}} \ + --cfg='feature="libc"' \ + --extern libc=%{_rust_dylibdir}/liblibc.so \ + ./src/lib.rs + +# ========================================================== +# install section +# ========================================================== +%install + install -d -m 0755 %{buildroot}%{_rust_dylibdir} + install -m 0644 lib%{real_crate_name}.so %{buildroot}/%{_rust_dylibdir}/lib%{real_crate_name}.so + +%clean + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + +# ========================================================== +# files section +# ========================================================== +%files +%manifest %{name}.manifest + %license LICENSE + %{_rust_dylibdir}/lib%{real_crate_name}.so -- 2.7.4