File tree Expand file tree Collapse file tree
wrapper/rust/wolfssl-wolfcrypt/tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#[ cfg( any( blake2b, blake2s) ) ]
22use wolfssl_wolfcrypt:: blake2:: * ;
3+ #[ cfg( any( blake2b, blake2s) ) ]
4+ use wolfssl_wolfcrypt:: sys;
35
46#[ test]
57#[ cfg( blake2b) ]
@@ -50,6 +52,15 @@ fn test_blake2b() {
5052 }
5153}
5254
55+ #[ test]
56+ #[ cfg( blake2b) ]
57+ fn test_blake2b_finalize_empty_buffer ( ) {
58+ let mut blake2b = BLAKE2b :: new ( 64 ) . expect ( "Error with new()" ) ;
59+ let mut hash: [ u8 ; 0 ] = [ ] ;
60+ let rc = blake2b. finalize ( & mut hash) . expect_err ( "finalize() should fail" ) ;
61+ assert_eq ! ( rc, sys:: wolfCrypt_ErrorCodes_BUFFER_E) ;
62+ }
63+
5364#[ test]
5465#[ cfg( blake2b_hmac) ]
5566fn test_blake2b_hmac ( ) {
@@ -151,6 +162,15 @@ fn test_blake2s() {
151162 }
152163}
153164
165+ #[ test]
166+ #[ cfg( blake2s) ]
167+ fn test_blake2s_finalize_empty_buffer ( ) {
168+ let mut blake2s = BLAKE2s :: new ( 32 ) . expect ( "Error with new()" ) ;
169+ let mut hash: [ u8 ; 0 ] = [ ] ;
170+ let rc = blake2s. finalize ( & mut hash) . expect_err ( "finalize() should fail" ) ;
171+ assert_eq ! ( rc, sys:: wolfCrypt_ErrorCodes_BUFFER_E) ;
172+ }
173+
154174#[ test]
155175#[ cfg( blake2s_hmac) ]
156176fn test_blake2s_hmac ( ) {
You can’t perform that action at this time.
0 commit comments