From b79878a0b581e2eaff719ec8be06d04a990b98ae Mon Sep 17 00:00:00 2001 From: JohnE Date: Wed, 11 Mar 2026 16:57:28 -0700 Subject: [PATCH] NEW: added bridge API and DTO for dart --- .vscode/settings.json | 6 + docs/ccc_rust_milestone2_phases.rst | 130 +-- lib/src/rust/api/crypto.dart | 137 +++ lib/src/rust/api/dto.dart | 260 +++++ lib/src/rust/api/dto.freezed.dart | 1408 +++++++++++++++++++++++++++ lib/src/rust/frb_generated.dart | 1205 ++++++++++++++++++++++- lib/src/rust/frb_generated.io.dart | 262 ++++- lib/src/rust/frb_generated.web.dart | 262 ++++- rust/src/api/crypto.rs | 185 ++++ rust/src/api/dto.rs | 328 +++++++ rust/src/api/mod.rs | 2 + rust/src/frb_generated.rs | 1398 +++++++++++++++++++++++++- 12 files changed, 5442 insertions(+), 141 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 lib/src/rust/api/crypto.dart create mode 100644 lib/src/rust/api/dto.dart create mode 100644 lib/src/rust/api/dto.freezed.dart create mode 100644 rust/src/api/crypto.rs create mode 100644 rust/src/api/dto.rs diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..dcf4623 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "chat.tools.terminal.autoApprove": { + "cargo check": true, + "flutter_rust_bridge_codegen": true + } +} \ No newline at end of file diff --git a/docs/ccc_rust_milestone2_phases.rst b/docs/ccc_rust_milestone2_phases.rst index 5aebd0a..698ea6a 100644 --- a/docs/ccc_rust_milestone2_phases.rst +++ b/docs/ccc_rust_milestone2_phases.rst @@ -39,7 +39,7 @@ Phase Overview Phase Title Status Depends on ====== ========================================== ========== ============ 1 Project Restructure & FRB Setup Done — -2 Rust Bridge Crate (DTOs + API) Not Started Phase 1 +2 Rust Bridge Crate (DTOs + API) Done Phase 1 3 Dart API Surface Not Started Phase 2 4 Platform Build Verification Not Started Phase 3 5 Unit Tests Not Started Phase 3 @@ -115,7 +115,7 @@ Exit Criteria Phase 2 — Rust Bridge Crate (DTOs + API) ------------------------------------------ -:Status: Not Started +:Status: Done :Depends on: Phase 1 **Goal:** Implement DTOs and thin Rust wrappers in the bridge crate that @@ -124,8 +124,13 @@ expose all ``ccc_rust`` provider functionality across the FRB bridge. The bridge crate lives at ``rust/`` and must not contain any cryptographic logic — only type conversions and delegation to ``ccc_rust`` providers. -DTOs (``rust/src/dto.rs``) -~~~~~~~~~~~~~~~~~~~~~~~~~~ +Files created: + +* ``rust/src/api/dto.rs`` — DTOs, algorithm enums, bridge error type +* ``rust/src/api/crypto.rs`` — 13 bridge entry-point functions + +DTOs (``rust/src/api/dto.rs``) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bridge-visible data transfer objects with ``From`` impls: @@ -137,29 +142,29 @@ Bridge-visible data transfer objects with ``From`` impls: - Task - Status * - 2.1 - - ``CapabilitiesDto`` — maps from ``ProviderCapabilities`` - (provider name, algorithm availability, efficiency/reliability - scores) - - ☐ + - ``CccCapabilities`` — maps from ``ProviderCapabilities`` + (provider name, per-category algorithm list with availability, + efficiency/reliability scores); flattened HashMap → Vec for FRB + - ✅ * - 2.2 - - ``KemKeyPairDto`` — maps from ``KemKeyPair`` + - ``CccKemKeyPair`` — maps from ``KemKeyPair`` (public_key, private_key as ``Vec``) - - ☐ + - ✅ * - 2.3 - - ``KemEncapDto`` — maps from KEM encapsulation result + - ``CccKemEncapResult`` — maps from ``KemEncapResult`` (ciphertext, shared_secret) - - ☐ + - ✅ * - 2.4 - - ``SelfTestDto`` — maps from ``SelfTestReport`` + - ``CccSelfTestReport`` — maps from ``SelfTestReport`` (overall pass/fail, per-algorithm results) - - ☐ + - ✅ * - 2.5 - - ``AlgoTestResultDto`` — maps from ``AlgoTestResult`` + - ``CccAlgoTestResult`` — maps from ``AlgoTestResult`` (algorithm ID, pass/fail, diagnostic message) - - ☐ + - ✅ -Bridge API (``rust/src/api.rs``) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Bridge API (``rust/src/api/crypto.rs``) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. list-table:: :header-rows: 1 @@ -169,86 +174,93 @@ Bridge API (``rust/src/api.rs``) - Task - Status * - 2.6 - - ``ccc_init()`` — register WolfSslProvider, run capability probe - - ☐ + - ``ccc_init()`` — register WolfSslProvider (idempotent) + - ✅ * - 2.7 - - ``ccc_list_providers()`` — return registered provider names - - ☐ + - ``ccc_list_providers()`` — return registered provider names (sync) + - ✅ * - 2.8 - - ``ccc_capabilities()`` / ``ccc_available_algorithms()`` - — return ``CapabilitiesDto`` for a provider - - ☐ + - ``ccc_capabilities()`` — return ``CccCapabilities`` for default provider + - ✅ * - 2.9 - ``ccc_aead_encrypt(algorithm, key, nonce, plaintext, aad)`` — thin wrapper over provider AEAD encrypt - - ☐ + - ✅ * - 2.10 - ``ccc_aead_decrypt(algorithm, key, nonce, ciphertext, aad)`` — thin wrapper over provider AEAD decrypt - - ☐ + - ✅ * - 2.11 - ``ccc_kdf_derive(algorithm, ikm, salt, info, len)`` — thin wrapper over provider KDF - - ☐ + - ✅ * - 2.12 - ``ccc_mac_compute(algorithm, key, data)`` — thin wrapper over provider MAC compute - - ☐ + - ✅ * - 2.13 - ``ccc_mac_verify(algorithm, key, data, mac)`` — thin wrapper over provider MAC verify - - ☐ + - ✅ * - 2.14 - ``ccc_hash(algorithm, data)`` — thin wrapper over provider hash - - ☐ + - ✅ * - 2.15 - ``ccc_kem_generate_keypair(algorithm)`` - — return ``KemKeyPairDto`` - - ☐ + — return ``CccKemKeyPair`` + - ✅ * - 2.16 - ``ccc_kem_encapsulate(algorithm, public_key)`` - — return ``KemEncapDto`` - - ☐ + — return ``CccKemEncapResult`` + - ✅ * - 2.17 - ``ccc_kem_decapsulate(algorithm, private_key, ciphertext)`` — return shared secret - - ☐ + - ✅ * - 2.18 - - ``ccc_self_test()`` — return ``SelfTestDto`` - - ☐ + - ``ccc_self_test()`` — return ``CccSelfTestReport`` + - ✅ * - 2.19 - - Define bridge-visible error enum mapping ``CryptoError`` - variants to structured types (``UnsupportedAlgorithm``, - ``InvalidKey``, ``InvalidNonce``, ``AuthenticationFailed``, + - ``CccCryptoError`` enum mapping all 7 ``CryptoError`` variants + (``UnsupportedAlgorithm``, ``InvalidKey``, ``InvalidNonce``, + ``AuthenticationFailed``, ``InvalidInput``, ``FeatureNotCompiled``, ``InternalError``) - - ☐ + - ✅ * - 2.20 - - Run ``flutter_rust_bridge_codegen generate`` — verify all - wrappers produce valid Dart bindings - - ☐ + - Run ``flutter_rust_bridge_codegen generate`` — Dart bindings + generated; ``flutter build macos`` succeeds (44.5 MB) + - ✅ DTO ↔ Rust Type Mapping ~~~~~~~~~~~~~~~~~~~~~~~~ -======================== =================================== ======================== -Bridge DTO Rust Core Type Direction -======================== =================================== ======================== -``CapabilitiesDto`` ``ProviderCapabilities`` Rust → Dart -``KemKeyPairDto`` ``KemKeyPair`` Rust → Dart -``KemEncapDto`` (ciphertext, shared_secret) Rust → Dart -``SelfTestDto`` ``SelfTestReport`` Rust → Dart -``AlgoTestResultDto`` ``AlgoTestResult`` Rust → Dart -``CryptoError`` enum ``CryptoError`` Rust → Dart exception -======================== =================================== ======================== +========================== =================================== ======================== +Bridge DTO Rust Core Type Direction +========================== =================================== ======================== +``CccCapabilities`` ``ProviderCapabilities`` Rust → Dart +``CccAlgorithmEntry`` (algo_id, name, capability) Rust → Dart +``CccAlgorithmCapability`` ``AlgorithmCapability`` Rust → Dart +``CccKemKeyPair`` ``KemKeyPair`` Rust → Dart +``CccKemEncapResult`` ``KemEncapResult`` Rust → Dart +``CccSelfTestReport`` ``SelfTestReport`` Rust → Dart +``CccAlgoTestResult`` ``AlgoTestResult`` Rust → Dart +``CccCryptoError`` enum ``CryptoError`` Rust → Dart exception +``CccAeadAlgorithm`` ``AeadAlgorithm`` Dart → Rust +``CccKdfAlgorithm`` ``KdfAlgorithm`` Dart → Rust +``CccMacAlgorithm`` ``MacAlgorithm`` Dart → Rust +``CccHashAlgorithm`` ``HashAlgorithm`` Dart → Rust +``CccKemAlgorithm`` ``KemAlgorithm`` Dart → Rust +========================== =================================== ======================== Exit Criteria ~~~~~~~~~~~~~ -* All DTOs defined with ``From<>`` impls. -* All 13 bridge entry points exist in ``api.rs``. -* Codegen produces Dart bindings without warnings. -* Rust crate compiles with ``ccc_rust`` linked. +* ✅ All DTOs defined with ``From<>`` impls. +* ✅ All 13 bridge entry points exist in ``crypto.rs``. +* ✅ Codegen produces Dart bindings (+ freezed). +* ✅ Rust crate compiles with ``ccc_rust`` linked. +* ✅ ``flutter build macos`` succeeds (44.5 MB). ---- diff --git a/lib/src/rust/api/crypto.dart b/lib/src/rust/api/crypto.dart new file mode 100644 index 0000000..fb1338e --- /dev/null +++ b/lib/src/rust/api/crypto.dart @@ -0,0 +1,137 @@ +// This file is automatically generated, so please do not edit it. +// @generated by `flutter_rust_bridge`@ 2.11.1. + +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import + +import '../frb_generated.dart'; +import 'dto.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; + +// These functions are ignored because they are not marked as `pub`: `default_provider`, `kem_provider` + +/// Initialise the CCC cryptographic subsystem. +/// +/// Registers the wolfSSL provider in the global registry. +/// Safe to call multiple times (idempotent). +Future cccInit() => RustLib.instance.api.crateApiCryptoCccInit(); + +/// List all registered provider names. +List cccListProviders() => + RustLib.instance.api.crateApiCryptoCccListProviders(); + +/// Return the capabilities of the default provider. +Future cccCapabilities() => + RustLib.instance.api.crateApiCryptoCccCapabilities(); + +/// Encrypt with an AEAD algorithm. +/// +/// Returns ciphertext‖tag. +Future cccAeadEncrypt({ + required CccAeadAlgorithm algorithm, + required List key, + required List nonce, + required List plaintext, + required List aad, +}) => RustLib.instance.api.crateApiCryptoCccAeadEncrypt( + algorithm: algorithm, + key: key, + nonce: nonce, + plaintext: plaintext, + aad: aad, +); + +/// Decrypt with an AEAD algorithm. +/// +/// Expects ciphertext‖tag as `ciphertext`. +Future cccAeadDecrypt({ + required CccAeadAlgorithm algorithm, + required List key, + required List nonce, + required List ciphertext, + required List aad, +}) => RustLib.instance.api.crateApiCryptoCccAeadDecrypt( + algorithm: algorithm, + key: key, + nonce: nonce, + ciphertext: ciphertext, + aad: aad, +); + +/// Derive key material using a KDF. +Future cccKdfDerive({ + required CccKdfAlgorithm algorithm, + required List ikm, + required List salt, + required List info, + required int length, +}) => RustLib.instance.api.crateApiCryptoCccKdfDerive( + algorithm: algorithm, + ikm: ikm, + salt: salt, + info: info, + length: length, +); + +/// Compute a MAC tag. +Future cccMacCompute({ + required CccMacAlgorithm algorithm, + required List key, + required List data, +}) => RustLib.instance.api.crateApiCryptoCccMacCompute( + algorithm: algorithm, + key: key, + data: data, +); + +/// Verify a MAC tag. Returns `true` if valid. +Future cccMacVerify({ + required CccMacAlgorithm algorithm, + required List key, + required List data, + required List mac, +}) => RustLib.instance.api.crateApiCryptoCccMacVerify( + algorithm: algorithm, + key: key, + data: data, + mac: mac, +); + +/// Compute a cryptographic hash. +Future cccHash({ + required CccHashAlgorithm algorithm, + required List data, +}) => RustLib.instance.api.crateApiCryptoCccHash( + algorithm: algorithm, + data: data, +); + +/// Generate a KEM key pair. +Future cccKemGenerateKeypair({ + required CccKemAlgorithm algorithm, +}) => RustLib.instance.api.crateApiCryptoCccKemGenerateKeypair( + algorithm: algorithm, +); + +/// KEM encapsulation — produce ciphertext + shared secret from a public key. +Future cccKemEncapsulate({ + required CccKemAlgorithm algorithm, + required List publicKey, +}) => RustLib.instance.api.crateApiCryptoCccKemEncapsulate( + algorithm: algorithm, + publicKey: publicKey, +); + +/// KEM decapsulation — recover shared secret from ciphertext + private key. +Future cccKemDecapsulate({ + required CccKemAlgorithm algorithm, + required List privateKey, + required List ciphertext, +}) => RustLib.instance.api.crateApiCryptoCccKemDecapsulate( + algorithm: algorithm, + privateKey: privateKey, + ciphertext: ciphertext, +); + +/// Run the provider self-test and return a structured report. +Future cccSelfTest() => + RustLib.instance.api.crateApiCryptoCccSelfTest(); diff --git a/lib/src/rust/api/dto.dart b/lib/src/rust/api/dto.dart new file mode 100644 index 0000000..ea07917 --- /dev/null +++ b/lib/src/rust/api/dto.dart @@ -0,0 +1,260 @@ +// This file is automatically generated, so please do not edit it. +// @generated by `flutter_rust_bridge`@ 2.11.1. + +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import + +import '../frb_generated.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +import 'package:freezed_annotation/freezed_annotation.dart' hide protected; +part 'dto.freezed.dart'; + +// These functions are ignored because they are not marked as `pub`: `to_core`, `to_core`, `to_core`, `to_core`, `to_core` +// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `fmt`, `fmt`, `from`, `from`, `from`, `from`, `from`, `from`, `from` + +/// AEAD algorithm identifiers — values match `ccc_rust` `#[repr(u32)]`. +enum CccAeadAlgorithm { + aesGcm256, + chaCha20Poly1305, + xChaCha20Poly1305, + ascon128A, +} + +/// Per-algorithm self-test result. +class CccAlgoTestResult { + final int algoId; + final String algoName; + final bool passed; + final String? errorMessage; + + const CccAlgoTestResult({ + required this.algoId, + required this.algoName, + required this.passed, + this.errorMessage, + }); + + @override + int get hashCode => + algoId.hashCode ^ + algoName.hashCode ^ + passed.hashCode ^ + errorMessage.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is CccAlgoTestResult && + runtimeType == other.runtimeType && + algoId == other.algoId && + algoName == other.algoName && + passed == other.passed && + errorMessage == other.errorMessage; +} + +/// Per-algorithm availability and quality scores. +class CccAlgorithmCapability { + final bool available; + final bool deterministicIo; + final int efficiencyScore; + final int reliabilityScore; + + const CccAlgorithmCapability({ + required this.available, + required this.deterministicIo, + required this.efficiencyScore, + required this.reliabilityScore, + }); + + @override + int get hashCode => + available.hashCode ^ + deterministicIo.hashCode ^ + efficiencyScore.hashCode ^ + reliabilityScore.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is CccAlgorithmCapability && + runtimeType == other.runtimeType && + available == other.available && + deterministicIo == other.deterministicIo && + efficiencyScore == other.efficiencyScore && + reliabilityScore == other.reliabilityScore; +} + +/// An algorithm entry in the capabilities list. +class CccAlgorithmEntry { + final int algoId; + final String algoName; + final CccAlgorithmCapability capability; + + const CccAlgorithmEntry({ + required this.algoId, + required this.algoName, + required this.capability, + }); + + @override + int get hashCode => algoId.hashCode ^ algoName.hashCode ^ capability.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is CccAlgorithmEntry && + runtimeType == other.runtimeType && + algoId == other.algoId && + algoName == other.algoName && + capability == other.capability; +} + +/// Provider capabilities — flattened from HashMap to Vec for FRB. +class CccCapabilities { + final String providerName; + final List aead; + final List kdf; + final List mac; + final List hash; + final List kem; + + const CccCapabilities({ + required this.providerName, + required this.aead, + required this.kdf, + required this.mac, + required this.hash, + required this.kem, + }); + + @override + int get hashCode => + providerName.hashCode ^ + aead.hashCode ^ + kdf.hashCode ^ + mac.hashCode ^ + hash.hashCode ^ + kem.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is CccCapabilities && + runtimeType == other.runtimeType && + providerName == other.providerName && + aead == other.aead && + kdf == other.kdf && + mac == other.mac && + hash == other.hash && + kem == other.kem; +} + +@freezed +sealed class CccCryptoError with _$CccCryptoError implements FrbException { + const CccCryptoError._(); + + const factory CccCryptoError.unsupportedAlgorithm(String field0) = + CccCryptoError_UnsupportedAlgorithm; + const factory CccCryptoError.invalidKey(String field0) = + CccCryptoError_InvalidKey; + const factory CccCryptoError.invalidNonce(String field0) = + CccCryptoError_InvalidNonce; + const factory CccCryptoError.authenticationFailed() = + CccCryptoError_AuthenticationFailed; + const factory CccCryptoError.invalidInput(String field0) = + CccCryptoError_InvalidInput; + const factory CccCryptoError.featureNotCompiled(String field0) = + CccCryptoError_FeatureNotCompiled; + const factory CccCryptoError.internalError(String field0) = + CccCryptoError_InternalError; +} + +/// Hash algorithm identifiers. +enum CccHashAlgorithm { sha256, sha384, sha512, blake2B512, sha3256, sha3512 } + +/// KDF algorithm identifiers. +enum CccKdfAlgorithm { sha256, sha384, sha512, blake2B512, argon2Id, kmac256 } + +/// KEM algorithm identifiers. +enum CccKemAlgorithm { + x25519, + x448, + mlKem768, + mlKem1024, + classicMcEliece460896, +} + +/// KEM encapsulation result — ciphertext + shared secret. +class CccKemEncapResult { + final Uint8List ciphertext; + final Uint8List sharedSecret; + + const CccKemEncapResult({ + required this.ciphertext, + required this.sharedSecret, + }); + + @override + int get hashCode => ciphertext.hashCode ^ sharedSecret.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is CccKemEncapResult && + runtimeType == other.runtimeType && + ciphertext == other.ciphertext && + sharedSecret == other.sharedSecret; +} + +/// KEM key pair — public + private key bytes. +class CccKemKeyPair { + final Uint8List publicKey; + final Uint8List privateKey; + + const CccKemKeyPair({required this.publicKey, required this.privateKey}); + + @override + int get hashCode => publicKey.hashCode ^ privateKey.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is CccKemKeyPair && + runtimeType == other.runtimeType && + publicKey == other.publicKey && + privateKey == other.privateKey; +} + +/// MAC algorithm identifiers. +enum CccMacAlgorithm { + hmacSha256, + hmacSha384, + hmacSha512, + blake2BMac, + poly1305, +} + +/// Aggregate self-test report. +class CccSelfTestReport { + final String providerName; + final List results; + final bool allPassed; + + const CccSelfTestReport({ + required this.providerName, + required this.results, + required this.allPassed, + }); + + @override + int get hashCode => + providerName.hashCode ^ results.hashCode ^ allPassed.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is CccSelfTestReport && + runtimeType == other.runtimeType && + providerName == other.providerName && + results == other.results && + allPassed == other.allPassed; +} diff --git a/lib/src/rust/api/dto.freezed.dart b/lib/src/rust/api/dto.freezed.dart new file mode 100644 index 0000000..1a26057 --- /dev/null +++ b/lib/src/rust/api/dto.freezed.dart @@ -0,0 +1,1408 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'dto.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models', +); + +/// @nodoc +mixin _$CccCryptoError { + @optionalTypeArgs + TResult when({ + required TResult Function(String field0) unsupportedAlgorithm, + required TResult Function(String field0) invalidKey, + required TResult Function(String field0) invalidNonce, + required TResult Function() authenticationFailed, + required TResult Function(String field0) invalidInput, + required TResult Function(String field0) featureNotCompiled, + required TResult Function(String field0) internalError, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String field0)? unsupportedAlgorithm, + TResult? Function(String field0)? invalidKey, + TResult? Function(String field0)? invalidNonce, + TResult? Function()? authenticationFailed, + TResult? Function(String field0)? invalidInput, + TResult? Function(String field0)? featureNotCompiled, + TResult? Function(String field0)? internalError, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String field0)? unsupportedAlgorithm, + TResult Function(String field0)? invalidKey, + TResult Function(String field0)? invalidNonce, + TResult Function()? authenticationFailed, + TResult Function(String field0)? invalidInput, + TResult Function(String field0)? featureNotCompiled, + TResult Function(String field0)? internalError, + required TResult orElse(), + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(CccCryptoError_UnsupportedAlgorithm value) + unsupportedAlgorithm, + required TResult Function(CccCryptoError_InvalidKey value) invalidKey, + required TResult Function(CccCryptoError_InvalidNonce value) invalidNonce, + required TResult Function(CccCryptoError_AuthenticationFailed value) + authenticationFailed, + required TResult Function(CccCryptoError_InvalidInput value) invalidInput, + required TResult Function(CccCryptoError_FeatureNotCompiled value) + featureNotCompiled, + required TResult Function(CccCryptoError_InternalError value) internalError, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(CccCryptoError_UnsupportedAlgorithm value)? + unsupportedAlgorithm, + TResult? Function(CccCryptoError_InvalidKey value)? invalidKey, + TResult? Function(CccCryptoError_InvalidNonce value)? invalidNonce, + TResult? Function(CccCryptoError_AuthenticationFailed value)? + authenticationFailed, + TResult? Function(CccCryptoError_InvalidInput value)? invalidInput, + TResult? Function(CccCryptoError_FeatureNotCompiled value)? + featureNotCompiled, + TResult? Function(CccCryptoError_InternalError value)? internalError, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(CccCryptoError_UnsupportedAlgorithm value)? + unsupportedAlgorithm, + TResult Function(CccCryptoError_InvalidKey value)? invalidKey, + TResult Function(CccCryptoError_InvalidNonce value)? invalidNonce, + TResult Function(CccCryptoError_AuthenticationFailed value)? + authenticationFailed, + TResult Function(CccCryptoError_InvalidInput value)? invalidInput, + TResult Function(CccCryptoError_FeatureNotCompiled value)? + featureNotCompiled, + TResult Function(CccCryptoError_InternalError value)? internalError, + required TResult orElse(), + }) => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $CccCryptoErrorCopyWith<$Res> { + factory $CccCryptoErrorCopyWith( + CccCryptoError value, + $Res Function(CccCryptoError) then, + ) = _$CccCryptoErrorCopyWithImpl<$Res, CccCryptoError>; +} + +/// @nodoc +class _$CccCryptoErrorCopyWithImpl<$Res, $Val extends CccCryptoError> + implements $CccCryptoErrorCopyWith<$Res> { + _$CccCryptoErrorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$CccCryptoError_UnsupportedAlgorithmImplCopyWith<$Res> { + factory _$$CccCryptoError_UnsupportedAlgorithmImplCopyWith( + _$CccCryptoError_UnsupportedAlgorithmImpl value, + $Res Function(_$CccCryptoError_UnsupportedAlgorithmImpl) then, + ) = __$$CccCryptoError_UnsupportedAlgorithmImplCopyWithImpl<$Res>; + @useResult + $Res call({String field0}); +} + +/// @nodoc +class __$$CccCryptoError_UnsupportedAlgorithmImplCopyWithImpl<$Res> + extends + _$CccCryptoErrorCopyWithImpl< + $Res, + _$CccCryptoError_UnsupportedAlgorithmImpl + > + implements _$$CccCryptoError_UnsupportedAlgorithmImplCopyWith<$Res> { + __$$CccCryptoError_UnsupportedAlgorithmImplCopyWithImpl( + _$CccCryptoError_UnsupportedAlgorithmImpl _value, + $Res Function(_$CccCryptoError_UnsupportedAlgorithmImpl) _then, + ) : super(_value, _then); + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? field0 = null}) { + return _then( + _$CccCryptoError_UnsupportedAlgorithmImpl( + null == field0 + ? _value.field0 + : field0 // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$CccCryptoError_UnsupportedAlgorithmImpl + extends CccCryptoError_UnsupportedAlgorithm { + const _$CccCryptoError_UnsupportedAlgorithmImpl(this.field0) : super._(); + + @override + final String field0; + + @override + String toString() { + return 'CccCryptoError.unsupportedAlgorithm(field0: $field0)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CccCryptoError_UnsupportedAlgorithmImpl && + (identical(other.field0, field0) || other.field0 == field0)); + } + + @override + int get hashCode => Object.hash(runtimeType, field0); + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$CccCryptoError_UnsupportedAlgorithmImplCopyWith< + _$CccCryptoError_UnsupportedAlgorithmImpl + > + get copyWith => + __$$CccCryptoError_UnsupportedAlgorithmImplCopyWithImpl< + _$CccCryptoError_UnsupportedAlgorithmImpl + >(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String field0) unsupportedAlgorithm, + required TResult Function(String field0) invalidKey, + required TResult Function(String field0) invalidNonce, + required TResult Function() authenticationFailed, + required TResult Function(String field0) invalidInput, + required TResult Function(String field0) featureNotCompiled, + required TResult Function(String field0) internalError, + }) { + return unsupportedAlgorithm(field0); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String field0)? unsupportedAlgorithm, + TResult? Function(String field0)? invalidKey, + TResult? Function(String field0)? invalidNonce, + TResult? Function()? authenticationFailed, + TResult? Function(String field0)? invalidInput, + TResult? Function(String field0)? featureNotCompiled, + TResult? Function(String field0)? internalError, + }) { + return unsupportedAlgorithm?.call(field0); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String field0)? unsupportedAlgorithm, + TResult Function(String field0)? invalidKey, + TResult Function(String field0)? invalidNonce, + TResult Function()? authenticationFailed, + TResult Function(String field0)? invalidInput, + TResult Function(String field0)? featureNotCompiled, + TResult Function(String field0)? internalError, + required TResult orElse(), + }) { + if (unsupportedAlgorithm != null) { + return unsupportedAlgorithm(field0); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(CccCryptoError_UnsupportedAlgorithm value) + unsupportedAlgorithm, + required TResult Function(CccCryptoError_InvalidKey value) invalidKey, + required TResult Function(CccCryptoError_InvalidNonce value) invalidNonce, + required TResult Function(CccCryptoError_AuthenticationFailed value) + authenticationFailed, + required TResult Function(CccCryptoError_InvalidInput value) invalidInput, + required TResult Function(CccCryptoError_FeatureNotCompiled value) + featureNotCompiled, + required TResult Function(CccCryptoError_InternalError value) internalError, + }) { + return unsupportedAlgorithm(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(CccCryptoError_UnsupportedAlgorithm value)? + unsupportedAlgorithm, + TResult? Function(CccCryptoError_InvalidKey value)? invalidKey, + TResult? Function(CccCryptoError_InvalidNonce value)? invalidNonce, + TResult? Function(CccCryptoError_AuthenticationFailed value)? + authenticationFailed, + TResult? Function(CccCryptoError_InvalidInput value)? invalidInput, + TResult? Function(CccCryptoError_FeatureNotCompiled value)? + featureNotCompiled, + TResult? Function(CccCryptoError_InternalError value)? internalError, + }) { + return unsupportedAlgorithm?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(CccCryptoError_UnsupportedAlgorithm value)? + unsupportedAlgorithm, + TResult Function(CccCryptoError_InvalidKey value)? invalidKey, + TResult Function(CccCryptoError_InvalidNonce value)? invalidNonce, + TResult Function(CccCryptoError_AuthenticationFailed value)? + authenticationFailed, + TResult Function(CccCryptoError_InvalidInput value)? invalidInput, + TResult Function(CccCryptoError_FeatureNotCompiled value)? + featureNotCompiled, + TResult Function(CccCryptoError_InternalError value)? internalError, + required TResult orElse(), + }) { + if (unsupportedAlgorithm != null) { + return unsupportedAlgorithm(this); + } + return orElse(); + } +} + +abstract class CccCryptoError_UnsupportedAlgorithm extends CccCryptoError { + const factory CccCryptoError_UnsupportedAlgorithm(final String field0) = + _$CccCryptoError_UnsupportedAlgorithmImpl; + const CccCryptoError_UnsupportedAlgorithm._() : super._(); + + String get field0; + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$CccCryptoError_UnsupportedAlgorithmImplCopyWith< + _$CccCryptoError_UnsupportedAlgorithmImpl + > + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$CccCryptoError_InvalidKeyImplCopyWith<$Res> { + factory _$$CccCryptoError_InvalidKeyImplCopyWith( + _$CccCryptoError_InvalidKeyImpl value, + $Res Function(_$CccCryptoError_InvalidKeyImpl) then, + ) = __$$CccCryptoError_InvalidKeyImplCopyWithImpl<$Res>; + @useResult + $Res call({String field0}); +} + +/// @nodoc +class __$$CccCryptoError_InvalidKeyImplCopyWithImpl<$Res> + extends _$CccCryptoErrorCopyWithImpl<$Res, _$CccCryptoError_InvalidKeyImpl> + implements _$$CccCryptoError_InvalidKeyImplCopyWith<$Res> { + __$$CccCryptoError_InvalidKeyImplCopyWithImpl( + _$CccCryptoError_InvalidKeyImpl _value, + $Res Function(_$CccCryptoError_InvalidKeyImpl) _then, + ) : super(_value, _then); + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? field0 = null}) { + return _then( + _$CccCryptoError_InvalidKeyImpl( + null == field0 + ? _value.field0 + : field0 // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$CccCryptoError_InvalidKeyImpl extends CccCryptoError_InvalidKey { + const _$CccCryptoError_InvalidKeyImpl(this.field0) : super._(); + + @override + final String field0; + + @override + String toString() { + return 'CccCryptoError.invalidKey(field0: $field0)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CccCryptoError_InvalidKeyImpl && + (identical(other.field0, field0) || other.field0 == field0)); + } + + @override + int get hashCode => Object.hash(runtimeType, field0); + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$CccCryptoError_InvalidKeyImplCopyWith<_$CccCryptoError_InvalidKeyImpl> + get copyWith => + __$$CccCryptoError_InvalidKeyImplCopyWithImpl< + _$CccCryptoError_InvalidKeyImpl + >(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String field0) unsupportedAlgorithm, + required TResult Function(String field0) invalidKey, + required TResult Function(String field0) invalidNonce, + required TResult Function() authenticationFailed, + required TResult Function(String field0) invalidInput, + required TResult Function(String field0) featureNotCompiled, + required TResult Function(String field0) internalError, + }) { + return invalidKey(field0); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String field0)? unsupportedAlgorithm, + TResult? Function(String field0)? invalidKey, + TResult? Function(String field0)? invalidNonce, + TResult? Function()? authenticationFailed, + TResult? Function(String field0)? invalidInput, + TResult? Function(String field0)? featureNotCompiled, + TResult? Function(String field0)? internalError, + }) { + return invalidKey?.call(field0); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String field0)? unsupportedAlgorithm, + TResult Function(String field0)? invalidKey, + TResult Function(String field0)? invalidNonce, + TResult Function()? authenticationFailed, + TResult Function(String field0)? invalidInput, + TResult Function(String field0)? featureNotCompiled, + TResult Function(String field0)? internalError, + required TResult orElse(), + }) { + if (invalidKey != null) { + return invalidKey(field0); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(CccCryptoError_UnsupportedAlgorithm value) + unsupportedAlgorithm, + required TResult Function(CccCryptoError_InvalidKey value) invalidKey, + required TResult Function(CccCryptoError_InvalidNonce value) invalidNonce, + required TResult Function(CccCryptoError_AuthenticationFailed value) + authenticationFailed, + required TResult Function(CccCryptoError_InvalidInput value) invalidInput, + required TResult Function(CccCryptoError_FeatureNotCompiled value) + featureNotCompiled, + required TResult Function(CccCryptoError_InternalError value) internalError, + }) { + return invalidKey(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(CccCryptoError_UnsupportedAlgorithm value)? + unsupportedAlgorithm, + TResult? Function(CccCryptoError_InvalidKey value)? invalidKey, + TResult? Function(CccCryptoError_InvalidNonce value)? invalidNonce, + TResult? Function(CccCryptoError_AuthenticationFailed value)? + authenticationFailed, + TResult? Function(CccCryptoError_InvalidInput value)? invalidInput, + TResult? Function(CccCryptoError_FeatureNotCompiled value)? + featureNotCompiled, + TResult? Function(CccCryptoError_InternalError value)? internalError, + }) { + return invalidKey?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(CccCryptoError_UnsupportedAlgorithm value)? + unsupportedAlgorithm, + TResult Function(CccCryptoError_InvalidKey value)? invalidKey, + TResult Function(CccCryptoError_InvalidNonce value)? invalidNonce, + TResult Function(CccCryptoError_AuthenticationFailed value)? + authenticationFailed, + TResult Function(CccCryptoError_InvalidInput value)? invalidInput, + TResult Function(CccCryptoError_FeatureNotCompiled value)? + featureNotCompiled, + TResult Function(CccCryptoError_InternalError value)? internalError, + required TResult orElse(), + }) { + if (invalidKey != null) { + return invalidKey(this); + } + return orElse(); + } +} + +abstract class CccCryptoError_InvalidKey extends CccCryptoError { + const factory CccCryptoError_InvalidKey(final String field0) = + _$CccCryptoError_InvalidKeyImpl; + const CccCryptoError_InvalidKey._() : super._(); + + String get field0; + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$CccCryptoError_InvalidKeyImplCopyWith<_$CccCryptoError_InvalidKeyImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$CccCryptoError_InvalidNonceImplCopyWith<$Res> { + factory _$$CccCryptoError_InvalidNonceImplCopyWith( + _$CccCryptoError_InvalidNonceImpl value, + $Res Function(_$CccCryptoError_InvalidNonceImpl) then, + ) = __$$CccCryptoError_InvalidNonceImplCopyWithImpl<$Res>; + @useResult + $Res call({String field0}); +} + +/// @nodoc +class __$$CccCryptoError_InvalidNonceImplCopyWithImpl<$Res> + extends + _$CccCryptoErrorCopyWithImpl<$Res, _$CccCryptoError_InvalidNonceImpl> + implements _$$CccCryptoError_InvalidNonceImplCopyWith<$Res> { + __$$CccCryptoError_InvalidNonceImplCopyWithImpl( + _$CccCryptoError_InvalidNonceImpl _value, + $Res Function(_$CccCryptoError_InvalidNonceImpl) _then, + ) : super(_value, _then); + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? field0 = null}) { + return _then( + _$CccCryptoError_InvalidNonceImpl( + null == field0 + ? _value.field0 + : field0 // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$CccCryptoError_InvalidNonceImpl extends CccCryptoError_InvalidNonce { + const _$CccCryptoError_InvalidNonceImpl(this.field0) : super._(); + + @override + final String field0; + + @override + String toString() { + return 'CccCryptoError.invalidNonce(field0: $field0)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CccCryptoError_InvalidNonceImpl && + (identical(other.field0, field0) || other.field0 == field0)); + } + + @override + int get hashCode => Object.hash(runtimeType, field0); + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$CccCryptoError_InvalidNonceImplCopyWith<_$CccCryptoError_InvalidNonceImpl> + get copyWith => + __$$CccCryptoError_InvalidNonceImplCopyWithImpl< + _$CccCryptoError_InvalidNonceImpl + >(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String field0) unsupportedAlgorithm, + required TResult Function(String field0) invalidKey, + required TResult Function(String field0) invalidNonce, + required TResult Function() authenticationFailed, + required TResult Function(String field0) invalidInput, + required TResult Function(String field0) featureNotCompiled, + required TResult Function(String field0) internalError, + }) { + return invalidNonce(field0); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String field0)? unsupportedAlgorithm, + TResult? Function(String field0)? invalidKey, + TResult? Function(String field0)? invalidNonce, + TResult? Function()? authenticationFailed, + TResult? Function(String field0)? invalidInput, + TResult? Function(String field0)? featureNotCompiled, + TResult? Function(String field0)? internalError, + }) { + return invalidNonce?.call(field0); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String field0)? unsupportedAlgorithm, + TResult Function(String field0)? invalidKey, + TResult Function(String field0)? invalidNonce, + TResult Function()? authenticationFailed, + TResult Function(String field0)? invalidInput, + TResult Function(String field0)? featureNotCompiled, + TResult Function(String field0)? internalError, + required TResult orElse(), + }) { + if (invalidNonce != null) { + return invalidNonce(field0); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(CccCryptoError_UnsupportedAlgorithm value) + unsupportedAlgorithm, + required TResult Function(CccCryptoError_InvalidKey value) invalidKey, + required TResult Function(CccCryptoError_InvalidNonce value) invalidNonce, + required TResult Function(CccCryptoError_AuthenticationFailed value) + authenticationFailed, + required TResult Function(CccCryptoError_InvalidInput value) invalidInput, + required TResult Function(CccCryptoError_FeatureNotCompiled value) + featureNotCompiled, + required TResult Function(CccCryptoError_InternalError value) internalError, + }) { + return invalidNonce(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(CccCryptoError_UnsupportedAlgorithm value)? + unsupportedAlgorithm, + TResult? Function(CccCryptoError_InvalidKey value)? invalidKey, + TResult? Function(CccCryptoError_InvalidNonce value)? invalidNonce, + TResult? Function(CccCryptoError_AuthenticationFailed value)? + authenticationFailed, + TResult? Function(CccCryptoError_InvalidInput value)? invalidInput, + TResult? Function(CccCryptoError_FeatureNotCompiled value)? + featureNotCompiled, + TResult? Function(CccCryptoError_InternalError value)? internalError, + }) { + return invalidNonce?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(CccCryptoError_UnsupportedAlgorithm value)? + unsupportedAlgorithm, + TResult Function(CccCryptoError_InvalidKey value)? invalidKey, + TResult Function(CccCryptoError_InvalidNonce value)? invalidNonce, + TResult Function(CccCryptoError_AuthenticationFailed value)? + authenticationFailed, + TResult Function(CccCryptoError_InvalidInput value)? invalidInput, + TResult Function(CccCryptoError_FeatureNotCompiled value)? + featureNotCompiled, + TResult Function(CccCryptoError_InternalError value)? internalError, + required TResult orElse(), + }) { + if (invalidNonce != null) { + return invalidNonce(this); + } + return orElse(); + } +} + +abstract class CccCryptoError_InvalidNonce extends CccCryptoError { + const factory CccCryptoError_InvalidNonce(final String field0) = + _$CccCryptoError_InvalidNonceImpl; + const CccCryptoError_InvalidNonce._() : super._(); + + String get field0; + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$CccCryptoError_InvalidNonceImplCopyWith<_$CccCryptoError_InvalidNonceImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$CccCryptoError_AuthenticationFailedImplCopyWith<$Res> { + factory _$$CccCryptoError_AuthenticationFailedImplCopyWith( + _$CccCryptoError_AuthenticationFailedImpl value, + $Res Function(_$CccCryptoError_AuthenticationFailedImpl) then, + ) = __$$CccCryptoError_AuthenticationFailedImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$CccCryptoError_AuthenticationFailedImplCopyWithImpl<$Res> + extends + _$CccCryptoErrorCopyWithImpl< + $Res, + _$CccCryptoError_AuthenticationFailedImpl + > + implements _$$CccCryptoError_AuthenticationFailedImplCopyWith<$Res> { + __$$CccCryptoError_AuthenticationFailedImplCopyWithImpl( + _$CccCryptoError_AuthenticationFailedImpl _value, + $Res Function(_$CccCryptoError_AuthenticationFailedImpl) _then, + ) : super(_value, _then); + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$CccCryptoError_AuthenticationFailedImpl + extends CccCryptoError_AuthenticationFailed { + const _$CccCryptoError_AuthenticationFailedImpl() : super._(); + + @override + String toString() { + return 'CccCryptoError.authenticationFailed()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CccCryptoError_AuthenticationFailedImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String field0) unsupportedAlgorithm, + required TResult Function(String field0) invalidKey, + required TResult Function(String field0) invalidNonce, + required TResult Function() authenticationFailed, + required TResult Function(String field0) invalidInput, + required TResult Function(String field0) featureNotCompiled, + required TResult Function(String field0) internalError, + }) { + return authenticationFailed(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String field0)? unsupportedAlgorithm, + TResult? Function(String field0)? invalidKey, + TResult? Function(String field0)? invalidNonce, + TResult? Function()? authenticationFailed, + TResult? Function(String field0)? invalidInput, + TResult? Function(String field0)? featureNotCompiled, + TResult? Function(String field0)? internalError, + }) { + return authenticationFailed?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String field0)? unsupportedAlgorithm, + TResult Function(String field0)? invalidKey, + TResult Function(String field0)? invalidNonce, + TResult Function()? authenticationFailed, + TResult Function(String field0)? invalidInput, + TResult Function(String field0)? featureNotCompiled, + TResult Function(String field0)? internalError, + required TResult orElse(), + }) { + if (authenticationFailed != null) { + return authenticationFailed(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(CccCryptoError_UnsupportedAlgorithm value) + unsupportedAlgorithm, + required TResult Function(CccCryptoError_InvalidKey value) invalidKey, + required TResult Function(CccCryptoError_InvalidNonce value) invalidNonce, + required TResult Function(CccCryptoError_AuthenticationFailed value) + authenticationFailed, + required TResult Function(CccCryptoError_InvalidInput value) invalidInput, + required TResult Function(CccCryptoError_FeatureNotCompiled value) + featureNotCompiled, + required TResult Function(CccCryptoError_InternalError value) internalError, + }) { + return authenticationFailed(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(CccCryptoError_UnsupportedAlgorithm value)? + unsupportedAlgorithm, + TResult? Function(CccCryptoError_InvalidKey value)? invalidKey, + TResult? Function(CccCryptoError_InvalidNonce value)? invalidNonce, + TResult? Function(CccCryptoError_AuthenticationFailed value)? + authenticationFailed, + TResult? Function(CccCryptoError_InvalidInput value)? invalidInput, + TResult? Function(CccCryptoError_FeatureNotCompiled value)? + featureNotCompiled, + TResult? Function(CccCryptoError_InternalError value)? internalError, + }) { + return authenticationFailed?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(CccCryptoError_UnsupportedAlgorithm value)? + unsupportedAlgorithm, + TResult Function(CccCryptoError_InvalidKey value)? invalidKey, + TResult Function(CccCryptoError_InvalidNonce value)? invalidNonce, + TResult Function(CccCryptoError_AuthenticationFailed value)? + authenticationFailed, + TResult Function(CccCryptoError_InvalidInput value)? invalidInput, + TResult Function(CccCryptoError_FeatureNotCompiled value)? + featureNotCompiled, + TResult Function(CccCryptoError_InternalError value)? internalError, + required TResult orElse(), + }) { + if (authenticationFailed != null) { + return authenticationFailed(this); + } + return orElse(); + } +} + +abstract class CccCryptoError_AuthenticationFailed extends CccCryptoError { + const factory CccCryptoError_AuthenticationFailed() = + _$CccCryptoError_AuthenticationFailedImpl; + const CccCryptoError_AuthenticationFailed._() : super._(); +} + +/// @nodoc +abstract class _$$CccCryptoError_InvalidInputImplCopyWith<$Res> { + factory _$$CccCryptoError_InvalidInputImplCopyWith( + _$CccCryptoError_InvalidInputImpl value, + $Res Function(_$CccCryptoError_InvalidInputImpl) then, + ) = __$$CccCryptoError_InvalidInputImplCopyWithImpl<$Res>; + @useResult + $Res call({String field0}); +} + +/// @nodoc +class __$$CccCryptoError_InvalidInputImplCopyWithImpl<$Res> + extends + _$CccCryptoErrorCopyWithImpl<$Res, _$CccCryptoError_InvalidInputImpl> + implements _$$CccCryptoError_InvalidInputImplCopyWith<$Res> { + __$$CccCryptoError_InvalidInputImplCopyWithImpl( + _$CccCryptoError_InvalidInputImpl _value, + $Res Function(_$CccCryptoError_InvalidInputImpl) _then, + ) : super(_value, _then); + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? field0 = null}) { + return _then( + _$CccCryptoError_InvalidInputImpl( + null == field0 + ? _value.field0 + : field0 // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$CccCryptoError_InvalidInputImpl extends CccCryptoError_InvalidInput { + const _$CccCryptoError_InvalidInputImpl(this.field0) : super._(); + + @override + final String field0; + + @override + String toString() { + return 'CccCryptoError.invalidInput(field0: $field0)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CccCryptoError_InvalidInputImpl && + (identical(other.field0, field0) || other.field0 == field0)); + } + + @override + int get hashCode => Object.hash(runtimeType, field0); + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$CccCryptoError_InvalidInputImplCopyWith<_$CccCryptoError_InvalidInputImpl> + get copyWith => + __$$CccCryptoError_InvalidInputImplCopyWithImpl< + _$CccCryptoError_InvalidInputImpl + >(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String field0) unsupportedAlgorithm, + required TResult Function(String field0) invalidKey, + required TResult Function(String field0) invalidNonce, + required TResult Function() authenticationFailed, + required TResult Function(String field0) invalidInput, + required TResult Function(String field0) featureNotCompiled, + required TResult Function(String field0) internalError, + }) { + return invalidInput(field0); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String field0)? unsupportedAlgorithm, + TResult? Function(String field0)? invalidKey, + TResult? Function(String field0)? invalidNonce, + TResult? Function()? authenticationFailed, + TResult? Function(String field0)? invalidInput, + TResult? Function(String field0)? featureNotCompiled, + TResult? Function(String field0)? internalError, + }) { + return invalidInput?.call(field0); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String field0)? unsupportedAlgorithm, + TResult Function(String field0)? invalidKey, + TResult Function(String field0)? invalidNonce, + TResult Function()? authenticationFailed, + TResult Function(String field0)? invalidInput, + TResult Function(String field0)? featureNotCompiled, + TResult Function(String field0)? internalError, + required TResult orElse(), + }) { + if (invalidInput != null) { + return invalidInput(field0); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(CccCryptoError_UnsupportedAlgorithm value) + unsupportedAlgorithm, + required TResult Function(CccCryptoError_InvalidKey value) invalidKey, + required TResult Function(CccCryptoError_InvalidNonce value) invalidNonce, + required TResult Function(CccCryptoError_AuthenticationFailed value) + authenticationFailed, + required TResult Function(CccCryptoError_InvalidInput value) invalidInput, + required TResult Function(CccCryptoError_FeatureNotCompiled value) + featureNotCompiled, + required TResult Function(CccCryptoError_InternalError value) internalError, + }) { + return invalidInput(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(CccCryptoError_UnsupportedAlgorithm value)? + unsupportedAlgorithm, + TResult? Function(CccCryptoError_InvalidKey value)? invalidKey, + TResult? Function(CccCryptoError_InvalidNonce value)? invalidNonce, + TResult? Function(CccCryptoError_AuthenticationFailed value)? + authenticationFailed, + TResult? Function(CccCryptoError_InvalidInput value)? invalidInput, + TResult? Function(CccCryptoError_FeatureNotCompiled value)? + featureNotCompiled, + TResult? Function(CccCryptoError_InternalError value)? internalError, + }) { + return invalidInput?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(CccCryptoError_UnsupportedAlgorithm value)? + unsupportedAlgorithm, + TResult Function(CccCryptoError_InvalidKey value)? invalidKey, + TResult Function(CccCryptoError_InvalidNonce value)? invalidNonce, + TResult Function(CccCryptoError_AuthenticationFailed value)? + authenticationFailed, + TResult Function(CccCryptoError_InvalidInput value)? invalidInput, + TResult Function(CccCryptoError_FeatureNotCompiled value)? + featureNotCompiled, + TResult Function(CccCryptoError_InternalError value)? internalError, + required TResult orElse(), + }) { + if (invalidInput != null) { + return invalidInput(this); + } + return orElse(); + } +} + +abstract class CccCryptoError_InvalidInput extends CccCryptoError { + const factory CccCryptoError_InvalidInput(final String field0) = + _$CccCryptoError_InvalidInputImpl; + const CccCryptoError_InvalidInput._() : super._(); + + String get field0; + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$CccCryptoError_InvalidInputImplCopyWith<_$CccCryptoError_InvalidInputImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$CccCryptoError_FeatureNotCompiledImplCopyWith<$Res> { + factory _$$CccCryptoError_FeatureNotCompiledImplCopyWith( + _$CccCryptoError_FeatureNotCompiledImpl value, + $Res Function(_$CccCryptoError_FeatureNotCompiledImpl) then, + ) = __$$CccCryptoError_FeatureNotCompiledImplCopyWithImpl<$Res>; + @useResult + $Res call({String field0}); +} + +/// @nodoc +class __$$CccCryptoError_FeatureNotCompiledImplCopyWithImpl<$Res> + extends + _$CccCryptoErrorCopyWithImpl< + $Res, + _$CccCryptoError_FeatureNotCompiledImpl + > + implements _$$CccCryptoError_FeatureNotCompiledImplCopyWith<$Res> { + __$$CccCryptoError_FeatureNotCompiledImplCopyWithImpl( + _$CccCryptoError_FeatureNotCompiledImpl _value, + $Res Function(_$CccCryptoError_FeatureNotCompiledImpl) _then, + ) : super(_value, _then); + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? field0 = null}) { + return _then( + _$CccCryptoError_FeatureNotCompiledImpl( + null == field0 + ? _value.field0 + : field0 // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$CccCryptoError_FeatureNotCompiledImpl + extends CccCryptoError_FeatureNotCompiled { + const _$CccCryptoError_FeatureNotCompiledImpl(this.field0) : super._(); + + @override + final String field0; + + @override + String toString() { + return 'CccCryptoError.featureNotCompiled(field0: $field0)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CccCryptoError_FeatureNotCompiledImpl && + (identical(other.field0, field0) || other.field0 == field0)); + } + + @override + int get hashCode => Object.hash(runtimeType, field0); + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$CccCryptoError_FeatureNotCompiledImplCopyWith< + _$CccCryptoError_FeatureNotCompiledImpl + > + get copyWith => + __$$CccCryptoError_FeatureNotCompiledImplCopyWithImpl< + _$CccCryptoError_FeatureNotCompiledImpl + >(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String field0) unsupportedAlgorithm, + required TResult Function(String field0) invalidKey, + required TResult Function(String field0) invalidNonce, + required TResult Function() authenticationFailed, + required TResult Function(String field0) invalidInput, + required TResult Function(String field0) featureNotCompiled, + required TResult Function(String field0) internalError, + }) { + return featureNotCompiled(field0); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String field0)? unsupportedAlgorithm, + TResult? Function(String field0)? invalidKey, + TResult? Function(String field0)? invalidNonce, + TResult? Function()? authenticationFailed, + TResult? Function(String field0)? invalidInput, + TResult? Function(String field0)? featureNotCompiled, + TResult? Function(String field0)? internalError, + }) { + return featureNotCompiled?.call(field0); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String field0)? unsupportedAlgorithm, + TResult Function(String field0)? invalidKey, + TResult Function(String field0)? invalidNonce, + TResult Function()? authenticationFailed, + TResult Function(String field0)? invalidInput, + TResult Function(String field0)? featureNotCompiled, + TResult Function(String field0)? internalError, + required TResult orElse(), + }) { + if (featureNotCompiled != null) { + return featureNotCompiled(field0); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(CccCryptoError_UnsupportedAlgorithm value) + unsupportedAlgorithm, + required TResult Function(CccCryptoError_InvalidKey value) invalidKey, + required TResult Function(CccCryptoError_InvalidNonce value) invalidNonce, + required TResult Function(CccCryptoError_AuthenticationFailed value) + authenticationFailed, + required TResult Function(CccCryptoError_InvalidInput value) invalidInput, + required TResult Function(CccCryptoError_FeatureNotCompiled value) + featureNotCompiled, + required TResult Function(CccCryptoError_InternalError value) internalError, + }) { + return featureNotCompiled(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(CccCryptoError_UnsupportedAlgorithm value)? + unsupportedAlgorithm, + TResult? Function(CccCryptoError_InvalidKey value)? invalidKey, + TResult? Function(CccCryptoError_InvalidNonce value)? invalidNonce, + TResult? Function(CccCryptoError_AuthenticationFailed value)? + authenticationFailed, + TResult? Function(CccCryptoError_InvalidInput value)? invalidInput, + TResult? Function(CccCryptoError_FeatureNotCompiled value)? + featureNotCompiled, + TResult? Function(CccCryptoError_InternalError value)? internalError, + }) { + return featureNotCompiled?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(CccCryptoError_UnsupportedAlgorithm value)? + unsupportedAlgorithm, + TResult Function(CccCryptoError_InvalidKey value)? invalidKey, + TResult Function(CccCryptoError_InvalidNonce value)? invalidNonce, + TResult Function(CccCryptoError_AuthenticationFailed value)? + authenticationFailed, + TResult Function(CccCryptoError_InvalidInput value)? invalidInput, + TResult Function(CccCryptoError_FeatureNotCompiled value)? + featureNotCompiled, + TResult Function(CccCryptoError_InternalError value)? internalError, + required TResult orElse(), + }) { + if (featureNotCompiled != null) { + return featureNotCompiled(this); + } + return orElse(); + } +} + +abstract class CccCryptoError_FeatureNotCompiled extends CccCryptoError { + const factory CccCryptoError_FeatureNotCompiled(final String field0) = + _$CccCryptoError_FeatureNotCompiledImpl; + const CccCryptoError_FeatureNotCompiled._() : super._(); + + String get field0; + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$CccCryptoError_FeatureNotCompiledImplCopyWith< + _$CccCryptoError_FeatureNotCompiledImpl + > + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$CccCryptoError_InternalErrorImplCopyWith<$Res> { + factory _$$CccCryptoError_InternalErrorImplCopyWith( + _$CccCryptoError_InternalErrorImpl value, + $Res Function(_$CccCryptoError_InternalErrorImpl) then, + ) = __$$CccCryptoError_InternalErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String field0}); +} + +/// @nodoc +class __$$CccCryptoError_InternalErrorImplCopyWithImpl<$Res> + extends + _$CccCryptoErrorCopyWithImpl<$Res, _$CccCryptoError_InternalErrorImpl> + implements _$$CccCryptoError_InternalErrorImplCopyWith<$Res> { + __$$CccCryptoError_InternalErrorImplCopyWithImpl( + _$CccCryptoError_InternalErrorImpl _value, + $Res Function(_$CccCryptoError_InternalErrorImpl) _then, + ) : super(_value, _then); + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? field0 = null}) { + return _then( + _$CccCryptoError_InternalErrorImpl( + null == field0 + ? _value.field0 + : field0 // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$CccCryptoError_InternalErrorImpl extends CccCryptoError_InternalError { + const _$CccCryptoError_InternalErrorImpl(this.field0) : super._(); + + @override + final String field0; + + @override + String toString() { + return 'CccCryptoError.internalError(field0: $field0)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CccCryptoError_InternalErrorImpl && + (identical(other.field0, field0) || other.field0 == field0)); + } + + @override + int get hashCode => Object.hash(runtimeType, field0); + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$CccCryptoError_InternalErrorImplCopyWith< + _$CccCryptoError_InternalErrorImpl + > + get copyWith => + __$$CccCryptoError_InternalErrorImplCopyWithImpl< + _$CccCryptoError_InternalErrorImpl + >(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String field0) unsupportedAlgorithm, + required TResult Function(String field0) invalidKey, + required TResult Function(String field0) invalidNonce, + required TResult Function() authenticationFailed, + required TResult Function(String field0) invalidInput, + required TResult Function(String field0) featureNotCompiled, + required TResult Function(String field0) internalError, + }) { + return internalError(field0); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String field0)? unsupportedAlgorithm, + TResult? Function(String field0)? invalidKey, + TResult? Function(String field0)? invalidNonce, + TResult? Function()? authenticationFailed, + TResult? Function(String field0)? invalidInput, + TResult? Function(String field0)? featureNotCompiled, + TResult? Function(String field0)? internalError, + }) { + return internalError?.call(field0); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String field0)? unsupportedAlgorithm, + TResult Function(String field0)? invalidKey, + TResult Function(String field0)? invalidNonce, + TResult Function()? authenticationFailed, + TResult Function(String field0)? invalidInput, + TResult Function(String field0)? featureNotCompiled, + TResult Function(String field0)? internalError, + required TResult orElse(), + }) { + if (internalError != null) { + return internalError(field0); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(CccCryptoError_UnsupportedAlgorithm value) + unsupportedAlgorithm, + required TResult Function(CccCryptoError_InvalidKey value) invalidKey, + required TResult Function(CccCryptoError_InvalidNonce value) invalidNonce, + required TResult Function(CccCryptoError_AuthenticationFailed value) + authenticationFailed, + required TResult Function(CccCryptoError_InvalidInput value) invalidInput, + required TResult Function(CccCryptoError_FeatureNotCompiled value) + featureNotCompiled, + required TResult Function(CccCryptoError_InternalError value) internalError, + }) { + return internalError(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(CccCryptoError_UnsupportedAlgorithm value)? + unsupportedAlgorithm, + TResult? Function(CccCryptoError_InvalidKey value)? invalidKey, + TResult? Function(CccCryptoError_InvalidNonce value)? invalidNonce, + TResult? Function(CccCryptoError_AuthenticationFailed value)? + authenticationFailed, + TResult? Function(CccCryptoError_InvalidInput value)? invalidInput, + TResult? Function(CccCryptoError_FeatureNotCompiled value)? + featureNotCompiled, + TResult? Function(CccCryptoError_InternalError value)? internalError, + }) { + return internalError?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(CccCryptoError_UnsupportedAlgorithm value)? + unsupportedAlgorithm, + TResult Function(CccCryptoError_InvalidKey value)? invalidKey, + TResult Function(CccCryptoError_InvalidNonce value)? invalidNonce, + TResult Function(CccCryptoError_AuthenticationFailed value)? + authenticationFailed, + TResult Function(CccCryptoError_InvalidInput value)? invalidInput, + TResult Function(CccCryptoError_FeatureNotCompiled value)? + featureNotCompiled, + TResult Function(CccCryptoError_InternalError value)? internalError, + required TResult orElse(), + }) { + if (internalError != null) { + return internalError(this); + } + return orElse(); + } +} + +abstract class CccCryptoError_InternalError extends CccCryptoError { + const factory CccCryptoError_InternalError(final String field0) = + _$CccCryptoError_InternalErrorImpl; + const CccCryptoError_InternalError._() : super._(); + + String get field0; + + /// Create a copy of CccCryptoError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$CccCryptoError_InternalErrorImplCopyWith< + _$CccCryptoError_InternalErrorImpl + > + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/src/rust/frb_generated.dart b/lib/src/rust/frb_generated.dart index c9faaa9..dce3bf0 100644 --- a/lib/src/rust/frb_generated.dart +++ b/lib/src/rust/frb_generated.dart @@ -3,6 +3,8 @@ // ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field +import 'api/crypto.dart'; +import 'api/dto.dart'; import 'api/simple.dart'; import 'dart:async'; import 'dart:convert'; @@ -66,7 +68,7 @@ class RustLib extends BaseEntrypoint { String get codegenVersion => '2.11.1'; @override - int get rustContentHash => -1918914929; + int get rustContentHash => -138461235; static const kDefaultExternalLibraryLoaderConfig = ExternalLibraryLoaderConfig( @@ -77,6 +79,71 @@ class RustLib extends BaseEntrypoint { } abstract class RustLibApi extends BaseApi { + Future crateApiCryptoCccAeadDecrypt({ + required CccAeadAlgorithm algorithm, + required List key, + required List nonce, + required List ciphertext, + required List aad, + }); + + Future crateApiCryptoCccAeadEncrypt({ + required CccAeadAlgorithm algorithm, + required List key, + required List nonce, + required List plaintext, + required List aad, + }); + + Future crateApiCryptoCccCapabilities(); + + Future crateApiCryptoCccHash({ + required CccHashAlgorithm algorithm, + required List data, + }); + + Future crateApiCryptoCccInit(); + + Future crateApiCryptoCccKdfDerive({ + required CccKdfAlgorithm algorithm, + required List ikm, + required List salt, + required List info, + required int length, + }); + + Future crateApiCryptoCccKemDecapsulate({ + required CccKemAlgorithm algorithm, + required List privateKey, + required List ciphertext, + }); + + Future crateApiCryptoCccKemEncapsulate({ + required CccKemAlgorithm algorithm, + required List publicKey, + }); + + Future crateApiCryptoCccKemGenerateKeypair({ + required CccKemAlgorithm algorithm, + }); + + List crateApiCryptoCccListProviders(); + + Future crateApiCryptoCccMacCompute({ + required CccMacAlgorithm algorithm, + required List key, + required List data, + }); + + Future crateApiCryptoCccMacVerify({ + required CccMacAlgorithm algorithm, + required List key, + required List data, + required List mac, + }); + + Future crateApiCryptoCccSelfTest(); + String crateApiSimpleGreet({required String name}); Future crateApiSimpleInitApp(); @@ -90,6 +157,445 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { required super.portManager, }); + @override + Future crateApiCryptoCccAeadDecrypt({ + required CccAeadAlgorithm algorithm, + required List key, + required List nonce, + required List ciphertext, + required List aad, + }) { + return handler.executeNormal( + NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_ccc_aead_algorithm(algorithm, serializer); + sse_encode_list_prim_u_8_loose(key, serializer); + sse_encode_list_prim_u_8_loose(nonce, serializer); + sse_encode_list_prim_u_8_loose(ciphertext, serializer); + sse_encode_list_prim_u_8_loose(aad, serializer); + pdeCallFfi( + generalizedFrbRustBinding, + serializer, + funcId: 1, + port: port_, + ); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_list_prim_u_8_strict, + decodeErrorData: sse_decode_ccc_crypto_error, + ), + constMeta: kCrateApiCryptoCccAeadDecryptConstMeta, + argValues: [algorithm, key, nonce, ciphertext, aad], + apiImpl: this, + ), + ); + } + + TaskConstMeta get kCrateApiCryptoCccAeadDecryptConstMeta => + const TaskConstMeta( + debugName: "ccc_aead_decrypt", + argNames: ["algorithm", "key", "nonce", "ciphertext", "aad"], + ); + + @override + Future crateApiCryptoCccAeadEncrypt({ + required CccAeadAlgorithm algorithm, + required List key, + required List nonce, + required List plaintext, + required List aad, + }) { + return handler.executeNormal( + NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_ccc_aead_algorithm(algorithm, serializer); + sse_encode_list_prim_u_8_loose(key, serializer); + sse_encode_list_prim_u_8_loose(nonce, serializer); + sse_encode_list_prim_u_8_loose(plaintext, serializer); + sse_encode_list_prim_u_8_loose(aad, serializer); + pdeCallFfi( + generalizedFrbRustBinding, + serializer, + funcId: 2, + port: port_, + ); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_list_prim_u_8_strict, + decodeErrorData: sse_decode_ccc_crypto_error, + ), + constMeta: kCrateApiCryptoCccAeadEncryptConstMeta, + argValues: [algorithm, key, nonce, plaintext, aad], + apiImpl: this, + ), + ); + } + + TaskConstMeta get kCrateApiCryptoCccAeadEncryptConstMeta => + const TaskConstMeta( + debugName: "ccc_aead_encrypt", + argNames: ["algorithm", "key", "nonce", "plaintext", "aad"], + ); + + @override + Future crateApiCryptoCccCapabilities() { + return handler.executeNormal( + NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + pdeCallFfi( + generalizedFrbRustBinding, + serializer, + funcId: 3, + port: port_, + ); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_ccc_capabilities, + decodeErrorData: sse_decode_ccc_crypto_error, + ), + constMeta: kCrateApiCryptoCccCapabilitiesConstMeta, + argValues: [], + apiImpl: this, + ), + ); + } + + TaskConstMeta get kCrateApiCryptoCccCapabilitiesConstMeta => + const TaskConstMeta(debugName: "ccc_capabilities", argNames: []); + + @override + Future crateApiCryptoCccHash({ + required CccHashAlgorithm algorithm, + required List data, + }) { + return handler.executeNormal( + NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_ccc_hash_algorithm(algorithm, serializer); + sse_encode_list_prim_u_8_loose(data, serializer); + pdeCallFfi( + generalizedFrbRustBinding, + serializer, + funcId: 4, + port: port_, + ); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_list_prim_u_8_strict, + decodeErrorData: sse_decode_ccc_crypto_error, + ), + constMeta: kCrateApiCryptoCccHashConstMeta, + argValues: [algorithm, data], + apiImpl: this, + ), + ); + } + + TaskConstMeta get kCrateApiCryptoCccHashConstMeta => const TaskConstMeta( + debugName: "ccc_hash", + argNames: ["algorithm", "data"], + ); + + @override + Future crateApiCryptoCccInit() { + return handler.executeNormal( + NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + pdeCallFfi( + generalizedFrbRustBinding, + serializer, + funcId: 5, + port: port_, + ); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: null, + ), + constMeta: kCrateApiCryptoCccInitConstMeta, + argValues: [], + apiImpl: this, + ), + ); + } + + TaskConstMeta get kCrateApiCryptoCccInitConstMeta => + const TaskConstMeta(debugName: "ccc_init", argNames: []); + + @override + Future crateApiCryptoCccKdfDerive({ + required CccKdfAlgorithm algorithm, + required List ikm, + required List salt, + required List info, + required int length, + }) { + return handler.executeNormal( + NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_ccc_kdf_algorithm(algorithm, serializer); + sse_encode_list_prim_u_8_loose(ikm, serializer); + sse_encode_list_prim_u_8_loose(salt, serializer); + sse_encode_list_prim_u_8_loose(info, serializer); + sse_encode_u_32(length, serializer); + pdeCallFfi( + generalizedFrbRustBinding, + serializer, + funcId: 6, + port: port_, + ); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_list_prim_u_8_strict, + decodeErrorData: sse_decode_ccc_crypto_error, + ), + constMeta: kCrateApiCryptoCccKdfDeriveConstMeta, + argValues: [algorithm, ikm, salt, info, length], + apiImpl: this, + ), + ); + } + + TaskConstMeta get kCrateApiCryptoCccKdfDeriveConstMeta => const TaskConstMeta( + debugName: "ccc_kdf_derive", + argNames: ["algorithm", "ikm", "salt", "info", "length"], + ); + + @override + Future crateApiCryptoCccKemDecapsulate({ + required CccKemAlgorithm algorithm, + required List privateKey, + required List ciphertext, + }) { + return handler.executeNormal( + NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_ccc_kem_algorithm(algorithm, serializer); + sse_encode_list_prim_u_8_loose(privateKey, serializer); + sse_encode_list_prim_u_8_loose(ciphertext, serializer); + pdeCallFfi( + generalizedFrbRustBinding, + serializer, + funcId: 7, + port: port_, + ); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_list_prim_u_8_strict, + decodeErrorData: sse_decode_ccc_crypto_error, + ), + constMeta: kCrateApiCryptoCccKemDecapsulateConstMeta, + argValues: [algorithm, privateKey, ciphertext], + apiImpl: this, + ), + ); + } + + TaskConstMeta get kCrateApiCryptoCccKemDecapsulateConstMeta => + const TaskConstMeta( + debugName: "ccc_kem_decapsulate", + argNames: ["algorithm", "privateKey", "ciphertext"], + ); + + @override + Future crateApiCryptoCccKemEncapsulate({ + required CccKemAlgorithm algorithm, + required List publicKey, + }) { + return handler.executeNormal( + NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_ccc_kem_algorithm(algorithm, serializer); + sse_encode_list_prim_u_8_loose(publicKey, serializer); + pdeCallFfi( + generalizedFrbRustBinding, + serializer, + funcId: 8, + port: port_, + ); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_ccc_kem_encap_result, + decodeErrorData: sse_decode_ccc_crypto_error, + ), + constMeta: kCrateApiCryptoCccKemEncapsulateConstMeta, + argValues: [algorithm, publicKey], + apiImpl: this, + ), + ); + } + + TaskConstMeta get kCrateApiCryptoCccKemEncapsulateConstMeta => + const TaskConstMeta( + debugName: "ccc_kem_encapsulate", + argNames: ["algorithm", "publicKey"], + ); + + @override + Future crateApiCryptoCccKemGenerateKeypair({ + required CccKemAlgorithm algorithm, + }) { + return handler.executeNormal( + NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_ccc_kem_algorithm(algorithm, serializer); + pdeCallFfi( + generalizedFrbRustBinding, + serializer, + funcId: 9, + port: port_, + ); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_ccc_kem_key_pair, + decodeErrorData: sse_decode_ccc_crypto_error, + ), + constMeta: kCrateApiCryptoCccKemGenerateKeypairConstMeta, + argValues: [algorithm], + apiImpl: this, + ), + ); + } + + TaskConstMeta get kCrateApiCryptoCccKemGenerateKeypairConstMeta => + const TaskConstMeta( + debugName: "ccc_kem_generate_keypair", + argNames: ["algorithm"], + ); + + @override + List crateApiCryptoCccListProviders() { + return handler.executeSync( + SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 10)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_list_String, + decodeErrorData: null, + ), + constMeta: kCrateApiCryptoCccListProvidersConstMeta, + argValues: [], + apiImpl: this, + ), + ); + } + + TaskConstMeta get kCrateApiCryptoCccListProvidersConstMeta => + const TaskConstMeta(debugName: "ccc_list_providers", argNames: []); + + @override + Future crateApiCryptoCccMacCompute({ + required CccMacAlgorithm algorithm, + required List key, + required List data, + }) { + return handler.executeNormal( + NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_ccc_mac_algorithm(algorithm, serializer); + sse_encode_list_prim_u_8_loose(key, serializer); + sse_encode_list_prim_u_8_loose(data, serializer); + pdeCallFfi( + generalizedFrbRustBinding, + serializer, + funcId: 11, + port: port_, + ); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_list_prim_u_8_strict, + decodeErrorData: sse_decode_ccc_crypto_error, + ), + constMeta: kCrateApiCryptoCccMacComputeConstMeta, + argValues: [algorithm, key, data], + apiImpl: this, + ), + ); + } + + TaskConstMeta get kCrateApiCryptoCccMacComputeConstMeta => + const TaskConstMeta( + debugName: "ccc_mac_compute", + argNames: ["algorithm", "key", "data"], + ); + + @override + Future crateApiCryptoCccMacVerify({ + required CccMacAlgorithm algorithm, + required List key, + required List data, + required List mac, + }) { + return handler.executeNormal( + NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_ccc_mac_algorithm(algorithm, serializer); + sse_encode_list_prim_u_8_loose(key, serializer); + sse_encode_list_prim_u_8_loose(data, serializer); + sse_encode_list_prim_u_8_loose(mac, serializer); + pdeCallFfi( + generalizedFrbRustBinding, + serializer, + funcId: 12, + port: port_, + ); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_bool, + decodeErrorData: sse_decode_ccc_crypto_error, + ), + constMeta: kCrateApiCryptoCccMacVerifyConstMeta, + argValues: [algorithm, key, data, mac], + apiImpl: this, + ), + ); + } + + TaskConstMeta get kCrateApiCryptoCccMacVerifyConstMeta => const TaskConstMeta( + debugName: "ccc_mac_verify", + argNames: ["algorithm", "key", "data", "mac"], + ); + + @override + Future crateApiCryptoCccSelfTest() { + return handler.executeNormal( + NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + pdeCallFfi( + generalizedFrbRustBinding, + serializer, + funcId: 13, + port: port_, + ); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_ccc_self_test_report, + decodeErrorData: sse_decode_ccc_crypto_error, + ), + constMeta: kCrateApiCryptoCccSelfTestConstMeta, + argValues: [], + apiImpl: this, + ), + ); + } + + TaskConstMeta get kCrateApiCryptoCccSelfTestConstMeta => + const TaskConstMeta(debugName: "ccc_self_test", argNames: []); + @override String crateApiSimpleGreet({required String name}) { return handler.executeSync( @@ -97,7 +603,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_String(name, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 1)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 14)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -122,7 +628,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { pdeCallFfi( generalizedFrbRustBinding, serializer, - funcId: 2, + funcId: 15, port: port_, ); }, @@ -146,12 +652,207 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return raw as String; } + @protected + bool dco_decode_bool(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as bool; + } + + @protected + CccAeadAlgorithm dco_decode_ccc_aead_algorithm(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return CccAeadAlgorithm.values[raw as int]; + } + + @protected + CccAlgoTestResult dco_decode_ccc_algo_test_result(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 4) + throw Exception('unexpected arr length: expect 4 but see ${arr.length}'); + return CccAlgoTestResult( + algoId: dco_decode_u_32(arr[0]), + algoName: dco_decode_String(arr[1]), + passed: dco_decode_bool(arr[2]), + errorMessage: dco_decode_opt_String(arr[3]), + ); + } + + @protected + CccAlgorithmCapability dco_decode_ccc_algorithm_capability(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 4) + throw Exception('unexpected arr length: expect 4 but see ${arr.length}'); + return CccAlgorithmCapability( + available: dco_decode_bool(arr[0]), + deterministicIo: dco_decode_bool(arr[1]), + efficiencyScore: dco_decode_u_8(arr[2]), + reliabilityScore: dco_decode_u_8(arr[3]), + ); + } + + @protected + CccAlgorithmEntry dco_decode_ccc_algorithm_entry(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 3) + throw Exception('unexpected arr length: expect 3 but see ${arr.length}'); + return CccAlgorithmEntry( + algoId: dco_decode_u_32(arr[0]), + algoName: dco_decode_String(arr[1]), + capability: dco_decode_ccc_algorithm_capability(arr[2]), + ); + } + + @protected + CccCapabilities dco_decode_ccc_capabilities(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 6) + throw Exception('unexpected arr length: expect 6 but see ${arr.length}'); + return CccCapabilities( + providerName: dco_decode_String(arr[0]), + aead: dco_decode_list_ccc_algorithm_entry(arr[1]), + kdf: dco_decode_list_ccc_algorithm_entry(arr[2]), + mac: dco_decode_list_ccc_algorithm_entry(arr[3]), + hash: dco_decode_list_ccc_algorithm_entry(arr[4]), + kem: dco_decode_list_ccc_algorithm_entry(arr[5]), + ); + } + + @protected + CccCryptoError dco_decode_ccc_crypto_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + switch (raw[0]) { + case 0: + return CccCryptoError_UnsupportedAlgorithm(dco_decode_String(raw[1])); + case 1: + return CccCryptoError_InvalidKey(dco_decode_String(raw[1])); + case 2: + return CccCryptoError_InvalidNonce(dco_decode_String(raw[1])); + case 3: + return CccCryptoError_AuthenticationFailed(); + case 4: + return CccCryptoError_InvalidInput(dco_decode_String(raw[1])); + case 5: + return CccCryptoError_FeatureNotCompiled(dco_decode_String(raw[1])); + case 6: + return CccCryptoError_InternalError(dco_decode_String(raw[1])); + default: + throw Exception("unreachable"); + } + } + + @protected + CccHashAlgorithm dco_decode_ccc_hash_algorithm(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return CccHashAlgorithm.values[raw as int]; + } + + @protected + CccKdfAlgorithm dco_decode_ccc_kdf_algorithm(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return CccKdfAlgorithm.values[raw as int]; + } + + @protected + CccKemAlgorithm dco_decode_ccc_kem_algorithm(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return CccKemAlgorithm.values[raw as int]; + } + + @protected + CccKemEncapResult dco_decode_ccc_kem_encap_result(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 2) + throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); + return CccKemEncapResult( + ciphertext: dco_decode_list_prim_u_8_strict(arr[0]), + sharedSecret: dco_decode_list_prim_u_8_strict(arr[1]), + ); + } + + @protected + CccKemKeyPair dco_decode_ccc_kem_key_pair(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 2) + throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); + return CccKemKeyPair( + publicKey: dco_decode_list_prim_u_8_strict(arr[0]), + privateKey: dco_decode_list_prim_u_8_strict(arr[1]), + ); + } + + @protected + CccMacAlgorithm dco_decode_ccc_mac_algorithm(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return CccMacAlgorithm.values[raw as int]; + } + + @protected + CccSelfTestReport dco_decode_ccc_self_test_report(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 3) + throw Exception('unexpected arr length: expect 3 but see ${arr.length}'); + return CccSelfTestReport( + providerName: dco_decode_String(arr[0]), + results: dco_decode_list_ccc_algo_test_result(arr[1]), + allPassed: dco_decode_bool(arr[2]), + ); + } + + @protected + int dco_decode_i_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as int; + } + + @protected + List dco_decode_list_String(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return (raw as List).map(dco_decode_String).toList(); + } + + @protected + List dco_decode_list_ccc_algo_test_result(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return (raw as List).map(dco_decode_ccc_algo_test_result).toList(); + } + + @protected + List dco_decode_list_ccc_algorithm_entry(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return (raw as List).map(dco_decode_ccc_algorithm_entry).toList(); + } + + @protected + List dco_decode_list_prim_u_8_loose(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as List; + } + @protected Uint8List dco_decode_list_prim_u_8_strict(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs return raw as Uint8List; } + @protected + String? dco_decode_opt_String(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_String(raw); + } + + @protected + int dco_decode_u_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as int; + } + @protected int dco_decode_u_8(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs @@ -171,6 +872,235 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return utf8.decoder.convert(inner); } + @protected + bool sse_decode_bool(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getUint8() != 0; + } + + @protected + CccAeadAlgorithm sse_decode_ccc_aead_algorithm(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_i_32(deserializer); + return CccAeadAlgorithm.values[inner]; + } + + @protected + CccAlgoTestResult sse_decode_ccc_algo_test_result( + SseDeserializer deserializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_algoId = sse_decode_u_32(deserializer); + var var_algoName = sse_decode_String(deserializer); + var var_passed = sse_decode_bool(deserializer); + var var_errorMessage = sse_decode_opt_String(deserializer); + return CccAlgoTestResult( + algoId: var_algoId, + algoName: var_algoName, + passed: var_passed, + errorMessage: var_errorMessage, + ); + } + + @protected + CccAlgorithmCapability sse_decode_ccc_algorithm_capability( + SseDeserializer deserializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_available = sse_decode_bool(deserializer); + var var_deterministicIo = sse_decode_bool(deserializer); + var var_efficiencyScore = sse_decode_u_8(deserializer); + var var_reliabilityScore = sse_decode_u_8(deserializer); + return CccAlgorithmCapability( + available: var_available, + deterministicIo: var_deterministicIo, + efficiencyScore: var_efficiencyScore, + reliabilityScore: var_reliabilityScore, + ); + } + + @protected + CccAlgorithmEntry sse_decode_ccc_algorithm_entry( + SseDeserializer deserializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_algoId = sse_decode_u_32(deserializer); + var var_algoName = sse_decode_String(deserializer); + var var_capability = sse_decode_ccc_algorithm_capability(deserializer); + return CccAlgorithmEntry( + algoId: var_algoId, + algoName: var_algoName, + capability: var_capability, + ); + } + + @protected + CccCapabilities sse_decode_ccc_capabilities(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_providerName = sse_decode_String(deserializer); + var var_aead = sse_decode_list_ccc_algorithm_entry(deserializer); + var var_kdf = sse_decode_list_ccc_algorithm_entry(deserializer); + var var_mac = sse_decode_list_ccc_algorithm_entry(deserializer); + var var_hash = sse_decode_list_ccc_algorithm_entry(deserializer); + var var_kem = sse_decode_list_ccc_algorithm_entry(deserializer); + return CccCapabilities( + providerName: var_providerName, + aead: var_aead, + kdf: var_kdf, + mac: var_mac, + hash: var_hash, + kem: var_kem, + ); + } + + @protected + CccCryptoError sse_decode_ccc_crypto_error(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var tag_ = sse_decode_i_32(deserializer); + switch (tag_) { + case 0: + var var_field0 = sse_decode_String(deserializer); + return CccCryptoError_UnsupportedAlgorithm(var_field0); + case 1: + var var_field0 = sse_decode_String(deserializer); + return CccCryptoError_InvalidKey(var_field0); + case 2: + var var_field0 = sse_decode_String(deserializer); + return CccCryptoError_InvalidNonce(var_field0); + case 3: + return CccCryptoError_AuthenticationFailed(); + case 4: + var var_field0 = sse_decode_String(deserializer); + return CccCryptoError_InvalidInput(var_field0); + case 5: + var var_field0 = sse_decode_String(deserializer); + return CccCryptoError_FeatureNotCompiled(var_field0); + case 6: + var var_field0 = sse_decode_String(deserializer); + return CccCryptoError_InternalError(var_field0); + default: + throw UnimplementedError(''); + } + } + + @protected + CccHashAlgorithm sse_decode_ccc_hash_algorithm(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_i_32(deserializer); + return CccHashAlgorithm.values[inner]; + } + + @protected + CccKdfAlgorithm sse_decode_ccc_kdf_algorithm(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_i_32(deserializer); + return CccKdfAlgorithm.values[inner]; + } + + @protected + CccKemAlgorithm sse_decode_ccc_kem_algorithm(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_i_32(deserializer); + return CccKemAlgorithm.values[inner]; + } + + @protected + CccKemEncapResult sse_decode_ccc_kem_encap_result( + SseDeserializer deserializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_ciphertext = sse_decode_list_prim_u_8_strict(deserializer); + var var_sharedSecret = sse_decode_list_prim_u_8_strict(deserializer); + return CccKemEncapResult( + ciphertext: var_ciphertext, + sharedSecret: var_sharedSecret, + ); + } + + @protected + CccKemKeyPair sse_decode_ccc_kem_key_pair(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_publicKey = sse_decode_list_prim_u_8_strict(deserializer); + var var_privateKey = sse_decode_list_prim_u_8_strict(deserializer); + return CccKemKeyPair(publicKey: var_publicKey, privateKey: var_privateKey); + } + + @protected + CccMacAlgorithm sse_decode_ccc_mac_algorithm(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_i_32(deserializer); + return CccMacAlgorithm.values[inner]; + } + + @protected + CccSelfTestReport sse_decode_ccc_self_test_report( + SseDeserializer deserializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_providerName = sse_decode_String(deserializer); + var var_results = sse_decode_list_ccc_algo_test_result(deserializer); + var var_allPassed = sse_decode_bool(deserializer); + return CccSelfTestReport( + providerName: var_providerName, + results: var_results, + allPassed: var_allPassed, + ); + } + + @protected + int sse_decode_i_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getInt32(); + } + + @protected + List sse_decode_list_String(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var len_ = sse_decode_i_32(deserializer); + var ans_ = []; + for (var idx_ = 0; idx_ < len_; ++idx_) { + ans_.add(sse_decode_String(deserializer)); + } + return ans_; + } + + @protected + List sse_decode_list_ccc_algo_test_result( + SseDeserializer deserializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var len_ = sse_decode_i_32(deserializer); + var ans_ = []; + for (var idx_ = 0; idx_ < len_; ++idx_) { + ans_.add(sse_decode_ccc_algo_test_result(deserializer)); + } + return ans_; + } + + @protected + List sse_decode_list_ccc_algorithm_entry( + SseDeserializer deserializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var len_ = sse_decode_i_32(deserializer); + var ans_ = []; + for (var idx_ = 0; idx_ < len_; ++idx_) { + ans_.add(sse_decode_ccc_algorithm_entry(deserializer)); + } + return ans_; + } + + @protected + List sse_decode_list_prim_u_8_loose(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var len_ = sse_decode_i_32(deserializer); + return deserializer.buffer.getUint8List(len_); + } + @protected Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -178,6 +1108,23 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return deserializer.buffer.getUint8List(len_); } + @protected + String? sse_decode_opt_String(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_String(deserializer)); + } else { + return null; + } + } + + @protected + int sse_decode_u_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getUint32(); + } + @protected int sse_decode_u_8(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -189,24 +1136,224 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { // Codec=Sse (Serialization based), see doc to use other codecs } - @protected - int sse_decode_i_32(SseDeserializer deserializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - return deserializer.buffer.getInt32(); - } - - @protected - bool sse_decode_bool(SseDeserializer deserializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - return deserializer.buffer.getUint8() != 0; - } - @protected void sse_encode_String(String self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs sse_encode_list_prim_u_8_strict(utf8.encoder.convert(self), serializer); } + @protected + void sse_encode_bool(bool self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putUint8(self ? 1 : 0); + } + + @protected + void sse_encode_ccc_aead_algorithm( + CccAeadAlgorithm self, + SseSerializer serializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.index, serializer); + } + + @protected + void sse_encode_ccc_algo_test_result( + CccAlgoTestResult self, + SseSerializer serializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_u_32(self.algoId, serializer); + sse_encode_String(self.algoName, serializer); + sse_encode_bool(self.passed, serializer); + sse_encode_opt_String(self.errorMessage, serializer); + } + + @protected + void sse_encode_ccc_algorithm_capability( + CccAlgorithmCapability self, + SseSerializer serializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_bool(self.available, serializer); + sse_encode_bool(self.deterministicIo, serializer); + sse_encode_u_8(self.efficiencyScore, serializer); + sse_encode_u_8(self.reliabilityScore, serializer); + } + + @protected + void sse_encode_ccc_algorithm_entry( + CccAlgorithmEntry self, + SseSerializer serializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_u_32(self.algoId, serializer); + sse_encode_String(self.algoName, serializer); + sse_encode_ccc_algorithm_capability(self.capability, serializer); + } + + @protected + void sse_encode_ccc_capabilities( + CccCapabilities self, + SseSerializer serializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_String(self.providerName, serializer); + sse_encode_list_ccc_algorithm_entry(self.aead, serializer); + sse_encode_list_ccc_algorithm_entry(self.kdf, serializer); + sse_encode_list_ccc_algorithm_entry(self.mac, serializer); + sse_encode_list_ccc_algorithm_entry(self.hash, serializer); + sse_encode_list_ccc_algorithm_entry(self.kem, serializer); + } + + @protected + void sse_encode_ccc_crypto_error( + CccCryptoError self, + SseSerializer serializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + switch (self) { + case CccCryptoError_UnsupportedAlgorithm(field0: final field0): + sse_encode_i_32(0, serializer); + sse_encode_String(field0, serializer); + case CccCryptoError_InvalidKey(field0: final field0): + sse_encode_i_32(1, serializer); + sse_encode_String(field0, serializer); + case CccCryptoError_InvalidNonce(field0: final field0): + sse_encode_i_32(2, serializer); + sse_encode_String(field0, serializer); + case CccCryptoError_AuthenticationFailed(): + sse_encode_i_32(3, serializer); + case CccCryptoError_InvalidInput(field0: final field0): + sse_encode_i_32(4, serializer); + sse_encode_String(field0, serializer); + case CccCryptoError_FeatureNotCompiled(field0: final field0): + sse_encode_i_32(5, serializer); + sse_encode_String(field0, serializer); + case CccCryptoError_InternalError(field0: final field0): + sse_encode_i_32(6, serializer); + sse_encode_String(field0, serializer); + } + } + + @protected + void sse_encode_ccc_hash_algorithm( + CccHashAlgorithm self, + SseSerializer serializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.index, serializer); + } + + @protected + void sse_encode_ccc_kdf_algorithm( + CccKdfAlgorithm self, + SseSerializer serializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.index, serializer); + } + + @protected + void sse_encode_ccc_kem_algorithm( + CccKemAlgorithm self, + SseSerializer serializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.index, serializer); + } + + @protected + void sse_encode_ccc_kem_encap_result( + CccKemEncapResult self, + SseSerializer serializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_list_prim_u_8_strict(self.ciphertext, serializer); + sse_encode_list_prim_u_8_strict(self.sharedSecret, serializer); + } + + @protected + void sse_encode_ccc_kem_key_pair( + CccKemKeyPair self, + SseSerializer serializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_list_prim_u_8_strict(self.publicKey, serializer); + sse_encode_list_prim_u_8_strict(self.privateKey, serializer); + } + + @protected + void sse_encode_ccc_mac_algorithm( + CccMacAlgorithm self, + SseSerializer serializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.index, serializer); + } + + @protected + void sse_encode_ccc_self_test_report( + CccSelfTestReport self, + SseSerializer serializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_String(self.providerName, serializer); + sse_encode_list_ccc_algo_test_result(self.results, serializer); + sse_encode_bool(self.allPassed, serializer); + } + + @protected + void sse_encode_i_32(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putInt32(self); + } + + @protected + void sse_encode_list_String(List self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.length, serializer); + for (final item in self) { + sse_encode_String(item, serializer); + } + } + + @protected + void sse_encode_list_ccc_algo_test_result( + List self, + SseSerializer serializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.length, serializer); + for (final item in self) { + sse_encode_ccc_algo_test_result(item, serializer); + } + } + + @protected + void sse_encode_list_ccc_algorithm_entry( + List self, + SseSerializer serializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.length, serializer); + for (final item in self) { + sse_encode_ccc_algorithm_entry(item, serializer); + } + } + + @protected + void sse_encode_list_prim_u_8_loose( + List self, + SseSerializer serializer, + ) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.length, serializer); + serializer.buffer.putUint8List( + self is Uint8List ? self : Uint8List.fromList(self), + ); + } + @protected void sse_encode_list_prim_u_8_strict( Uint8List self, @@ -217,6 +1364,22 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { serializer.buffer.putUint8List(self); } + @protected + void sse_encode_opt_String(String? self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + sse_encode_bool(self != null, serializer); + if (self != null) { + sse_encode_String(self, serializer); + } + } + + @protected + void sse_encode_u_32(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putUint32(self); + } + @protected void sse_encode_u_8(int self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -227,16 +1390,4 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { void sse_encode_unit(void self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs } - - @protected - void sse_encode_i_32(int self, SseSerializer serializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - serializer.buffer.putInt32(self); - } - - @protected - void sse_encode_bool(bool self, SseSerializer serializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - serializer.buffer.putUint8(self ? 1 : 0); - } } diff --git a/lib/src/rust/frb_generated.io.dart b/lib/src/rust/frb_generated.io.dart index d797351..0812904 100644 --- a/lib/src/rust/frb_generated.io.dart +++ b/lib/src/rust/frb_generated.io.dart @@ -3,6 +3,8 @@ // ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field +import 'api/crypto.dart'; +import 'api/dto.dart'; import 'api/simple.dart'; import 'dart:async'; import 'dart:convert'; @@ -21,9 +23,72 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected String dco_decode_String(dynamic raw); + @protected + bool dco_decode_bool(dynamic raw); + + @protected + CccAeadAlgorithm dco_decode_ccc_aead_algorithm(dynamic raw); + + @protected + CccAlgoTestResult dco_decode_ccc_algo_test_result(dynamic raw); + + @protected + CccAlgorithmCapability dco_decode_ccc_algorithm_capability(dynamic raw); + + @protected + CccAlgorithmEntry dco_decode_ccc_algorithm_entry(dynamic raw); + + @protected + CccCapabilities dco_decode_ccc_capabilities(dynamic raw); + + @protected + CccCryptoError dco_decode_ccc_crypto_error(dynamic raw); + + @protected + CccHashAlgorithm dco_decode_ccc_hash_algorithm(dynamic raw); + + @protected + CccKdfAlgorithm dco_decode_ccc_kdf_algorithm(dynamic raw); + + @protected + CccKemAlgorithm dco_decode_ccc_kem_algorithm(dynamic raw); + + @protected + CccKemEncapResult dco_decode_ccc_kem_encap_result(dynamic raw); + + @protected + CccKemKeyPair dco_decode_ccc_kem_key_pair(dynamic raw); + + @protected + CccMacAlgorithm dco_decode_ccc_mac_algorithm(dynamic raw); + + @protected + CccSelfTestReport dco_decode_ccc_self_test_report(dynamic raw); + + @protected + int dco_decode_i_32(dynamic raw); + + @protected + List dco_decode_list_String(dynamic raw); + + @protected + List dco_decode_list_ccc_algo_test_result(dynamic raw); + + @protected + List dco_decode_list_ccc_algorithm_entry(dynamic raw); + + @protected + List dco_decode_list_prim_u_8_loose(dynamic raw); + @protected Uint8List dco_decode_list_prim_u_8_strict(dynamic raw); + @protected + String? dco_decode_opt_String(dynamic raw); + + @protected + int dco_decode_u_32(dynamic raw); + @protected int dco_decode_u_8(dynamic raw); @@ -33,41 +98,214 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected String sse_decode_String(SseDeserializer deserializer); + @protected + bool sse_decode_bool(SseDeserializer deserializer); + + @protected + CccAeadAlgorithm sse_decode_ccc_aead_algorithm(SseDeserializer deserializer); + + @protected + CccAlgoTestResult sse_decode_ccc_algo_test_result( + SseDeserializer deserializer, + ); + + @protected + CccAlgorithmCapability sse_decode_ccc_algorithm_capability( + SseDeserializer deserializer, + ); + + @protected + CccAlgorithmEntry sse_decode_ccc_algorithm_entry( + SseDeserializer deserializer, + ); + + @protected + CccCapabilities sse_decode_ccc_capabilities(SseDeserializer deserializer); + + @protected + CccCryptoError sse_decode_ccc_crypto_error(SseDeserializer deserializer); + + @protected + CccHashAlgorithm sse_decode_ccc_hash_algorithm(SseDeserializer deserializer); + + @protected + CccKdfAlgorithm sse_decode_ccc_kdf_algorithm(SseDeserializer deserializer); + + @protected + CccKemAlgorithm sse_decode_ccc_kem_algorithm(SseDeserializer deserializer); + + @protected + CccKemEncapResult sse_decode_ccc_kem_encap_result( + SseDeserializer deserializer, + ); + + @protected + CccKemKeyPair sse_decode_ccc_kem_key_pair(SseDeserializer deserializer); + + @protected + CccMacAlgorithm sse_decode_ccc_mac_algorithm(SseDeserializer deserializer); + + @protected + CccSelfTestReport sse_decode_ccc_self_test_report( + SseDeserializer deserializer, + ); + + @protected + int sse_decode_i_32(SseDeserializer deserializer); + + @protected + List sse_decode_list_String(SseDeserializer deserializer); + + @protected + List sse_decode_list_ccc_algo_test_result( + SseDeserializer deserializer, + ); + + @protected + List sse_decode_list_ccc_algorithm_entry( + SseDeserializer deserializer, + ); + + @protected + List sse_decode_list_prim_u_8_loose(SseDeserializer deserializer); + @protected Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer); + @protected + String? sse_decode_opt_String(SseDeserializer deserializer); + + @protected + int sse_decode_u_32(SseDeserializer deserializer); + @protected int sse_decode_u_8(SseDeserializer deserializer); @protected void sse_decode_unit(SseDeserializer deserializer); - @protected - int sse_decode_i_32(SseDeserializer deserializer); - - @protected - bool sse_decode_bool(SseDeserializer deserializer); - @protected void sse_encode_String(String self, SseSerializer serializer); + @protected + void sse_encode_bool(bool self, SseSerializer serializer); + + @protected + void sse_encode_ccc_aead_algorithm( + CccAeadAlgorithm self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_algo_test_result( + CccAlgoTestResult self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_algorithm_capability( + CccAlgorithmCapability self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_algorithm_entry( + CccAlgorithmEntry self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_capabilities( + CccCapabilities self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_crypto_error( + CccCryptoError self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_hash_algorithm( + CccHashAlgorithm self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_kdf_algorithm( + CccKdfAlgorithm self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_kem_algorithm( + CccKemAlgorithm self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_kem_encap_result( + CccKemEncapResult self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_kem_key_pair( + CccKemKeyPair self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_mac_algorithm( + CccMacAlgorithm self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_self_test_report( + CccSelfTestReport self, + SseSerializer serializer, + ); + + @protected + void sse_encode_i_32(int self, SseSerializer serializer); + + @protected + void sse_encode_list_String(List self, SseSerializer serializer); + + @protected + void sse_encode_list_ccc_algo_test_result( + List self, + SseSerializer serializer, + ); + + @protected + void sse_encode_list_ccc_algorithm_entry( + List self, + SseSerializer serializer, + ); + + @protected + void sse_encode_list_prim_u_8_loose(List self, SseSerializer serializer); + @protected void sse_encode_list_prim_u_8_strict( Uint8List self, SseSerializer serializer, ); + @protected + void sse_encode_opt_String(String? self, SseSerializer serializer); + + @protected + void sse_encode_u_32(int self, SseSerializer serializer); + @protected void sse_encode_u_8(int self, SseSerializer serializer); @protected void sse_encode_unit(void self, SseSerializer serializer); - - @protected - void sse_encode_i_32(int self, SseSerializer serializer); - - @protected - void sse_encode_bool(bool self, SseSerializer serializer); } // Section: wire_class diff --git a/lib/src/rust/frb_generated.web.dart b/lib/src/rust/frb_generated.web.dart index 431eaa9..feaa7ff 100644 --- a/lib/src/rust/frb_generated.web.dart +++ b/lib/src/rust/frb_generated.web.dart @@ -6,6 +6,8 @@ // Static analysis wrongly picks the IO variant, thus ignore this // ignore_for_file: argument_type_not_assignable +import 'api/crypto.dart'; +import 'api/dto.dart'; import 'api/simple.dart'; import 'dart:async'; import 'dart:convert'; @@ -23,9 +25,72 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected String dco_decode_String(dynamic raw); + @protected + bool dco_decode_bool(dynamic raw); + + @protected + CccAeadAlgorithm dco_decode_ccc_aead_algorithm(dynamic raw); + + @protected + CccAlgoTestResult dco_decode_ccc_algo_test_result(dynamic raw); + + @protected + CccAlgorithmCapability dco_decode_ccc_algorithm_capability(dynamic raw); + + @protected + CccAlgorithmEntry dco_decode_ccc_algorithm_entry(dynamic raw); + + @protected + CccCapabilities dco_decode_ccc_capabilities(dynamic raw); + + @protected + CccCryptoError dco_decode_ccc_crypto_error(dynamic raw); + + @protected + CccHashAlgorithm dco_decode_ccc_hash_algorithm(dynamic raw); + + @protected + CccKdfAlgorithm dco_decode_ccc_kdf_algorithm(dynamic raw); + + @protected + CccKemAlgorithm dco_decode_ccc_kem_algorithm(dynamic raw); + + @protected + CccKemEncapResult dco_decode_ccc_kem_encap_result(dynamic raw); + + @protected + CccKemKeyPair dco_decode_ccc_kem_key_pair(dynamic raw); + + @protected + CccMacAlgorithm dco_decode_ccc_mac_algorithm(dynamic raw); + + @protected + CccSelfTestReport dco_decode_ccc_self_test_report(dynamic raw); + + @protected + int dco_decode_i_32(dynamic raw); + + @protected + List dco_decode_list_String(dynamic raw); + + @protected + List dco_decode_list_ccc_algo_test_result(dynamic raw); + + @protected + List dco_decode_list_ccc_algorithm_entry(dynamic raw); + + @protected + List dco_decode_list_prim_u_8_loose(dynamic raw); + @protected Uint8List dco_decode_list_prim_u_8_strict(dynamic raw); + @protected + String? dco_decode_opt_String(dynamic raw); + + @protected + int dco_decode_u_32(dynamic raw); + @protected int dco_decode_u_8(dynamic raw); @@ -35,41 +100,214 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected String sse_decode_String(SseDeserializer deserializer); + @protected + bool sse_decode_bool(SseDeserializer deserializer); + + @protected + CccAeadAlgorithm sse_decode_ccc_aead_algorithm(SseDeserializer deserializer); + + @protected + CccAlgoTestResult sse_decode_ccc_algo_test_result( + SseDeserializer deserializer, + ); + + @protected + CccAlgorithmCapability sse_decode_ccc_algorithm_capability( + SseDeserializer deserializer, + ); + + @protected + CccAlgorithmEntry sse_decode_ccc_algorithm_entry( + SseDeserializer deserializer, + ); + + @protected + CccCapabilities sse_decode_ccc_capabilities(SseDeserializer deserializer); + + @protected + CccCryptoError sse_decode_ccc_crypto_error(SseDeserializer deserializer); + + @protected + CccHashAlgorithm sse_decode_ccc_hash_algorithm(SseDeserializer deserializer); + + @protected + CccKdfAlgorithm sse_decode_ccc_kdf_algorithm(SseDeserializer deserializer); + + @protected + CccKemAlgorithm sse_decode_ccc_kem_algorithm(SseDeserializer deserializer); + + @protected + CccKemEncapResult sse_decode_ccc_kem_encap_result( + SseDeserializer deserializer, + ); + + @protected + CccKemKeyPair sse_decode_ccc_kem_key_pair(SseDeserializer deserializer); + + @protected + CccMacAlgorithm sse_decode_ccc_mac_algorithm(SseDeserializer deserializer); + + @protected + CccSelfTestReport sse_decode_ccc_self_test_report( + SseDeserializer deserializer, + ); + + @protected + int sse_decode_i_32(SseDeserializer deserializer); + + @protected + List sse_decode_list_String(SseDeserializer deserializer); + + @protected + List sse_decode_list_ccc_algo_test_result( + SseDeserializer deserializer, + ); + + @protected + List sse_decode_list_ccc_algorithm_entry( + SseDeserializer deserializer, + ); + + @protected + List sse_decode_list_prim_u_8_loose(SseDeserializer deserializer); + @protected Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer); + @protected + String? sse_decode_opt_String(SseDeserializer deserializer); + + @protected + int sse_decode_u_32(SseDeserializer deserializer); + @protected int sse_decode_u_8(SseDeserializer deserializer); @protected void sse_decode_unit(SseDeserializer deserializer); - @protected - int sse_decode_i_32(SseDeserializer deserializer); - - @protected - bool sse_decode_bool(SseDeserializer deserializer); - @protected void sse_encode_String(String self, SseSerializer serializer); + @protected + void sse_encode_bool(bool self, SseSerializer serializer); + + @protected + void sse_encode_ccc_aead_algorithm( + CccAeadAlgorithm self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_algo_test_result( + CccAlgoTestResult self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_algorithm_capability( + CccAlgorithmCapability self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_algorithm_entry( + CccAlgorithmEntry self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_capabilities( + CccCapabilities self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_crypto_error( + CccCryptoError self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_hash_algorithm( + CccHashAlgorithm self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_kdf_algorithm( + CccKdfAlgorithm self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_kem_algorithm( + CccKemAlgorithm self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_kem_encap_result( + CccKemEncapResult self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_kem_key_pair( + CccKemKeyPair self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_mac_algorithm( + CccMacAlgorithm self, + SseSerializer serializer, + ); + + @protected + void sse_encode_ccc_self_test_report( + CccSelfTestReport self, + SseSerializer serializer, + ); + + @protected + void sse_encode_i_32(int self, SseSerializer serializer); + + @protected + void sse_encode_list_String(List self, SseSerializer serializer); + + @protected + void sse_encode_list_ccc_algo_test_result( + List self, + SseSerializer serializer, + ); + + @protected + void sse_encode_list_ccc_algorithm_entry( + List self, + SseSerializer serializer, + ); + + @protected + void sse_encode_list_prim_u_8_loose(List self, SseSerializer serializer); + @protected void sse_encode_list_prim_u_8_strict( Uint8List self, SseSerializer serializer, ); + @protected + void sse_encode_opt_String(String? self, SseSerializer serializer); + + @protected + void sse_encode_u_32(int self, SseSerializer serializer); + @protected void sse_encode_u_8(int self, SseSerializer serializer); @protected void sse_encode_unit(void self, SseSerializer serializer); - - @protected - void sse_encode_i_32(int self, SseSerializer serializer); - - @protected - void sse_encode_bool(bool self, SseSerializer serializer); } // Section: wire_class diff --git a/rust/src/api/crypto.rs b/rust/src/api/crypto.rs new file mode 100644 index 0000000..b99e677 --- /dev/null +++ b/rust/src/api/crypto.rs @@ -0,0 +1,185 @@ +// Bridge API — thin wrappers that delegate to ccc_rust providers. +// +// No cryptographic logic here; only type conversions and registry lookups. + +use ccc_crypto_core::{KemProvider, ProviderRegistry}; +use ccc_crypto_wolfssl::WolfSslProvider; + +use crate::api::dto::*; + +// ── Helpers ────────────────────────────────────────────────────────────────── + +/// Default provider name used when the caller doesn't specify one. +const DEFAULT_PROVIDER: &str = "wolfssl"; + +/// Get the default provider from the registry or return an error. +fn default_provider( +) -> Result, CccCryptoError> { + ProviderRegistry::global() + .get(DEFAULT_PROVIDER) + .ok_or_else(|| { + CccCryptoError::InternalError(format!( + "provider '{DEFAULT_PROVIDER}' not registered — call ccc_init() first" + )) + }) +} + +/// A lazily-initialised KemProvider instance. +/// +/// `KemProvider` is not part of the `CryptoProvider` supertrait, so we keep +/// a standalone `WolfSslProvider` for KEM operations. +fn kem_provider() -> &'static WolfSslProvider { + use std::sync::OnceLock; + static KEM: OnceLock = OnceLock::new(); + KEM.get_or_init(WolfSslProvider::new) +} + +// ── Init ───────────────────────────────────────────────────────────────────── + +/// Initialise the CCC cryptographic subsystem. +/// +/// Registers the wolfSSL provider in the global registry. +/// Safe to call multiple times (idempotent). +pub fn ccc_init() { + flutter_rust_bridge::setup_default_user_utils(); + if !ProviderRegistry::global().contains(DEFAULT_PROVIDER) { + ccc_crypto_wolfssl::init(); + } +} + +// ── Provider info ──────────────────────────────────────────────────────────── + +/// List all registered provider names. +#[flutter_rust_bridge::frb(sync)] +pub fn ccc_list_providers() -> Vec { + ProviderRegistry::global().list() +} + +/// Return the capabilities of the default provider. +pub fn ccc_capabilities() -> Result { + let provider = default_provider()?; + Ok(CccCapabilities::from(provider.capabilities())) +} + +// ── AEAD ───────────────────────────────────────────────────────────────────── + +/// Encrypt with an AEAD algorithm. +/// +/// Returns ciphertext‖tag. +pub fn ccc_aead_encrypt( + algorithm: CccAeadAlgorithm, + key: Vec, + nonce: Vec, + plaintext: Vec, + aad: Vec, +) -> Result, CccCryptoError> { + let provider = default_provider()?; + Ok(provider.encrypt_aead(algorithm.to_core(), &key, &nonce, &plaintext, &aad)?) +} + +/// Decrypt with an AEAD algorithm. +/// +/// Expects ciphertext‖tag as `ciphertext`. +pub fn ccc_aead_decrypt( + algorithm: CccAeadAlgorithm, + key: Vec, + nonce: Vec, + ciphertext: Vec, + aad: Vec, +) -> Result, CccCryptoError> { + let provider = default_provider()?; + Ok(provider.decrypt_aead(algorithm.to_core(), &key, &nonce, &ciphertext, &aad)?) +} + +// ── KDF ────────────────────────────────────────────────────────────────────── + +/// Derive key material using a KDF. +pub fn ccc_kdf_derive( + algorithm: CccKdfAlgorithm, + ikm: Vec, + salt: Vec, + info: Vec, + length: u32, +) -> Result, CccCryptoError> { + let provider = default_provider()?; + let derived = provider.derive_key( + algorithm.to_core(), + &ikm, + &salt, + &info, + length as usize, + )?; + // Move out of Zeroizing wrapper — FRB will copy to Dart. + Ok(derived.to_vec()) +} + +// ── MAC ────────────────────────────────────────────────────────────────────── + +/// Compute a MAC tag. +pub fn ccc_mac_compute( + algorithm: CccMacAlgorithm, + key: Vec, + data: Vec, +) -> Result, CccCryptoError> { + let provider = default_provider()?; + Ok(provider.compute_mac(algorithm.to_core(), &key, &data)?) +} + +/// Verify a MAC tag. Returns `true` if valid. +pub fn ccc_mac_verify( + algorithm: CccMacAlgorithm, + key: Vec, + data: Vec, + mac: Vec, +) -> Result { + let provider = default_provider()?; + Ok(provider.verify_mac(algorithm.to_core(), &key, &data, &mac)?) +} + +// ── Hash ───────────────────────────────────────────────────────────────────── + +/// Compute a cryptographic hash. +pub fn ccc_hash( + algorithm: CccHashAlgorithm, + data: Vec, +) -> Result, CccCryptoError> { + let provider = default_provider()?; + Ok(provider.hash(algorithm.to_core(), &data)?) +} + +// ── KEM ────────────────────────────────────────────────────────────────────── + +/// Generate a KEM key pair. +pub fn ccc_kem_generate_keypair( + algorithm: CccKemAlgorithm, +) -> Result { + let kp = kem_provider().generate_keypair(algorithm.to_core())?; + Ok(CccKemKeyPair::from(kp)) +} + +/// KEM encapsulation — produce ciphertext + shared secret from a public key. +pub fn ccc_kem_encapsulate( + algorithm: CccKemAlgorithm, + public_key: Vec, +) -> Result { + let result = kem_provider().encapsulate(algorithm.to_core(), &public_key)?; + Ok(CccKemEncapResult::from(result)) +} + +/// KEM decapsulation — recover shared secret from ciphertext + private key. +pub fn ccc_kem_decapsulate( + algorithm: CccKemAlgorithm, + private_key: Vec, + ciphertext: Vec, +) -> Result, CccCryptoError> { + let ss = kem_provider().decapsulate(algorithm.to_core(), &private_key, &ciphertext)?; + Ok(ss.to_vec()) +} + +// ── Self-test ──────────────────────────────────────────────────────────────── + +/// Run the provider self-test and return a structured report. +pub fn ccc_self_test() -> Result { + let provider = default_provider()?; + Ok(CccSelfTestReport::from(provider.self_test())) +} diff --git a/rust/src/api/dto.rs b/rust/src/api/dto.rs new file mode 100644 index 0000000..7f300f2 --- /dev/null +++ b/rust/src/api/dto.rs @@ -0,0 +1,328 @@ +// Bridge-visible DTOs — no crypto logic, only type conversions. +// +// flutter_rust_bridge codegen picks up all pub types under crate::api +// and generates corresponding Dart classes. + +use ccc_crypto_core::{ + AeadAlgorithm, AlgoTestResult, AlgorithmCapability, HashAlgorithm, KdfAlgorithm, + KemAlgorithm, KemEncapResult, KemKeyPair, MacAlgorithm, ProviderCapabilities, SelfTestReport, +}; + +// ── Algorithm ID enums (mirror Rust repr(u32) values) ──────────────────────── + +/// AEAD algorithm identifiers — values match `ccc_rust` `#[repr(u32)]`. +#[flutter_rust_bridge::frb(dart_metadata=("freezed"))] +pub enum CccAeadAlgorithm { + AesGcm256 = 12, + ChaCha20Poly1305 = 13, + XChaCha20Poly1305 = 14, + Ascon128a = 15, +} + +/// KDF algorithm identifiers. +#[flutter_rust_bridge::frb(dart_metadata=("freezed"))] +pub enum CccKdfAlgorithm { + Sha256 = 1, + Sha384 = 2, + Sha512 = 3, + Blake2b512 = 4, + Argon2id = 5, + Kmac256 = 6, +} + +/// MAC algorithm identifiers. +#[flutter_rust_bridge::frb(dart_metadata=("freezed"))] +pub enum CccMacAlgorithm { + HmacSha256 = 30, + HmacSha384 = 31, + HmacSha512 = 32, + Blake2bMac = 33, + Poly1305 = 35, +} + +/// Hash algorithm identifiers. +#[flutter_rust_bridge::frb(dart_metadata=("freezed"))] +pub enum CccHashAlgorithm { + Sha256 = 40, + Sha384 = 41, + Sha512 = 42, + Blake2b512 = 43, + Sha3_256 = 44, + Sha3_512 = 45, +} + +/// KEM algorithm identifiers. +#[flutter_rust_bridge::frb(dart_metadata=("freezed"))] +pub enum CccKemAlgorithm { + X25519 = 50, + X448 = 51, + MlKem768 = 52, + MlKem1024 = 53, + ClassicMcEliece460896 = 54, +} + +// ── Enum conversions ───────────────────────────────────────────────────────── + +impl CccAeadAlgorithm { + pub(crate) fn to_core(&self) -> AeadAlgorithm { + match self { + Self::AesGcm256 => AeadAlgorithm::AesGcm256, + Self::ChaCha20Poly1305 => AeadAlgorithm::ChaCha20Poly1305, + Self::XChaCha20Poly1305 => AeadAlgorithm::XChaCha20Poly1305, + Self::Ascon128a => AeadAlgorithm::Ascon128a, + } + } +} + +impl CccKdfAlgorithm { + pub(crate) fn to_core(&self) -> KdfAlgorithm { + match self { + Self::Sha256 => KdfAlgorithm::Sha256, + Self::Sha384 => KdfAlgorithm::Sha384, + Self::Sha512 => KdfAlgorithm::Sha512, + Self::Blake2b512 => KdfAlgorithm::Blake2b512, + Self::Argon2id => KdfAlgorithm::Argon2id, + Self::Kmac256 => KdfAlgorithm::Kmac256, + } + } +} + +impl CccMacAlgorithm { + pub(crate) fn to_core(&self) -> MacAlgorithm { + match self { + Self::HmacSha256 => MacAlgorithm::HmacSha256, + Self::HmacSha384 => MacAlgorithm::HmacSha384, + Self::HmacSha512 => MacAlgorithm::HmacSha512, + Self::Blake2bMac => MacAlgorithm::Blake2bMac, + Self::Poly1305 => MacAlgorithm::Poly1305, + } + } +} + +impl CccHashAlgorithm { + pub(crate) fn to_core(&self) -> HashAlgorithm { + match self { + Self::Sha256 => HashAlgorithm::Sha256, + Self::Sha384 => HashAlgorithm::Sha384, + Self::Sha512 => HashAlgorithm::Sha512, + Self::Blake2b512 => HashAlgorithm::Blake2b512, + Self::Sha3_256 => HashAlgorithm::Sha3_256, + Self::Sha3_512 => HashAlgorithm::Sha3_512, + } + } +} + +impl CccKemAlgorithm { + pub(crate) fn to_core(&self) -> KemAlgorithm { + match self { + Self::X25519 => KemAlgorithm::X25519, + Self::X448 => KemAlgorithm::X448, + Self::MlKem768 => KemAlgorithm::MlKem768, + Self::MlKem1024 => KemAlgorithm::MlKem1024, + Self::ClassicMcEliece460896 => KemAlgorithm::ClassicMcEliece460896, + } + } +} + +// ── DTO structs ────────────────────────────────────────────────────────────── + +/// Per-algorithm availability and quality scores. +pub struct CccAlgorithmCapability { + pub available: bool, + pub deterministic_io: bool, + pub efficiency_score: u8, + pub reliability_score: u8, +} + +impl From<&AlgorithmCapability> for CccAlgorithmCapability { + fn from(cap: &AlgorithmCapability) -> Self { + Self { + available: cap.available, + deterministic_io: cap.deterministic_io, + efficiency_score: cap.efficiency_score, + reliability_score: cap.reliability_score, + } + } +} + +/// An algorithm entry in the capabilities list. +pub struct CccAlgorithmEntry { + pub algo_id: u32, + pub algo_name: String, + pub capability: CccAlgorithmCapability, +} + +/// Provider capabilities — flattened from HashMap to Vec for FRB. +pub struct CccCapabilities { + pub provider_name: String, + pub aead: Vec, + pub kdf: Vec, + pub mac: Vec, + pub hash: Vec, + pub kem: Vec, +} + +impl From for CccCapabilities { + fn from(caps: ProviderCapabilities) -> Self { + Self { + provider_name: caps.provider_name, + aead: caps + .aead + .iter() + .map(|(algo, cap)| CccAlgorithmEntry { + algo_id: *algo as u32, + algo_name: algo.name().to_string(), + capability: CccAlgorithmCapability::from(cap), + }) + .collect(), + kdf: caps + .kdf + .iter() + .map(|(algo, cap)| CccAlgorithmEntry { + algo_id: *algo as u32, + algo_name: algo.name().to_string(), + capability: CccAlgorithmCapability::from(cap), + }) + .collect(), + mac: caps + .mac + .iter() + .map(|(algo, cap)| CccAlgorithmEntry { + algo_id: *algo as u32, + algo_name: algo.name().to_string(), + capability: CccAlgorithmCapability::from(cap), + }) + .collect(), + hash: caps + .hash + .iter() + .map(|(algo, cap)| CccAlgorithmEntry { + algo_id: *algo as u32, + algo_name: algo.name().to_string(), + capability: CccAlgorithmCapability::from(cap), + }) + .collect(), + kem: caps + .kem + .iter() + .map(|(algo, cap)| CccAlgorithmEntry { + algo_id: *algo as u32, + algo_name: algo.name().to_string(), + capability: CccAlgorithmCapability::from(cap), + }) + .collect(), + } + } +} + +/// KEM key pair — public + private key bytes. +pub struct CccKemKeyPair { + pub public_key: Vec, + pub private_key: Vec, +} + +impl From for CccKemKeyPair { + fn from(kp: KemKeyPair) -> Self { + Self { + public_key: kp.public_key.clone(), + private_key: kp.private_key.clone(), + } + } +} + +/// KEM encapsulation result — ciphertext + shared secret. +pub struct CccKemEncapResult { + pub ciphertext: Vec, + pub shared_secret: Vec, +} + +impl From for CccKemEncapResult { + fn from(er: KemEncapResult) -> Self { + Self { + ciphertext: er.ciphertext.clone(), + shared_secret: er.shared_secret.clone(), + } + } +} + +/// Per-algorithm self-test result. +pub struct CccAlgoTestResult { + pub algo_id: u32, + pub algo_name: String, + pub passed: bool, + pub error_message: Option, +} + +impl From<&AlgoTestResult> for CccAlgoTestResult { + fn from(r: &AlgoTestResult) -> Self { + Self { + algo_id: r.algo_id, + algo_name: r.algo_name.clone(), + passed: r.passed, + error_message: r.error_message.clone(), + } + } +} + +/// Aggregate self-test report. +pub struct CccSelfTestReport { + pub provider_name: String, + pub results: Vec, + pub all_passed: bool, +} + +impl From for CccSelfTestReport { + fn from(report: SelfTestReport) -> Self { + Self { + provider_name: report.provider_name, + results: report.results.iter().map(CccAlgoTestResult::from).collect(), + all_passed: report.all_passed, + } + } +} + +// ── Bridge error ───────────────────────────────────────────────────────────── + +/// Bridge-visible error type — maps 1:1 from `ccc_rust::CryptoError`. +/// +/// FRB translates this into a Dart exception. +#[derive(Debug)] +pub enum CccCryptoError { + UnsupportedAlgorithm(String), + InvalidKey(String), + InvalidNonce(String), + AuthenticationFailed, + InvalidInput(String), + FeatureNotCompiled(String), + InternalError(String), +} + +impl std::fmt::Display for CccCryptoError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::UnsupportedAlgorithm(s) => write!(f, "unsupported algorithm: {s}"), + Self::InvalidKey(s) => write!(f, "invalid key: {s}"), + Self::InvalidNonce(s) => write!(f, "invalid nonce: {s}"), + Self::AuthenticationFailed => write!(f, "authentication failed"), + Self::InvalidInput(s) => write!(f, "invalid input: {s}"), + Self::FeatureNotCompiled(s) => write!(f, "feature not compiled: {s}"), + Self::InternalError(s) => write!(f, "internal error: {s}"), + } + } +} + +impl std::error::Error for CccCryptoError {} + +impl From for CccCryptoError { + fn from(e: ccc_crypto_core::CryptoError) -> Self { + match e { + ccc_crypto_core::CryptoError::UnsupportedAlgorithm(s) => Self::UnsupportedAlgorithm(s), + ccc_crypto_core::CryptoError::InvalidKey(s) => Self::InvalidKey(s), + ccc_crypto_core::CryptoError::InvalidNonce(s) => Self::InvalidNonce(s), + ccc_crypto_core::CryptoError::AuthenticationFailed => Self::AuthenticationFailed, + ccc_crypto_core::CryptoError::InvalidInput(s) => Self::InvalidInput(s), + ccc_crypto_core::CryptoError::FeatureNotCompiled(s) => Self::FeatureNotCompiled(s), + ccc_crypto_core::CryptoError::InternalError(s) => Self::InternalError(s), + } + } +} diff --git a/rust/src/api/mod.rs b/rust/src/api/mod.rs index b252f36..6d5cd6f 100644 --- a/rust/src/api/mod.rs +++ b/rust/src/api/mod.rs @@ -1 +1,3 @@ +pub mod crypto; +pub mod dto; pub mod simple; diff --git a/rust/src/frb_generated.rs b/rust/src/frb_generated.rs index 4f41c47..0f80f0f 100644 --- a/rust/src/frb_generated.rs +++ b/rust/src/frb_generated.rs @@ -37,7 +37,7 @@ flutter_rust_bridge::frb_generated_boilerplate!( default_rust_auto_opaque = RustAutoOpaqueMoi, ); pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.11.1"; -pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -1918914929; +pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -138461235; // Section: executor @@ -45,6 +45,480 @@ flutter_rust_bridge::frb_generated_default_handler!(); // Section: wire_funcs +fn wire__crate__api__crypto__ccc_aead_decrypt_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "ccc_aead_decrypt", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_algorithm = ::sse_decode(&mut deserializer); + let api_key = >::sse_decode(&mut deserializer); + let api_nonce = >::sse_decode(&mut deserializer); + let api_ciphertext = >::sse_decode(&mut deserializer); + let api_aad = >::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, crate::api::dto::CccCryptoError>((move || { + let output_ok = crate::api::crypto::ccc_aead_decrypt( + api_algorithm, + api_key, + api_nonce, + api_ciphertext, + api_aad, + )?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__crypto__ccc_aead_encrypt_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "ccc_aead_encrypt", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_algorithm = ::sse_decode(&mut deserializer); + let api_key = >::sse_decode(&mut deserializer); + let api_nonce = >::sse_decode(&mut deserializer); + let api_plaintext = >::sse_decode(&mut deserializer); + let api_aad = >::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, crate::api::dto::CccCryptoError>((move || { + let output_ok = crate::api::crypto::ccc_aead_encrypt( + api_algorithm, + api_key, + api_nonce, + api_plaintext, + api_aad, + )?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__crypto__ccc_capabilities_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "ccc_capabilities", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + deserializer.end(); + move |context| { + transform_result_sse::<_, crate::api::dto::CccCryptoError>((move || { + let output_ok = crate::api::crypto::ccc_capabilities()?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__crypto__ccc_hash_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "ccc_hash", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_algorithm = ::sse_decode(&mut deserializer); + let api_data = >::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, crate::api::dto::CccCryptoError>((move || { + let output_ok = crate::api::crypto::ccc_hash(api_algorithm, api_data)?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__crypto__ccc_init_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "ccc_init", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + deserializer.end(); + move |context| { + transform_result_sse::<_, ()>((move || { + let output_ok = Result::<_, ()>::Ok({ + crate::api::crypto::ccc_init(); + })?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__crypto__ccc_kdf_derive_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "ccc_kdf_derive", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_algorithm = ::sse_decode(&mut deserializer); + let api_ikm = >::sse_decode(&mut deserializer); + let api_salt = >::sse_decode(&mut deserializer); + let api_info = >::sse_decode(&mut deserializer); + let api_length = ::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, crate::api::dto::CccCryptoError>((move || { + let output_ok = crate::api::crypto::ccc_kdf_derive( + api_algorithm, + api_ikm, + api_salt, + api_info, + api_length, + )?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__crypto__ccc_kem_decapsulate_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "ccc_kem_decapsulate", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_algorithm = ::sse_decode(&mut deserializer); + let api_private_key = >::sse_decode(&mut deserializer); + let api_ciphertext = >::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, crate::api::dto::CccCryptoError>((move || { + let output_ok = crate::api::crypto::ccc_kem_decapsulate( + api_algorithm, + api_private_key, + api_ciphertext, + )?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__crypto__ccc_kem_encapsulate_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "ccc_kem_encapsulate", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_algorithm = ::sse_decode(&mut deserializer); + let api_public_key = >::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, crate::api::dto::CccCryptoError>((move || { + let output_ok = + crate::api::crypto::ccc_kem_encapsulate(api_algorithm, api_public_key)?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__crypto__ccc_kem_generate_keypair_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "ccc_kem_generate_keypair", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_algorithm = ::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, crate::api::dto::CccCryptoError>((move || { + let output_ok = crate::api::crypto::ccc_kem_generate_keypair(api_algorithm)?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__crypto__ccc_list_providers_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "ccc_list_providers", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let output_ok = Result::<_, ()>::Ok(crate::api::crypto::ccc_list_providers())?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__crypto__ccc_mac_compute_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "ccc_mac_compute", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_algorithm = ::sse_decode(&mut deserializer); + let api_key = >::sse_decode(&mut deserializer); + let api_data = >::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, crate::api::dto::CccCryptoError>((move || { + let output_ok = + crate::api::crypto::ccc_mac_compute(api_algorithm, api_key, api_data)?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__crypto__ccc_mac_verify_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "ccc_mac_verify", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_algorithm = ::sse_decode(&mut deserializer); + let api_key = >::sse_decode(&mut deserializer); + let api_data = >::sse_decode(&mut deserializer); + let api_mac = >::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, crate::api::dto::CccCryptoError>((move || { + let output_ok = crate::api::crypto::ccc_mac_verify( + api_algorithm, + api_key, + api_data, + api_mac, + )?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__crypto__ccc_self_test_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "ccc_self_test", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + deserializer.end(); + move |context| { + transform_result_sse::<_, crate::api::dto::CccCryptoError>((move || { + let output_ok = crate::api::crypto::ccc_self_test()?; + Ok(output_ok) + })()) + } + }, + ) +} fn wire__crate__api__simple__greet_impl( ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, rust_vec_len_: i32, @@ -120,6 +594,280 @@ impl SseDecode for String { } } +impl SseDecode for bool { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_u8().unwrap() != 0 + } +} + +impl SseDecode for crate::api::dto::CccAeadAlgorithm { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return match inner { + 0 => crate::api::dto::CccAeadAlgorithm::AesGcm256, + 1 => crate::api::dto::CccAeadAlgorithm::ChaCha20Poly1305, + 2 => crate::api::dto::CccAeadAlgorithm::XChaCha20Poly1305, + 3 => crate::api::dto::CccAeadAlgorithm::Ascon128a, + _ => unreachable!("Invalid variant for CccAeadAlgorithm: {}", inner), + }; + } +} + +impl SseDecode for crate::api::dto::CccAlgoTestResult { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_algoId = ::sse_decode(deserializer); + let mut var_algoName = ::sse_decode(deserializer); + let mut var_passed = ::sse_decode(deserializer); + let mut var_errorMessage = >::sse_decode(deserializer); + return crate::api::dto::CccAlgoTestResult { + algo_id: var_algoId, + algo_name: var_algoName, + passed: var_passed, + error_message: var_errorMessage, + }; + } +} + +impl SseDecode for crate::api::dto::CccAlgorithmCapability { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_available = ::sse_decode(deserializer); + let mut var_deterministicIo = ::sse_decode(deserializer); + let mut var_efficiencyScore = ::sse_decode(deserializer); + let mut var_reliabilityScore = ::sse_decode(deserializer); + return crate::api::dto::CccAlgorithmCapability { + available: var_available, + deterministic_io: var_deterministicIo, + efficiency_score: var_efficiencyScore, + reliability_score: var_reliabilityScore, + }; + } +} + +impl SseDecode for crate::api::dto::CccAlgorithmEntry { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_algoId = ::sse_decode(deserializer); + let mut var_algoName = ::sse_decode(deserializer); + let mut var_capability = + ::sse_decode(deserializer); + return crate::api::dto::CccAlgorithmEntry { + algo_id: var_algoId, + algo_name: var_algoName, + capability: var_capability, + }; + } +} + +impl SseDecode for crate::api::dto::CccCapabilities { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_providerName = ::sse_decode(deserializer); + let mut var_aead = >::sse_decode(deserializer); + let mut var_kdf = >::sse_decode(deserializer); + let mut var_mac = >::sse_decode(deserializer); + let mut var_hash = >::sse_decode(deserializer); + let mut var_kem = >::sse_decode(deserializer); + return crate::api::dto::CccCapabilities { + provider_name: var_providerName, + aead: var_aead, + kdf: var_kdf, + mac: var_mac, + hash: var_hash, + kem: var_kem, + }; + } +} + +impl SseDecode for crate::api::dto::CccCryptoError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut tag_ = ::sse_decode(deserializer); + match tag_ { + 0 => { + let mut var_field0 = ::sse_decode(deserializer); + return crate::api::dto::CccCryptoError::UnsupportedAlgorithm(var_field0); + } + 1 => { + let mut var_field0 = ::sse_decode(deserializer); + return crate::api::dto::CccCryptoError::InvalidKey(var_field0); + } + 2 => { + let mut var_field0 = ::sse_decode(deserializer); + return crate::api::dto::CccCryptoError::InvalidNonce(var_field0); + } + 3 => { + return crate::api::dto::CccCryptoError::AuthenticationFailed; + } + 4 => { + let mut var_field0 = ::sse_decode(deserializer); + return crate::api::dto::CccCryptoError::InvalidInput(var_field0); + } + 5 => { + let mut var_field0 = ::sse_decode(deserializer); + return crate::api::dto::CccCryptoError::FeatureNotCompiled(var_field0); + } + 6 => { + let mut var_field0 = ::sse_decode(deserializer); + return crate::api::dto::CccCryptoError::InternalError(var_field0); + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseDecode for crate::api::dto::CccHashAlgorithm { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return match inner { + 0 => crate::api::dto::CccHashAlgorithm::Sha256, + 1 => crate::api::dto::CccHashAlgorithm::Sha384, + 2 => crate::api::dto::CccHashAlgorithm::Sha512, + 3 => crate::api::dto::CccHashAlgorithm::Blake2b512, + 4 => crate::api::dto::CccHashAlgorithm::Sha3_256, + 5 => crate::api::dto::CccHashAlgorithm::Sha3_512, + _ => unreachable!("Invalid variant for CccHashAlgorithm: {}", inner), + }; + } +} + +impl SseDecode for crate::api::dto::CccKdfAlgorithm { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return match inner { + 0 => crate::api::dto::CccKdfAlgorithm::Sha256, + 1 => crate::api::dto::CccKdfAlgorithm::Sha384, + 2 => crate::api::dto::CccKdfAlgorithm::Sha512, + 3 => crate::api::dto::CccKdfAlgorithm::Blake2b512, + 4 => crate::api::dto::CccKdfAlgorithm::Argon2id, + 5 => crate::api::dto::CccKdfAlgorithm::Kmac256, + _ => unreachable!("Invalid variant for CccKdfAlgorithm: {}", inner), + }; + } +} + +impl SseDecode for crate::api::dto::CccKemAlgorithm { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return match inner { + 0 => crate::api::dto::CccKemAlgorithm::X25519, + 1 => crate::api::dto::CccKemAlgorithm::X448, + 2 => crate::api::dto::CccKemAlgorithm::MlKem768, + 3 => crate::api::dto::CccKemAlgorithm::MlKem1024, + 4 => crate::api::dto::CccKemAlgorithm::ClassicMcEliece460896, + _ => unreachable!("Invalid variant for CccKemAlgorithm: {}", inner), + }; + } +} + +impl SseDecode for crate::api::dto::CccKemEncapResult { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_ciphertext = >::sse_decode(deserializer); + let mut var_sharedSecret = >::sse_decode(deserializer); + return crate::api::dto::CccKemEncapResult { + ciphertext: var_ciphertext, + shared_secret: var_sharedSecret, + }; + } +} + +impl SseDecode for crate::api::dto::CccKemKeyPair { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_publicKey = >::sse_decode(deserializer); + let mut var_privateKey = >::sse_decode(deserializer); + return crate::api::dto::CccKemKeyPair { + public_key: var_publicKey, + private_key: var_privateKey, + }; + } +} + +impl SseDecode for crate::api::dto::CccMacAlgorithm { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return match inner { + 0 => crate::api::dto::CccMacAlgorithm::HmacSha256, + 1 => crate::api::dto::CccMacAlgorithm::HmacSha384, + 2 => crate::api::dto::CccMacAlgorithm::HmacSha512, + 3 => crate::api::dto::CccMacAlgorithm::Blake2bMac, + 4 => crate::api::dto::CccMacAlgorithm::Poly1305, + _ => unreachable!("Invalid variant for CccMacAlgorithm: {}", inner), + }; + } +} + +impl SseDecode for crate::api::dto::CccSelfTestReport { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_providerName = ::sse_decode(deserializer); + let mut var_results = >::sse_decode(deserializer); + let mut var_allPassed = ::sse_decode(deserializer); + return crate::api::dto::CccSelfTestReport { + provider_name: var_providerName, + results: var_results, + all_passed: var_allPassed, + }; + } +} + +impl SseDecode for i32 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_i32::().unwrap() + } +} + +impl SseDecode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut len_ = ::sse_decode(deserializer); + let mut ans_ = vec![]; + for idx_ in 0..len_ { + ans_.push(::sse_decode(deserializer)); + } + return ans_; + } +} + +impl SseDecode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut len_ = ::sse_decode(deserializer); + let mut ans_ = vec![]; + for idx_ in 0..len_ { + ans_.push(::sse_decode( + deserializer, + )); + } + return ans_; + } +} + +impl SseDecode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut len_ = ::sse_decode(deserializer); + let mut ans_ = vec![]; + for idx_ in 0..len_ { + ans_.push(::sse_decode( + deserializer, + )); + } + return ans_; + } +} + impl SseDecode for Vec { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { @@ -132,6 +880,24 @@ impl SseDecode for Vec { } } +impl SseDecode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + if (::sse_decode(deserializer)) { + return Some(::sse_decode(deserializer)); + } else { + return None; + } + } +} + +impl SseDecode for u32 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_u32::().unwrap() + } +} + impl SseDecode for u8 { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { @@ -144,20 +910,6 @@ impl SseDecode for () { fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {} } -impl SseDecode for i32 { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { - deserializer.cursor.read_i32::().unwrap() - } -} - -impl SseDecode for bool { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { - deserializer.cursor.read_u8().unwrap() != 0 - } -} - fn pde_ffi_dispatcher_primary_impl( func_id: i32, port: flutter_rust_bridge::for_generated::MessagePort, @@ -167,7 +919,24 @@ fn pde_ffi_dispatcher_primary_impl( ) { // Codec=Pde (Serialization + dispatch), see doc to use other codecs match func_id { - 2 => wire__crate__api__simple__init_app_impl(port, ptr, rust_vec_len, data_len), + 1 => wire__crate__api__crypto__ccc_aead_decrypt_impl(port, ptr, rust_vec_len, data_len), + 2 => wire__crate__api__crypto__ccc_aead_encrypt_impl(port, ptr, rust_vec_len, data_len), + 3 => wire__crate__api__crypto__ccc_capabilities_impl(port, ptr, rust_vec_len, data_len), + 4 => wire__crate__api__crypto__ccc_hash_impl(port, ptr, rust_vec_len, data_len), + 5 => wire__crate__api__crypto__ccc_init_impl(port, ptr, rust_vec_len, data_len), + 6 => wire__crate__api__crypto__ccc_kdf_derive_impl(port, ptr, rust_vec_len, data_len), + 7 => wire__crate__api__crypto__ccc_kem_decapsulate_impl(port, ptr, rust_vec_len, data_len), + 8 => wire__crate__api__crypto__ccc_kem_encapsulate_impl(port, ptr, rust_vec_len, data_len), + 9 => wire__crate__api__crypto__ccc_kem_generate_keypair_impl( + port, + ptr, + rust_vec_len, + data_len, + ), + 11 => wire__crate__api__crypto__ccc_mac_compute_impl(port, ptr, rust_vec_len, data_len), + 12 => wire__crate__api__crypto__ccc_mac_verify_impl(port, ptr, rust_vec_len, data_len), + 13 => wire__crate__api__crypto__ccc_self_test_impl(port, ptr, rust_vec_len, data_len), + 15 => wire__crate__api__simple__init_app_impl(port, ptr, rust_vec_len, data_len), _ => unreachable!(), } } @@ -180,13 +949,333 @@ fn pde_ffi_dispatcher_sync_impl( ) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { // Codec=Pde (Serialization + dispatch), see doc to use other codecs match func_id { - 1 => wire__crate__api__simple__greet_impl(ptr, rust_vec_len, data_len), + 10 => wire__crate__api__crypto__ccc_list_providers_impl(ptr, rust_vec_len, data_len), + 14 => wire__crate__api__simple__greet_impl(ptr, rust_vec_len, data_len), _ => unreachable!(), } } // Section: rust2dart +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::dto::CccAeadAlgorithm { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + Self::AesGcm256 => 0.into_dart(), + Self::ChaCha20Poly1305 => 1.into_dart(), + Self::XChaCha20Poly1305 => 2.into_dart(), + Self::Ascon128a => 3.into_dart(), + _ => unreachable!(), + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::dto::CccAeadAlgorithm +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::dto::CccAeadAlgorithm +{ + fn into_into_dart(self) -> crate::api::dto::CccAeadAlgorithm { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::dto::CccAlgoTestResult { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.algo_id.into_into_dart().into_dart(), + self.algo_name.into_into_dart().into_dart(), + self.passed.into_into_dart().into_dart(), + self.error_message.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::dto::CccAlgoTestResult +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::dto::CccAlgoTestResult +{ + fn into_into_dart(self) -> crate::api::dto::CccAlgoTestResult { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::dto::CccAlgorithmCapability { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.available.into_into_dart().into_dart(), + self.deterministic_io.into_into_dart().into_dart(), + self.efficiency_score.into_into_dart().into_dart(), + self.reliability_score.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::dto::CccAlgorithmCapability +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::dto::CccAlgorithmCapability +{ + fn into_into_dart(self) -> crate::api::dto::CccAlgorithmCapability { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::dto::CccAlgorithmEntry { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.algo_id.into_into_dart().into_dart(), + self.algo_name.into_into_dart().into_dart(), + self.capability.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::dto::CccAlgorithmEntry +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::dto::CccAlgorithmEntry +{ + fn into_into_dart(self) -> crate::api::dto::CccAlgorithmEntry { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::dto::CccCapabilities { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.provider_name.into_into_dart().into_dart(), + self.aead.into_into_dart().into_dart(), + self.kdf.into_into_dart().into_dart(), + self.mac.into_into_dart().into_dart(), + self.hash.into_into_dart().into_dart(), + self.kem.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::dto::CccCapabilities +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::dto::CccCapabilities +{ + fn into_into_dart(self) -> crate::api::dto::CccCapabilities { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::dto::CccCryptoError { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + crate::api::dto::CccCryptoError::UnsupportedAlgorithm(field0) => { + [0.into_dart(), field0.into_into_dart().into_dart()].into_dart() + } + crate::api::dto::CccCryptoError::InvalidKey(field0) => { + [1.into_dart(), field0.into_into_dart().into_dart()].into_dart() + } + crate::api::dto::CccCryptoError::InvalidNonce(field0) => { + [2.into_dart(), field0.into_into_dart().into_dart()].into_dart() + } + crate::api::dto::CccCryptoError::AuthenticationFailed => [3.into_dart()].into_dart(), + crate::api::dto::CccCryptoError::InvalidInput(field0) => { + [4.into_dart(), field0.into_into_dart().into_dart()].into_dart() + } + crate::api::dto::CccCryptoError::FeatureNotCompiled(field0) => { + [5.into_dart(), field0.into_into_dart().into_dart()].into_dart() + } + crate::api::dto::CccCryptoError::InternalError(field0) => { + [6.into_dart(), field0.into_into_dart().into_dart()].into_dart() + } + _ => { + unimplemented!(""); + } + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::dto::CccCryptoError +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::dto::CccCryptoError +{ + fn into_into_dart(self) -> crate::api::dto::CccCryptoError { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::dto::CccHashAlgorithm { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + Self::Sha256 => 0.into_dart(), + Self::Sha384 => 1.into_dart(), + Self::Sha512 => 2.into_dart(), + Self::Blake2b512 => 3.into_dart(), + Self::Sha3_256 => 4.into_dart(), + Self::Sha3_512 => 5.into_dart(), + _ => unreachable!(), + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::dto::CccHashAlgorithm +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::dto::CccHashAlgorithm +{ + fn into_into_dart(self) -> crate::api::dto::CccHashAlgorithm { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::dto::CccKdfAlgorithm { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + Self::Sha256 => 0.into_dart(), + Self::Sha384 => 1.into_dart(), + Self::Sha512 => 2.into_dart(), + Self::Blake2b512 => 3.into_dart(), + Self::Argon2id => 4.into_dart(), + Self::Kmac256 => 5.into_dart(), + _ => unreachable!(), + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::dto::CccKdfAlgorithm +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::dto::CccKdfAlgorithm +{ + fn into_into_dart(self) -> crate::api::dto::CccKdfAlgorithm { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::dto::CccKemAlgorithm { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + Self::X25519 => 0.into_dart(), + Self::X448 => 1.into_dart(), + Self::MlKem768 => 2.into_dart(), + Self::MlKem1024 => 3.into_dart(), + Self::ClassicMcEliece460896 => 4.into_dart(), + _ => unreachable!(), + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::dto::CccKemAlgorithm +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::dto::CccKemAlgorithm +{ + fn into_into_dart(self) -> crate::api::dto::CccKemAlgorithm { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::dto::CccKemEncapResult { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.ciphertext.into_into_dart().into_dart(), + self.shared_secret.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::dto::CccKemEncapResult +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::dto::CccKemEncapResult +{ + fn into_into_dart(self) -> crate::api::dto::CccKemEncapResult { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::dto::CccKemKeyPair { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.public_key.into_into_dart().into_dart(), + self.private_key.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::dto::CccKemKeyPair +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::dto::CccKemKeyPair +{ + fn into_into_dart(self) -> crate::api::dto::CccKemKeyPair { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::dto::CccMacAlgorithm { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + Self::HmacSha256 => 0.into_dart(), + Self::HmacSha384 => 1.into_dart(), + Self::HmacSha512 => 2.into_dart(), + Self::Blake2bMac => 3.into_dart(), + Self::Poly1305 => 4.into_dart(), + _ => unreachable!(), + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::dto::CccMacAlgorithm +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::dto::CccMacAlgorithm +{ + fn into_into_dart(self) -> crate::api::dto::CccMacAlgorithm { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::dto::CccSelfTestReport { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.provider_name.into_into_dart().into_dart(), + self.results.into_into_dart().into_dart(), + self.all_passed.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::dto::CccSelfTestReport +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::dto::CccSelfTestReport +{ + fn into_into_dart(self) -> crate::api::dto::CccSelfTestReport { + self + } +} + impl SseEncode for String { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -194,6 +1283,250 @@ impl SseEncode for String { } } +impl SseEncode for bool { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_u8(self as _).unwrap(); + } +} + +impl SseEncode for crate::api::dto::CccAeadAlgorithm { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode( + match self { + crate::api::dto::CccAeadAlgorithm::AesGcm256 => 0, + crate::api::dto::CccAeadAlgorithm::ChaCha20Poly1305 => 1, + crate::api::dto::CccAeadAlgorithm::XChaCha20Poly1305 => 2, + crate::api::dto::CccAeadAlgorithm::Ascon128a => 3, + _ => { + unimplemented!(""); + } + }, + serializer, + ); + } +} + +impl SseEncode for crate::api::dto::CccAlgoTestResult { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.algo_id, serializer); + ::sse_encode(self.algo_name, serializer); + ::sse_encode(self.passed, serializer); + >::sse_encode(self.error_message, serializer); + } +} + +impl SseEncode for crate::api::dto::CccAlgorithmCapability { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.available, serializer); + ::sse_encode(self.deterministic_io, serializer); + ::sse_encode(self.efficiency_score, serializer); + ::sse_encode(self.reliability_score, serializer); + } +} + +impl SseEncode for crate::api::dto::CccAlgorithmEntry { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.algo_id, serializer); + ::sse_encode(self.algo_name, serializer); + ::sse_encode(self.capability, serializer); + } +} + +impl SseEncode for crate::api::dto::CccCapabilities { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.provider_name, serializer); + >::sse_encode(self.aead, serializer); + >::sse_encode(self.kdf, serializer); + >::sse_encode(self.mac, serializer); + >::sse_encode(self.hash, serializer); + >::sse_encode(self.kem, serializer); + } +} + +impl SseEncode for crate::api::dto::CccCryptoError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + match self { + crate::api::dto::CccCryptoError::UnsupportedAlgorithm(field0) => { + ::sse_encode(0, serializer); + ::sse_encode(field0, serializer); + } + crate::api::dto::CccCryptoError::InvalidKey(field0) => { + ::sse_encode(1, serializer); + ::sse_encode(field0, serializer); + } + crate::api::dto::CccCryptoError::InvalidNonce(field0) => { + ::sse_encode(2, serializer); + ::sse_encode(field0, serializer); + } + crate::api::dto::CccCryptoError::AuthenticationFailed => { + ::sse_encode(3, serializer); + } + crate::api::dto::CccCryptoError::InvalidInput(field0) => { + ::sse_encode(4, serializer); + ::sse_encode(field0, serializer); + } + crate::api::dto::CccCryptoError::FeatureNotCompiled(field0) => { + ::sse_encode(5, serializer); + ::sse_encode(field0, serializer); + } + crate::api::dto::CccCryptoError::InternalError(field0) => { + ::sse_encode(6, serializer); + ::sse_encode(field0, serializer); + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseEncode for crate::api::dto::CccHashAlgorithm { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode( + match self { + crate::api::dto::CccHashAlgorithm::Sha256 => 0, + crate::api::dto::CccHashAlgorithm::Sha384 => 1, + crate::api::dto::CccHashAlgorithm::Sha512 => 2, + crate::api::dto::CccHashAlgorithm::Blake2b512 => 3, + crate::api::dto::CccHashAlgorithm::Sha3_256 => 4, + crate::api::dto::CccHashAlgorithm::Sha3_512 => 5, + _ => { + unimplemented!(""); + } + }, + serializer, + ); + } +} + +impl SseEncode for crate::api::dto::CccKdfAlgorithm { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode( + match self { + crate::api::dto::CccKdfAlgorithm::Sha256 => 0, + crate::api::dto::CccKdfAlgorithm::Sha384 => 1, + crate::api::dto::CccKdfAlgorithm::Sha512 => 2, + crate::api::dto::CccKdfAlgorithm::Blake2b512 => 3, + crate::api::dto::CccKdfAlgorithm::Argon2id => 4, + crate::api::dto::CccKdfAlgorithm::Kmac256 => 5, + _ => { + unimplemented!(""); + } + }, + serializer, + ); + } +} + +impl SseEncode for crate::api::dto::CccKemAlgorithm { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode( + match self { + crate::api::dto::CccKemAlgorithm::X25519 => 0, + crate::api::dto::CccKemAlgorithm::X448 => 1, + crate::api::dto::CccKemAlgorithm::MlKem768 => 2, + crate::api::dto::CccKemAlgorithm::MlKem1024 => 3, + crate::api::dto::CccKemAlgorithm::ClassicMcEliece460896 => 4, + _ => { + unimplemented!(""); + } + }, + serializer, + ); + } +} + +impl SseEncode for crate::api::dto::CccKemEncapResult { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + >::sse_encode(self.ciphertext, serializer); + >::sse_encode(self.shared_secret, serializer); + } +} + +impl SseEncode for crate::api::dto::CccKemKeyPair { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + >::sse_encode(self.public_key, serializer); + >::sse_encode(self.private_key, serializer); + } +} + +impl SseEncode for crate::api::dto::CccMacAlgorithm { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode( + match self { + crate::api::dto::CccMacAlgorithm::HmacSha256 => 0, + crate::api::dto::CccMacAlgorithm::HmacSha384 => 1, + crate::api::dto::CccMacAlgorithm::HmacSha512 => 2, + crate::api::dto::CccMacAlgorithm::Blake2bMac => 3, + crate::api::dto::CccMacAlgorithm::Poly1305 => 4, + _ => { + unimplemented!(""); + } + }, + serializer, + ); + } +} + +impl SseEncode for crate::api::dto::CccSelfTestReport { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.provider_name, serializer); + >::sse_encode(self.results, serializer); + ::sse_encode(self.all_passed, serializer); + } +} + +impl SseEncode for i32 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_i32::(self).unwrap(); + } +} + +impl SseEncode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.len() as _, serializer); + for item in self { + ::sse_encode(item, serializer); + } + } +} + +impl SseEncode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.len() as _, serializer); + for item in self { + ::sse_encode(item, serializer); + } + } +} + +impl SseEncode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.len() as _, serializer); + for item in self { + ::sse_encode(item, serializer); + } + } +} + impl SseEncode for Vec { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -204,6 +1537,23 @@ impl SseEncode for Vec { } } +impl SseEncode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.is_some(), serializer); + if let Some(value) = self { + ::sse_encode(value, serializer); + } + } +} + +impl SseEncode for u32 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_u32::(self).unwrap(); + } +} + impl SseEncode for u8 { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -216,20 +1566,6 @@ impl SseEncode for () { fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {} } -impl SseEncode for i32 { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - serializer.cursor.write_i32::(self).unwrap(); - } -} - -impl SseEncode for bool { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - serializer.cursor.write_u8(self as _).unwrap(); - } -} - #[cfg(not(target_family = "wasm"))] mod io { // This file is automatically generated, so please do not edit it.