CryptoUtils Module¶
-
virtualsmartcard.CryptoUtils.
_makesalt
()¶ Return a 48-bit pseudorandom salt for crypt().
This function is not suitable for generating cryptographic secrets.
-
virtualsmartcard.CryptoUtils.
append_padding
(blocklen, data, padding_class=1)¶ Append padding to the data. Length of padding depends on length of data and the block size of the specified encryption algorithm. Different types of padding may be selected via the padding_class parameter
-
virtualsmartcard.CryptoUtils.
calculate_MAC
(session_key, message, iv=b'\x00\x00\x00\x00\x00\x00\x00\x00')¶ Cyberflex MAC is the last Block of the input encrypted with DES3-CBC
-
virtualsmartcard.CryptoUtils.
cipher
(do_encrypt, cipherspec, key, data, iv=None)¶ Do a cryptographic operation. operation = do_encrypt ? encrypt : decrypt, cipherspec must be of the form “cipher-mode”, or “cipher”
-
virtualsmartcard.CryptoUtils.
crypto_checksum
(algo, key, data, iv=None, ssc=None)¶ Compute various types of cryptographic checksums.
- Parameters
algo – A string specifying the algorithm to use. Currently supported algorithms are “MAX” “HMAC” and “CC” (Meaning a cryptographic checksum as used by the ICAO passports)
key – They key used to computed the cryptographic checksum
data – The data for which to calculate the checksum
iv – Optional. An initialization vector. Only used by the “MAC” algorithm
ssc – Optional. A send sequence counter to be prepended to the data. Only used by the “CC” algorithm
-
virtualsmartcard.CryptoUtils.
decrypt
(cipherspec, key, data, iv=None)¶
-
virtualsmartcard.CryptoUtils.
encrypt
(cipherspec, key, data, iv=None)¶
-
virtualsmartcard.CryptoUtils.
get_cipher
(cipherspec, key, iv=None)¶
-
virtualsmartcard.CryptoUtils.
get_cipher_blocklen
(cipherspec)¶
-
virtualsmartcard.CryptoUtils.
get_cipher_keylen
(cipherspec)¶
-
virtualsmartcard.CryptoUtils.
hash
(hashmethod, data)¶
-
virtualsmartcard.CryptoUtils.
operation_on_string
(string1, string2, op)¶
-
virtualsmartcard.CryptoUtils.
strip_padding
(blocklen, data, padding_class=1)¶ Strip the padding of decrypted data. Returns data without padding