From 10a1d34fc0d4dfe0dd6f5ec73f62dc1afa04af6c Mon Sep 17 00:00:00 2001 From: Dorjoy Chowdhury Date: Fri, 6 Sep 2024 01:57:30 +0600 Subject: crypto: Introduce x509 utils MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An utility function for getting fingerprint from X.509 certificate has been introduced. Implementation only provided using gnutls. Signed-off-by: Dorjoy Chowdhury [DB: fixed missing gnutls_x509_crt_deinit in success path] Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Daniel P. Berrangé --- include/crypto/x509-utils.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 include/crypto/x509-utils.h (limited to 'include/crypto/x509-utils.h') diff --git a/include/crypto/x509-utils.h b/include/crypto/x509-utils.h new file mode 100644 index 0000000000..4210dfbcfc --- /dev/null +++ b/include/crypto/x509-utils.h @@ -0,0 +1,22 @@ +/* + * X.509 certificate related helpers + * + * Copyright (c) 2024 Dorjoy Chowdhury + * + * This work is licensed under the terms of the GNU GPL, version 2 or + * (at your option) any later version. See the COPYING file in the + * top-level directory. + */ + +#ifndef QCRYPTO_X509_UTILS_H +#define QCRYPTO_X509_UTILS_H + +#include "crypto/hash.h" + +int qcrypto_get_x509_cert_fingerprint(uint8_t *cert, size_t size, + QCryptoHashAlgorithm hash, + uint8_t *result, + size_t *resultlen, + Error **errp); + +#endif -- cgit 1.4.1