Skip to content

Commit b3e9173

Browse files
committed
update docs
1 parent 6eeef5f commit b3e9173

3 files changed

Lines changed: 24 additions & 11 deletions

File tree

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ This crates provides a basic library [httpsig](./httpsig) and [its extension](./
1717
- [x] Ed25519
1818
- [x] ECDSA-P256 using SHA-256
1919
- [ ] ECDSA-P384 using SHA-384
20+
- [x] RSASSA-PSS using SHA-512
21+
- [x] RSASSA-PKCS1-v1_5 using SHA-256
2022

21-
~~- [ ] RSASSA-PSS using SHA-512~~
22-
23-
~~- [ ] RSASSA-PKCS1-v1_5 using SHA-256~~
24-
25-
At this point, we have no plan to support RSA signature due to [the problem related to the non-constant time operation](https://github.com/RustCrypto/RSA/issues/19), i.e., [Mervin Attack](https://people.redhat.com/~hkario/marvin/).
23+
At this point, **RSA signature is non-default** due to [the problem related to the non-constant time operation](https://github.com/RustCrypto/RSA/issues/19), i.e., [Mervin Attack](https://people.redhat.com/~hkario/marvin/). If you want to use RSA signature, please enable the `rsa-signature` feature flag in your `Cargo.toml`.
2624

2725
## Usage of Extension for `hyper` (`httpsig-hyper`)
2826

@@ -48,8 +46,11 @@ async fn signer<B>(&mut req: Request<B>) -> HttpSigResult<()> {
4846
.unwrap();
4947
let mut signature_params = HttpSignatureParams::try_new(&covered_components).unwrap();
5048

49+
// specify algorithm name since we cannot always infer it from key info
50+
let alg = AlgorithmName::Ed25519;
51+
5152
// set signing/verifying key information, alg and keyid
52-
let secret_key = SecretKey::from_pem(SECRET_KEY_STRING).unwrap();
53+
let secret_key = SecretKey::from_pem(&alg, SECRET_KEY_STRING).unwrap();
5354
signature_params.set_key_info(&secret_key);
5455

5556
req
@@ -59,7 +60,11 @@ async fn signer<B>(&mut req: Request<B>) -> HttpSigResult<()> {
5960

6061
/// Validation function that verifies a request with a signature
6162
async fn verifier<B>(req: &Request<B>) -> HttpSigResult<SignatureName> {
62-
let public_key = PublicKey::from_pem(PUBLIC_KEY_STRING).unwrap();
63+
// specify algorithm name since we cannot always infer it from key info
64+
let alg = AlgorithmName::Ed25519; // directly use Ed25519 algorithm
65+
// or else infer it from the request. Find your public key from IndexMap with alg and key_id pairs
66+
// let alg_key_id_map = req.get_alg_key_ids().unwrap();
67+
let public_key = PublicKey::from_pem(&alg, PUBLIC_KEY_STRING).unwrap();
6368
let key_id = public_key.key_id();
6469

6570
// verify signature with checking key_id
@@ -105,8 +110,11 @@ async fn signer<B>(&mut res: Response<B>, corresponding_req: &Request<B>) -> Htt
105110
.unwrap();
106111
let mut signature_params = HttpSignatureParams::try_new(&covered_components).unwrap();
107112

113+
// specify algorithm name since we cannot always infer it from key info
114+
let alg = AlgorithmName::Ed25519;
115+
108116
// set signing/verifying key information, alg and keyid
109-
let secret_key = SecretKey::from_pem(SECRET_KEY_STRING).unwrap();
117+
let secret_key = SecretKey::from_pem(&alg, SECRET_KEY_STRING).unwrap();
110118
signature_params.set_key_info(&secret_key);
111119

112120
req
@@ -116,7 +124,11 @@ async fn signer<B>(&mut res: Response<B>, corresponding_req: &Request<B>) -> Htt
116124

117125
/// Validation function that verifies a response with a signature from response itself and sent request
118126
async fn verifier<B>(res: &Response<B>, sent_req: &Request<B>) -> HttpSigResult<SignatureName> {
119-
let public_key = PublicKey::from_pem(PUBLIC_KEY_STRING).unwrap();
127+
// specify algorithm name since we cannot always infer it from key info
128+
let alg = AlgorithmName::Ed25519; // directly use Ed25519 algorithm
129+
// or else infer it from the response. Find your public key from IndexMap with alg and key_id pairs
130+
// let alg_key_id_map = res.get_alg_key_ids().unwrap
131+
let public_key = PublicKey::from_pem(&alg, PUBLIC_KEY_STRING).unwrap();
120132
let key_id = public_key.key_id();
121133

122134
// verify signature with checking key_id

httpsig-hyper/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ rust-version.workspace = true
1313
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1414

1515
[features]
16-
default = ["blocking"]
16+
default = ["blocking", "rsasig"]
1717
blocking = ["futures/executor"]
18+
rsasig = ["httpsig/rsasig"]
1819

1920

2021
[dependencies]

httpsig/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ rust-version.workspace = true
1313
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1414

1515
[features]
16-
default = ["rsasig"]
16+
default = []
1717
rsasig = ["rsa"]
1818

1919
[dependencies]

0 commit comments

Comments
 (0)