summaryrefslogtreecommitdiffstats
path: root/lib/digsig.c
AgeCommit message (Expand)Author
2020-11-20crypto: sha - split sha.h into sha1.h and sha2.hEric Biggers
2019-07-10Revert "Merge tag 'keys-acl-20190703' of git://git.kernel.org/pub/scm/linux/k...Linus Torvalds
2019-07-08Merge tag 'keys-acl-20190703' of git://git.kernel.org/pub/scm/linux/kernel/gi...Linus Torvalds
2019-07-08Merge tag 'keys-namespace-20190627' of git://git.kernel.org/pub/scm/linux/ker...Linus Torvalds
2019-06-27keys: Replace uid/gid/perm permissions checking with an ACLDavid Howells
2019-06-26keys: Add a 'recurse' flag for keyring searchesDavid Howells
2019-06-05treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441Thomas Gleixner
2019-04-25crypto: shash - remove shash_desc::flagsEric Biggers
2017-10-12lib/digsig: fix dereference of NULL user_key_payloadEric Biggers
2017-03-02KEYS: Differentiate uses of rcu_dereference_key() and user_key_payload()David Howells
2016-05-31lib/digsig: digsig_verify_rsa(): return -EINVAL if modulo length is zeroNicolai Stange
2016-05-31lib/mpi: mpi_read_from_buffer(): return error codeNicolai Stange
2015-10-21KEYS: Merge the type-specific data with the payload dataDavid Howells
2014-06-04lib/digsig.c: kernel-doc warning fixesFabian Frederick
2013-11-13lib/digsig.c: use ERR_CAST inlined function instead of ERR_PTR(PTR_ERR(...))Duan Jiong
2013-02-21Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/...Linus Torvalds
2013-02-01digsig: remove unnecessary memory allocation and copyingDmitry Kasatkin
2013-02-01digsig: Fix memory leakage in digsig_verify_rsa()YOSHIFUJI Hideaki
2012-09-13digsig: add hash size comparision on signature verificationDmitry Kasatkin
2012-02-02lib/digsig: checks for NULL return valueDmitry Kasatkin
2012-02-02lib/digsig: pkcs_1_v1_5_decode_emsa cleanupDmitry Kasatkin
2012-02-02lib/digsig: additional sanity checks against badly formated key payloadDmitry Kasatkin
2011-11-09crypto: digital signature verification supportDmitry Kasatkin
n96' href='#n96'>96 97 98
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef NETDATA_RRDENGINELIB_H
#define NETDATA_RRDENGINELIB_H

#include "libnetdata/libnetdata.h"

/* Forward declarations */
struct rrdengine_instance;

#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)

#define BITS_PER_ULONG (sizeof(unsigned long) * 8)

#define ALIGN_BYTES_FLOOR(x) (((x) / RRDENG_BLOCK_SIZE) * RRDENG_BLOCK_SIZE)
#define ALIGN_BYTES_CEILING(x) ((((x) + RRDENG_BLOCK_SIZE - 1) / RRDENG_BLOCK_SIZE) * RRDENG_BLOCK_SIZE)

#define ROUND_USEC_TO_SEC(x) (((x) + USEC_PER_SEC / 2 - 1) / USEC_PER_SEC)

typedef uintptr_t rrdeng_stats_t;

#ifdef __ATOMIC_RELAXED
#define rrd_atomic_fetch_add(p, n) __atomic_fetch_add(p, n, __ATOMIC_RELAXED)
#define rrd_atomic_add_fetch(p, n) __atomic_add_fetch(p, n, __ATOMIC_RELAXED)
#else
#define rrd_atomic_fetch_add(p, n) __sync_fetch_and_add(p, n)
#define rrd_atomic_add_fetch(p, n) __sync_add_and_fetch(p, n)
#endif

#define rrd_stat_atomic_add(p, n) rrd_atomic_fetch_add(p, n)

/* returns -1 if it didn't find the first cleared bit, the position otherwise. Starts from LSB. */
static inline int find_first_zero(unsigned x)
{
    return ffs((int)(~x)) - 1;
}

/* Starts from LSB. */
static inline uint8_t check_bit(unsigned x, size_t pos)
{
    return !!(x & (1 << pos));
}

/* Starts from LSB. val is 0 or 1 */
static inline void modify_bit(unsigned *x, unsigned pos, uint8_t val)
{
    switch(val) {
    case 0:
        *x &= ~(1U << pos);
        break;
    case 1:
        *x |= 1U << pos;
        break;
    default:
        netdata_log_error("modify_bit() called with invalid argument.");
        break;
    }
}

#define RRDENG_PATH_MAX (FILENAME_MAX + 1)

/* returns old *ptr value */
static inline unsigned long ulong_compare_and_swap(volatile unsigned long *ptr,
                                                   unsigned long oldval, unsigned long newval)
{
    return __sync_val_compare_and_swap(ptr, oldval, newval);
}

#ifndef O_DIRECT
/* Workaround for OS X */
#define O_DIRECT (0)
#endif

static inline int crc32cmp(void *crcp, uLong crc)
{
    return (*(uint32_t *)crcp != crc);
}

static inline void crc32set(void *crcp, uLong crc)
{
    *(uint32_t *)crcp = crc;
}

int check_file_properties(uv_file file, uint64_t *file_size, size_t min_size);
int open_file_for_io(char *path, int flags, uv_file *file, int direct);
static inline int open_file_direct_io(char *path, int flags, uv_file *file)
{
    return open_file_for_io(path, flags, file, 1);
}
static inline int open_file_buffered_io(char *path, int flags, uv_file *file)
{
    return open_file_for_io(path, flags, file, 0);
}
int compute_multidb_diskspace();
int is_legacy_child(const char *machine_guid);

#endif /* NETDATA_RRDENGINELIB_H */