Skip to content

Commit

Permalink
Add new error value for invalid optional block padding
Browse files Browse the repository at this point in the history
Given various other API changes intended for the next release that are
not backward compatible, this is just one more such change.
  • Loading branch information
leonlynch committed Oct 15, 2023
1 parent 6d86e77 commit 7365924
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/tr31.c
Original file line number Diff line number Diff line change
Expand Up @@ -1296,10 +1296,10 @@ int tr31_import(
// ISO 20038:2017, A.2.1 (page 10) indicates that the total length of all
// optional blocks must be a multiple of the encryption block size and
// does not make an exception for format version E.
// So we'll use the encryption block size which is determined by the TR-31
// format version.
// So we'll use the encryption block size which is determined by the key
// block format version.
if (opt_blk_len_total & (enc_block_size-1)) {
r = TR31_ERROR_INVALID_OPTIONAL_BLOCK_DATA;
r = TR31_ERROR_INVALID_OPTIONAL_BLOCK_PADDING;
goto error;
}

Expand Down Expand Up @@ -2737,6 +2737,7 @@ const char* tr31_get_error_string(enum tr31_error_t error)
case TR31_ERROR_INVALID_NUMBER_OF_OPTIONAL_BLOCKS_FIELD: return "Invalid number of optional blocks field";
case TR31_ERROR_INVALID_OPTIONAL_BLOCK_LENGTH: return "Invalid optional block length";
case TR31_ERROR_INVALID_OPTIONAL_BLOCK_DATA: return "Invalid optional block data";
case TR31_ERROR_INVALID_OPTIONAL_BLOCK_PADDING: return "Invalid optional block padding";
case TR31_ERROR_INVALID_PAYLOAD_FIELD: return "Invalid payload data field";
case TR31_ERROR_INVALID_AUTHENTICATOR_FIELD: return "Invalid authenticator data field";
case TR31_ERROR_UNSUPPORTED_KBPK_ALGORITHM: return "Unsupported key block protection key algorithm";
Expand Down
1 change: 1 addition & 0 deletions src/tr31.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ enum tr31_error_t {
TR31_ERROR_INVALID_NUMBER_OF_OPTIONAL_BLOCKS_FIELD, ///< Invalid number of optional blocks field
TR31_ERROR_INVALID_OPTIONAL_BLOCK_LENGTH, ///< Invalid optional block length
TR31_ERROR_INVALID_OPTIONAL_BLOCK_DATA, ///< Invalid optional block data
TR31_ERROR_INVALID_OPTIONAL_BLOCK_PADDING, ///< Invalid optional block padding
TR31_ERROR_INVALID_PAYLOAD_FIELD, ///< Invalid payload data field
TR31_ERROR_INVALID_AUTHENTICATOR_FIELD, ///< Invalid authenticator data field
TR31_ERROR_UNSUPPORTED_KBPK_ALGORITHM, ///< Unsupported key block protection key algorithm
Expand Down

0 comments on commit 7365924

Please sign in to comment.