From a0b9a486dfca6f394188ea02138d5a74d8087f5f Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Thu, 15 Jun 2023 14:46:05 +0200 Subject: [PATCH] Initial import (#2213270) --- .gitignore | 1 + ...es-to-code-related-to-the-p434-curve.patch | 24 +++++ README.md | 3 - fiat-crypto-fix-metadata.diff | 11 +++ gen_clean_tarball.sh | 43 +++++++++ rust-fiat-crypto.spec | 92 +++++++++++++++++++ sources | 1 + 7 files changed, 172 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 0001-remove-references-to-code-related-to-the-p434-curve.patch delete mode 100644 README.md create mode 100644 fiat-crypto-fix-metadata.diff create mode 100755 gen_clean_tarball.sh create mode 100644 rust-fiat-crypto.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7c5b3a0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/fiat-crypto-0.1.20-clean.crate diff --git a/0001-remove-references-to-code-related-to-the-p434-curve.patch b/0001-remove-references-to-code-related-to-the-p434-curve.patch new file mode 100644 index 0000000..d48df13 --- /dev/null +++ b/0001-remove-references-to-code-related-to-the-p434-curve.patch @@ -0,0 +1,24 @@ +From 600fac16c465a709b22717dfc0e5947c511641d1 Mon Sep 17 00:00:00 2001 +From: Fabio Valentini +Date: Wed, 7 Jun 2023 18:36:25 +0200 +Subject: [PATCH] remove references to code related to the p434 curve + +--- + src/lib.rs | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/src/lib.rs b/src/lib.rs +index d72509a..3fc2995 100644 +--- a/src/lib.rs ++++ b/src/lib.rs +@@ -15,7 +15,6 @@ pub mod p384_32; + pub mod p384_64; + pub mod p384_scalar_32; + pub mod p384_scalar_64; +-pub mod p434_64; + pub mod p448_solinas_32; + pub mod p448_solinas_64; + pub mod p521_64; +-- +2.40.1 + diff --git a/README.md b/README.md deleted file mode 100644 index 41dfde3..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# rust-fiat-crypto - -The rust-fiat-crypto package diff --git a/fiat-crypto-fix-metadata.diff b/fiat-crypto-fix-metadata.diff new file mode 100644 index 0000000..b6887c0 --- /dev/null +++ b/fiat-crypto-fix-metadata.diff @@ -0,0 +1,11 @@ +--- fiat-crypto-0.1.20/Cargo.toml 1970-01-01T00:00:01+00:00 ++++ fiat-crypto-0.1.20/Cargo.toml 2023-06-07T16:32:24.435431+00:00 +@@ -14,7 +14,7 @@ + name = "fiat-crypto" + version = "0.1.20" + authors = ["Fiat Crypto library authors "] +-description = "Fiat-crypto generated Rust" ++description = "Correct-by-Construction Code for Cryptographic Primitives" + homepage = "https://github.com/mit-plv/fiat-crypto" + readme = "README.md" + license = "MIT OR Apache-2.0 OR BSD-1-Clause" diff --git a/gen_clean_tarball.sh b/gen_clean_tarball.sh new file mode 100755 index 0000000..b08ba74 --- /dev/null +++ b/gen_clean_tarball.sh @@ -0,0 +1,43 @@ +#!/usr/bin/bash + +set -e + +CRATE="fiat-crypto" +NAME="rust-${CRATE}" + +VERSION=$(rpmspec -q $NAME.spec --srpm --qf "%{version}") +URL="https://crates.io/api/v1/crates/${CRATE}/${VERSION}/download" + +ROOTDIR="${CRATE}-${VERSION}" + +# download and extract published crate from crates.io +wget $URL -O ${ROOTDIR}.crate +tar -xzf ${ROOTDIR}.crate +rm ${ROOTDIR}.crate + +pushd ${ROOTDIR} + +# remove code related to the p434 curve which is not permitted in Fedora: +# https://lists.fedoraproject.org/archives/list/legal@lists.fedoraproject.org/thread/FBZU2X7ZKTK2BVZKBHFUCI44SMY4UQCE/ +rm src/p434_64.rs + +# clean up cargo files +rm .cargo_vcs_info.json +mv Cargo.toml.orig Cargo.toml + +# initialize git repo and remove references to code related to the p434 curve +git init +git add . +git apply ../0001-remove-references-to-code-related-to-the-p434-curve.patch +git commit -a -m "import" + +# repackage crate +cargo package + +# move clean crate +mv target/package/${ROOTDIR}.crate ../${ROOTDIR}-clean.crate +popd + +# remove temporary directory +rm -rf ${ROOTDIR} + diff --git a/rust-fiat-crypto.spec b/rust-fiat-crypto.spec new file mode 100644 index 0000000..337ec37 --- /dev/null +++ b/rust-fiat-crypto.spec @@ -0,0 +1,92 @@ +# Generated by rust2rpm 24 +%bcond_without check +%global debug_package %{nil} + +%global crate fiat-crypto + +Name: rust-fiat-crypto +Version: 0.1.20 +Release: %autorelease +Summary: Correct-by-Construction Code for Cryptographic Primitives + +License: MIT OR Apache-2.0 OR BSD-1-Clause +URL: https://crates.io/crates/fiat-crypto +Source: %{crate}-%{version_no_tilde}-clean.crate +# script to create tarball with only permissible content: +# run "rust2rpm" and then "./gen_clean_tarball.sh" for new versions +Source: gen_clean_tarball.sh +Source: 0001-remove-references-to-code-related-to-the-p434-curve.patch +# Manually created patch for downstream crate metadata changes +# * change crate description to something more meaningful +Patch: fiat-crypto-fix-metadata.diff + +BuildRequires: rust-packaging >= 21 + +%global _description %{expand: +Correct-by-Construction Code for Cryptographic Primitives.} + +%description %{_description} + +%package devel +Summary: %{summary} +BuildArch: noarch + +%description devel %{_description} + +This package contains library source intended for building other packages which +use the "%{crate}" crate. + +%files devel +%license %{crate_instdir}/COPYRIGHT +%license %{crate_instdir}/LICENSE-APACHE +%license %{crate_instdir}/LICENSE-BSD-1 +%license %{crate_instdir}/LICENSE-MIT +%doc %{crate_instdir}/AUTHORS +%doc %{crate_instdir}/CONTRIBUTORS +%doc %{crate_instdir}/README.md +%{crate_instdir}/ + +%package -n %{name}+default-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+default-devel %{_description} + +This package contains library source intended for building other packages which +use the "default" feature of the "%{crate}" crate. + +%files -n %{name}+default-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+std-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+std-devel %{_description} + +This package contains library source intended for building other packages which +use the "std" feature of the "%{crate}" crate. + +%files -n %{name}+std-devel +%ghost %{crate_instdir}/Cargo.toml + +%prep +%autosetup -n %{crate}-%{version_no_tilde} -p1 +%cargo_prep + +%generate_buildrequires +%cargo_generate_buildrequires + +%build +%cargo_build + +%install +%cargo_install + +%if %{with check} +%check +%cargo_test +%endif + +%changelog +%autochangelog diff --git a/sources b/sources new file mode 100644 index 0000000..c912e2c --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (fiat-crypto-0.1.20-clean.crate) = ce1bf06e8eada5b00f59ff8a2b0a9b43d1bd266e0574940d846f98d5c6a90835e9239c2a24a5e4a6989f38afd099103fdfa4d654f8c2e5cdc9788c2f8a86d6cf