はじめに
Kurimochiです。PQCを使いたいがためだけにGnuPGからSequoiaへ移行していたのですが(!?)、公式様のインストール手順では不具合が生じたので解決策を備忘録として載せておきます。
↓公式様
結論
リポジトリをクローンし、pqcブランチに移動します。
$ git clone https://gitlab.com/sequoia-pgp/sequoia-sq.git
$ cd sequoia-sq
$ git checkout pqc
Cargo.tomlを以下のとおり変更します。versionのSemVerだけ変更すれば問題ありません。
...
[dependencies]
...
sequoia-directories = "0.1"
- sequoia-openpgp = { version = "2.2.0-pqc.1", default-features = false, features = ["compression"] }
+ sequoia-openpgp = { version = "=2.2.0-pqc.1", default-features = false, features = ["compression"] }
sequoia-autocrypt = { version = "0.27.0-pqc.1", default-features = false }
...
最後にcargo updateしてからインストールします。
$ cargo update
$ cargo install --path . --no-default-features --features crypto-openssl
その後のテストや使い方は公式様のドキュメントをご覧ください。
詳細
ここからは具体的な問題と取った解決策についてまとめています(ほとんどが余談かもしれません)。
問題1. osslのバージョン問題
公式様のドキュメント通りにインストールを進めると、最初にosslというクレートのエラーにぶつかります。
$ cargo build --release --locked --no-default-features --features crypto-openssl
...
error[E0080]: attempt to compute `1_usize - 16_usize`, which would overflow
--> /home/kurimochi/Documents/sequoia-sq/target/release/build/ossl-2709b5a7a7f2b523/out/ossl_bindings.rs:2533:34
|
2533 | ["Size of ossl_dispatch_st"][::std::mem::size_of::<ossl_dispatch_st>() - 16usize];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `bindings::_` failed here
error[E0080]: attempt to compute `1_usize - 16_usize`, which would overflow
--> /home/kurimochi/Documents/sequoia-sq/target/release/build/ossl-2709b5a7a7f2b523/out/ossl_bindings.rs:2545:30
|
2545 | ["Size of ossl_item_st"][::std::mem::size_of::<ossl_item_st>() - 16usize];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `bindings::_` failed here
error[E0080]: attempt to compute `1_usize - 32_usize`, which would overflow
--> /home/kurimochi/Documents/sequoia-sq/target/release/build/ossl-2709b5a7a7f2b523/out/ossl_bindings.rs:2555:35
|
2555 | ["Size of ossl_algorithm_st"][::std::mem::size_of::<ossl_algorithm_st>() - 32usize];
|
...
Some errors have detailed explanations: E0080, E0560, E0609.
For more information about an error, try `rustc --explain E0080`.
error: could not compile `ossl` (lib) due to 29 previous errors
warning: build failed, waiting for other jobs to finish...
このosslクレートはC言語のOpenSSLライブラリ(libcrypto)のRustラッパーですが、docs.rsいわくCargo.lockで指定されているバージョンv1.3.1はビルドが通らないようです。docs.rsのチカラってスゲー
幸いosslはビルドできる後続バージョン(v1.4.0, v1.5.0)が提供されているので、諸々含めてアップデートするだけで解消されます。
$ cargo update
問題2. sequoia-openpgpのSemVer問題
一難去ってまた一難。
$ cargo build --release --locked --no-default-features --features crypto-openssl
...
error[E0599]: no variant or associated item named `MLDSA65_Ed25519` found for enum `AsymmetricAlgorithm` in the current scope
--> /home/kurimochi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sequoia-policy-config-0.9.0-pqc.1/src/lib.rs:517:46
|
517 | ("mldsa65-ed25519", AsymmetricAlgorithm::MLDSA65_Ed25519, &[]),
| ^^^^^^^^^^^^^^^ variant or associated item not found in `AsymmetricAlgorithm`
error[E0599]: no variant or associated item named `MLDSA87_Ed448` found for enum `AsymmetricAlgorithm` in the current scope
--> /home/kurimochi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sequoia-policy-config-0.9.0-pqc.1/src/lib.rs:518:44
|
518 | ("mldsa87-ed448", AsymmetricAlgorithm::MLDSA87_Ed448, &[]),
| ^^^^^^^^^^^^^ variant or associated item not found in `AsymmetricAlgorithm`
error[E0599]: no variant or associated item named `SLHDSA128s` found for enum `AsymmetricAlgorithm` in the current scope
--> /home/kurimochi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sequoia-policy-config-0.9.0-pqc.1/src/lib.rs:519:41
|
519 | ("slhdsa128s", AsymmetricAlgorithm::SLHDSA128s, &[]),
| ^^^^^^^^^^ variant or associated item not found in `AsymmetricAlgorithm`
error[E0599]: no variant or associated item named `SLHDSA128f` found for enum `AsymmetricAlgorithm` in the current scope
--> /home/kurimochi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sequoia-policy-config-0.9.0-pqc.1/src/lib.rs:520:41
|
520 | ("slhdsa128f", AsymmetricAlgorithm::SLHDSA128f, &[]),
| ^^^^^^^^^^ variant or associated item not found in `AsymmetricAlgorithm`
error[E0599]: no variant or associated item named `SLHDSA256s` found for enum `AsymmetricAlgorithm` in the current scope
--> /home/kurimochi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sequoia-policy-config-0.9.0-pqc.1/src/lib.rs:521:41
|
521 | ("slhdsa256s", AsymmetricAlgorithm::SLHDSA256s, &[]),
| ^^^^^^^^^^ variant or associated item not found in `AsymmetricAlgorithm`
error[E0599]: no variant or associated item named `MLKEM768_X25519` found for enum `AsymmetricAlgorithm` in the current scope
--> /home/kurimochi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sequoia-policy-config-0.9.0-pqc.1/src/lib.rs:522:46
|
522 | ("mlkem768-x25519", AsymmetricAlgorithm::MLKEM768_X25519, &[]),
| ^^^^^^^^^^^^^^^ variant or associated item not found in `AsymmetricAlgorithm`
error[E0599]: no variant or associated item named `MLKEM1024_X448` found for enum `AsymmetricAlgorithm` in the current scope
--> /home/kurimochi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sequoia-policy-config-0.9.0-pqc.1/src/lib.rs:523:45
|
523 | ("mlkem1024-x448", AsymmetricAlgorithm::MLKEM1024_X448, &[]),
| ^^^^^^^^^^^^^^ variant or associated item not found in `AsymmetricAlgorithm`
For more information about this error, try `rustc --explain E0599`.
error: could not compile `sequoia-policy-config` (lib) due to 7 previous errors
warning: build failed, waiting for other jobs to finish...
リポジトリやら残存キャッシュやらを漁りに漁りまくった結果、sequoia-openpgpのバージョン違いだという結論に至りました。
cargo treeを覗くと以下の通りv2.2.0でした。PQC版Sequoiaではほとんどのクレートのバージョンが末尾に-pqc.1のつくプレリリースで(sequoia-directoriesだけ例外?)、sequoia-openpgpも例外ではないはずですが...
$ cargo tree -p sequoia-openpgp
sequoia-openpgp v2.2.0
├── anyhow v1.0.102
├── argon2 v0.5.3
...
しかしCargo.tomlにはしっかり2.2.0-pqc.1が指定されています。
...
[dependencies]
...
sequoia-openpgp = { version = "2.2.0-pqc.1", default-features = false, features = ["compression"] }
...
結局原因がわからなかったのでCodexに聞いてみると、SemVerの問題だと言われました。SemVerではプレリリースよりも正式リリースのほうを最新と見なすようで、先程のcargo updateでバージョンが上がってv2.2.0になっていたらしいです。
というわけでSemVerを変えてバージョン完全一致にしてあげれば解消です。
[dependencies]
...
- sequoia-openpgp = { version = "2.2.0-pqc.1", default-features = false, features = ["compression"] }
+ sequoia-openpgp = { version = "=2.2.0-pqc.1", default-features = false, features = ["compression"] }
...
$ cargo update -p sequoia-openpgp --precise 2.2.0-pqc.1
$ cargo build --release --locked --no-default-features --features crypto-openssl
...
Finished `release` profile [optimized + debuginfo] target(s) in 56.72s