public class MessageProtector extends Object
Constructor and Description |
---|
MessageProtector(byte[] key)
Constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
authenticateMessage(byte[] message,
byte[] mac,
String data)
Verifies an incoming message with an associated MAC
|
boolean |
authenticateRequest(byte[] request,
byte[] mac) |
boolean |
authenticateResponse(byte[] response,
byte[] mac) |
byte[] |
encryptRequest(byte[] message)
Encrypts a message from the client to either FOI or Merchant.
|
SecretKey |
getBaseKey()
This method returns the baseKey
|
byte[] |
getDerivedIv(String data)
getDerivedIv
|
byte[] |
getDerivedKey(String data)
Derive a key from the basekey.
|
byte[] |
getMessageMac(byte[] message,
String data)
Calculates and returns the MAC for the message.
|
byte[] |
getRequestMac(byte[] message)
Calculates the MAC for a message prepared by the client.
|
byte[] |
getResponseMac(byte[] message)
Calculates the MAC for a message prepared for the client.
|
public SecretKey getBaseKey()
public byte[] encryptRequest(byte[] message) throws NoSuchAlgorithmException, InvalidKeyException, org.bouncycastle.crypto.InvalidCipherTextException
message
- NoSuchAlgorithmException
InvalidKeyException
org.bouncycastle.crypto.InvalidCipherTextException
public byte[] getMessageMac(byte[] message, String data) throws NoSuchAlgorithmException, InvalidKeyException
message
- - the message to calculate the Mac for.data
- - the data used to derive the macNoSuchAlgorithmException
InvalidKeyException
public byte[] getRequestMac(byte[] message) throws NoSuchAlgorithmException, InvalidKeyException, IllegalStateException
message
- NoSuchAlgorithmException
InvalidKeyException
IllegalStateException
public boolean authenticateMessage(byte[] message, byte[] mac, String data) throws InvalidKeyException, NoSuchAlgorithmException
message
- - the message to authenticatemac
- - the MAC for this messagedata
- - the data used to derive the macNoSuchAlgorithmException
- - if something goes wrongInvalidKeyException
- - if something goes wrongIllegalStateException
public byte[] getDerivedKey(String data) throws InvalidKeyException, NoSuchAlgorithmException
data
- - the data used to derive the keyNoSuchAlgorithmException
- - if something goes wrongInvalidKeyException
- - if something goes wrongIllegalStateException
public byte[] getDerivedIv(String data) throws InvalidKeyException, NoSuchAlgorithmException
data
- - the data / string used to derive the IVNoSuchAlgorithmException
- - if something goes wrongInvalidKeyException
- - if something goes wrongIllegalStateException
public byte[] getResponseMac(byte[] message) throws NoSuchAlgorithmException, InvalidKeyException
message
- NoSuchAlgorithmException
InvalidKeyException
public boolean authenticateRequest(byte[] request, byte[] mac) throws NoSuchAlgorithmException, InvalidKeyException
public boolean authenticateResponse(byte[] response, byte[] mac) throws NoSuchAlgorithmException, InvalidKeyException
Copyright © 2017 Nets Branch Norway. All Rights Reserved.