Compare commits
3 commits
6d1ae370fa
...
43b4220de2
Author | SHA1 | Date | |
---|---|---|---|
43b4220de2 | |||
a563e46162 | |||
aa4432bf37 |
3 changed files with 3 additions and 77 deletions
|
@ -78,25 +78,3 @@ pub const ADD_PRE_CHAIN: Endpoint = (reqwest::Method::POST, "/ct/v1/add-pre-chai
|
||||||
/// tree_head_signature: A TreeHeadSignature for the above data.
|
/// tree_head_signature: A TreeHeadSignature for the above data.
|
||||||
/// ```
|
/// ```
|
||||||
pub const GET_STH: Endpoint = (reqwest::Method::GET, "/ct/v1/get-sth");
|
pub const GET_STH: Endpoint = (reqwest::Method::GET, "/ct/v1/get-sth");
|
||||||
|
|
||||||
/// Reference: https://datatracker.ietf.org/doc/html/rfc6962#section-4.4
|
|
||||||
/// ```txt
|
|
||||||
/// GET https://<log server>/ct/v1/get-sth-consistency
|
|
||||||
///
|
|
||||||
/// Inputs:
|
|
||||||
///
|
|
||||||
/// first: The tree_size of the first tree, in decimal.
|
|
||||||
///
|
|
||||||
/// second: The tree_size of the second tree, in decimal.
|
|
||||||
///
|
|
||||||
/// Both tree sizes must be from existing v1 STHs (Signed Tree Heads).
|
|
||||||
///
|
|
||||||
/// Outputs:
|
|
||||||
///
|
|
||||||
/// consistency: An array of Merkle Tree nodes, base64 encoded.
|
|
||||||
///
|
|
||||||
/// Note that no signature is required on this data, as it is used to
|
|
||||||
/// verify an STH, which is signed.
|
|
||||||
/// ```
|
|
||||||
pub const GET_STH_CONSISTENCY: Endpoint =
|
|
||||||
(reqwest::Method::GET, "/ct/v1/get-sth-consistency");
|
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
use reqwest::Url;
|
use reqwest::Url;
|
||||||
use responses::{
|
use responses::{AddChainRequest, AddChainResponse, GetSthResponse};
|
||||||
AddChainRequest,
|
|
||||||
AddChainResponse,
|
|
||||||
GetSthConsistencyResponse,
|
|
||||||
GetSthResponse
|
|
||||||
};
|
|
||||||
|
|
||||||
pub mod endpoints;
|
pub mod endpoints;
|
||||||
pub mod responses;
|
pub mod responses;
|
||||||
|
@ -24,7 +19,7 @@ impl CtApiClient {
|
||||||
|
|
||||||
/// Adds a standard x509 chain to the CT log.
|
/// Adds a standard x509 chain to the CT log.
|
||||||
///
|
///
|
||||||
/// See: [`endpoints::ADD_CHAIN`]
|
/// See: [`endpoints::ADD_CHAIN_ENDPOINT`]
|
||||||
///
|
///
|
||||||
/// ## Errors
|
/// ## Errors
|
||||||
///
|
///
|
||||||
|
@ -54,7 +49,7 @@ impl CtApiClient {
|
||||||
/// [`CtApiClient::add_chain`], except is used specifically when the chain
|
/// [`CtApiClient::add_chain`], except is used specifically when the chain
|
||||||
/// starts with a precertificate rather than the final end-user certificate.
|
/// starts with a precertificate rather than the final end-user certificate.
|
||||||
///
|
///
|
||||||
/// See: [`endpoints::ADD_PRE_CHAIN`]
|
/// See: [`endpoints::ADD_PRE_CHAIN_ENDPOINT`]
|
||||||
///
|
///
|
||||||
/// ## Errors
|
/// ## Errors
|
||||||
///
|
///
|
||||||
|
@ -83,14 +78,6 @@ impl CtApiClient {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fetches the Signed Tree Head information for the current CT log tree
|
|
||||||
///
|
|
||||||
/// See: [`endpoints::GET_STH`]
|
|
||||||
///
|
|
||||||
/// ## Errors
|
|
||||||
///
|
|
||||||
/// This may error if either the request failed (due to lack of internet or
|
|
||||||
/// invalid domain, for example).
|
|
||||||
pub async fn get_signed_tree_head(&self) -> reqwest::Result<GetSthResponse> {
|
pub async fn get_signed_tree_head(&self) -> reqwest::Result<GetSthResponse> {
|
||||||
self.inner_client
|
self.inner_client
|
||||||
.request(
|
.request(
|
||||||
|
@ -103,34 +90,4 @@ impl CtApiClient {
|
||||||
.json()
|
.json()
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fetches the Signed Tree Head consistency proof for a specified start
|
|
||||||
/// tree_size and end tree_size.
|
|
||||||
///
|
|
||||||
/// See: [`endpoints::GET_STH_CONSISTENCY`]
|
|
||||||
///
|
|
||||||
/// ## Errors
|
|
||||||
///
|
|
||||||
/// This may error if either the request failed (due to lack of internet or
|
|
||||||
/// invalid domain, for example), or if the CT log gave a 4xx/5xx response.
|
|
||||||
/// The CT log may error the response if your first and second tree sizes
|
|
||||||
/// are invalid, for example if the second is smaller than the first or if
|
|
||||||
/// the tree has never contained a size specified in `first` or `second`.
|
|
||||||
pub async fn get_signed_tree_head_consistency(
|
|
||||||
&self,
|
|
||||||
first: u64,
|
|
||||||
second: u64
|
|
||||||
) -> reqwest::Result<GetSthConsistencyResponse> {
|
|
||||||
self.inner_client
|
|
||||||
.request(
|
|
||||||
endpoints::GET_STH_CONSISTENCY.0,
|
|
||||||
self.log_url.to_string() + endpoints::GET_STH_CONSISTENCY.1
|
|
||||||
)
|
|
||||||
.query(&[("first", first), ("second", second)])
|
|
||||||
.send()
|
|
||||||
.await?
|
|
||||||
.error_for_status()?
|
|
||||||
.json()
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,12 +32,3 @@ pub struct GetSthResponse {
|
||||||
pub sha256_root_hash: String,
|
pub sha256_root_hash: String,
|
||||||
pub tree_head_signature: String
|
pub tree_head_signature: String
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A response given when fetching the Signed Tree Head consistency proof of a
|
|
||||||
/// CT log
|
|
||||||
///
|
|
||||||
/// See: [`super::endpoints::GET_STH_CONSISTENCY`]
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct GetSthConsistencyResponse {
|
|
||||||
pub consistency: Vec<String>
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue