         cipher(Consts.aesPlaintext, key: Consts.aesKey_256, IV: nil, expectedCyphertext: Consts.aesCiphertext_CBC_256, algorithm: .AES, options: [])
         cipher(Consts.aesPlaintext, key: Consts.aesKey_256, IV: Consts.aesIV_256, expectedCyphertext: Consts.aesCiphertext_CBC_256_IV, algorithm: .AES, options: [])
         cipher(Consts.message.dataUsingEncoding(NSUTF8StringEncoding)!.base64EncodedStringWithOptions([]), key: Consts.aesKey_256, IV: nil, expectedCyphertext: Consts.aesCiphertext_CBC_256_Padding, algorithm: .AES, options: .PKCS7Padding)
+    }
+
+    func testThrowsAlignmentError() {
+        var didFail = false
+        do {
+            let plaintext = Consts.message.dataUsingEncoding(NSUTF8StringEncoding)!
+            let aesKey = NSData(base64EncodedString: Consts.aesKey_256, options: [])!
+            try plaintext.encrypt(.AES, options: [], key: aesKey, iv: nil)
+        } catch SCryptoError.AlignmentError {
+            didFail = true
+        } catch {
+            XCTFail()
+        }
+        XCTAssertTrue(didFail, "AES requires padding in CBC mode!")
     }
 
     func cipher(plaintext: String, key: String, IV: String?, expectedCyphertext: String, algorithm: Cipher.Algorithm, options: Cipher.Options) {

    }

    private func hmac(algorithm: HMAC.Algorithm, key: String, message: String, expectedHMAC: String) {
        let key = key.dataUsingEncoding(NSUTF8StringEncoding)!
        let message = message.dataUsingEncoding(NSUTF8StringEncoding)!
        let hmac = message.hmac(algorithm, key: key).hexString()
        XCTAssertEqual(hmac, expectedHMAC)
    }

    // MARK: PBKDF

    func testDerivedKey_SHA1() {
        PBKDF2(Consts.key, salt: Consts.pbkdfSalt, pseudoRandomAlgorithm: .SHA1, rounds: 20, derivedKeyLength: 16, expectedDerivedKey: Consts.pbkdfSHA1)
    }

    func testDerivedKey_SHA256() {
        PBKDF2(Consts.key, salt: Consts.pbkdfSalt, pseudoRandomAlgorithm: .SHA256, rounds: 20, derivedKeyLength: 32, expectedDerivedKey: Consts.pbkdfSHA256)
    }

    func testDerivedKey_SHA512() {
        PBKDF2(Consts.key, salt: Consts.pbkdfSalt, pseudoRandomAlgorithm: .SHA512, rounds: 20, derivedKeyLength: 64, expectedDerivedKey: Consts.pbkdfSHA512)
    }


        let aesKey = NSData(base64EncodedString: key, options: [])!
        let IV = IV == nil ? nil : NSData(base64EncodedString: IV!, options: [])
        let ciphertext = try! plaintext.encrypt(algorithm, options: options, key: aesKey, iv: IV)
        let plaintextProof = try! ciphertext.decrypt(algorithm, options: options, key: aesKey, iv: IV)
        XCTAssertEqual(plaintext, plaintextProof)
        XCTAssertEqual(ciphertext.base64EncodedStringWithOptions([]), expectedCyphertext)
    }

