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)
| 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 | /// |
nothing calls this directly
no test coverage detected