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) |
byte[] |
encryptMessage(NXCPMessage msg)
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() |
int |
getKeyLength()
Get key length (in bytes)
|
static boolean |
testCipher(int cipherId)
Test cipher with given ID
|
protected EncryptionContext(int cipher) throws GeneralSecurityException
GeneralSecurityException
public 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 messageGeneralSecurityException
public byte[] getEncryptedIv(NXCPMessage msg) throws GeneralSecurityException
msg
- encryption setup messageGeneralSecurityException
public byte[] encryptMessage(NXCPMessage msg) throws IOException, GeneralSecurityException
msg
- message to encryptIOException
GeneralSecurityException
InvalidKeyException
public byte[] decryptMessage(NXCPDataInputStream inputStream, int length) throws GeneralSecurityException, IOException
inputStream
- length
- GeneralSecurityException
IOException
public int getCipher()
public int getKeyLength()
public int getIvLength()
Copyright © 2015. All rights reserved.