mirror of
https://github.com/openharmony/third_party_fsverity-utils.git
synced 2026-07-01 10:05:35 -04:00
ab794fd565
This allows libfsverity to be used by software with other common licenses, e.g. LGPL, MIT, BSD, and Apache 2.0. It also avoids the incompatibility that some people perceive between OpenSSL and the GPL. See discussion at https://lkml.kernel.org/linux-fscrypt/20200211000037.189180-1-Jes.Sorensen@gmail.com/T/#u Link: https://lkml.kernel.org/linux-fscrypt/20200731191156.22602-1-ebiggers@kernel.org Acked-by: Chris Mason <clm@fb.com> # FB copyrighted material Acked-by: Jes Sorensen <jsorensen@fb.com> Signed-off-by: Eric Biggers <ebiggers@google.com>
46 lines
1.3 KiB
C
46 lines
1.3 KiB
C
// SPDX-License-Identifier: MIT
|
|
/*
|
|
* Test the hash algorithm-related libfsverity APIs.
|
|
*
|
|
* Copyright 2020 Google LLC
|
|
*
|
|
* Use of this source code is governed by an MIT-style
|
|
* license that can be found in the LICENSE file or at
|
|
* https://opensource.org/licenses/MIT.
|
|
*/
|
|
|
|
#include "utils.h"
|
|
|
|
#define SHA256_DIGEST_SIZE 32
|
|
#define SHA512_DIGEST_SIZE 64
|
|
|
|
int main(void)
|
|
{
|
|
install_libfsverity_error_handler();
|
|
|
|
ASSERT(libfsverity_get_digest_size(0) == -1);
|
|
ASSERT(libfsverity_get_hash_name(0) == NULL);
|
|
ASSERT(libfsverity_find_hash_alg_by_name("bad") == 0);
|
|
ASSERT(libfsverity_find_hash_alg_by_name(NULL) == 0);
|
|
|
|
ASSERT(libfsverity_get_digest_size(100) == -1);
|
|
ASSERT(libfsverity_get_hash_name(100) == NULL);
|
|
|
|
ASSERT(libfsverity_get_digest_size(FS_VERITY_HASH_ALG_SHA256) ==
|
|
SHA256_DIGEST_SIZE);
|
|
ASSERT(!strcmp("sha256",
|
|
libfsverity_get_hash_name(FS_VERITY_HASH_ALG_SHA256)));
|
|
ASSERT(libfsverity_find_hash_alg_by_name("sha256") ==
|
|
FS_VERITY_HASH_ALG_SHA256);
|
|
|
|
ASSERT(libfsverity_get_digest_size(FS_VERITY_HASH_ALG_SHA512) ==
|
|
SHA512_DIGEST_SIZE);
|
|
ASSERT(!strcmp("sha512",
|
|
libfsverity_get_hash_name(FS_VERITY_HASH_ALG_SHA512)));
|
|
ASSERT(libfsverity_find_hash_alg_by_name("sha512") ==
|
|
FS_VERITY_HASH_ALG_SHA512);
|
|
|
|
printf("test_hash_algs passed\n");
|
|
return 0;
|
|
}
|