sdcp: uncrustify

This commit is contained in:
Joshua Grisham
2025-09-01 18:29:03 +02:00
parent 74e15c793b
commit 99ed5d139b
6 changed files with 66 additions and 54 deletions

View File

@@ -52,5 +52,6 @@ fp_dbg_hex_dump_gbytes (const gchar *log_domain,
{
gsize len = 0;
const guint8 *buf = g_bytes_get_data (gbytes, &len);
fp_dbg_hex_dump_bytes (log_domain, buf, len);
}

View File

@@ -343,6 +343,7 @@ fpi_sdcp_device_open_complete (FpSdcpDevice *self,
GError *error)
{
FpSdcpDeviceClass *cls = FP_SDCP_DEVICE_GET_CLASS (self);
g_autoptr(GBytes) application_secret = NULL;
if (!error)
@@ -482,6 +483,7 @@ fpi_sdcp_device_connect_complete (FpSdcpDevice *self,
{
FpSdcpDevicePrivate *priv = fp_sdcp_device_get_instance_private (self);
FpSdcpDeviceClass *cls = FP_SDCP_DEVICE_GET_CLASS (self);
g_autoptr(GBytes) application_secret = NULL;
FpiDeviceAction action;
@@ -506,8 +508,8 @@ fpi_sdcp_device_connect_complete (FpSdcpDevice *self,
}
if (!device_random || !claim || !mac ||
(!claim->model_certificate || !claim->device_public_key || !claim->firmware_public_key
|| !claim->firmware_hash || !claim->model_signature || !claim->device_signature))
(!claim->model_certificate || !claim->device_public_key || !claim->firmware_public_key ||
!claim->firmware_hash || !claim->model_signature || !claim->device_signature))
{
fp_dbg ("Driver did not provide all required information to callback; returning error instead.");
g_clear_pointer (&device_random, g_bytes_unref);
@@ -563,6 +565,7 @@ fpi_sdcp_device_reconnect_complete (FpSdcpDevice *self,
GError *error)
{
FpSdcpDevicePrivate *priv = fp_sdcp_device_get_instance_private (self);
g_autoptr(GBytes) application_secret = NULL;
FpiDeviceAction action;
@@ -687,6 +690,7 @@ fpi_sdcp_device_enroll_commit (FpSdcpDevice *self,
GError *error)
{
FpSdcpDeviceClass *cls = FP_SDCP_DEVICE_GET_CLASS (self);
g_autoptr(GBytes) application_secret = NULL;
GBytes *id = NULL;
FpPrint *print;
@@ -804,6 +808,7 @@ fpi_sdcp_device_identify_complete (FpSdcpDevice *self,
GError *error)
{
FpSdcpDevicePrivate *priv = fp_sdcp_device_get_instance_private (self);
g_autoptr(GBytes) application_secret = NULL;
FpPrint *identified_print;
FpiDeviceAction action;
@@ -822,8 +827,8 @@ fpi_sdcp_device_identify_complete (FpSdcpDevice *self,
}
/* No error and no valid id/mac provided means that there was no match from the device */
if (!id || !mac || g_bytes_get_size (id) != SDCP_ENROLLMENT_ID_SIZE
|| g_bytes_get_size (mac) != SDCP_MAC_SIZE)
if (!id || !mac || g_bytes_get_size (id) != SDCP_ENROLLMENT_ID_SIZE ||
g_bytes_get_size (mac) != SDCP_MAC_SIZE)
{
g_clear_pointer (&priv->identify_nonce, g_bytes_unref);
if (action == FPI_DEVICE_ACTION_VERIFY)

View File

@@ -44,6 +44,7 @@ static void
print_openssl_errors (void)
{
gulong e = 0;
e = ERR_get_error ();
while (e != 0)
{
@@ -79,10 +80,10 @@ fpi_sdcp_verify_signature (EVP_PKEY *pkey,
EVP_PKEY_CTX *pctx = NULL;
mdctx = EVP_MD_CTX_create ();
pctx = EVP_PKEY_CTX_new(pkey, NULL);
EVP_MD_CTX_set_pkey_ctx(mdctx, pctx);
pctx = EVP_PKEY_CTX_new (pkey, NULL);
EVP_MD_CTX_set_pkey_ctx (mdctx, pctx);
if (!EVP_DigestVerifyInit(mdctx, NULL, EVP_sha256 (), NULL, pkey))
if (!EVP_DigestVerifyInit (mdctx, NULL, EVP_sha256 (), NULL, pkey))
goto out_error;
if (label)
@@ -90,16 +91,20 @@ fpi_sdcp_verify_signature (EVP_PKEY *pkey,
goto out_error;
if (data_a)
{
if (!EVP_DigestVerifyUpdate (mdctx,
g_bytes_get_data (data_a, NULL),
g_bytes_get_size (data_a)))
goto out_error;
}
if (data_b)
{
if (!EVP_DigestVerifyUpdate (mdctx,
g_bytes_get_data (data_b, NULL),
g_bytes_get_size (data_b)))
goto out_error;
}
if (!EVP_DigestVerifyUpdate (mdctx,
g_bytes_get_data (signature, NULL),
@@ -128,7 +133,7 @@ static X509_STORE *
fpi_sdcp_get_truststore (GError **error)
{
g_autoptr(GResource) truststore_resource = NULL;
const gchar* truststore_resource_path = "/org/freedesktop/fprint/sdcp/truststore/";
const gchar *truststore_resource_path = "/org/freedesktop/fprint/sdcp/truststore/";
char **trustcert_names = NULL;
gchar *trustcert_path = NULL;
GBytes *trustcert_gb = NULL;
@@ -516,13 +521,13 @@ fpi_sdcp_get_private_pkey (GBytes *private_key,
/* set up parameters */
param_bld = OSSL_PARAM_BLD_new ();
if (!OSSL_PARAM_BLD_push_utf8_string(param_bld, OSSL_PKEY_PARAM_GROUP_NAME,
if (!OSSL_PARAM_BLD_push_utf8_string (param_bld, OSSL_PKEY_PARAM_GROUP_NAME,
SN_X9_62_prime256v1, sizeof (SN_X9_62_prime256v1)))
goto out_error;
if (!OSSL_PARAM_BLD_push_octet_string(param_bld, OSSL_PKEY_PARAM_PUB_KEY,
if (!OSSL_PARAM_BLD_push_octet_string (param_bld, OSSL_PKEY_PARAM_PUB_KEY,
public_key_buf, SDCP_PUBLIC_KEY_SIZE))
goto out_error;
if (!OSSL_PARAM_BLD_push_BN(param_bld, OSSL_PKEY_PARAM_PRIV_KEY, private_key_bn))
if (!OSSL_PARAM_BLD_push_BN (param_bld, OSSL_PKEY_PARAM_PRIV_KEY, private_key_bn))
goto out_error;
params = OSSL_PARAM_BLD_to_param (param_bld);
@@ -577,7 +582,7 @@ fpi_sdcp_get_public_pkey (GBytes *public_key,
if (!EVP_PKEY_fromdata_init (ctx))
goto out_error;
if (!EVP_PKEY_fromdata(ctx, &key, EVP_PKEY_PUBLIC_KEY, params))
if (!EVP_PKEY_fromdata (ctx, &key, EVP_PKEY_PUBLIC_KEY, params))
goto out_error;
EVP_PKEY_CTX_free (ctx);

View File

@@ -96,6 +96,7 @@ static void
fpi_sdcp_device_fake_reconnect (FpSdcpDevice *sdcp_device)
{
FpiSdcpDeviceFake *fake_device = FPI_SDCP_DEVICE_FAKE (sdcp_device);
g_autoptr(GError) error = NULL;
g_autoptr(GBytes) random = NULL;
g_autoptr(GBytes) reconnect_mac = g_bytes_from_hex (reconnect_mac_hex);

View File

@@ -19,12 +19,11 @@
#include "test-sdcp-utils.h"
static const guint8 from_hex_map[] =
{
static const guint8 from_hex_map[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // 01234567
0x08, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 89:;<=>?
0x00, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, // @abcdef
};
};
GBytes *
g_bytes_from_hex (const gchar *hex)
@@ -36,9 +35,9 @@ g_bytes_from_hex (const gchar *hex)
for (int i = 0; i < strlen (hex) - 1; i += 2)
{
b0 = ((guint8)hex[i+0] & 0x1F) ^ 0x10;
b1 = ((guint8)hex[i+1] & 0x1F) ^ 0x10;
bytes[i/2] = (guint8)(from_hex_map[b0] << 4) | from_hex_map[b1];
b0 = ((guint8) hex[i + 0] & 0x1F) ^ 0x10;
b1 = ((guint8) hex[i + 1] & 0x1F) ^ 0x10;
bytes[i / 2] = (guint8) (from_hex_map[b0] << 4) | from_hex_map[b1];
}
res = g_bytes_new_take (bytes, bytes_len);
@@ -50,6 +49,7 @@ FpiSdcpClaim *
sdcp_test_claim (void)
{
FpiSdcpClaim *claim = g_new0 (FpiSdcpClaim, 1);
claim->model_certificate = g_bytes_from_hex (model_certificate_hex);
claim->device_public_key = g_bytes_from_hex (device_public_key_hex);
claim->firmware_public_key = g_bytes_from_hex (firmware_public_key_hex);