Skip to content

Commit 1ee4815

Browse files
authored
crypto: Clean up the windows rsa impl (#3611)
Drop the RustCrypto crates for parsing, as windows does indeed provide parsers. Then switch the error type back to a struct instead of an enum. Clean up various small helpers.
1 parent 2918a31 commit 1ee4815

7 files changed

Lines changed: 277 additions & 189 deletions

File tree

support/crypto/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ windows = { workspace = true, features = [
7878
] }
7979
windows-result.workspace = true
8080
zerocopy.workspace = true
81-
# Used by the native BCrypt RSA backend to parse/encode PKCS#8 / PKCS#1.
82-
der.workspace = true
83-
pkcs1.workspace = true
84-
pkcs8 = { workspace = true, features = ["alloc"] }
8581

8682
# Used by the native Security.framework RSA backend to parse/encode PKCS#8 / PKCS#1.
8783
[target.'cfg(target_os = "macos")'.dependencies]

support/crypto/src/aes_256_gcm/win.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static AES_256_GCM: LazyLock<Result<AlgHandle, Aes256GcmError>> = LazyLock::new(
4242
});
4343

4444
fn err(err: windows_result::Error, op: &'static str) -> Aes256GcmError {
45-
Aes256GcmError(crate::BackendError::Bcrypt(err, op))
45+
Aes256GcmError(crate::BackendError(err, op))
4646
}
4747

4848
pub struct Aes256GcmInner {

support/crypto/src/lib.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,8 @@ pub(crate) struct BackendError(#[source] openssl::error::ErrorStack, &'static st
4242
/// operation being performed when the error occurred.
4343
#[cfg(all(native, windows))]
4444
#[derive(Clone, Debug, thiserror::Error)]
45-
pub(crate) enum BackendError {
46-
/// An error from a BCrypt / CryptoAPI call.
47-
#[error("windows crypto error during {1}")]
48-
Bcrypt(#[source] windows_result::Error, &'static str),
49-
/// An error from encoding or decoding PKCS#8.
50-
#[error("PKCS#8 error during {1}")]
51-
Pkcs8(#[source] pkcs8::Error, &'static str),
52-
/// An error from DER encoding or decoding.
53-
#[error("DER error during {1}")]
54-
Der(#[source] der::Error, &'static str),
55-
}
45+
#[error("windows crypto error during {1}")]
46+
pub(crate) struct BackendError(#[source] windows_result::Error, &'static str);
5647

5748
/// An error that occurred in the crypto backend, with a description of the
5849
/// operation being performed when the error occurred.

support/crypto/src/pkcs7/win.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use windows::Win32::Foundation::NTE_BAD_SIGNATURE;
1010
use windows::Win32::Security::Cryptography::*;
1111

1212
fn err(e: windows_result::Error, op: &'static str) -> Pkcs7Error {
13-
Pkcs7Error(crate::BackendError::Bcrypt(e, op))
13+
Pkcs7Error(crate::BackendError(e, op))
1414
}
1515

1616
/// RAII wrapper for HCERTSTORE.

0 commit comments

Comments
 (0)