+
+ SILC_LOG_DEBUG(("Allocating twofish-256-cfb cipher"));
+ if (!silc_cipher_alloc("twofish-256-cfb", &cipher)) {
+ SILC_LOG_DEBUG(("Allocating twofish-256-cfb cipher failed"));
+ goto err;
+ }
+ if (!silc_cipher_alloc("twofish-256-cfb", &cipher2)) {
+ SILC_LOG_DEBUG(("Allocating twofish-256-cfb cipher failed"));
+ goto err;
+ }
+
+ /* Fifth test vector */
+ SILC_LOG_DEBUG(("CFB test vector"));
+ memset(dst, 0, sizeof(dst));
+ memset(pdst, 0, sizeof(pdst));
+ silc_cipher_set_iv(cipher, iv6);
+ assert(silc_cipher_set_key(cipher, key6, key6_len, TRUE));
+ assert(silc_cipher_set_key(cipher2, key6, key6_len, FALSE));
+ assert(silc_cipher_encrypt(cipher, p6, dst, p6_len, NULL));
+ SILC_LOG_DEBUG(("block len %d, key len %d, name %s",
+ silc_cipher_get_block_len(cipher),
+ silc_cipher_get_key_len(cipher),
+ silc_cipher_get_name(cipher)));
+ SILC_LOG_HEXDUMP(("Plaintext"), (unsigned char *)p6, p6_len);
+ SILC_LOG_HEXDUMP(("Ciphertext"), (unsigned char *)dst, p6_len);
+ SILC_LOG_HEXDUMP(("Expected ciphertext"), (unsigned char *)c6, p6_len);
+ if (memcmp(dst, c6, p6_len)) {
+ SILC_LOG_DEBUG(("Encrypt failed"));
+ goto err;
+ }
+ SILC_LOG_DEBUG(("Encrypt is successful"));
+ silc_cipher_set_iv(cipher2, iv6);
+ assert(silc_cipher_decrypt(cipher2, dst, pdst, p6_len, NULL));
+ SILC_LOG_HEXDUMP(("Decrypted plaintext"), (unsigned char *)pdst, p6_len);
+ SILC_LOG_HEXDUMP(("Expected plaintext"), (unsigned char *)p5, p6_len);
+ if (memcmp(pdst, p6, p6_len)) {
+ SILC_LOG_DEBUG(("Decrypt failed"));
+ goto err;
+ }
+ SILC_LOG_DEBUG(("Decrypt is successful"));
+ silc_cipher_free(cipher2);
+