public class SecurityProviderSymmetricKey extends SecurityProvider
Constructor and Description |
---|
SecurityProviderSymmetricKey(byte[] symmetricKey,
String registrationId)
Constructor for Symmetric key security provider
|
SecurityProviderSymmetricKey(String primaryKey,
String secondaryKey,
String registrationId)
Constructor for Symmetric key security provider that takes both keys
|
Modifier and Type | Method and Description |
---|---|
static byte[] |
ComputeDerivedSymmetricKey(byte[] enrollmentGroupSymmetricKey,
String deviceId)
Compute the derived symmetric key for authenticating your device based on it's group enrollment's symmetric key and
from the device's registrationId.
|
String |
getRegistrationId()
Unique id required for registration
|
byte[] |
getSecondaryKey()
Getter for Secondary key
|
byte[] |
getSymmetricKey()
Getter for Symmetric key
|
byte[] |
HMACSignData(byte[] signature,
byte[] base64DecodedKey)
Signs data using the provided base 64 decoded key using HMAC SHA 256
|
getSSLContext
public SecurityProviderSymmetricKey(byte[] symmetricKey, String registrationId)
symmetricKey
- Symmetric key to be used. For authenticating devices that are under an individual enrollment,
this symmetric key is the same symmetric key that the enrollment has. For authenticating devices
that are under a group enrollment, this symmetric key is derived from the enrollment group's symmetric keyregistrationId
- Registration ID to be usedpublic SecurityProviderSymmetricKey(String primaryKey, String secondaryKey, String registrationId)
primaryKey
- Primary key to be usedsecondaryKey
- Secondary key to be usedregistrationId
- Registration ID to be usedpublic byte[] getSymmetricKey()
public byte[] getSecondaryKey()
public String getRegistrationId() throws SecurityProviderException
getRegistrationId
in class SecurityProvider
SecurityProviderException
- If registration id with the underlying implementation could not be retrievedpublic byte[] HMACSignData(byte[] signature, byte[] base64DecodedKey) throws SecurityProviderException
signature
- Data to be signedbase64DecodedKey
- Key used for signingSecurityProviderException
- If signing was not successfulpublic static byte[] ComputeDerivedSymmetricKey(byte[] enrollmentGroupSymmetricKey, String deviceId) throws InvalidKeyException, NoSuchAlgorithmException
enrollmentGroupSymmetricKey
- The primary or secondary key of the group enrollment for which a device is computing it's derived symmetric key. Must be a UTF-8 byte array.deviceId
- The Id of the particular device to compute the derived key for. The user is expected to decide what the
deviceId should be prior to attempting to provision the device.InvalidKeyException
- If any exception occurs while initializing the HMAC with the provided keyNoSuchAlgorithmException
- If your device does not support HMAC_SHA256Copyright © 2022. All rights reserved.