MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / signed_by

Method signed_by

ra-tls/src/cert.rs:200–215  ·  view source on GitHub ↗

Signs the CSR data using the provided key pair. # Arguments `key` - The ECDSA key pair used to sign the CSR. # Returns The DER-encoded ECDSA signature as a byte vector. # Errors Returns an error if key pair creation or signing fails.

(&self, key: &KeyPair)

Source from the content-addressed store, hash-verified

198 /// # Errors
199 /// Returns an error if key pair creation or signing fails.
200 fn signed_by(&self, key: &KeyPair) -> Result<Vec<u8>> {
201 let encoded = self.data_to_sign();
202 let rng = SystemRandom::new();
203 // Extract the DER-encoded private key and create an ECDSA key pair
204 let key_pair =
205 EcdsaKeyPair::from_pkcs8(&ECDSA_P256_SHA256_ASN1_SIGNING, &key.serialize_der(), &rng)
206 .context("Failed to create key pair from DER")?;
207
208 // Sign the encoded CSR
209 let signature = key_pair
210 .sign(&rng, &encoded)
211 .context("Failed to sign CSR")?
212 .as_ref()
213 .to_vec();
214 Ok(signature)
215 }
216
217 /// Verifies the signature of the CSR.
218 ///

Callers

nothing calls this directly

Implementers 1

cert.rsra-tls/src/cert.rs

Calls 4

data_to_signMethod · 0.80
to_vecMethod · 0.80
as_refMethod · 0.45
signMethod · 0.45

Tested by

no test coverage detected