forked from steffengy/schannel-rs
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow certificate private key lookup
We have to pull some ncrypt stuff in temporarily until retep998/winapi-rs#319 lands.
- Loading branch information
Showing
8 changed files
with
121 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
extern crate build; | ||
|
||
// FIXME https://github.com/retep998/winapi-rs/pull/319 | ||
fn main() { | ||
build::link("ncrypt", true) | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//! Private keys. | ||
|
||
use advapi32; | ||
use winapi; | ||
|
||
use KeyHandlePriv; | ||
|
||
/// A handle to a private key. | ||
pub struct KeyHandle { | ||
handle: winapi::HCRYPTPROV_OR_NCRYPT_KEY_HANDLE, | ||
spec: winapi::DWORD, | ||
} | ||
|
||
// FIXME https://github.com/retep998/winapi-rs/pull/319 | ||
extern "system" { | ||
fn NCryptFreeObject(handle: winapi::NCRYPT_HANDLE) -> winapi::SECURITY_STATUS; | ||
} | ||
|
||
impl Drop for KeyHandle { | ||
fn drop(&mut self) { | ||
unsafe { | ||
if self.spec == winapi::CERT_NCRYPT_KEY_SPEC { | ||
NCryptFreeObject(self.handle); | ||
} else { | ||
advapi32::CryptReleaseContext(self.handle, 0); | ||
} | ||
} | ||
} | ||
} | ||
|
||
impl KeyHandlePriv for KeyHandle { | ||
fn new(handle: winapi::HCRYPTPROV_OR_NCRYPT_KEY_HANDLE, spec: winapi::DWORD) -> KeyHandle { | ||
KeyHandle { | ||
handle: handle, | ||
spec: spec, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.