Implement verify_signature, check_integrity, and get_system_profile functions
This commit is contained in:
@@ -66,4 +66,21 @@ int runtime_exists(void);
|
||||
|
||||
int is_process_root(void);
|
||||
|
||||
/*
|
||||
* get_system_profile
|
||||
*
|
||||
* DESCRIPTION: get_system_profile fetches the system profile, which contains information about the architecture and libc implementation.
|
||||
* PARAMETERS:
|
||||
* None. (void)
|
||||
* RETURN VALUES:
|
||||
* A pointer to a string containing the system profile (e.g., "x86_64-musl").
|
||||
* CAVEATS:
|
||||
* None.
|
||||
* EXAMPLE:
|
||||
* char *profile = get_system_profile();
|
||||
* infolog(profile);
|
||||
*/
|
||||
|
||||
char *get_system_profile(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -95,4 +95,45 @@ int print_hash(uchar *hash, uint length);
|
||||
|
||||
int stash_hash(char *stored_hash, unsigned int stored_hash_size, const uchar *hash, uint length);
|
||||
|
||||
/*
|
||||
* verify_signature
|
||||
*
|
||||
* DESCRIPTION: Checks if a package's signature is valid against the trusted keyring
|
||||
* PARAMETERS:
|
||||
* char PACKAGE[] -> The package file to verify
|
||||
* char SIGNATURE[] -> The signature file to check against
|
||||
* RETURN VALUES:
|
||||
* 0 on valid signature, 1 on invalid signature, 2 on file not found
|
||||
* CAVEATS:
|
||||
* None
|
||||
* EXAMPLE:
|
||||
* if (verify_signature("package.tar", "package.tar.sig") != 0) {
|
||||
* errlog("invalid package signature");
|
||||
* return(EXIT_FAILURE);
|
||||
* }
|
||||
*/
|
||||
|
||||
int verify_signature(char PACKAGE[], char SIGNATURE[]);
|
||||
|
||||
/*
|
||||
* check_integrity
|
||||
*
|
||||
* DESCRIPTION: Verifies a package's SHA256 checksum against the expected value
|
||||
* PARAMETERS:
|
||||
* char PACKAGE[] -> The package file to check
|
||||
* char EXPECTED_HASH[] -> The expected SHA256 hash
|
||||
* RETURN VALUES:
|
||||
* 0 on hash match, 1 on hash mismatch, 2 on file not found or hash calculation error
|
||||
* CAVEATS:
|
||||
* None
|
||||
* EXAMPLE:
|
||||
* char *expected = "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592";
|
||||
* if (check_integrity("package.tar", expected) != 0) {
|
||||
* errlog("package integrity check failed");
|
||||
* return(EXIT_FAILURE);
|
||||
* }
|
||||
*/
|
||||
|
||||
int check_integrity(char PACKAGE[], char EXPECTED_HASH[]);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user