com.baidubce.services.iothisk.device
Class IotHiskDevice

java.lang.Object
  extended by com.baidubce.services.iothisk.device.IotHiskDevice

public class IotHiskDevice
extends Object

Provides the hisk device with the local secure element ability. Currently, only baidu mbed_akey secure element is supported.


Constructor Summary
IotHiskDevice(Device device)
          Constructs a new hisk device client using the provided hisk device info.
 
Method Summary
 byte[] decrypt(byte[] cipherMessage)
          Decrypt cipher with device secure element.
 byte[] encrypt(byte[] message)
          Encrypt message with device secure element.
 byte[] getActiveData()
          Get device active data generated by device secure element
 long getCurrentCounter()
          Get device client current counter.
 String getDeviceId()
          Get unique device id in ascii encoding
 void setCurrentCounter(long counter)
          Set device counter by user specified counter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IotHiskDevice

public IotHiskDevice(Device device)
Constructs a new hisk device client using the provided hisk device info.

Parameters:
device - specified hisk basic device info, corresponding to the contract created in hisk cloud service.
Method Detail

getDeviceId

public String getDeviceId()
Get unique device id in ascii encoding

Returns:
unique device id

getActiveData

public byte[] getActiveData()
Get device active data generated by device secure element

Returns:
successful device active data in byte array, otherwise an exception will be thrown

encrypt

public byte[] encrypt(byte[] message)
Encrypt message with device secure element.

Parameters:
message - plain message in byte array
Returns:
successful cipher message in byte array, otherwise an exception will be thrown

decrypt

public byte[] decrypt(byte[] cipherMessage)
Decrypt cipher with device secure element.

Parameters:
cipherMessage - cipher message in byte array
Returns:
successful plain message in byte array, otherwise an exception will be thrown

getCurrentCounter

public long getCurrentCounter()
Get device client current counter. Counter will be used to check message to resist replay attack.

Returns:
current device counter.

setCurrentCounter

public void setCurrentCounter(long counter)
Set device counter by user specified counter.

Parameters:
counter - specified counter


Copyright © 2020. All rights reserved.