-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dpapi): implement basic RPC structures encoding/decoding (#342)
- Loading branch information
1 parent
a8272f7
commit 1bcff60
Showing
18 changed files
with
1,632 additions
and
120 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,25 @@ | ||
[package] | ||
name = "dpapi" | ||
version = "0.1.0" | ||
edition = "2021" | ||
readme = "README.md" | ||
license = "MIT/Apache-2.0" | ||
homepage = "https://github.com/devolutions/sspi-rs" | ||
repository = "https://github.com/devolutions/sspi-rs" | ||
authors = ["Devolutions Inc. <[email protected]>"] | ||
description = "A Rust implementation of Windows DPAPI" | ||
|
||
[lib] | ||
name = "dpapi" | ||
|
||
[dependencies] | ||
bitflags.workspace = true | ||
byteorder.workspace = true | ||
num-derive.workspace = true | ||
num-traits = { workspace = true, default-features = true } | ||
uuid = { workspace = true, features = ["std"] } | ||
|
||
thiserror = "2.0" | ||
|
||
[dev-dependencies] | ||
paste = "1.0" |
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,9 @@ | ||
# dpapi-rs | ||
|
||
This crate contains a Windows [DPAPI](https://learn.microsoft.com/en-us/windows/win32/seccng/cng-dpapi) implementation. It can encrypt the data/decrypt DPAPI blobs using the domain's root key. | ||
|
||
It automatically makes RPC calls to obtain the root key. The user must provide credentials to authenticate in the DC. | ||
|
||
It implements the [MS-GKDI Group Key Distribution Protocol](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-gkdi/943dd4f6-6b80-4a66-8594-80df6d2aad0a). | ||
|
||
The original DPAPI supports many [protection descriptors](https://learn.microsoft.com/en-us/windows/win32/seccng/protection-descriptors). This library implements only SID protection descriptor. |
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,51 @@ | ||
use thiserror::Error; | ||
|
||
#[derive(Debug, Error)] | ||
pub enum Error { | ||
#[error("IO error")] | ||
Io(#[from] std::io::Error), | ||
|
||
#[error("UUID error: {0}")] | ||
Uuid(#[from] uuid::Error), | ||
|
||
#[error(transparent)] | ||
IntConversion(#[from] std::num::TryFromIntError), | ||
|
||
#[error("provided buf contains invalid UTF-8 data")] | ||
Utf8(#[from] std::string::FromUtf8Error), | ||
|
||
#[error("invalid context result code value: {0}")] | ||
InvalidContextResultCode(u16), | ||
|
||
#[error("invalid integer representation value: {0}")] | ||
InvalidIntRepr(u8), | ||
|
||
#[error("invalid character representation value: {0}")] | ||
InvalidCharacterRepr(u8), | ||
|
||
#[error("invalid floating point representation value: {0}")] | ||
InvalidFloatingPointRepr(u8), | ||
|
||
#[error("invalid packet type value: {0}")] | ||
InvalidPacketType(u8), | ||
|
||
#[error("invalid packet flags value: {0}")] | ||
InvalidPacketFlags(u8), | ||
|
||
#[error("invalid security provider value: {0}")] | ||
InvalidSecurityProvider(u8), | ||
|
||
#[error("invalid authentication level value: {0}")] | ||
InvalidAuthenticationLevel(u8), | ||
|
||
#[error("invalid fault flags value: {0}")] | ||
InvalidFaultFlags(u8), | ||
|
||
#[error("{0:?} PDU is not supported")] | ||
PduNotSupported(crate::rpc::pdu::PacketType), | ||
|
||
#[error("invalid fragment (PDU) length: {0}")] | ||
InvalidFragLength(u16), | ||
} | ||
|
||
pub type DpapiResult<T> = Result<T, Error>; |
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,8 @@ | ||
// #![warn(missing_docs)] | ||
#![doc = include_str!("../README.md")] | ||
#![allow(dead_code)] | ||
|
||
mod error; | ||
pub mod rpc; | ||
|
||
pub use error::*; |
Oops, something went wrong.