v2 #12
| @ -33,14 +33,14 @@ dependencies: | |||||||
| dev_dependencies: | dev_dependencies: | ||||||
|   flutter_test: { sdk: flutter } |   flutter_test: { sdk: flutter } | ||||||
| 
 | 
 | ||||||
|   mockito: ^5.3.2 |   mockito: ^5.4.0 | ||||||
|   plugin_platform_interface: ^2.1.3 |   plugin_platform_interface: ^2.1.4 | ||||||
| 
 | 
 | ||||||
|   wyatt_analysis: |   wyatt_analysis: | ||||||
|     hosted: |     hosted: | ||||||
|       url: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/ |       url: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/ | ||||||
|       name: wyatt_analysis |       name: wyatt_analysis | ||||||
|     version: 2.4.0 |     version: 2.4.1 | ||||||
| 
 | 
 | ||||||
| flutter: | flutter: | ||||||
|   plugin: |   plugin: | ||||||
|  | |||||||
| @ -6,7 +6,7 @@ | |||||||
| 
 | 
 | ||||||
| import 'dart:typed_data'; | import 'dart:typed_data'; | ||||||
| 
 | 
 | ||||||
| import 'package:native_crypto_platform_interface/native_crypto_platform_interface.dart'; | import 'package:native_crypto_platform_interface/native_crypto_platform_interface_gen.dart'; | ||||||
| 
 | 
 | ||||||
| class MockNativeCryptoAPI implements NativeCryptoAPI { | class MockNativeCryptoAPI implements NativeCryptoAPI { | ||||||
|   static Uint8List? Function(int length)? generateSecureRandomFn; |   static Uint8List? Function(int length)? generateSecureRandomFn; | ||||||
| @ -41,6 +41,13 @@ class MockNativeCryptoAPI implements NativeCryptoAPI { | |||||||
|     String algorithm, |     String algorithm, | ||||||
|   )? encryptFn; |   )? encryptFn; | ||||||
| 
 | 
 | ||||||
|  |   static Uint8List? Function( | ||||||
|  |     Uint8List plainText, | ||||||
|  |     Uint8List key, | ||||||
|  |     Uint8List iv, | ||||||
|  |     String algorithm, | ||||||
|  |   )? encryptWithIVFn; | ||||||
|  | 
 | ||||||
|   static bool? Function( |   static bool? Function( | ||||||
|     String plainTextPath, |     String plainTextPath, | ||||||
|     String cipherTextPath, |     String cipherTextPath, | ||||||
| @ -48,12 +55,13 @@ class MockNativeCryptoAPI implements NativeCryptoAPI { | |||||||
|     String algorithm, |     String algorithm, | ||||||
|   )? encryptFileFn; |   )? encryptFileFn; | ||||||
| 
 | 
 | ||||||
|   static Uint8List? Function( |   static bool? Function( | ||||||
|     Uint8List plainText, |     String plainTextPath, | ||||||
|  |     String cipherTextPath, | ||||||
|     Uint8List key, |     Uint8List key, | ||||||
|     Uint8List iv, |     Uint8List iv, | ||||||
|     String algorithm, |     String algorithm, | ||||||
|   )? encryptWithIVFn; |   )? encryptFileWithIVFn; | ||||||
| 
 | 
 | ||||||
|   static Uint8List? Function( |   static Uint8List? Function( | ||||||
|     Uint8List password, |     Uint8List password, | ||||||
| @ -64,130 +72,158 @@ class MockNativeCryptoAPI implements NativeCryptoAPI { | |||||||
|   )? pbkdf2Fn; |   )? pbkdf2Fn; | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   Future<DecryptResponse> decrypt(DecryptRequest argRequest) async => |   Future<Uint8List?> decrypt( | ||||||
|       decryptFn != null |     Uint8List argCiphertext, | ||||||
|           ? DecryptResponse( |     Uint8List argKey, | ||||||
|               plainText: decryptFn!( |     CipherAlgorithm argAlgorithm, | ||||||
|                 argRequest.cipherText!, |   ) async { | ||||||
|                 argRequest.key!, |     if (decryptFn != null) { | ||||||
|                 argRequest.algorithm!, |       return decryptFn!(argCiphertext, argKey, argAlgorithm.toString()); | ||||||
|               ), |     } else { | ||||||
|             ) |       return Uint8List.fromList([1, 2, 3]); | ||||||
|           : DecryptResponse( |     } | ||||||
|               plainText: Uint8List.fromList([1, 2, 3]), |   } | ||||||
|  | 
 | ||||||
|  |   @override | ||||||
|  |   Future<bool?> decryptFile( | ||||||
|  |     String argCiphertextpath, | ||||||
|  |     String argPlaintextpath, | ||||||
|  |     Uint8List argKey, | ||||||
|  |     CipherAlgorithm argAlgorithm, | ||||||
|  |   ) async { | ||||||
|  |     if (decryptFileFn != null) { | ||||||
|  |       return decryptFileFn!( | ||||||
|  |         argCiphertextpath, | ||||||
|  |         argPlaintextpath, | ||||||
|  |         argKey, | ||||||
|  |         argAlgorithm.toString(), | ||||||
|       ); |       ); | ||||||
|  |     } else { | ||||||
|  |       return Future.value(true); | ||||||
|  |     } | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   Future<DecryptFileResponse> decryptFile( |   Future<Uint8List?> encrypt( | ||||||
|     DecryptFileRequest argRequest, |     Uint8List argPlaintext, | ||||||
|   ) async => |     Uint8List argKey, | ||||||
|       decryptFileFn != null |     CipherAlgorithm argAlgorithm, | ||||||
|           ? DecryptFileResponse( |   ) async { | ||||||
|               success: decryptFileFn!( |     if (encryptFn != null) { | ||||||
|                 argRequest.cipherTextPath!, |       return encryptFn!(argPlaintext, argKey, argAlgorithm.toString()); | ||||||
|                 argRequest.plainTextPath!, |     } else { | ||||||
|                 argRequest.key!, |       return Uint8List.fromList([1, 2, 3]); | ||||||
|                 argRequest.algorithm!, |     } | ||||||
|               ), |   } | ||||||
|             ) |  | ||||||
|           : DecryptFileResponse(success: true); |  | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   Future<EncryptResponse> encrypt(EncryptRequest argRequest) async => |   Future<bool?> encryptFile( | ||||||
|       encryptFn != null |     String argPlaintextpath, | ||||||
|           ? EncryptResponse( |     String argCiphertextpath, | ||||||
|               cipherText: encryptFn!( |     Uint8List argKey, | ||||||
|                 argRequest.plainText!, |     CipherAlgorithm argAlgorithm, | ||||||
|                 argRequest.key!, |   ) async { | ||||||
|                 argRequest.algorithm!, |     if (encryptFileFn != null) { | ||||||
|               ), |       return encryptFileFn!( | ||||||
|             ) |         argPlaintextpath, | ||||||
|           : EncryptResponse( |         argCiphertextpath, | ||||||
|               cipherText: Uint8List.fromList([1, 2, 3]), |         argKey, | ||||||
|  |         argAlgorithm.toString(), | ||||||
|       ); |       ); | ||||||
|  |     } else { | ||||||
|  |       return Future.value(true); | ||||||
|  |     } | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   Future<EncryptFileResponse> encryptFile( |   Future<bool?> encryptFileWithIV( | ||||||
|     EncryptFileRequest argRequest, |     String argPlaintextpath, | ||||||
|   ) async => |     String argCiphertextpath, | ||||||
|       encryptFileFn != null |     Uint8List argIv, | ||||||
|           ? EncryptFileResponse( |     Uint8List argKey, | ||||||
|               success: encryptFileFn!( |     CipherAlgorithm argAlgorithm, | ||||||
|                 argRequest.plainTextPath!, |   ) async { | ||||||
|                 argRequest.cipherTextPath!, |     if (encryptFileWithIVFn != null) { | ||||||
|                 argRequest.key!, |       return encryptFileWithIVFn!( | ||||||
|                 argRequest.algorithm!, |         argPlaintextpath, | ||||||
|               ), |         argCiphertextpath, | ||||||
|             ) |         argKey, | ||||||
|           : EncryptFileResponse(success: true); |         argIv, | ||||||
| 
 |         argAlgorithm.toString(), | ||||||
|   @override |  | ||||||
|   Future<EncryptResponse> encryptWithIV( |  | ||||||
|     EncryptWithIVRequest argRequest, |  | ||||||
|   ) async => |  | ||||||
|       encryptWithIVFn != null |  | ||||||
|           ? EncryptResponse( |  | ||||||
|               cipherText: encryptWithIVFn!( |  | ||||||
|                 argRequest.plainText!, |  | ||||||
|                 argRequest.key!, |  | ||||||
|                 argRequest.iv!, |  | ||||||
|                 argRequest.algorithm!, |  | ||||||
|               ), |  | ||||||
|             ) |  | ||||||
|           : EncryptResponse( |  | ||||||
|               cipherText: Uint8List.fromList([1, 2, 3]), |  | ||||||
|       ); |       ); | ||||||
|  |     } else { | ||||||
|  |       return Future.value(true); | ||||||
|  |     } | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   Future<GenerateSecureRandomResponse> generateSecureRandom( |   Future<Uint8List?> encryptWithIV( | ||||||
|     GenerateSecureRandomRequest argRequest, |     Uint8List argPlaintext, | ||||||
|   ) async => |     Uint8List argIv, | ||||||
|       generateSecureRandomFn != null |     Uint8List argKey, | ||||||
|           ? GenerateSecureRandomResponse( |     CipherAlgorithm argAlgorithm, | ||||||
|               random: generateSecureRandomFn!(argRequest.length!), |   ) async { | ||||||
|             ) |     if (encryptWithIVFn != null) { | ||||||
|           : GenerateSecureRandomResponse( |       return encryptWithIVFn!( | ||||||
|               random: Uint8List.fromList([1, 2, 3]), |         argPlaintext, | ||||||
|  |         argKey, | ||||||
|  |         argIv, | ||||||
|  |         argAlgorithm.toString(), | ||||||
|       ); |       ); | ||||||
|  |     } else { | ||||||
|  |       return Future.value(Uint8List.fromList([1, 2, 3])); | ||||||
|  |     } | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   Future<HashResponse> hash(HashRequest argRequest) async => hashFn != null |   Future<Uint8List?> generateSecureRandom(int argLength) { | ||||||
|       ? HashResponse( |     if (generateSecureRandomFn != null) { | ||||||
|           hash: hashFn!( |       return Future.value(generateSecureRandomFn!(argLength)); | ||||||
|             argRequest.data!, |     } else { | ||||||
|             argRequest.algorithm!, |       return Future.value(Uint8List.fromList([1, 2, 3])); | ||||||
|           ), |     } | ||||||
|         ) |   } | ||||||
|       : HashResponse( |  | ||||||
|           hash: Uint8List.fromList([1, 2, 3]), |  | ||||||
|         ); |  | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   Future<HmacResponse> hmac(HmacRequest argRequest) async => hmacFn != null |   Future<Uint8List?> hash(Uint8List argData, HashAlgorithm argAlgorithm) { | ||||||
|       ? HmacResponse( |     if (hashFn != null) { | ||||||
|           hmac: hmacFn!( |       return Future.value(hashFn!(argData, argAlgorithm.toString())); | ||||||
|             argRequest.data!, |     } else { | ||||||
|             argRequest.key!, |       return Future.value(Uint8List.fromList([1, 2, 3])); | ||||||
|             argRequest.algorithm!, |     } | ||||||
|           ), |   } | ||||||
|         ) |  | ||||||
|       : HmacResponse( |  | ||||||
|           hmac: Uint8List.fromList([1, 2, 3]), |  | ||||||
|         ); |  | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   Future<Pbkdf2Response> pbkdf2(Pbkdf2Request argRequest) async => |   Future<Uint8List?> hmac( | ||||||
|       pbkdf2Fn != null |     Uint8List argData, | ||||||
|           ? Pbkdf2Response( |     Uint8List argKey, | ||||||
|               key: pbkdf2Fn!( |     HashAlgorithm argAlgorithm, | ||||||
|                 argRequest.password!, |   ) { | ||||||
|                 argRequest.salt!, |     if (hmacFn != null) { | ||||||
|                 argRequest.iterations!, |       return Future.value(hmacFn!(argData, argKey, argAlgorithm.toString())); | ||||||
|                 argRequest.length!, |     } else { | ||||||
|                 argRequest.hashAlgorithm!, |       return Future.value(Uint8List.fromList([1, 2, 3])); | ||||||
|               ), |     } | ||||||
|             ) |   } | ||||||
|           : Pbkdf2Response( | 
 | ||||||
|               key: Uint8List.fromList([1, 2, 3]), |   @override | ||||||
|             ); |   Future<Uint8List?> pbkdf2( | ||||||
|  |     Uint8List argPassword, | ||||||
|  |     Uint8List argSalt, | ||||||
|  |     int argLength, | ||||||
|  |     int argIterations, | ||||||
|  |     HashAlgorithm argAlgorithm, | ||||||
|  |   ) { | ||||||
|  |     if (pbkdf2Fn != null) { | ||||||
|  |       return Future.value(pbkdf2Fn!( | ||||||
|  |         argPassword, | ||||||
|  |         argSalt, | ||||||
|  |         argIterations, | ||||||
|  |         argLength, | ||||||
|  |         argAlgorithm.toString(), | ||||||
|  |       ),); | ||||||
|  |     } else { | ||||||
|  |       return Future.value(Uint8List.fromList([1, 2, 3])); | ||||||
|  |     } | ||||||
|  |   } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user