// Path: src/test/java/org/unitedid/yhsm/SetupCommon.java
// public class SetupCommon {
//     public YubiHSM hsm;
//     public DeviceHandler deviceHandler;
//     public int keyHandle = 8192;
//     public final String configPassPhrase = "";
//     public final String hsmPassPhrase = "badabada";
//     public final String adminYubikey = "ftftftfteeee";
// 
// 
//     @BeforeTest
//     public void setUp() throws Exception {
//         String deviceName = "/dev/ttyACM0";
//         if (System.getProperty("hsm.test.deviceName") != null) {
//             deviceName = System.getProperty("hsm.test.deviceName");
//         }
//         hsm = new YubiHSM(deviceName);
//         deviceHandler = hsm.getRawDevice();
//     }
// 
//     @AfterTest
//     public void tearDown() throws Exception {
//         hsm = null;
//         deviceHandler = null;
//     }
// 
// }


import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import org.unitedid.yhsm.SetupCommon;
import static org.testng.Assert.*;

    @AfterTest
    public void tearDown() throws Exception {
        super.tearDown();
    }

    @Test
    public void testEncryptAndDecrypt() throws YubiHSMCommandFailedException, YubiHSMErrorException, YubiHSMInputException {
        String plaintext = "World domination";
        String cipherText = hsm.encryptAES_ECB(plaintext, khEncrypt);
        assertNotSame(plaintext, cipherText);

        String decrypted = hsm.decryptAES_ECB(cipherText, khDecrypt);
        assertEquals(decrypted, plaintext);
    }

    @Test(expectedExceptions = YubiHSMInputException.class,
          expectedExceptionsMessageRegExp = "Argument 'plaintext' is too long, expected max 16 but got 26")
    public void testEncryptInputException() throws YubiHSMCommandFailedException, YubiHSMErrorException, YubiHSMInputException {
        String aTooLongString = "abcdefghijklmonpqrstuvwxyz";
        hsm.encryptAES_ECB(aTooLongString, khEncrypt);
    }

    @Test(expectedExceptions = YubiHSMInputException.class,
          expectedExceptionsMessageRegExp = "Wrong size of argument 'cipherText', expected 16 but got 19")
    public void testDecryptInputException() throws YubiHSMCommandFailedException, YubiHSMErrorException, YubiHSMInputException {
        String aTooLongCipher = "112233445566778899aaccddeeff1122334455";
        hsm.decryptAES_ECB(aTooLongCipher, khDecrypt);
    }

// Path: src/test/java/org/unitedid/yhsm/SetupCommon.java
// public class SetupCommon {
//     public YubiHSM hsm;
//     public DeviceHandler deviceHandler;
//     public int keyHandle = 8192;
//     public final String configPassPhrase = "";
//     public final String hsmPassPhrase = "badabada";
//     public final String adminYubikey = "ftftftfteeee";
// 
// 
//     @BeforeTest
//     public void setUp() throws Exception {
//         String deviceName = "/dev/ttyACM0";
//         if (System.getProperty("hsm.test.deviceName") != null) {
//             deviceName = System.getProperty("hsm.test.deviceName");
//         }
//         hsm = new YubiHSM(deviceName);
//         deviceHandler = hsm.getRawDevice();
//     }
// 
//     @AfterTest
//     public void tearDown() throws Exception {
//         hsm = null;
//         deviceHandler = null;
//     }
// 
// }


// Path: src/test/java/org/unitedid/yhsm/internal/AESECBCmdTest.java
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import org.unitedid.yhsm.SetupCommon;
import static org.testng.Assert.*;


    @AfterTest
    public void tearDown() throws Exception {
        super.tearDown();
    }

    @Test
    public void testEncryptAndDecrypt() throws YubiHSMCommandFailedException, YubiHSMErrorException, YubiHSMInputException {
        String plaintext = "World domination";
        String cipherText = hsm.encryptAES_ECB(plaintext, khEncrypt);
        assertNotSame(plaintext, cipherText);

        String decrypted = hsm.decryptAES_ECB(cipherText, khDecrypt);
        assertEquals(decrypted, plaintext);
    }

    @Test(expectedExceptions = YubiHSMInputException.class,
          expectedExceptionsMessageRegExp = "Argument 'plaintext' is too long, expected max 16 but got 26")
    public void testEncryptInputException() throws YubiHSMCommandFailedException, YubiHSMErrorException, YubiHSMInputException {
        String aTooLongString = "abcdefghijklmonpqrstuvwxyz";
        hsm.encryptAES_ECB(aTooLongString, khEncrypt);
    }

    @Test(expectedExceptions = YubiHSMInputException.class,
          expectedExceptionsMessageRegExp = "Wrong size of argument 'cipherText', expected 16 but got 19")
    public void testDecryptInputException() throws YubiHSMCommandFailedException, YubiHSMErrorException, YubiHSMInputException {
        String aTooLongCipher = "112233445566778899aaccddeeff1122334455";
        hsm.decryptAES_ECB(aTooLongCipher, khDecrypt);
    }

    @Test