setParam(params, name, createRandomBufferCAPI(32));
// decrypt
- assert_crypto_result(EncryptionError::SERVER_ERROR,
+ assert_crypto_result(EncryptionError::INVALID_PARAM,
apiDecrypt,
params.get(),
aliases.prv.c_str(),
{ 116, EncryptionError::INVALID_PARAM },
{ 124, EncryptionError::INVALID_PARAM },
{ 256, EncryptionError::INVALID_PARAM },
- // legal tag lengths (EVP_CipherFinal fails but we can't get the error code)
- { 32, EncryptionError::SERVER_ERROR },
- { 64, EncryptionError::SERVER_ERROR },
- { 96, EncryptionError::SERVER_ERROR },
- { 104, EncryptionError::SERVER_ERROR },
- { 112, EncryptionError::SERVER_ERROR },
- { 120, EncryptionError::SERVER_ERROR },
+ // legal tag lengths but different than the one used for encryption
+ { 32, EncryptionError::INVALID_PARAM },
+ { 64, EncryptionError::INVALID_PARAM },
+ { 96, EncryptionError::INVALID_PARAM },
+ { 104, EncryptionError::INVALID_PARAM },
+ { 112, EncryptionError::INVALID_PARAM },
+ { 120, EncryptionError::INVALID_PARAM },
// legal tag length that was actually used for encryption (default)
{ 128, EncryptionError::SUCCESS },
};
// modify tag (last 16B of encrypted message)
ret.encrypted->data[ret.encrypted->size-1]++;
- // EVP_CipherFinal fails but we can't get error code
- assert_crypto_result(EncryptionError::SERVER_ERROR,
+ // EVP_CipherFinal fails because of an authentication error
+ assert_crypto_result(EncryptionError::INVALID_PARAM,
apiDecrypt,
ret.params.get(),
ret.prvKey.c_str(),
// add different key
KeyAliasPair differentKeys = algo->keyGen(nullptr, "_wrong");
-
if (success) {
// some algorithms don't verify key validity
assert_crypto_positive(apiDecrypt,
assert_buffers_equal(*plain.get(), *decrypted, false);
} else {
- // different key should not be accepted
- assert_crypto_result(EncryptionError::SERVER_ERROR,
+ assert_crypto_result(EncryptionError::INVALID_PARAM,
apiDecrypt,
ret.params.get(),
differentKeys.prv.c_str(),
nullptr,
*ret.encrypted.get(),
&decrypted);
- }
+ }
// Cleanup before testing next algorithm. Ignore results because not all keys are present
ckmc_remove_alias(ret.prvKey.c_str());
ckmc_param_list_h handle = NULL;
assert_positive(ckmc_generate_new_params, algo->m_type, &handle);
ret.params = ParamListPtr(handle, ckmc_param_list_free);
- assert_crypto_result(EncryptionError::SERVER_ERROR,
+ assert_crypto_result(EncryptionError::INVALID_PARAM,
apiEncrypt,
ret.params.get(),
aliases.pub.c_str(),