File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -304,23 +304,24 @@ impl MechanismType {
304304 ///
305305 /// # Arguments
306306 ///
307- /// * `adding ` - The adding based on `CKM_VENDOR_DEFINED`
307+ /// * `val ` - The value of vendor defined mechanism
308308 ///
309- /// Usually vendors defines custom mechanism like this:
310- /// ```c
311- /// #define CKM_SOME_CUSTOM_MECH (CKM_VENDOR_DEFINED | 0x00000001UL)
312- /// ```
309+ /// # Errors
310+ ///
311+ /// If `val` is less then `CKM_VENDOR_DEFINED`, a `Error::InvalidValue` will be returned
313312 ///
314- /// It maps to
313+ /// # Examples
315314 /// ```rust
316- /// use cryptoki::mechanism::MechanismType;
315+ /// use cryptoki::mechanism::{vendor_defined::CKM_VENDOR_DEFINED, MechanismType} ;
317316 ///
318- /// pub const CKM_SOME_CUSTOM_MECH : MechanismType =
319- /// MechanismType::new_vendor_defined(0x00000001);
317+ /// let some_custom_mech : MechanismType =
318+ /// MechanismType::new_vendor_defined(CKM_VENDOR_DEFINED | 0x00000001).unwrap( );
320319 /// ```
321- pub const fn new_vendor_defined ( adding : CK_ULONG ) -> MechanismType {
322- MechanismType {
323- val : CKM_VENDOR_DEFINED | adding,
320+ pub fn new_vendor_defined ( val : CK_MECHANISM_TYPE ) -> crate :: error:: Result < MechanismType > {
321+ if val < CKM_VENDOR_DEFINED {
322+ Err ( Error :: InvalidValue )
323+ } else {
324+ Ok ( MechanismType { val } )
324325 }
325326 }
326327
Original file line number Diff line number Diff line change 66
77use std:: { marker:: PhantomData , ptr:: null_mut} ;
88
9+ pub use cryptoki_sys:: CKM_VENDOR_DEFINED ;
910use cryptoki_sys:: CK_MECHANISM ;
1011
1112use super :: { make_mechanism, MechanismType } ;
You can’t perform that action at this time.
0 commit comments