public final class EncryptionContext extends Object
| Modifier | Constructor and Description |
|---|---|
protected |
EncryptionContext(int cipher)
Internal constructor
|
| Modifier and Type | Method and Description |
|---|---|
static EncryptionContext |
createInstance(NXCPMessage request)
Create encryption context based on information from session key request message.
|
byte[] |
decryptMessage(NXCPDataInputStream inputStream,
int length)
Decrypt message from input stream
|
byte[] |
encryptMessage(NXCPMessage msg,
boolean allowCompression)
Encrypt NXCP message.
|
int |
getCipher()
Get cipher
|
static String |
getCipherName(int cipher)
Get cipher name
|
byte[] |
getEncryptedIv(NXCPMessage msg)
Encrypt initialization vector with public key from encryption setup message.
|
byte[] |
getEncryptedSessionKey(NXCPMessage msg)
Encrypt session key with public key from encryption setup message.
|
int |
getIvLength()
Get initialization vector length (in bytes)
|
int |
getKeyLength()
Get key length (in bytes)
|
static boolean |
testCipher(int cipherId)
Test cipher with given ID
|
protected EncryptionContext(int cipher)
throws GeneralSecurityException
cipher - cipher to useGeneralSecurityExceptionpublic static String getCipherName(int cipher)
cipher - cipher IDpublic static boolean testCipher(int cipherId)
cipherId - public static EncryptionContext createInstance(NXCPMessage request) throws NXCPException
request - session key request messageNXCPException - if encryption context cannot be createdpublic byte[] getEncryptedSessionKey(NXCPMessage msg) throws GeneralSecurityException
msg - encryption setup messageGeneralSecurityExceptionpublic byte[] getEncryptedIv(NXCPMessage msg) throws GeneralSecurityException
msg - encryption setup messageGeneralSecurityExceptionpublic byte[] encryptMessage(NXCPMessage msg, boolean allowCompression) throws IOException, GeneralSecurityException
msg - message to encryptallowCompression - true if payload compression is allowedIOExceptionGeneralSecurityExceptionInvalidKeyExceptionpublic byte[] decryptMessage(NXCPDataInputStream inputStream, int length) throws GeneralSecurityException, IOException
inputStream - input streamlength - length of encrypted messageGeneralSecurityExceptionIOExceptionpublic int getCipher()
public int getKeyLength()
public int getIvLength()
Copyright © 2017. All rights reserved.