diff --git a/src/main.cpp b/src/main.cpp index 4181e27..94f0873 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -619,6 +619,26 @@ int main(int argc, char **argv) } const scsi::algorithm_descriptor& ad = *algo_it; + auto encrypt_c {static_cast( + ad.flags1 & scsi::algorithm_descriptor::flags1_encrypt_c_mask)}; + if (enc_mode != scsi::encrypt_mode::off && + encrypt_c != 2u << scsi::algorithm_descriptor::flags1_encrypt_c_pos) { + std::cerr + << "stenc: Device does not support encryption using algorithm index " + << std::dec << static_cast(*algorithm_index) << '\n'; + std::exit(EXIT_FAILURE); + } + + auto decrypt_c {static_cast( + ad.flags1 & scsi::algorithm_descriptor::flags1_decrypt_c_mask)}; + if (dec_mode != scsi::decrypt_mode::off && + decrypt_c != 2u << scsi::algorithm_descriptor::flags1_decrypt_c_pos) { + std::cerr + << "stenc: Device does not support decryption using algorithm index " + << std::dec << static_cast(*algorithm_index) << '\n'; + std::exit(EXIT_FAILURE); + } + if ((enc_mode != scsi::encrypt_mode::off || dec_mode != scsi::decrypt_mode::off) && key.size() != ntohs(ad.key_length)) {