Skip to content

Commit 9def0e5

Browse files
committed
pkey_ctx: add Selection trait for Param/Public/Private markers
1 parent f63fca6 commit 9def0e5

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
@@ -70,6 +70,8 @@ use crate::cipher::CipherRef;
7070
use crate::error::ErrorStack;
7171
use crate::md::MdRef;
7272
use crate::nid::Nid;
73+
#[cfg(ossl300)]
74+
use crate::pkey::Public;
7375
use crate::pkey::{HasPrivate, HasPublic, Id, PKey, PKeyRef, Params, Private};
7476
use crate::rsa::Padding;
7577
use crate::sign::RsaPssSaltlen;
@@ -127,6 +129,27 @@ impl NonceType {
127129
pub const DETERMINISTIC_K: Self = NonceType(1);
128130
}
129131

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

0 commit comments

Comments
 (0)