File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed
Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -31,3 +31,47 @@ pub mod prf;
3131pub mod random;
3232pub mod rsa;
3333pub mod sha;
34+
35+ use crate :: sys;
36+
37+ /// Initialize resources used by wolfCrypt.
38+ ///
39+ /// # Returns
40+ ///
41+ /// Returns either Ok(()) on success or Err(e) containing the wolfSSL
42+ /// library error code value.
43+ ///
44+ /// # Example
45+ ///
46+ /// ```rust
47+ /// use wolfssl::wolfcrypt::*;
48+ /// wolfcrypt_init().expect("Error with wolfcrypt_init()");
49+ /// ```
50+ pub fn wolfcrypt_init ( ) -> Result < ( ) , i32 > {
51+ let rc = unsafe { sys:: wolfCrypt_Init ( ) } ;
52+ if rc != 0 {
53+ return Err ( rc) ;
54+ }
55+ Ok ( ( ) )
56+ }
57+
58+ /// Clean up resources used by wolfCrypt.
59+ ///
60+ /// # Returns
61+ ///
62+ /// Returns either Ok(()) on success or Err(e) containing the wolfSSL
63+ /// library error code value.
64+ ///
65+ /// # Example
66+ ///
67+ /// ```rust
68+ /// use wolfssl::wolfcrypt::*;
69+ /// wolfcrypt_cleanup().expect("Error with wolfcrypt_cleanup()");
70+ /// ```
71+ pub fn wolfcrypt_cleanup ( ) -> Result < ( ) , i32 > {
72+ let rc = unsafe { sys:: wolfCrypt_Cleanup ( ) } ;
73+ if rc != 0 {
74+ return Err ( rc) ;
75+ }
76+ Ok ( ( ) )
77+ }
Original file line number Diff line number Diff line change 1+ use wolfssl:: wolfcrypt:: * ;
2+
3+ #[ test]
4+ fn test_wolfcrypt_init ( ) {
5+ wolfcrypt_init ( ) . expect ( "Error with wolfcrypt_init()" ) ;
6+ }
7+
8+ #[ test]
9+ fn test_wolfcrypt_cleanup ( ) {
10+ wolfcrypt_cleanup ( ) . expect ( "Error with wolfcrypt_cleanup()" ) ;
11+ }
You can’t perform that action at this time.
0 commit comments