|
| 1 | +// Copyright 2019-2023 Hugo Pointcheval |
| 2 | +// |
| 3 | +// Use of this source code is governed by an MIT-style |
| 4 | +// license that can be found in the LICENSE file or at |
| 5 | +// https://opensource.org/licenses/MIT. |
| 6 | +// -- |
| 7 | +// Autogenerated from Pigeon (v9.2.0), do not edit directly. |
| 8 | +// See also: https://pub.dev/packages/pigeon |
| 9 | +// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import |
| 10 | + |
| 11 | +import 'dart:async'; |
| 12 | +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; |
| 13 | + |
| 14 | +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; |
| 15 | +import 'package:flutter/services.dart'; |
| 16 | + |
| 17 | +enum HashAlgorithm { |
| 18 | + sha256, |
| 19 | + sha384, |
| 20 | + sha512, |
| 21 | +} |
| 22 | + |
| 23 | +enum CipherAlgorithm { |
| 24 | + aes, |
| 25 | +} |
| 26 | + |
| 27 | +class NativeCryptoAPI { |
| 28 | + /// Constructor for [NativeCryptoAPI]. The [binaryMessenger] named argument is |
| 29 | + /// available for dependency injection. If it is left null, the default |
| 30 | + /// BinaryMessenger will be used which routes to the host platform. |
| 31 | + NativeCryptoAPI({BinaryMessenger? binaryMessenger}) |
| 32 | + : _binaryMessenger = binaryMessenger; |
| 33 | + final BinaryMessenger? _binaryMessenger; |
| 34 | + |
| 35 | + static const MessageCodec<Object?> codec = StandardMessageCodec(); |
| 36 | + |
| 37 | + Future<Uint8List?> hash(Uint8List arg_data, HashAlgorithm arg_algorithm) async { |
| 38 | + final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( |
| 39 | + 'dev.flutter.pigeon.NativeCryptoAPI.hash', codec, |
| 40 | + binaryMessenger: _binaryMessenger); |
| 41 | + final List<Object?>? replyList = |
| 42 | + await channel.send(<Object?>[arg_data, arg_algorithm.index]) as List<Object?>?; |
| 43 | + if (replyList == null) { |
| 44 | + throw PlatformException( |
| 45 | + code: 'channel-error', |
| 46 | + message: 'Unable to establish connection on channel.', |
| 47 | + ); |
| 48 | + } else if (replyList.length > 1) { |
| 49 | + throw PlatformException( |
| 50 | + code: replyList[0]! as String, |
| 51 | + message: replyList[1] as String?, |
| 52 | + details: replyList[2], |
| 53 | + ); |
| 54 | + } else { |
| 55 | + return (replyList[0] as Uint8List?); |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + Future<Uint8List?> hmac(Uint8List arg_data, Uint8List arg_key, HashAlgorithm arg_algorithm) async { |
| 60 | + final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( |
| 61 | + 'dev.flutter.pigeon.NativeCryptoAPI.hmac', codec, |
| 62 | + binaryMessenger: _binaryMessenger); |
| 63 | + final List<Object?>? replyList = |
| 64 | + await channel.send(<Object?>[arg_data, arg_key, arg_algorithm.index]) as List<Object?>?; |
| 65 | + if (replyList == null) { |
| 66 | + throw PlatformException( |
| 67 | + code: 'channel-error', |
| 68 | + message: 'Unable to establish connection on channel.', |
| 69 | + ); |
| 70 | + } else if (replyList.length > 1) { |
| 71 | + throw PlatformException( |
| 72 | + code: replyList[0]! as String, |
| 73 | + message: replyList[1] as String?, |
| 74 | + details: replyList[2], |
| 75 | + ); |
| 76 | + } else { |
| 77 | + return (replyList[0] as Uint8List?); |
| 78 | + } |
| 79 | + } |
| 80 | + |
| 81 | + Future<Uint8List?> generateSecureRandom(int arg_length) async { |
| 82 | + final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( |
| 83 | + 'dev.flutter.pigeon.NativeCryptoAPI.generateSecureRandom', codec, |
| 84 | + binaryMessenger: _binaryMessenger); |
| 85 | + final List<Object?>? replyList = |
| 86 | + await channel.send(<Object?>[arg_length]) as List<Object?>?; |
| 87 | + if (replyList == null) { |
| 88 | + throw PlatformException( |
| 89 | + code: 'channel-error', |
| 90 | + message: 'Unable to establish connection on channel.', |
| 91 | + ); |
| 92 | + } else if (replyList.length > 1) { |
| 93 | + throw PlatformException( |
| 94 | + code: replyList[0]! as String, |
| 95 | + message: replyList[1] as String?, |
| 96 | + details: replyList[2], |
| 97 | + ); |
| 98 | + } else { |
| 99 | + return (replyList[0] as Uint8List?); |
| 100 | + } |
| 101 | + } |
| 102 | + |
| 103 | + Future<Uint8List?> pbkdf2(Uint8List arg_password, Uint8List arg_salt, int arg_length, int arg_iterations, HashAlgorithm arg_algorithm) async { |
| 104 | + final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( |
| 105 | + 'dev.flutter.pigeon.NativeCryptoAPI.pbkdf2', codec, |
| 106 | + binaryMessenger: _binaryMessenger); |
| 107 | + final List<Object?>? replyList = |
| 108 | + await channel.send(<Object?>[arg_password, arg_salt, arg_length, arg_iterations, arg_algorithm.index]) as List<Object?>?; |
| 109 | + if (replyList == null) { |
| 110 | + throw PlatformException( |
| 111 | + code: 'channel-error', |
| 112 | + message: 'Unable to establish connection on channel.', |
| 113 | + ); |
| 114 | + } else if (replyList.length > 1) { |
| 115 | + throw PlatformException( |
| 116 | + code: replyList[0]! as String, |
| 117 | + message: replyList[1] as String?, |
| 118 | + details: replyList[2], |
| 119 | + ); |
| 120 | + } else { |
| 121 | + return (replyList[0] as Uint8List?); |
| 122 | + } |
| 123 | + } |
| 124 | + |
| 125 | + Future<Uint8List?> encrypt(Uint8List arg_plainText, Uint8List arg_key, CipherAlgorithm arg_algorithm) async { |
| 126 | + final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( |
| 127 | + 'dev.flutter.pigeon.NativeCryptoAPI.encrypt', codec, |
| 128 | + binaryMessenger: _binaryMessenger); |
| 129 | + final List<Object?>? replyList = |
| 130 | + await channel.send(<Object?>[arg_plainText, arg_key, arg_algorithm.index]) as List<Object?>?; |
| 131 | + if (replyList == null) { |
| 132 | + throw PlatformException( |
| 133 | + code: 'channel-error', |
| 134 | + message: 'Unable to establish connection on channel.', |
| 135 | + ); |
| 136 | + } else if (replyList.length > 1) { |
| 137 | + throw PlatformException( |
| 138 | + code: replyList[0]! as String, |
| 139 | + message: replyList[1] as String?, |
| 140 | + details: replyList[2], |
| 141 | + ); |
| 142 | + } else { |
| 143 | + return (replyList[0] as Uint8List?); |
| 144 | + } |
| 145 | + } |
| 146 | + |
| 147 | + Future<Uint8List?> encryptWithIV(Uint8List arg_plainText, Uint8List arg_iv, Uint8List arg_key, CipherAlgorithm arg_algorithm) async { |
| 148 | + final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( |
| 149 | + 'dev.flutter.pigeon.NativeCryptoAPI.encryptWithIV', codec, |
| 150 | + binaryMessenger: _binaryMessenger); |
| 151 | + final List<Object?>? replyList = |
| 152 | + await channel.send(<Object?>[arg_plainText, arg_iv, arg_key, arg_algorithm.index]) as List<Object?>?; |
| 153 | + if (replyList == null) { |
| 154 | + throw PlatformException( |
| 155 | + code: 'channel-error', |
| 156 | + message: 'Unable to establish connection on channel.', |
| 157 | + ); |
| 158 | + } else if (replyList.length > 1) { |
| 159 | + throw PlatformException( |
| 160 | + code: replyList[0]! as String, |
| 161 | + message: replyList[1] as String?, |
| 162 | + details: replyList[2], |
| 163 | + ); |
| 164 | + } else { |
| 165 | + return (replyList[0] as Uint8List?); |
| 166 | + } |
| 167 | + } |
| 168 | + |
| 169 | + Future<Uint8List?> decrypt(Uint8List arg_cipherText, Uint8List arg_key, CipherAlgorithm arg_algorithm) async { |
| 170 | + final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( |
| 171 | + 'dev.flutter.pigeon.NativeCryptoAPI.decrypt', codec, |
| 172 | + binaryMessenger: _binaryMessenger); |
| 173 | + final List<Object?>? replyList = |
| 174 | + await channel.send(<Object?>[arg_cipherText, arg_key, arg_algorithm.index]) as List<Object?>?; |
| 175 | + if (replyList == null) { |
| 176 | + throw PlatformException( |
| 177 | + code: 'channel-error', |
| 178 | + message: 'Unable to establish connection on channel.', |
| 179 | + ); |
| 180 | + } else if (replyList.length > 1) { |
| 181 | + throw PlatformException( |
| 182 | + code: replyList[0]! as String, |
| 183 | + message: replyList[1] as String?, |
| 184 | + details: replyList[2], |
| 185 | + ); |
| 186 | + } else { |
| 187 | + return (replyList[0] as Uint8List?); |
| 188 | + } |
| 189 | + } |
| 190 | + |
| 191 | + Future<bool?> encryptFile(String arg_plainTextPath, String arg_cipherTextPath, Uint8List arg_key, CipherAlgorithm arg_algorithm) async { |
| 192 | + final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( |
| 193 | + 'dev.flutter.pigeon.NativeCryptoAPI.encryptFile', codec, |
| 194 | + binaryMessenger: _binaryMessenger); |
| 195 | + final List<Object?>? replyList = |
| 196 | + await channel.send(<Object?>[arg_plainTextPath, arg_cipherTextPath, arg_key, arg_algorithm.index]) as List<Object?>?; |
| 197 | + if (replyList == null) { |
| 198 | + throw PlatformException( |
| 199 | + code: 'channel-error', |
| 200 | + message: 'Unable to establish connection on channel.', |
| 201 | + ); |
| 202 | + } else if (replyList.length > 1) { |
| 203 | + throw PlatformException( |
| 204 | + code: replyList[0]! as String, |
| 205 | + message: replyList[1] as String?, |
| 206 | + details: replyList[2], |
| 207 | + ); |
| 208 | + } else { |
| 209 | + return (replyList[0] as bool?); |
| 210 | + } |
| 211 | + } |
| 212 | + |
| 213 | + Future<bool?> encryptFileWithIV(String arg_plainTextPath, String arg_cipherTextPath, Uint8List arg_iv, Uint8List arg_key, CipherAlgorithm arg_algorithm) async { |
| 214 | + final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( |
| 215 | + 'dev.flutter.pigeon.NativeCryptoAPI.encryptFileWithIV', codec, |
| 216 | + binaryMessenger: _binaryMessenger); |
| 217 | + final List<Object?>? replyList = |
| 218 | + await channel.send(<Object?>[arg_plainTextPath, arg_cipherTextPath, arg_iv, arg_key, arg_algorithm.index]) as List<Object?>?; |
| 219 | + if (replyList == null) { |
| 220 | + throw PlatformException( |
| 221 | + code: 'channel-error', |
| 222 | + message: 'Unable to establish connection on channel.', |
| 223 | + ); |
| 224 | + } else if (replyList.length > 1) { |
| 225 | + throw PlatformException( |
| 226 | + code: replyList[0]! as String, |
| 227 | + message: replyList[1] as String?, |
| 228 | + details: replyList[2], |
| 229 | + ); |
| 230 | + } else { |
| 231 | + return (replyList[0] as bool?); |
| 232 | + } |
| 233 | + } |
| 234 | + |
| 235 | + Future<bool?> decryptFile(String arg_cipherTextPath, String arg_plainTextPath, Uint8List arg_key, CipherAlgorithm arg_algorithm) async { |
| 236 | + final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( |
| 237 | + 'dev.flutter.pigeon.NativeCryptoAPI.decryptFile', codec, |
| 238 | + binaryMessenger: _binaryMessenger); |
| 239 | + final List<Object?>? replyList = |
| 240 | + await channel.send(<Object?>[arg_cipherTextPath, arg_plainTextPath, arg_key, arg_algorithm.index]) as List<Object?>?; |
| 241 | + if (replyList == null) { |
| 242 | + throw PlatformException( |
| 243 | + code: 'channel-error', |
| 244 | + message: 'Unable to establish connection on channel.', |
| 245 | + ); |
| 246 | + } else if (replyList.length > 1) { |
| 247 | + throw PlatformException( |
| 248 | + code: replyList[0]! as String, |
| 249 | + message: replyList[1] as String?, |
| 250 | + details: replyList[2], |
| 251 | + ); |
| 252 | + } else { |
| 253 | + return (replyList[0] as bool?); |
| 254 | + } |
| 255 | + } |
| 256 | +} |
0 commit comments