mirror of
https://github.com/localsend/localsend.git
synced 2026-08-07 07:14:52 +00:00
75 lines
2.7 KiB
Dart
75 lines
2.7 KiB
Dart
// This file is automatically generated, so please do not edit it.
|
|
// @generated by `flutter_rust_bridge`@ 2.12.0.
|
|
|
|
// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import
|
|
|
|
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
|
|
import 'package:localsend_isolates/rust/api/cancel.dart';
|
|
import 'package:localsend_isolates/rust/frb_generated.dart';
|
|
|
|
Future<void> verifyCert({required String cert, required String publicKey}) =>
|
|
RustLib.instance.api.crateApiCryptoVerifyCert(cert: cert, publicKey: publicKey);
|
|
|
|
Future<KeyPair> generateKeyPair() => RustLib.instance.api.crateApiCryptoGenerateKeyPair();
|
|
|
|
/// Generates a new device identity: an RSA-2048 key pair and a self-signed
|
|
/// certificate whose SHA-256 fingerprint identifies the device.
|
|
Future<SecurityContext> generateSecurityContext() => RustLib.instance.api.crateApiCryptoGenerateSecurityContext();
|
|
|
|
/// Computes the SHA-256 checksum of a file, encoded as lowercase hex.
|
|
///
|
|
/// The file is read chunk by chunk, so it is never fully loaded into memory.
|
|
/// Cancelling [cancel_token] aborts the read, so hashing a large file does not
|
|
/// have to be waited out.
|
|
///
|
|
/// Exactly one content source must be provided:
|
|
/// a [path] to a regular file, a [file_descriptor] (Android only), or [bytes]
|
|
/// for a file that only lives in memory.
|
|
Future<String> hashFile({String? path, int? fileDescriptor, Uint8List? bytes, required RsCancellationToken cancelToken}) =>
|
|
RustLib.instance.api.crateApiCryptoHashFile(path: path, fileDescriptor: fileDescriptor, bytes: bytes, cancelToken: cancelToken);
|
|
|
|
class KeyPair {
|
|
final String privateKey;
|
|
final String publicKey;
|
|
|
|
const KeyPair({
|
|
required this.privateKey,
|
|
required this.publicKey,
|
|
});
|
|
|
|
@override
|
|
int get hashCode => privateKey.hashCode ^ publicKey.hashCode;
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
other is KeyPair && runtimeType == other.runtimeType && privateKey == other.privateKey && publicKey == other.publicKey;
|
|
}
|
|
|
|
class SecurityContext {
|
|
final String privateKey;
|
|
final String publicKey;
|
|
final String certificate;
|
|
final String certificateHash;
|
|
|
|
const SecurityContext({
|
|
required this.privateKey,
|
|
required this.publicKey,
|
|
required this.certificate,
|
|
required this.certificateHash,
|
|
});
|
|
|
|
@override
|
|
int get hashCode => privateKey.hashCode ^ publicKey.hashCode ^ certificate.hashCode ^ certificateHash.hashCode;
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
other is SecurityContext &&
|
|
runtimeType == other.runtimeType &&
|
|
privateKey == other.privateKey &&
|
|
publicKey == other.publicKey &&
|
|
certificate == other.certificate &&
|
|
certificateHash == other.certificateHash;
|
|
}
|