// Path: src/main/java/net/seleucus/wsp/crypto/fwknop/fields/HmacType.java
// public enum HmacType {
// 
//     HmacMD5(0, "HmacMD5", 16, 22),
//     HmacSHA1(1, "HmacSHA1", 20, 27),
//     HmacSHA256(2, "HmacSHA256", 32, 43),
//     HmacSHA384(3, "HmacSHA384", 48, 64),
//     HmacSHA512(4, "HmacSHA512", 64, 86);
// 
//     private final int id;
//     private final String algorithmName;
//     private final int length;
//     private final int base64Length;
// 
//     private HmacType(int id, String algorithmName, int length, int base64Length) {
//         this.id = id;
//         this.algorithmName = algorithmName;
//         this.length = length;
//         this.base64Length = base64Length;
//     }
// 
//     public int id() {
//         return id;
//     }
// 
//     public String algorithmName() {
//         return algorithmName;
//     }
// 
//     public int length() {
//         return length;
//     }
// 
//     public int base64Length(){
//         return base64Length;
//     }
// }
// 
// Path: src/main/java/net/seleucus/wsp/crypto/fwknop/MessageBuilder.java
// public static MessageBuilder createMessage(){
//     return new MessageBuilder();
// }
// 
// Path: src/main/java/net/seleucus/wsp/crypto/fwknop/fields/HmacType.java
// public enum HmacType {
// 
//     HmacMD5(0, "HmacMD5", 16, 22),
//     HmacSHA1(1, "HmacSHA1", 20, 27),
//     HmacSHA256(2, "HmacSHA256", 32, 43),
//     HmacSHA384(3, "HmacSHA384", 48, 64),
//     HmacSHA512(4, "HmacSHA512", 64, 86);
// 
//     private final int id;
//     private final String algorithmName;
//     private final int length;
//     private final int base64Length;
// 
//     private HmacType(int id, String algorithmName, int length, int base64Length) {
//         this.id = id;
//         this.algorithmName = algorithmName;
//         this.length = length;
//         this.base64Length = base64Length;
//     }
// 
//     public int id() {
//         return id;
//     }
// 
//     public String algorithmName() {
//         return algorithmName;
//     }
// 
//     public int length() {
//         return length;
//     }
// 
//     public int base64Length(){
//         return base64Length;
//     }
// }


import net.seleucus.wsp.crypto.fwknop.fields.HmacType;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
import java.security.SecureRandom;
import static java.lang.Math.abs;
import static net.seleucus.wsp.crypto.fwknop.MessageBuilder.createMessage;
import static net.seleucus.wsp.crypto.fwknop.fields.DigestType.SHA256;
import static net.seleucus.wsp.crypto.fwknop.fields.EncryptionMode.CBC;
import static net.seleucus.wsp.crypto.fwknop.fields.EncryptionType.AES;
import static net.seleucus.wsp.crypto.fwknop.fields.HmacType.*;
import static net.seleucus.wsp.crypto.fwknop.fields.MessageType.AccessMessage;
import static org.junit.Assert.*;
     *
     *  SPA Field Values:
     *  =================
     *
     *     Random Value: 1662754693713426
     *         Username: imberda
     *        Timestamp: 1424728557
     *      FKO Version: 2.0.2
     *     Message Type: 1 (Access msg)
     *   Message String: 1.1.1.1,tcp/80
     *       Nat Access: <NULL>
     *      Server Auth: <NULL>
     *   Client Timeout: 0
     *      Digest Type: 3 (SHA256)
     *        HMAC Type: 3 (SHA256)
     *  Encryption Type: 1 (Rijndael)
     *  Encryption Mode: 2 (CBC)
     *     Encoded Data: 1662754693713426:aW1iZXJkYQ:1424728557:2.0.2:1:MS4xLjEuMSx0Y3AvODA
     *  SPA Data Digest: jEscqvxrSt7+Lb2cQ+ICwgX4mhuSp86P8XikxSbga1s
     *             HMAC: Kn75C+V+O0xu3nzVvvdteuHk0zBptmFep8LQD/JgfWo
     *  Final SPA Data: 9sPsHAzpiUCLultUmkjizcRSb0eIkvlXLq9noQ4WbXAT3HlZhWLHoKGAM+TOOtIMxRJ6sOSAlzhx6wNgCQiZ3msYcNslJC0F9xxVYVhw8kNon4uuzXoZyCBb3g9m+nZVVyRyy3f0UO+eljC9WRHTsRs5m6Qlryzec
     *
     *
     * @throws Exception
     */
    @Test
    public void shouldEncryptAndDecrypt() throws Exception {

        final byte[] encryptKey = "ENCRYPTION_KEY".getBytes();

// Path: src/main/java/net/seleucus/wsp/crypto/fwknop/fields/HmacType.java
// public enum HmacType {
// 
//     HmacMD5(0, "HmacMD5", 16, 22),
//     HmacSHA1(1, "HmacSHA1", 20, 27),
//     HmacSHA256(2, "HmacSHA256", 32, 43),
//     HmacSHA384(3, "HmacSHA384", 48, 64),
//     HmacSHA512(4, "HmacSHA512", 64, 86);
// 
//     private final int id;
//     private final String algorithmName;
//     private final int length;
//     private final int base64Length;
// 
//     private HmacType(int id, String algorithmName, int length, int base64Length) {
//         this.id = id;
//         this.algorithmName = algorithmName;
//         this.length = length;
//         this.base64Length = base64Length;
//     }
// 
//     public int id() {
//         return id;
//     }
// 
//     public String algorithmName() {
//         return algorithmName;
//     }
// 
//     public int length() {
//         return length;
//     }
// 
//     public int base64Length(){
//         return base64Length;
//     }
// }
// 
// Path: src/main/java/net/seleucus/wsp/crypto/fwknop/MessageBuilder.java
// public static MessageBuilder createMessage(){
//     return new MessageBuilder();
// }
// 
// Path: src/main/java/net/seleucus/wsp/crypto/fwknop/fields/HmacType.java
// public enum HmacType {
// 
//     HmacMD5(0, "HmacMD5", 16, 22),
//     HmacSHA1(1, "HmacSHA1", 20, 27),
//     HmacSHA256(2, "HmacSHA256", 32, 43),
//     HmacSHA384(3, "HmacSHA384", 48, 64),
//     HmacSHA512(4, "HmacSHA512", 64, 86);
// 
//     private final int id;
//     private final String algorithmName;
//     private final int length;
//     private final int base64Length;
// 
//     private HmacType(int id, String algorithmName, int length, int base64Length) {
//         this.id = id;
//         this.algorithmName = algorithmName;
//         this.length = length;
//         this.base64Length = base64Length;
//     }
// 
//     public int id() {
//         return id;
//     }
// 
//     public String algorithmName() {
//         return algorithmName;
//     }
// 
//     public int length() {
//         return length;
//     }
// 
//     public int base64Length(){
//         return base64Length;
//     }
// }


// Path: src/test/java/net/seleucus/wsp/crypto/fwknop/FwknopSymmetricCryptoServiceTest.java
import net.seleucus.wsp.crypto.fwknop.fields.HmacType;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
import java.security.SecureRandom;
import static java.lang.Math.abs;
import static net.seleucus.wsp.crypto.fwknop.MessageBuilder.createMessage;
import static net.seleucus.wsp.crypto.fwknop.fields.DigestType.SHA256;
import static net.seleucus.wsp.crypto.fwknop.fields.EncryptionMode.CBC;
import static net.seleucus.wsp.crypto.fwknop.fields.EncryptionType.AES;
import static net.seleucus.wsp.crypto.fwknop.fields.HmacType.*;
import static net.seleucus.wsp.crypto.fwknop.fields.MessageType.AccessMessage;
import static org.junit.Assert.*;

     *
     *  SPA Field Values:
     *  =================
     *
     *     Random Value: 1662754693713426
     *         Username: imberda
     *        Timestamp: 1424728557
     *      FKO Version: 2.0.2
     *     Message Type: 1 (Access msg)
     *   Message String: 1.1.1.1,tcp/80
     *       Nat Access: <NULL>
     *      Server Auth: <NULL>
     *   Client Timeout: 0
     *      Digest Type: 3 (SHA256)
     *        HMAC Type: 3 (SHA256)
     *  Encryption Type: 1 (Rijndael)
     *  Encryption Mode: 2 (CBC)
     *     Encoded Data: 1662754693713426:aW1iZXJkYQ:1424728557:2.0.2:1:MS4xLjEuMSx0Y3AvODA
     *  SPA Data Digest: jEscqvxrSt7+Lb2cQ+ICwgX4mhuSp86P8XikxSbga1s
     *             HMAC: Kn75C+V+O0xu3nzVvvdteuHk0zBptmFep8LQD/JgfWo
     *  Final SPA Data: 9sPsHAzpiUCLultUmkjizcRSb0eIkvlXLq9noQ4WbXAT3HlZhWLHoKGAM+TOOtIMxRJ6sOSAlzhx6wNgCQiZ3msYcNslJC0F9xxVYVhw8kNon4uuzXoZyCBb3g9m+nZVVyRyy3f0UO+eljC9WRHTsRs5m6Qlryzec
     *
     *
     * @throws Exception
     */
    @Test
    public void shouldEncryptAndDecrypt() throws Exception {

        final byte[] encryptKey = "ENCRYPTION_KEY".getBytes();

        final Message message = createMessage()