mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-10 19:50:22 +01:00
We use clang-format for automatic formatting of our source files. Since clang-format is actively maintained software, the actual formatting depends on the used version of clang-format. That is unfortunate and painful, but really unavoidable unless clang-format would be strictly bug-compatible. So the version that we must use is from the current Fedora release, which is also tested by our gitlab-ci. Previously, we were using Fedora 34 with clang-tools-extra-12.0.1-1.fc34.x86_64. As Fedora 35 comes along, we need to update our formatting as Fedora 35 comes with version "13.0.0~rc1-1.fc35". An alternative would be to freeze on version 12, but that has different problems (like, it's cumbersome to rebuild clang 12 on Fedora 35 and it would be cumbersome for our developers which are on Fedora 35 to use a clang that they cannot easily install). The (differently painful) solution is to reformat from time to time, as we switch to a new Fedora (and thus clang) version. Usually we would expect that such a reformatting brings minor changes. But this time, the changes are huge. That is mentioned in the release notes [1] as Makes PointerAligment: Right working with AlignConsecutiveDeclarations. (Fixes https://llvm.org/PR27353) [1] https://releases.llvm.org/13.0.0/tools/clang/docs/ReleaseNotes.html#clang-format
96 lines
3.9 KiB
C
96 lines
3.9 KiB
C
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
/*
|
|
* Dan Williams <dcbw@redhat.com>
|
|
* Copyright (C) 2007 - 2014 Red Hat, Inc.
|
|
*/
|
|
|
|
#ifndef __NM_CRYPTO_H__
|
|
#define __NM_CRYPTO_H__
|
|
|
|
typedef enum {
|
|
NM_CRYPTO_CIPHER_UNKNOWN,
|
|
NM_CRYPTO_CIPHER_DES_EDE3_CBC,
|
|
NM_CRYPTO_CIPHER_DES_CBC,
|
|
NM_CRYPTO_CIPHER_AES_128_CBC,
|
|
NM_CRYPTO_CIPHER_AES_192_CBC,
|
|
NM_CRYPTO_CIPHER_AES_256_CBC,
|
|
} NMCryptoCipherType;
|
|
|
|
typedef struct {
|
|
const char *name;
|
|
NMCryptoCipherType cipher;
|
|
guint8 digest_len;
|
|
guint8 real_iv_len;
|
|
} NMCryptoCipherInfo;
|
|
|
|
const NMCryptoCipherInfo *nm_crypto_cipher_get_info(NMCryptoCipherType cipher);
|
|
const NMCryptoCipherInfo *nm_crypto_cipher_get_info_by_name(const char *cipher_name, gssize p_len);
|
|
|
|
typedef enum {
|
|
NM_CRYPTO_KEY_TYPE_UNKNOWN = 0,
|
|
NM_CRYPTO_KEY_TYPE_RSA,
|
|
NM_CRYPTO_KEY_TYPE_DSA
|
|
} NMCryptoKeyType;
|
|
|
|
typedef enum {
|
|
NM_CRYPTO_FILE_FORMAT_UNKNOWN = 0,
|
|
NM_CRYPTO_FILE_FORMAT_X509,
|
|
NM_CRYPTO_FILE_FORMAT_RAW_KEY,
|
|
NM_CRYPTO_FILE_FORMAT_PKCS12
|
|
} NMCryptoFileFormat;
|
|
|
|
/*****************************************************************************/
|
|
|
|
GBytes *nm_crypto_read_file(const char *filename, GError **error);
|
|
|
|
gboolean nm_crypto_load_and_verify_certificate(const char *file,
|
|
NMCryptoFileFormat *out_file_format,
|
|
GBytes **out_certificat,
|
|
GError **error);
|
|
|
|
gboolean nm_crypto_is_pkcs12_file(const char *file, GError **error);
|
|
|
|
gboolean nm_crypto_is_pkcs12_data(const guint8 *data, gsize len, GError **error);
|
|
|
|
NMCryptoFileFormat nm_crypto_verify_private_key_data(const guint8 *data,
|
|
gsize data_len,
|
|
const char *password,
|
|
gboolean *out_is_encrypted,
|
|
GError **error);
|
|
|
|
NMCryptoFileFormat nm_crypto_verify_private_key(const char *file,
|
|
const char *password,
|
|
gboolean *out_is_encrypted,
|
|
GError **error);
|
|
|
|
gboolean nm_crypto_randomize(void *buffer, gsize buffer_len, GError **error);
|
|
|
|
/*****************************************************************************/
|
|
|
|
GBytes *nmtst_crypto_decrypt_openssl_private_key_data(const guint8 *data,
|
|
gsize data_len,
|
|
const char *password,
|
|
NMCryptoKeyType *out_key_type,
|
|
GError **error);
|
|
|
|
GBytes *nmtst_crypto_decrypt_openssl_private_key(const char *file,
|
|
const char *password,
|
|
NMCryptoKeyType *out_key_type,
|
|
GError **error);
|
|
|
|
GBytes *nmtst_crypto_rsa_key_encrypt(const guint8 *data,
|
|
gsize len,
|
|
const char *in_password,
|
|
char **out_password,
|
|
GError **error);
|
|
|
|
guint8 *nmtst_crypto_make_des_aes_key(NMCryptoCipherType cipher,
|
|
const guint8 *salt,
|
|
gsize salt_len,
|
|
const char *password,
|
|
gsize *out_len,
|
|
GError **error);
|
|
|
|
/*****************************************************************************/
|
|
|
|
#endif /* __NM_CRYPTO_H__ */
|