CryptoUtils class
Helper class for cryptographic operations
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
addPKCS7Padding(
Uint8List bytes, int blockSizeBytes) → Uint8List -
Adds a PKCS7 / PKCS5 padding to the given
bytesandblockSizeBytes -
ecPrivateKeyFromDerBytes(
Uint8List bytes, {bool pkcs8 = false, ECDomainParameters? parameters}) → ECPrivateKey -
Decode the given
bytesinto an ECPrivateKey. -
ecPrivateKeyFromPem(
String pem) → ECPrivateKey -
Decode a ECPrivateKey from the given
pemString. -
ecPublicKeyFromDerBytes(
Uint8List bytes, {ECDomainParameters? parameters}) → ECPublicKey -
Decode the given
bytesinto an ECPublicKey. -
ecPublicKeyFromPem(
String pem) → ECPublicKey -
Decode a ECPublicKey from the given
pemString. -
ecSign(
ECPrivateKey privateKey, Uint8List dataToSign, {String algorithmName = 'SHA-1/ECDSA'}) → ECSignature -
Signing the given
dataToSignwith the givenprivateKey. -
ecSignatureFromBase64(
String b64) → ECSignature - Converts a base64 DER encoded string to an ECSignature. The der encoded content must follow the following structure.
-
ecSignatureFromDerBytes(
Uint8List data) → ECSignature - Converts the given DER bytes to an ECSignature. The der encoded content must follow the following structure.
-
ecSignatureToBase64(
ECSignature signature) → String -
Convert ECSignature
signatureto DER encoded base64 string. -
ecVerify(
ECPublicKey publicKey, Uint8List signedData, ECSignature signature, {String algorithm = 'SHA-1/ECDSA'}) → bool -
Verifying the given
signedDatawith the givenpublicKeyand the givensignature. Will return true if the givensignaturematches thesignedData. -
ecVerifyBase64(
ECPublicKey publicKey, Uint8List origData, String signature, {String algorithm = 'SHA-1/ECDSA'}) → bool -
Verifying the given
signedDatawith the givenpublicKeyand the givensignaturein base64. Will return true if the givensignaturematches thesignedData. -
encodeEcPrivateKeyToPem(
ECPrivateKey ecPrivateKey) → String -
Enode the given elliptic curve
publicKeyto PEM format. -
encodeEcPublicKeyToPem(
ECPublicKey publicKey) → String -
Enode the given elliptic curve
publicKeyto PEM format. -
encodePrivateEcdsaKeyToPkcs8(
ECPrivateKey privateKey) → String - Encode a private ECDSA key to PKCS8 format
-
encodeRSAPrivateKeyToDERBytes(
RSAPrivateKey rsaPrivateKey) → Uint8List -
Enode the given
rsaPrivateKeyto DER Bytes using the PKCS#8 standard. -
encodeRSAPrivateKeyToPem(
RSAPrivateKey rsaPrivateKey) → String -
Enode the given
rsaPrivateKeyto PEM format using the PKCS#8 standard. -
encodeRSAPrivateKeyToPemPkcs1(
RSAPrivateKey rsaPrivateKey) → String -
Enode the given
rsaPrivateKeyto PEM format using the PKCS#1 standard. -
encodeRSAPublicKeyToDERBytes(
RSAPublicKey publicKey) → Uint8List -
Enode the given
publicKeyto DER bytes using the PKCS#8 standard. -
encodeRSAPublicKeyToPem(
RSAPublicKey publicKey) → String -
Enode the given
publicKeyto PEM format using the PKCS#8 standard. -
encodeRSAPublicKeyToPemPkcs1(
RSAPublicKey rsaPublicKey) → String -
Enode the given
rsaPublicKeyto PEM format using the PKCS#1 standard. -
generateEcKeyPair(
{String curve = 'prime256v1'}) → AsymmetricKeyPair< PublicKey, PrivateKey> - Generates a elliptic curve AsymmetricKeyPair.
-
generateRSAKeyPair(
{int keySize = 2048}) → AsymmetricKeyPair< PublicKey, PrivateKey> -
Generates a RSA AsymmetricKeyPair with the given
keySize. The default value for thekeySizeis 2048 bits. -
getBytesFromPEMString(
String pem, {bool checkHeader = true}) → Uint8List -
Helper function for decoding the base64 in
pem. -
getHash(
Uint8List bytes, {String algorithmName = 'SHA-256'}) → String -
Get a hash for the given
bytesusing the givenalgorithm -
getHashPlain(
Uint8List bytes, {String algorithmName = 'SHA-256'}) → Uint8List -
Get a hash for the given
bytesusing the givenalgorithm -
getMd5ThumbprintFromBytes(
Uint8List bytes) → String -
Get a MD5 Thumbprint for the given
bytes. -
getModulusFromRSAPrivateKeyPem(
String pem) → BigInt -
Returns the modulus of the given
pemthat represents an RSA private key. -
getPrivateKeyType(
String pem) → String -
Returns the private key type of the given
pem -
getSecureRandom(
) → SecureRandom -
Generates a secure
FortunaRandom -
getSha1ThumbprintFromBytes(
Uint8List bytes) → String -
Get a SHA1 Thumbprint for the given
bytes. -
getSha256ThumbprintFromBytes(
Uint8List bytes) → String -
Get a SHA256 Thumbprint for the given
bytes. -
i2osp(
BigInt number, {int? outLen, Endian endian = Endian.big}) → Uint8List - Conversion of integer to bytes according to RFC 3447 at datatracker.ietf.org/doc/html/rfc3447#page-8
-
osp2i(
Iterable< int> bytes, {Endian endian = Endian.big}) → BigInt - Conversion of bytes to integer according to RFC 3447 at datatracker.ietf.org/doc/html/rfc3447#page-8
-
removePKCS7Padding(
Uint8List padded) → Uint8List -
Revomes the PKCS7 / PKCS5 padding from the
paddedbytes -
rsaDecrypt(
String cipherMessage, RSAPrivateKey privateKey) → String -
Decrypt the given
cipherMessageusing the given RSAprivateKey. -
rsaEncrypt(
String message, RSAPublicKey publicKey) → String -
Encrypt the given
messageusing the given RSApublicKey. -
rsaPrivateKeyExponentToBytes(
RSAPrivateKey privateKey) → Uint8List -
Converts the RSAPrivateKey.exponent from the given
privateKeyto a Uint8List. -
rsaPrivateKeyFromDERBytes(
Uint8List bytes) → RSAPrivateKey -
Decode the given
bytesinto an RSAPrivateKey. -
rsaPrivateKeyFromDERBytesPkcs1(
Uint8List bytes) → RSAPrivateKey -
Decode the given
bytesinto an RSAPrivateKey. -
rsaPrivateKeyFromPem(
String pem) → RSAPrivateKey -
Decode a RSAPrivateKey from the given
pemString. -
rsaPrivateKeyFromPemPkcs1(
String pem) → RSAPrivateKey -
Decode a RSAPrivateKey from the given
pemstring formated in the pkcs1 standard. -
rsaPrivateKeyModulusToBytes(
RSAPrivateKey privateKey) → Uint8List -
Converts the RSAPrivateKey.modulus from the given
privateKeyto a Uint8List. -
rsaPssSign(
RSAPrivateKey privateKey, Uint8List dataToSign, Uint8List salt, {String algorithm = 'SHA-256/PSS'}) → Uint8List -
Signing the given
dataToSignwith the givenprivateKeyand the givensalt. -
rsaPssVerify(
RSAPublicKey publicKey, Uint8List signedData, Uint8List signature, int saltLength, {String algorithm = 'SHA-256/PSS'}) → bool -
Verifying the given
signedDatawith the givenpublicKey, the givensignatureand the givensaltLength. Will return true if the givensignaturematches thesignedData. -
rsaPublicKeyExponentToBytes(
RSAPublicKey publicKey) → Uint8List -
Converts the RSAPublicKey.exponent from the given
publicKeyto a Uint8List. -
rsaPublicKeyFromDERBytes(
Uint8List bytes) → RSAPublicKey -
Decode the given
bytesinto an RSAPublicKey. -
rsaPublicKeyFromDERBytesPkcs1(
Uint8List bytes) → RSAPublicKey -
Decode the given
bytesinto an RSAPublicKey. -
rsaPublicKeyFromPem(
String pem) → RSAPublicKey -
Decode a RSAPublicKey from the given
pemString. -
rsaPublicKeyFromPemPkcs1(
String pem) → RSAPublicKey -
Decode a RSAPublicKey from the given
pemstring formated in the pkcs1 standard. -
rsaPublicKeyModulusToBytes(
RSAPublicKey publicKey) → Uint8List -
Converts the RSAPublicKey.modulus from the given
publicKeyto a Uint8List. -
rsaSign(
RSAPrivateKey privateKey, Uint8List dataToSign, {String algorithmName = 'SHA-256/RSA'}) → Uint8List -
Signing the given
dataToSignwith the givenprivateKey. -
rsaVerify(
RSAPublicKey publicKey, Uint8List signedData, Uint8List signature, {String algorithm = 'SHA-256/RSA'}) → bool -
Verifying the given
signedDatawith the givenpublicKeyand the givensignature. Will return true if the givensignaturematches thesignedData.
Constants
- BEGIN_EC_PRIVATE_KEY → const String
- BEGIN_EC_PUBLIC_KEY → const String
- BEGIN_PRIVATE_KEY → const String
- BEGIN_PUBLIC_KEY → const String
- BEGIN_RSA_PRIVATE_KEY → const String
- BEGIN_RSA_PUBLIC_KEY → const String
- END_EC_PRIVATE_KEY → const String
- END_EC_PUBLIC_KEY → const String
- END_PRIVATE_KEY → const String
- END_PUBLIC_KEY → const String
- END_RSA_PRIVATE_KEY → const String
- END_RSA_PUBLIC_KEY → const String