public class SecurityUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
SecurityUtils.KeyId |
static class |
SecurityUtils.SecurityPolicy |
Constructor and Description |
---|
SecurityUtils() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
aes128Ciphering(byte[] masterKey,
byte[] bytesToCipher)
Encrypts a byte array with a master key with the algorithm AES in mode CBC and no padding.
|
static byte[] |
aesRFC3394KeyWrap(byte[] kek,
byte[] key)
This function wraps a key with a kek (key encryption key)
|
static byte[] |
generateAES128Key()
Generates a random AES 128 key
|
static MethodParameter |
globalKeyTransfer(byte[] masterKey,
byte[] globalKey,
SecurityUtils.KeyId keyId)
Returns the method parameter for updating a single key of a dlms server.
|
static MethodParameter |
securityActivate(SecurityUtils.SecurityPolicy securityPolicy)
Sets the security policy method parameter
|
public static MethodParameter globalKeyTransfer(byte[] masterKey, byte[] globalKey, SecurityUtils.KeyId keyId) throws java.io.IOException
masterKey
- the master key, also known as kekglobalKey
- the new key to update to the dlms serverkeyId
- the type of key to updatejava.io.IOException
- throws IOExceptionpublic static MethodParameter securityActivate(SecurityUtils.SecurityPolicy securityPolicy) throws java.io.IOException
securityPolicy
- the security policy to set forjava.io.IOException
- throws IOExceptionpublic static byte[] aes128Ciphering(byte[] masterKey, byte[] bytesToCipher) throws java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException, java.security.InvalidKeyException, javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException
masterKey
- the master key for encryption the bytesToCypherbytesToCipher
- the bytes to cipherjava.security.NoSuchAlgorithmException
- throws a NoSuchAlgorithmExceptionjavax.crypto.NoSuchPaddingException
- throws a NoSuchPaddingExceptionjava.security.InvalidKeyException
- throws a InvalidKeyExceptionjavax.crypto.IllegalBlockSizeException
- throws a IllegalBlockSizeExceptionjavax.crypto.BadPaddingException
- throws a BadPaddingExceptionpublic static byte[] aesRFC3394KeyWrap(byte[] kek, byte[] key)
kek
- the key encryption key for wrapping the keykey
- the key to wrappublic static byte[] generateAES128Key()