Skip to content

Commit

Permalink
reopening #9754 after the changes where overrun
Browse files Browse the repository at this point in the history
changing the SPM error codes from invalid argument to bad state aligned to PSA spec
  • Loading branch information
Netanel Gonen committed Feb 25, 2019
1 parent 5f38878 commit b5b0e98
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ psa_status_t psa_mac_update(psa_mac_operation_t *operation,
};

if (operation->handle <= 0) {
return (PSA_ERROR_INVALID_ARGUMENT);
return (PSA_ERROR_BAD_STATE);
}

err = psa_call(operation->handle, in_vec, 2, NULL, 0);
Expand All @@ -153,7 +153,7 @@ psa_status_t psa_mac_sign_finish(psa_mac_operation_t *operation,
psa_outvec out_vec[2] = { { mac, mac_size }, { mac_length, sizeof(*mac_length) } };

if (operation->handle <= 0) {
return (PSA_ERROR_INVALID_ARGUMENT);
return (PSA_ERROR_BAD_STATE);
}

err_call = psa_call(operation->handle, in_vec, 2, out_vec, 2);
Expand All @@ -178,7 +178,7 @@ psa_status_t psa_mac_verify_finish(psa_mac_operation_t *operation,
};

if (operation->handle <= 0) {
return (PSA_ERROR_INVALID_ARGUMENT);
return (PSA_ERROR_BAD_STATE);
}

err_call = psa_call(operation->handle, in_vec, 3, NULL, 0);
Expand Down Expand Up @@ -248,7 +248,7 @@ psa_status_t psa_hash_update(psa_hash_operation_t *operation,
};

if (operation->handle <= 0) {
return (PSA_ERROR_INVALID_ARGUMENT);
return (PSA_ERROR_BAD_STATE);
}

err = psa_call(operation->handle, in_vec, 2, NULL, 0);
Expand All @@ -274,7 +274,7 @@ psa_status_t psa_hash_finish(psa_hash_operation_t *operation,
};

if (operation->handle <= 0) {
return (PSA_ERROR_INVALID_ARGUMENT);
return (PSA_ERROR_BAD_STATE);
}

err_call = psa_call(operation->handle, in_vec, 2, out_vec, 2);
Expand All @@ -299,7 +299,7 @@ psa_status_t psa_hash_verify(psa_hash_operation_t *operation,
};

if (operation->handle <= 0) {
return (PSA_ERROR_INVALID_ARGUMENT);
return (PSA_ERROR_BAD_STATE);
}

err_call = psa_call(operation->handle, in_vec, 3, NULL, 0);
Expand Down Expand Up @@ -1103,7 +1103,7 @@ psa_status_t psa_get_generator_capacity(const psa_crypto_generator_t *generator,
psa_outvec out_vec = { capacity, sizeof(*capacity) };

if (generator->handle <= 0) {
return (PSA_ERROR_INVALID_ARGUMENT);
return (PSA_ERROR_BAD_STATE);
}

err_call = psa_call(generator->handle, &in_vec, 1, &out_vec, 1);
Expand All @@ -1122,7 +1122,7 @@ psa_status_t psa_generator_read(psa_crypto_generator_t *generator,
psa_outvec out_vec = { output, output_length };

if (generator->handle <= 0) {
return (PSA_ERROR_INVALID_ARGUMENT);
return (PSA_ERROR_BAD_STATE);
}

err_call = psa_call(generator->handle, &in_vec, 1, &out_vec, 1);
Expand All @@ -1145,7 +1145,7 @@ psa_status_t psa_generator_import_key(psa_key_handle_t key_handle,
};

if (generator->handle <= 0) {
return (PSA_ERROR_INVALID_ARGUMENT);
return (PSA_ERROR_BAD_STATE);
}

err_call = psa_call(generator->handle, in_vec, 3, NULL, 0);
Expand Down Expand Up @@ -1306,7 +1306,7 @@ psa_status_t psa_cipher_generate_iv(psa_cipher_operation_t *operation,
};

if (operation->handle <= 0) {
return (PSA_ERROR_INVALID_ARGUMENT);
return (PSA_ERROR_BAD_STATE);
}

err = psa_call(operation->handle, &in_vec, 1, out_vec, 2);
Expand All @@ -1332,7 +1332,7 @@ psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation,
};

if (operation->handle <= 0) {
return (PSA_ERROR_INVALID_ARGUMENT);
return (PSA_ERROR_BAD_STATE);
}

err = psa_call(operation->handle, in_vec, 2, NULL, 0);
Expand Down Expand Up @@ -1370,7 +1370,7 @@ psa_status_t psa_cipher_update(psa_cipher_operation_t *operation,
};

if (operation->handle <= 0) {
return (PSA_ERROR_INVALID_ARGUMENT);
return (PSA_ERROR_BAD_STATE);
}

err = psa_call(operation->handle, in_vec, 2, out_vec, 2);
Expand Down Expand Up @@ -1403,7 +1403,7 @@ psa_status_t psa_cipher_finish(psa_cipher_operation_t *operation,
};

if (operation->handle <= 0) {
return (PSA_ERROR_INVALID_ARGUMENT);
return (PSA_ERROR_BAD_STATE);
}

err_call = psa_call(operation->handle, &in_vec, 1, out_vec, 2);
Expand Down

0 comments on commit b5b0e98

Please sign in to comment.