File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ name = "rust-scrypt"
33authors = [
" Constantine Kryvomaz <[email protected] >" ]
44description = " Bindings into C for Tarsnap's `Scrypt` algorithm"
55repository = " https://github.com/r8d8/rust-scrypt"
6- version = " 1.2 .0"
6+ version = " 1.3 .0"
77build = " build.rs"
88keywords = [" rust" , " crypto" , " scrypt" ]
99readme = " README.md"
Original file line number Diff line number Diff line change 55#![ cfg_attr( feature = "dev" , plugin( clippy) ) ]
66#![ allow( non_upper_case_globals) ]
77
8+ use std:: mem:: size_of;
9+
810#[ link( name = "scrypt" ) ]
911extern "C" {
1012 pub fn crypto_scrypt (
@@ -33,6 +35,26 @@ pub struct ScryptParams {
3335 pub p : u32 ,
3436}
3537
38+ impl ScryptParams {
39+
40+ ///Create a new instance of ScryptParams
41+ ///
42+ /// # Arguments:
43+ /// log_n - The log2 of the Scrypt parameter N
44+ /// r - The Scrypt parameter r
45+ /// p - The Scrypt parameter p
46+ ///
47+ pub fn new ( n : u64 , r : u32 , p : u32 ) -> ScryptParams {
48+ assert ! ( r > 0 ) ;
49+ assert ! ( p > 0 ) ;
50+ assert ! ( n > 0 ) ;
51+ assert ! ( size_of:: <usize >( ) >= size_of:: <u32 >( ) || ( r <= std:: usize :: MAX as u32 && p < std:: usize :: MAX as u32 ) ) ;
52+
53+ ScryptParams { n, r, p }
54+ }
55+
56+ }
57+
3658/// Derive fixed size key for given `salt` and `passphrase`
3759///
3860/// #Arguments:
You can’t perform that action at this time.
0 commit comments