public class SecurityUtils
extends java.lang.Object
This class is useful if you may want to change the security setup of the remote meter.
Modifier and Type | Class and Description |
---|---|
static class |
SecurityUtils.KeyId |
Modifier and Type | Method and Description |
---|---|
static byte[] |
cipherWithAes128(byte[] masterKey,
byte[] bytesToCipher)
Encrypts a byte array with a master key with the algorithm AES in mode CBC and no padding.
|
static byte[] |
generateAES128Key()
Generates a random AES 128 key
|
static MethodParameter |
keyChangeMethodParamFor(byte[] masterKey,
byte[] newKey,
SecurityUtils.KeyId keyId)
Returns the method parameter for updating a single key of a DLMS server.
|
static MethodParameter |
securityActivateMethodParamFor(SecuritySuite.SecurityPolicy securityPolicy)
Sets the security policy method parameter
|
static byte[] |
unwrapAesRFC3394Key(byte[] kek,
byte[] wrappedKey)
This function unwraps a wrapped key with the kek (key encryption key)
|
static byte[] |
wrapAesRFC3394Key(byte[] kek,
byte[] key)
This function wraps a key with a kek (key encryption key)
|
public static MethodParameter keyChangeMethodParamFor(byte[] masterKey, byte[] newKey, SecurityUtils.KeyId keyId) throws java.io.IOException
masterKey
- the master key, also known as KEKnewKey
- the new key to update to the DLMS serverkeyId
- the type of key to updatejava.io.IOException
- throws IOExceptionpublic static MethodParameter securityActivateMethodParamFor(SecuritySuite.SecurityPolicy securityPolicy)
securityPolicy
- the security policy to set forpublic static byte[] cipherWithAes128(byte[] masterKey, byte[] bytesToCipher) throws java.security.GeneralSecurityException
masterKey
- the master key for encryption the bytesToCypherbytesToCipher
- the bytes to cipherjava.security.GeneralSecurityException
- caused by Cipher.doFinal(byte[])
or Cipher.init(int, Key)
public static byte[] wrapAesRFC3394Key(byte[] kek, byte[] key)
kek
- the key encryption key for wrapping the keykey
- the key to wrappublic static byte[] unwrapAesRFC3394Key(byte[] kek, byte[] wrappedKey) throws org.bouncycastle.crypto.InvalidCipherTextException
kek
- the key encryption key for unwrapping the wrapped keywrappedKey
- the wrapped key to unwraporg.bouncycastle.crypto.InvalidCipherTextException
- will thrown if something unexpected is in the wrappedKeypublic static byte[] generateAES128Key()