File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -193,15 +193,12 @@ impl CryptKdf {
193193
194194 /// Convert from a C `char *`
195195 pub ( crate ) fn from_ptr ( ptr : * const c_char ) -> Result < Self , LibcryptErr > {
196- if libcryptsetup_rs_sys:: CRYPT_KDF_PBKDF2 == unsafe { CStr :: from_ptr ( ptr) } . to_bytes ( ) {
196+ let p_bytes = unsafe { CStr :: from_ptr ( ptr) } . to_bytes_with_nul ( ) ;
197+ if libcryptsetup_rs_sys:: CRYPT_KDF_PBKDF2 == p_bytes {
197198 Ok ( CryptKdf :: Pbkdf2 )
198- } else if libcryptsetup_rs_sys:: CRYPT_KDF_ARGON2I
199- == unsafe { CStr :: from_ptr ( ptr) } . to_bytes ( )
200- {
199+ } else if libcryptsetup_rs_sys:: CRYPT_KDF_ARGON2I == p_bytes {
201200 Ok ( CryptKdf :: Argon2I )
202- } else if libcryptsetup_rs_sys:: CRYPT_KDF_ARGON2ID
203- == unsafe { CStr :: from_ptr ( ptr) } . to_bytes ( )
204- {
201+ } else if libcryptsetup_rs_sys:: CRYPT_KDF_ARGON2ID == p_bytes {
205202 Ok ( CryptKdf :: Argon2Id )
206203 } else {
207204 Err ( LibcryptErr :: InvalidConversion )
You can’t perform that action at this time.
0 commit comments