virgil_crypto.card_crypto module

class virgil_crypto.card_crypto.CardCrypto(crypto=<virgil_crypto.crypto.VirgilCrypto object>)[source]

Bases: object

Cards cryptographic operations. Class provides a cryptographic operations for Cards.

property crypto

Gets Virgil Crypto.

Returns

Card Crypto

export_public_key(public_key)[source]

Exports the Public key into material representation.

Parameters

public_key – public key for export.

Returns

Key material representation bytes.

Raises

ValueError – if public key missing or malformed.

generate_sha512(data)[source]

Computes the sha512 hash of specified data.

Parameters

data – data bytes for fingerprint calculation.

Returns

Hash bytes.

Raises

ValueError – if data missed.

generate_signature(data, private_key)[source]

Signs the specified data using Private key.

Parameters
  • data – raw data bytes for signing.

  • private_key – private key for signing.

Returns

Signature bytes.

Raises

ValueError – if data or private key missing or malformed

import_public_key(data)[source]

Imports the Public key from material representation.

Parameters

data – key material representation bytes.

Returns

Imported public key.

Raises

ValueError – if key data missing

verify_signature(signature, data, public_key)[source]

Verifies the specified signature using original data and signer’s public key.

Parameters
  • signature – signature bytes for verification.

  • data – original data bytes for verification.

  • public_key – signer public key for verification.

Returns

True if signature is valid, False otherwise.

Raises

ValueError – if data, signature, public key missing or malformed.