Ejemplo n.º 1
0
    def data_encrypt(secret, inputs, data):
        """inputs = confirmation_salt + provisioner_random + device_random"""
        provisioning_salt = s1(inputs)
        provisioning_key = k1(secret, provisioning_salt, b"prsk")
        provisioning_nonce = k1(secret, provisioning_salt, b"prsn")[-13:]

        return aes_ccm_encrypt(provisioning_key,
                               provisioning_nonce,
                               data,
                               tag_length=8)
def test_k1(app_key):
    N = app_key
    SALT = bytes.fromhex("2ba14ffa0df84a2831938d57d276cab4")
    P = bytes.fromhex("5a09d60797eeb4478aada59db3352a0d")

    k = k1(N, SALT, P)

    assert k == bytes.fromhex("f6ed15a8934afbe7d83e8dcb57fcf5d7")
Ejemplo n.º 3
0
    def confirmation_encrypt(secret, inputs, random, auth=None):
        """inputs = invite(attention) + capabilities(without opcode) + start(msg) + provisioner_key + device_key"""
        confirmation_salt = s1(inputs)
        confirmation_key = k1(secret, confirmation_salt, b"prck")

        return (
            confirmation_salt,
            confirmation_key,
            aes_cmac(confirmation_key,
                     random + struct.pack("16s", auth or b"")),
        )
Ejemplo n.º 4
0
 def provisioning_device_key(secret, provisioning_salt):
     return k1(secret, provisioning_salt, b"prdk")