openssl3 3.5.8+4 copy "openssl3: ^3.5.8+4" to clipboard
openssl3: ^3.5.8+4 copied to clipboard

Prebuilt OpenSSL 3.5 LTS libcrypto for Dart and Flutter, bundled as a code asset via build hooks. No OpenSSL, Perl or C toolchain needed at build time.

example/openssl3_example.dart

// Minimal example for package:openssl3. Run with `dart run` (the build hook
// bundles libopenssl3_crypto automatically) or see example/cli in the
// repository for the full smoke test and example/flutter_app for Flutter.
import 'dart:convert';

import 'package:openssl3/evp.dart';
import 'package:openssl3/openssl3.dart' show OpenSSLCapabilities, initNoConfig;

void main() {
  initNoConfig();
  final caps = OpenSSLCapabilities.instance;
  print(caps.versionString); // OpenSSL 3.5.8 ...
  print('ML-KEM-768: ${caps.hasMlKem768}, ML-DSA-65: ${caps.hasMlDsa65}');

  // Authenticated encryption.
  final key = Random.privateBytes(32);
  final nonce = Random.bytes(12);
  final aead = Aead.aes256Gcm(key);
  final box = aead.seal(nonce, utf8.encode('hello'), aad: utf8.encode('v1'));
  print(utf8.decode(aead.open(nonce, box, aad: utf8.encode('v1')))); // hello

  // Post-quantum key encapsulation.
  final kem = MlKem768.keyPair();
  final enc = MlKem768.encaps(kem.publicKey);
  final shared = MlKem768.decaps(kem.seed!, enc.ciphertext);
  print(shared.length); // 32

  // Post-quantum signatures.
  final dsa = MlDsa65.keyPair();
  final sig = MlDsa65.sign(dsa.privateKey, utf8.encode('message'));
  print(MlDsa65.verify(dsa.publicKey, utf8.encode('message'), sig)); // true
}
0
likes
160
points
20
downloads

Documentation

API reference

Publisher

verified publisheratsign.org

Weekly Downloads

Prebuilt OpenSSL 3.5 LTS libcrypto for Dart and Flutter, bundled as a code asset via build hooks. No OpenSSL, Perl or C toolchain needed at build time.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#openssl #cryptography #ffi #native-assets

License

BSD-3-Clause (license)

Dependencies

code_assets, crypto, ffi, hooks, meta, path

More

Packages that depend on openssl3