File tree 2 files changed +14
-12
lines changed
2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -304,23 +304,24 @@ impl MechanismType {
304
304
///
305
305
/// # Arguments
306
306
///
307
- /// * `adding ` - The adding based on `CKM_VENDOR_DEFINED`
307
+ /// * `val ` - The value of vendor defined mechanism
308
308
///
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
313
312
///
314
- /// It maps to
313
+ /// # Examples
315
314
/// ```rust
316
- /// use cryptoki::mechanism::MechanismType;
315
+ /// use cryptoki::mechanism::{vendor_defined::CKM_VENDOR_DEFINED, MechanismType} ;
317
316
///
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( );
320
319
/// ```
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 } )
324
325
}
325
326
}
326
327
Original file line number Diff line number Diff line change 6
6
7
7
use std:: { marker:: PhantomData , ptr:: null_mut} ;
8
8
9
+ pub use cryptoki_sys:: CKM_VENDOR_DEFINED ;
9
10
use cryptoki_sys:: CK_MECHANISM ;
10
11
11
12
use super :: { make_mechanism, MechanismType } ;
You can’t perform that action at this time.
0 commit comments