Skip to content

Commit 78f23d6

Browse files
committed
pkey_ctx: add Selection trait for Param/Public/Private markers
1 parent c80455e commit 78f23d6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

openssl/src/pkey_ctx.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ use crate::cipher::CipherRef;
6969
use crate::error::ErrorStack;
7070
use crate::md::MdRef;
7171
use crate::nid::Nid;
72+
#[cfg(ossl300)]
73+
use crate::pkey::Public;
7274
use crate::pkey::{HasPrivate, HasPublic, Id, PKey, PKeyRef, Params, Private};
7375
use crate::rsa::Padding;
7476
use crate::sign::RsaPssSaltlen;
@@ -125,6 +127,27 @@ impl NonceType {
125127
pub const DETERMINISTIC_K: Self = NonceType(1);
126128
}
127129

130+
cfg_if! {
131+
if #[cfg(ossl300)] {
132+
/// Selection for fromdata operation.
133+
pub(crate) trait Selection {
134+
const SELECTION: c_int;
135+
}
136+
137+
impl Selection for Params {
138+
const SELECTION: c_int = ffi::EVP_PKEY_KEY_PARAMETERS;
139+
}
140+
141+
impl Selection for Public {
142+
const SELECTION: c_int = ffi::EVP_PKEY_PUBLIC_KEY;
143+
}
144+
145+
impl Selection for Private {
146+
const SELECTION: c_int = ffi::EVP_PKEY_KEYPAIR;
147+
}
148+
}
149+
}
150+
128151
generic_foreign_type_and_impl_send_sync! {
129152
type CType = ffi::EVP_PKEY_CTX;
130153
fn drop = ffi::EVP_PKEY_CTX_free;

0 commit comments

Comments
 (0)