/** * \file * \author Egor Tensin * \date 2015 * \copyright This file is licensed under the terms of the MIT License. * See LICENSE.txt for details. */ #pragma once #include #include #include #include #include static std::istream& operator>>(std::istream& is, aesni::Mode& dest) { static const char* const argument_name = "mode"; std::string src; is >> src; if (boost::iequals(src, "ecb")) dest = AESNI_ECB; else if (boost::iequals(src, "cbc")) dest = AESNI_CBC; else if (boost::iequals(src, "cfb")) dest = AESNI_CFB; else if (boost::iequals(src, "ofb")) dest = AESNI_OFB; else if (boost::iequals(src, "ctr")) dest = AESNI_CTR; else { throw boost::program_options::validation_error( boost::program_options::validation_error::invalid_option_value, argument_name, src); } return is; } static std::istream& operator>>(std::istream& is, aesni::Algorithm& dest) { static const char* const argument_name = "algorithm"; std::string src; is >> src; if (boost::iequals(src, "aes128")) dest = AESNI_AES128; else if (boost::iequals(src, "aes192")) dest = AESNI_AES192; else if (boost::iequals(src, "aes256")) dest = AESNI_AES256; else { throw boost::program_options::validation_error( boost::program_options::validation_error::invalid_option_value, argument_name, src); } return is; }