Skip to content

Commit b61393a

Browse files
committed
key_pair: emphasize PKCS8 in from der & alg constructor
The `KeyPair::from_der_and_sign_algo` fn expects PKCS8 formatted DER as input. This commit renames the fn to `Keypair::from_pkcs8_der_and_sign_algo` to emphasize this, and to pave the way for a more generalized fn to be added in the future.
1 parent 05b5fd9 commit b61393a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

rcgen/src/key_pair.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl KeyPair {
197197
) -> Result<Self, Error> {
198198
let private_key = pem::parse(pem_str)._err()?;
199199
let private_key_der: &[_] = private_key.contents();
200-
Self::from_der_and_sign_algo(&PrivatePkcs8KeyDer::from(private_key_der), alg)
200+
Self::from_pkcs8_der_and_sign_algo(&PrivatePkcs8KeyDer::from(private_key_der), alg)
201201
}
202202

203203
/// Obtains the key pair from a DER formatted key using the specified [`SignatureAlgorithm`]
@@ -215,7 +215,7 @@ impl KeyPair {
215215
/// [`rustls_pemfile::private_key()`]: https://docs.rs/rustls-pemfile/latest/rustls_pemfile/fn.private_key.html
216216
/// [`PrivateKeyDer`]: https://docs.rs/rustls-pki-types/latest/rustls_pki_types/enum.PrivateKeyDer.html
217217
#[cfg(feature = "crypto")]
218-
pub fn from_der_and_sign_algo(
218+
pub fn from_pkcs8_der_and_sign_algo(
219219
pkcs8: &PrivatePkcs8KeyDer<'_>,
220220
alg: &'static SignatureAlgorithm,
221221
) -> Result<Self, Error> {

rustls-cert-gen/src/cert.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl KeyPairAlgorithm {
239239
let pkcs8_bytes =
240240
Ed25519KeyPair::generate_pkcs8(&rng).or(Err(rcgen::Error::RingUnspecified))?;
241241

242-
rcgen::KeyPair::from_der_and_sign_algo(&pkcs8_bytes.as_ref().into(), alg)
242+
rcgen::KeyPair::from_pkcs8_der_and_sign_algo(&pkcs8_bytes.as_ref().into(), alg)
243243
},
244244
KeyPairAlgorithm::EcdsaP256 => {
245245
use ring::signature::EcdsaKeyPair;
@@ -250,7 +250,7 @@ impl KeyPairAlgorithm {
250250
let pkcs8_bytes =
251251
EcdsaKeyPair::generate_pkcs8(&ECDSA_P256_SHA256_ASN1_SIGNING, &rng)
252252
.or(Err(rcgen::Error::RingUnspecified))?;
253-
rcgen::KeyPair::from_der_and_sign_algo(&pkcs8_bytes.as_ref().into(), alg)
253+
rcgen::KeyPair::from_pkcs8_der_and_sign_algo(&pkcs8_bytes.as_ref().into(), alg)
254254
},
255255
KeyPairAlgorithm::EcdsaP384 => {
256256
use ring::signature::EcdsaKeyPair;
@@ -262,7 +262,7 @@ impl KeyPairAlgorithm {
262262
EcdsaKeyPair::generate_pkcs8(&ECDSA_P384_SHA384_ASN1_SIGNING, &rng)
263263
.or(Err(rcgen::Error::RingUnspecified))?;
264264

265-
rcgen::KeyPair::from_der_and_sign_algo(&pkcs8_bytes.as_ref().into(), alg)
265+
rcgen::KeyPair::from_pkcs8_der_and_sign_algo(&pkcs8_bytes.as_ref().into(), alg)
266266
},
267267
}
268268
}

0 commit comments

Comments
 (0)