OpenSSL class

A classe principal que representa uma instância da biblioteca OpenSSL. Agrega funcionalidade através de Mixins.

Inheritance
Mixed-in types

Constructors

OpenSSL({String? cryptoPath, String? sslPath})
Carrega a biblioteca OpenSSL.

Properties

bindings → OpenSslFfi
Acesso aos bindings brutos gerados.
no setteroverride
hashCode → int
The hash code for this object.
no setterinherited
loader → OpenSslBindings
Acesso ao loader/configuração (opcional, se precisarmos de caminhos).
no setteroverride
opensslVersionMajor → int
OpenSSL version (major).
no setter
opensslVersionMinor → int
OpenSSL version (minor).
no setter
opensslVersionPatch → int
OpenSSL version (patch).
no setter
opensslVersionString → String
OpenSSL version string (major.minor.patch).
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

aes128CbcDecrypt({required Uint8List ciphertext, required Uint8List key, required Uint8List iv}) → Uint8List
Decrypts ciphertext using AES-128-CBC with PKCS#7 padding.
inherited
aes128CbcEncrypt({required Uint8List data, required Uint8List key, required Uint8List iv}) → Uint8List
Encrypts data using AES-128-CBC with PKCS#7 padding.
inherited
aes128GcmDecrypt({required Uint8List ciphertext, required Uint8List key, required Uint8List iv, required Uint8List tag, Uint8List? aad}) → Uint8List
Decrypts ciphertext using AES-128-GCM.
inherited
aes128GcmEncrypt({required Uint8List data, required Uint8List key, required Uint8List iv, Uint8List? aad}) → Map<String, Uint8List>
Encrypts data using AES-128-GCM.
inherited
aes256CbcDecrypt({required Uint8List ciphertext, required Uint8List key, required Uint8List iv}) → Uint8List
Decrypts ciphertext using AES-256-CBC with PKCS#7 padding.
inherited
aes256CbcEncrypt({required Uint8List data, required Uint8List key, required Uint8List iv}) → Uint8List
Encrypts data using AES-256-CBC with PKCS#7 padding.
inherited
aes256GcmDecrypt({required Uint8List ciphertext, required Uint8List key, required Uint8List iv, required Uint8List tag, Uint8List? aad}) → Uint8List
Decrypts ciphertext using AES-256-GCM. Throws OpenSslException if authentication fails (Tag mismatch).
inherited
aes256GcmEncrypt({required Uint8List data, required Uint8List key, required Uint8List iv, Uint8List? aad}) → Map<String, Uint8List>
Encrypts data using AES-256-GCM.
inherited
aesCbcPkcs7Decrypt({required Uint8List ciphertext, required Uint8List key, required Uint8List iv}) → Uint8List
Convenience helper that decrypts using AES-CBC with PKCS#7 padding.
inherited
aesCbcPkcs7Encrypt({required Uint8List data, required Uint8List key, required Uint8List iv}) → Uint8List
Convenience helper that encrypts using AES-CBC with PKCS#7 padding.
inherited
asn1IntegerFromHex(String hex) → Pointer<ASN1_INTEGER>
Converts hexadecimal string to ASN1_INTEGER through BIGNUM.
inherited
asn1IntegerToDecimal(Pointer<ASN1_INTEGER> value) → String
Converts ASN1_INTEGER to decimal string via BIGNUM.
inherited
asn1IntegerToHex(Pointer<ASN1_INTEGER> value) → String
Converts ASN1_INTEGER to hexadecimal string via BIGNUM.
inherited
bioToString(Pointer<BIO> bio) → String
Lê todo o conteúdo de um BIO para String.
inherited
buildOcspRequest({required X509Certificate certificate, required X509Certificate issuerCertificate, String hashAlgorithm = 'SHA1', int? nonceLength}) → Uint8List
Builds a DER-encoded OCSP request for certificate/issuerCertificate.
inherited
buildOcspResponse({required Uint8List requestDer, required Map<String, OcspStatusInfo> statusBySerial, required X509Certificate responderCertificate, required EvpPkey responderKey, List<X509Certificate>? extraCertificates, String hashAlgorithm = 'SHA256', DateTime? defaultThisUpdate, DateTime? defaultNextUpdate, bool includeNonce = true, OcspNoncePolicy? noncePolicy, bool responderIdByKey = false}) → Uint8List
Builds a DER-encoded OCSP response for the given request.
inherited
certMatchesIssuer({Uint8List? childAki, Uint8List? issuerSki, Uint8List? issuerSerialBytes, String? issuerNameHash}) → bool
Pre-filter for issuer candidates based on AKI/SKI + serial/name hints.
inherited
chacha20Decrypt({required Uint8List ciphertext, required Uint8List key, required Uint8List iv}) → Uint8List
Decrypts ciphertext using ChaCha20 (stream cipher).
inherited
chacha20Encrypt({required Uint8List data, required Uint8List key, required Uint8List iv}) → Uint8List
Encrypts data using ChaCha20 (stream cipher).
inherited
chacha20Poly1305Decrypt({required Uint8List ciphertext, required Uint8List key, required Uint8List iv, required Uint8List tag, Uint8List? aad}) → Uint8List
Decrypts ciphertext using ChaCha20-Poly1305 (AEAD).
inherited
chacha20Poly1305Encrypt({required Uint8List data, required Uint8List key, required Uint8List iv, Uint8List? aad}) → Map<String, Uint8List>
Encrypts data using ChaCha20-Poly1305 (AEAD).
inherited
computeSharedSecret(EvpPkey privateKey, EvpPkey peerPublicKey) → Uint8List
Computes shared secret (ECDH) between privateKey and peerPublicKey.
inherited
convertCertificateDerToPem(Uint8List der) → String
Converts a DER certificate into PEM string.
inherited
convertCertificatePemToDer(String pem) → Uint8List
Converts a PEM certificate into DER bytes.
inherited
convertPemChainToDerList(String pemChain) → List<Uint8List>
Converts a PEM chain string into a list of DER-encoded certificates.
inherited
createBio() → Pointer<BIO>
Cria um BIO vazio (Writable).
inherited
createBioFromString(String text) → Pointer<BIO>
Cria um BIO a partir de uma String.
inherited
createCertificate() → X509Certificate
Creates a new empty X509 Certificate structure. Useful for building new certificates.
inherited
createCrossCertificate({required X509Certificate subjectCert, required EvpPkey subjectKeyPair, required X509Certificate issuerCert, required EvpPkey issuerKeyPair, int? serialNumber, BigInt? serialNumberBigInt, int notBeforeOffset = 0, int notAfterOffset = _defaultCaValiditySeconds, int? pathLen, bool basicConstraintsCritical = true, bool keyUsageKeyCertSign = true, bool keyUsageCrlSign = true, bool keyUsageCritical = true, String hashAlgorithm = 'SHA256'}) → Uint8List
Creates a cross certificate for CA rollover.
inherited
createPkcs12({required EvpPkey privateKey, required X509Certificate certificate, List<X509Certificate> caCertificates = const [], String? password, String? friendlyName, int iterations = 2048, int macIterations = 2048}) → Uint8List
Creates a PKCS#12/PFX bundle (DER) with key + certificate (+ optional chain).
inherited
createRolloverCrossCertificates({required X509Certificate oldCaCert, required EvpPkey oldCaKey, required X509Certificate newCaCert, required EvpPkey newCaKey, BigInt? oldSignedByNewSerial, BigInt? newSignedByOldSerial, int notBeforeOffset = 0, int notAfterOffset = _defaultCaValiditySeconds, int? pathLen, bool basicConstraintsCritical = true, bool keyUsageKeyCertSign = true, bool keyUsageCrlSign = true, bool keyUsageCritical = true, String hashAlgorithm = 'SHA256'}) → RolloverChain
Creates the pair of cross certificates used during CA rollover.
inherited
createUserCertificate({required EvpPkey keyPair, required EvpPkey issuerKeyPair, required String subjectDn, required String issuerDn, int? serialNumber, BigInt? serialNumberBigInt, int notBeforeOffset = 0, int notAfterOffset = 31536000, bool isCa = false, int? pathLen, bool basicConstraintsCritical = true, bool keyUsageDigitalSignature = true, bool keyUsageNonRepudiation = false, bool keyUsageKeyEncipherment = true, bool keyUsageDataEncipherment = false, bool keyUsageKeyAgreement = false, bool keyUsageKeyCertSign = false, bool keyUsageCrlSign = false, bool keyUsageEncipherOnly = false, bool keyUsageDecipherOnly = false, bool keyUsageCritical = true, List<String> extendedKeyUsageOids = const [], String hashAlgorithm = 'SHA256'}) → Uint8List
Creates a user certificate and returns DER bytes.
inherited
decodeCms(Uint8List der) → CmsContent
Decodes a DER CMS/PKCS#7 into a managed CmsContent wrapper.
inherited
digest(String algorithmName, Uint8List data) → Uint8List
Calcula o hash (digest) dos dados usando o algoritmo especificado.
inherited
encodeAsn1Integer(Pointer<ASN1_INTEGER> integer) → Uint8List
Encode an ASN1_INTEGER to DER.
inherited
encodeCertificateDer(X509Certificate cert) → Uint8List
Encodes an X509 Certificate to DER bytes.
inherited
encodeCertificatePem(X509Certificate cert) → String
Encodes an X509 Certificate to PEM string.
inherited
encodeCms(CmsContent cms) → Uint8List
Encodes a CMS/PKCS#7 structure to DER.
inherited
encodeX509(X509Certificate cert) → Uint8List
Encode an X509 certificate to DER.
inherited
encodeX509Name(Pointer<X509_NAME> name) → Uint8List
Encode an X509_NAME to DER.
inherited
extractAkiSki(Pointer<X509> cert) → ({Uint8List? aki, String issuerNameHash, Uint8List serialBytes, Uint8List? ski})
Parses AKI/SKI + issuer matching material from certificate.
inherited
extractIssuerAndSerialDer(Uint8List certificateDer) → ({Uint8List issuerDer, Uint8List serialDer})
Extract issuer name (DER) and serial number (DER) from a certificate DER.
inherited
fingerprintSha256(Uint8List data) → String
SHA-256 fingerprint in lowercase hexadecimal.
inherited
freeBio(Pointer<BIO> bio) → void
Libera um BIO.
inherited
generateEc(String curveName) → EvpPkey
Gera um par de chaves EC (Elliptic Curve).
inherited
generateEd25519() → EvpPkey
Generates an Ed25519 key pair.
inherited
generateEd448() → EvpPkey
Generates an Ed448 key pair.
inherited
generateKeyByName(String algorithmName, {Map<String, String>? utf8Params}) → EvpPkey
Generates a key pair by algorithm name supported by OpenSSL providers.
inherited
generateMlDsa44() → EvpPkey
Generates an ML-DSA-44 key pair (if supported by the loaded OpenSSL).
inherited
generateMlDsa65() → EvpPkey
Generates an ML-DSA-65 key pair (if supported by the loaded OpenSSL).
inherited
generateMlDsa87() → EvpPkey
Generates an ML-DSA-87 key pair (if supported by the loaded OpenSSL).
inherited
generateRsa(int bits) → EvpPkey
Gera um par de chaves RSA.
inherited
generateSerialNumberBigInt({int bytes = 16}) → BigInt
Generates a cryptographically strong random serial number.
inherited
generateX25519() → EvpPkey
Generates an X25519 key pair.
inherited
generateX448() → EvpPkey
Generates an X448 key pair.
inherited
getCachedCrl(String key) → Uint8List?
Optional CRL cache with TTL to avoid mass re-fetch.
inherited
getCachedOcsp(String key) → Uint8List?
Optional OCSP cache with TTL to avoid mass re-fetch.
inherited
getOrCreateParsedX509(Uint8List der) → Pointer<X509>
Returns cached parsed certificate pointer keyed by DER fingerprint.
inherited
getOrCreateStore(String storeKey, List<Uint8List> rootsDer) → X509Store
Returns a cached X509_STORE for a truststore fingerprint key.
inherited
hmac(String algorithmName, Uint8List key, Uint8List data) → Uint8List
Calcula o HMAC dos dados usando o algoritmo e chave especificados.
inherited
issuerSerialKey({required Uint8List issuerSerialBytes, required String issuerNameHash}) → String
Stable key for maps/indexes keyed by issuer name hash + serial bytes.
inherited
loadCertificateBytes(Uint8List bytes) → X509Certificate
Loads an X509 Certificate from bytes (auto-detect PEM vs DER).
inherited
loadCertificateDer(Uint8List der) → X509Certificate
Loads an X509 Certificate from DER bytes.
inherited
loadCertificatePem(String pem) → X509Certificate
Loads an X509 Certificate from PEM string.
inherited
loadCertificatesFromPemChain(String pemChain) → List<X509Certificate>
Loads a list of certificates from a PEM chain string.
inherited
loadCertificatesFromPkcs7Bytes(Uint8List bytes) → List<X509Certificate>
Extracts certificates from PKCS#7 bytes (auto-detect PEM vs DER).
inherited
loadCertificatesFromPkcs7Der(Uint8List der) → List<X509Certificate>
Extracts certificates from a PKCS#7/CMS DER payload (.p7b).
inherited
loadCertificatesFromPkcs7Pem(String pem) → List<X509Certificate>
Extracts certificates from a PKCS#7/CMS PEM string (.p7b).
inherited
loadCrlBytes(Uint8List bytes) → X509Crl
Loads an X509 CRL from bytes (auto-detect PEM vs DER).
inherited
loadCrlDer(Uint8List der) → X509Crl
Loads an X509 CRL from DER bytes.
inherited
loadCrlPem(String pem) → X509Crl
Loads an X509 CRL from PEM string.
inherited
loadPrivateKeyPem(String pem, {String? password}) → EvpPkey
Carrega uma Chave Privada de PEM, opcionalmente decifrando com password.
inherited
loadPublicKeyPem(String pem) → EvpPkey
Carrega um Chave Pública de PEM.
inherited
lookup<T extends Function>(String name) → Pointer<NativeFunction<T>>
Helper para pegar endereços de funções (para NativeFinalizer).
override
newCertificateBuilder() → X509CertificateBuilder
Creates a new Builder for creating and signing X509 Certificates.
inherited
newCrlBuilder() → X509CrlBuilder
Creates a new Builder for creating and signing X509 CRLs.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parsePkcs12(Uint8List der, {String password = ''}) → Pkcs12Bundle
Parses PKCS#12/PFX (DER) and returns key, certificate and chain.
inherited
pbkdf2({required Uint8List password, required Uint8List salt, int iterations = 10000, int keyLength = 32}) → Uint8List
Deriva uma chave a partir de uma senha usando PBKDF2-HMAC-SHA256.
inherited
pkcs7Pad(Uint8List data, {int blockSize = 16}) → Uint8List
Applies PKCS#7 padding to data for a given blockSize.
inherited
pkcs7Unpad(Uint8List padded, {int blockSize = 16}) → Uint8List
Removes PKCS#7 padding from padded for a given blockSize.
inherited
prefilterIssuerCandidates<T>({required List<T> candidates, required bool matches(T candidate)}) → List<T>
Applies binary pre-filter and falls back to full set on failure/ambiguity.
inherited
putCachedCrl(String key, Uint8List value, {Duration ttl = const Duration(minutes: 15)}) → void
Optional CRL cache with TTL to avoid mass re-fetch.
inherited
putCachedOcsp(String key, Uint8List value, {Duration ttl = const Duration(minutes: 5)}) → void
Optional OCSP cache with TTL to avoid mass re-fetch.
inherited
readOcspResponseStatus({required Uint8List responseDer, required X509Certificate certificate, required X509Certificate issuerCertificate, String hashAlgorithm = 'SHA1', bool requireSuccessfulResponse = true}) → OcspCertificateStatusResult
Reads OCSP response status for certificate/issuerCertificate.
inherited
rijndael128CbcDecrypt({required Uint8List ciphertext, required Uint8List key, required Uint8List iv}) → Uint8List
Rijndael is AES. Alias for AES-128-CBC.
inherited
rijndael128CbcEncrypt({required Uint8List data, required Uint8List key, required Uint8List iv}) → Uint8List
Rijndael is AES. Alias for AES-128-CBC.
inherited
rijndael128GcmDecrypt({required Uint8List ciphertext, required Uint8List key, required Uint8List iv, required Uint8List tag, Uint8List? aad}) → Uint8List
Rijndael is AES. Alias for AES-128-GCM.
inherited
rijndael128GcmEncrypt({required Uint8List data, required Uint8List key, required Uint8List iv, Uint8List? aad}) → Map<String, Uint8List>
Rijndael is AES. Alias for AES-128-GCM.
inherited
rijndael256CbcDecrypt({required Uint8List ciphertext, required Uint8List key, required Uint8List iv}) → Uint8List
Rijndael is AES. Alias for AES-256-CBC.
inherited
rijndael256CbcEncrypt({required Uint8List data, required Uint8List key, required Uint8List iv}) → Uint8List
Rijndael is AES. Alias for AES-256-CBC.
inherited
rijndael256GcmDecrypt({required Uint8List ciphertext, required Uint8List key, required Uint8List iv, required Uint8List tag, Uint8List? aad}) → Uint8List
Rijndael is AES. Alias for AES-256-GCM.
inherited
rijndael256GcmEncrypt({required Uint8List data, required Uint8List key, required Uint8List iv, Uint8List? aad}) → Map<String, Uint8List>
Rijndael is AES. Alias for AES-256-GCM.
inherited
sha256(List<int> data) → Uint8List
Computes SHA-256 digest of data.
inherited
sign(EvpPkey key, Uint8List data, {String algorithm = 'SHA256'}) → Uint8List
Signs data using the private key.
inherited
signDetached({required Uint8List content, required X509Certificate certificate, required EvpPkey privateKey, List<Uint8List> extraCertsDer = const [], String? hashAlgorithm}) → Uint8List
Generates a detached CMS/PKCS#7 signature (DER) for content.
inherited
signDetachedContentInfo({required Uint8List content, required X509Certificate certificate, required EvpPkey privateKey}) → CmsContent
Generates a detached CMS/PKCS#7 signature and returns CmsContent.
inherited
signDetachedDigest({required Uint8List digest, required X509Certificate certificate, required EvpPkey privateKey, List<Uint8List> extraCertsDer = const [], String hashAlgorithm = 'SHA256'}) → Uint8List
Generates a CMS/PKCS#7 signature for a pre-calculated digest. digest must be the SHA-256 hash of the content (32 bytes).
inherited
signMlDsa(EvpPkey key, Uint8List data, {MlDsaSignatureOptions? options}) → Uint8List
High-level ML-DSA one-shot sign helper.
inherited
signOneShot(EvpPkey key, Uint8List data, {String? algorithm, MlDsaSignatureOptions? mlDsaOptions}) → Uint8List
Signs data in one-shot mode (no Update calls).
inherited
splitPemChain(String pemChain) → List<String>
Splits a PEM chain into individual PEM certificate blocks.
inherited
toString() → String
A string representation of this object.
inherited
verify(EvpPkey key, Uint8List data, Uint8List signature, {String algorithm = 'SHA256'}) → bool
Verifies signature for data using key.
inherited
verifyCmsDetached({required Uint8List cmsDer, required Uint8List content, X509Store? store, Uint8List? trustedCertDer}) → bool
Verifies a detached CMS/PKCS#7 signature using the provided content and a trusted store or a specific trustedCertDer.
inherited
verifyCmsDetachedContentInfo({required CmsContent cms, required Uint8List content, X509Store? store, Uint8List? trustedCertDer, bool skipSignerCertVerify = false}) → bool
Verifies a detached CMS signature using a provided CmsContent.
inherited
verifyCmsDetachedFullChain({required CmsContent cms, required Uint8List content, required X509Store store}) → bool
Verifies signature and signer certificate chain using store.
inherited
verifyCmsDetachedSignatureOnly({required CmsContent cms, required Uint8List content}) → bool
Verifies only the signature (skips signer cert chain validation).
inherited
verifyCmsDetachedWithResult({required Uint8List cmsDer, required Uint8List content, X509Store? store, Uint8List? trustedCertDer}) → CmsValidationResult
Verifies a detached CMS/PKCS#7 signature and returns detailed result.
inherited
verifyMlDsa(EvpPkey key, Uint8List data, Uint8List signature, {MlDsaSignatureOptions? options}) → bool
High-level ML-DSA one-shot verify helper.
inherited
verifyOneShot(EvpPkey key, Uint8List data, Uint8List signature, {String? algorithm, MlDsaSignatureOptions? mlDsaOptions}) → bool
Verifies signature for data in one-shot mode (no Update calls).
inherited
x509GetSerialBytes(Pointer<X509> cert) → Uint8List
Reads certificate serial bytes directly from ASN1_INTEGER payload.
inherited
x509GetSerialDecimal(Pointer<X509> cert) → String
Gets certificate serial as decimal string using BIGNUM conversion.
inherited
x509GetSerialHex(Pointer<X509> cert, {bool prefixed = true}) → String
Gets certificate serial as hexadecimal string.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited