Skip to content

Commit

Permalink
Use imaevm_signhash if available
Browse files Browse the repository at this point in the history
sign_hash is deprecated in the newest libimaevm

Resolves: rpm-software-management#3419
  • Loading branch information
ffesti committed Nov 20, 2024
1 parent 39df85d commit c227360
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ endif()

if (WITH_IMAEVM)
list(APPEND REQFUNCS lsetxattr)
list(APPEND OPTFUNCS imaevm_signhash)
add_library(IMA::IMA UNKNOWN IMPORTED)
find_path(IMA_INCLUDE_DIR NAMES imaevm.h REQUIRED)
find_library(IMA_LIBRARY NAMES imaevm REQUIRED)
Expand Down
9 changes: 9 additions & 0 deletions sign/rpmsignfiles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,16 @@ const char *key, char *keypass, uint32_t *siglenp)
signature[0] = '\x03';

/* calculate file signature */
#if HAVE_IMAEVM_SIGNHASH
imaevm_ossl_access access_info = {
.type = IMAEVM_OSSL_ACCESS_TYPE_NONE,
};
siglen = imaevm_signhash(algo, fdigest, diglen, key, keypass, signature+1, 0, &access_info, 0);

#else
siglen = sign_hash(algo, fdigest, diglen, key, keypass, signature+1);
#endif

if (siglen < 0) {
rpmlog(RPMLOG_ERR, _("sign_hash failed\n"));
return NULL;
Expand Down

0 comments on commit c227360

Please sign in to comment.