File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#[ cfg( test) ]
22mod key_tests {
3+ use crate :: errors:: { CryptoError , VerificationError } ;
34 use ed25519_consensus:: SigningKey as Ed25519SigningKey ;
45 use prism_serde:: base64:: { FromBase64 , ToBase64 } ;
56 use rand:: rngs:: OsRng ;
@@ -346,6 +347,28 @@ mod key_tests {
346347 assert ! ( result. is_err( ) ) ;
347348 }
348349
350+ #[ test]
351+ fn test_verifying_key_with_invalid_bytes ( ) {
352+ let invalid_bytes = [ 0u8 ; 1 ] ;
353+
354+ let algorithms = [
355+ CryptoAlgorithm :: Ed25519 ,
356+ CryptoAlgorithm :: Secp256k1 ,
357+ CryptoAlgorithm :: Secp256r1 ,
358+ CryptoAlgorithm :: Eip191 ,
359+ CryptoAlgorithm :: CosmosAdr36 ,
360+ ] ;
361+
362+ for algorithm in algorithms {
363+ let result = VerifyingKey :: from_algorithm_and_bytes ( algorithm, & invalid_bytes) ;
364+ assert ! ( matches!(
365+ result,
366+ Err ( CryptoError :: VerificationError (
367+ VerificationError :: VerifyError ( _, _)
368+ ) )
369+ ) ) ;
370+ }
371+
349372 #[ test]
350373 fn test_verifying_key_from_spki_pem_path_or_base64 ( ) {
351374 let temp_dir = tempdir ( ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments