Commit 8def4161 authored by trinity-1686a's avatar trinity-1686a
Browse files

change check_key to take a Option<&_> instead of &Option<_>

parent bb3dbb07
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ let cert_bin = base64::decode(cert_base64).unwrap();

// Decode the cert and check its signature.
let cert = Ed25519Cert::decode(&cert_bin).unwrap()
    .check_key(&None).unwrap()
    .check_key(None).unwrap()
    .check_signature().unwrap()
    .dangerously_assume_timely();
let signed_key = cert.subject_key();
+1 −0
Original line number Diff line number Diff line
BREAKING: `Ed25519Cert::check_key` prototype changed from taking `&Option<ed25519::PublicKey>` to `Option<&ed25519::PublicKey>`
+1 −1
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ mod test {

        let decoded = Ed25519Cert::decode(&encoded).unwrap(); // Well-formed?
        let validated = decoded
            .check_key(&Some(keypair.public))
            .check_key(Some(&keypair.public))
            .unwrap()
            .check_signature()
            .unwrap(); // Well-signed?
+2 −2
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@
//!
//! // Decode the cert and check its signature.
//! let cert = Ed25519Cert::decode(&cert_bin).unwrap()
//!     .check_key(&None).unwrap()
//!     .check_key(None).unwrap()
//!     .check_signature().unwrap()
//!     .dangerously_assume_timely();
//! let signed_key = cert.subject_key();
@@ -465,7 +465,7 @@ impl KeyUnknownCert {
    ///
    /// On success, we can check whether the certificate is well-signed;
    /// otherwise, we can't check the certificate.
    pub fn check_key(self, pkey: &Option<ed25519::PublicKey>) -> CertResult<UncheckedCert> {
    pub fn check_key(self, pkey: Option<&ed25519::PublicKey>) -> CertResult<UncheckedCert> {
        let real_key = match (pkey, self.cert.cert.signed_with) {
            (Some(a), Some(b)) if a == &b => b,
            (Some(_), Some(_)) => return Err(CertError::KeyMismatch),
+2 −2
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ fn mismatched_signing_key() {
    // We give the wrong key to check_key, so it will tell us that
    // wasn't what the cert contained.
    assert_eq!(
        cert.check_key(&Some(not_that_key)).err().unwrap(),
        cert.check_key(Some(&not_that_key)).err().unwrap(),
        CertError::KeyMismatch
    );

@@ -86,7 +86,7 @@ fn mismatched_signing_key() {
    // We give no key to check_key, which will tell us that there wasn't
    // a signing-key extension in the cert.
    assert_eq!(
        cert.check_key(&None).err().unwrap(),
        cert.check_key(None).err().unwrap(),
        CertError::MissingPubKey
    );
}
Loading