Crypto

object Crypto

Functions

Link copied to clipboard
fun authenticate(pdu: ByteArray, beaconKey: ByteArray): Boolean

Authenticates the received Secure Network beacon using the given Beacon Key.

Link copied to clipboard

Calculates the AID for a given ApplicationKey.

Link copied to clipboard
fun calculateConfirmation(confirmationInputs: ByteArray, sharedSecret: ByteArray, deviceRandom: ByteArray, authValue: ByteArray, algorithm: Algorithm): ByteArray

Calculates the provisioning confirmation based on the confirmation inputs, device random, shared secret and the auth value.

Link copied to clipboard

Calculates the device public key based on the provisioners public key.

Link copied to clipboard

Calculates Electronic Code Book (ECB) for the given data and key.

Link copied to clipboard
fun calculateHash(data: ByteArray, identityKey: ByteArray): ByteArray

Generates Node Identity Hash using the given Identity Key

Link copied to clipboard

Calculates the NID, EncryptionKey, PrivacyKey, NetworkID, IdentityKey, BeaconKey, PrivateBeaconKey for a given NetworkKey

/** Calculates the Friendship Credentials NID, EncryptionKey, PrivacyKey, NetworkID, IdentityKey, BeaconKey, PrivateBeaconKey for a given NetworkKey

Link copied to clipboard
fun calculateKeys(algorithm: Algorithm, confirmationInputs: ByteArray, sharedSecret: ByteArray, provisionerRandom: ByteArray, deviceRandom: ByteArray): Triple<ByteArray, ByteArray, ByteArray>

Calculates the Session Key, Session Nonce and the Device Key based on the Confirmation Inputs, 16 or 32-byte Provisioner Random and 16 or 32-byte device Random.

Link copied to clipboard

Calculates the 64-bit Network ID. The Network ID is derived from the network key such that each network key generates one Network ID.

Link copied to clipboard

Calculates the salt based on a given input.

Link copied to clipboard

Calculates the salt based on a given input.

Link copied to clipboard
fun calculateSharedSecret(privateKey: PrivateKey, publicKey: ByteArray): ByteArray

Calculates the shared secret based on the given public key and the local private key.

Link copied to clipboard

Creates a 16-bit virtual address for a given UUID.

Link copied to clipboard
fun decodeAndAuthenticate(pdu: ByteArray, privateBeaconKey: ByteArray): Pair<Byte, ByteArray>?

Decodes and authenticates the received Private Beacon using the given Private Beacon Key.

Link copied to clipboard
fun decrypt(data: ByteArray, key: ByteArray, nonce: ByteArray, additionalData: ByteArray? = null, micSize: Int): ByteArray?

Decrypts the given data with the EncryptionKey, Nonce and authenticates the generated MIC(Message Integrity Check).

Link copied to clipboard
Link copied to clipboard
fun encrypt(data: ByteArray, key: ByteArray, nonce: ByteArray, additionalData: ByteArray? = null, micSize: Int): ByteArray

Encrypts the data with the EncryptionKey , Nonce and concatenates the MIC(Message Integrity Check).

Link copied to clipboard

Generates a pair of Private and Public Keys using P256 Elliptic Curve.

Link copied to clipboard
fun generateRandom(sizeInBits: Int): ByteArray

Generates a random number of the given size in bits.

Link copied to clipboard

Generates a 128-bit random key using a SecureRandom.

Link copied to clipboard
fun obfuscate(data: ByteArray, random: ByteArray, ivIndex: UInt, privacyKey: ByteArray): ByteArray

Obfuscates or De+obfuscates given data by XORing it with PECB, which is calculated by encrypting Privacy Plaintext (encrypted data (used as Privacy Random) and IV Index) using the given key.

Link copied to clipboard

Returns the public key encoded as a 64-byte array