Fix CryCiphers::supportedCipherNames()

This commit is contained in:
Sebastian Messmer 2018-07-29 14:03:36 -07:00
parent 1b577d000c
commit 797581b9d2
2 changed files with 14 additions and 7 deletions

View File

@ -92,10 +92,15 @@ const CryCipher& CryCiphers::find(const string &cipherName) {
return **found;
}
vector<string> CryCiphers::supportedCipherNames() {
vector<string> result;
for (const auto& cipher : CryCiphers::SUPPORTED_CIPHERS) {
result.push_back(cipher->cipherName());
}
return result;
vector<string> CryCiphers::_buildSupportedCipherNames() {
vector<string> result;
for (const auto& cipher : CryCiphers::SUPPORTED_CIPHERS) {
result.push_back(cipher->cipherName());
}
return result;
}
const vector<string>& CryCiphers::supportedCipherNames() {
static vector<string> supportedCipherNames = _buildSupportedCipherNames();
return supportedCipherNames;
}

View File

@ -15,7 +15,7 @@ class CryCipher;
class CryCiphers final {
public:
static std::vector<std::string> supportedCipherNames();
static const std::vector<std::string>& supportedCipherNames();
//A static_assert in CryCipherInstance ensures that there is no cipher with a key size larger than specified here.
//TODO Calculate this from SUPPORTED_CIPHERS instead of setting it manually
@ -27,6 +27,8 @@ private:
static const std::string INTEGRITY_WARNING;
static const std::vector<std::shared_ptr<CryCipher>> SUPPORTED_CIPHERS;
static std::vector<std::string> _buildSupportedCipherNames();
};