mirror of
https://github.com/cryb-to/cryb-to.git
synced 2025-01-03 10:21:10 +00:00
Big reorganization and cleanup
This commit is contained in:
parent
c030e63ef2
commit
06a757e878
148 changed files with 2349 additions and 790 deletions
|
@ -1,6 +1,6 @@
|
||||||
AC_PREREQ([2.63])
|
AC_PREREQ([2.63])
|
||||||
AC_INIT([cryb.to], [devel], [des@des.no], [cryb-to], [http://cryb.to/])
|
AC_INIT([cryb.to], [devel], [des@des.no], [cryb-to], [http://cryb.to/])
|
||||||
AC_CONFIG_SRCDIR([include/cryb/to.h])
|
AC_CONFIG_SRCDIR([include/cryb/core.h])
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
AM_INIT_AUTOMAKE([foreign no-dist-gzip dist-xz])
|
AM_INIT_AUTOMAKE([foreign no-dist-gzip dist-xz])
|
||||||
AM_CONFIG_HEADER([include/config.h])
|
AM_CONFIG_HEADER([include/config.h])
|
||||||
|
@ -83,9 +83,8 @@ AC_SUBST(RT_LIBS)
|
||||||
AC_ARG_ENABLE([doc],
|
AC_ARG_ENABLE([doc],
|
||||||
AC_HELP_STRING([--disable-doc],
|
AC_HELP_STRING([--disable-doc],
|
||||||
[do not build the documentation]),
|
[do not build the documentation]),
|
||||||
[],
|
[with_doc=$enableval])
|
||||||
[with_doc=yes])
|
AM_CONDITIONAL([WITH_DOC], [test x"$with_doc" != x"no"])
|
||||||
AM_CONDITIONAL([WITH_DOC], [test x"$with_doc" = x"yes"])
|
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
#
|
#
|
||||||
|
|
|
@ -15,6 +15,7 @@ cryb_HEADERS += \
|
||||||
algorithm.h \
|
algorithm.h \
|
||||||
attributes.h \
|
attributes.h \
|
||||||
bitwise.h \
|
bitwise.h \
|
||||||
|
core.h \
|
||||||
ctype.h \
|
ctype.h \
|
||||||
endian.h \
|
endian.h \
|
||||||
memset_s.h \
|
memset_s.h \
|
||||||
|
@ -22,7 +23,6 @@ cryb_HEADERS += \
|
||||||
strlcat.h \
|
strlcat.h \
|
||||||
strlcmp.h \
|
strlcmp.h \
|
||||||
strlcpy.h \
|
strlcpy.h \
|
||||||
version.h \
|
|
||||||
wstring.h \
|
wstring.h \
|
||||||
\
|
\
|
||||||
to.h
|
to.h
|
||||||
|
@ -84,10 +84,10 @@ endif CRYB_MPI
|
||||||
|
|
||||||
if CRYB_OATH
|
if CRYB_OATH
|
||||||
cryb_HEADERS += \
|
cryb_HEADERS += \
|
||||||
hotp.h \
|
|
||||||
oath_constants.h \
|
oath_constants.h \
|
||||||
|
oath_hotp.h \
|
||||||
|
oath_totp.h \
|
||||||
oath_types.h \
|
oath_types.h \
|
||||||
totp.h \
|
|
||||||
\
|
\
|
||||||
oath.h
|
oath.h
|
||||||
endif CRYB_OATH
|
endif CRYB_OATH
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_AES_H_INCLUDED
|
#ifndef CRYB_AES_H_INCLUDED
|
||||||
#define CRYB_AES_H_INCLUDED
|
#define CRYB_AES_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/cipher.h>
|
#include <cryb/cipher.h>
|
||||||
|
|
||||||
#define AES_BLOCK_LEN 16
|
#define AES_BLOCK_LEN 16
|
||||||
|
|
|
@ -31,6 +31,10 @@
|
||||||
#ifndef CRYB_ALGORITHM_H_INCLUDED
|
#ifndef CRYB_ALGORITHM_H_INCLUDED
|
||||||
#define CRYB_ALGORITHM_H_INCLUDED
|
#define CRYB_ALGORITHM_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef enum algorithm_type {
|
typedef enum algorithm_type {
|
||||||
digest_algorithm,
|
digest_algorithm,
|
||||||
mac_algorithm,
|
mac_algorithm,
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_ATTRIBUTES_H_INCLUDED
|
#ifndef CRYB_ATTRIBUTES_H_INCLUDED
|
||||||
#define CRYB_ATTRIBUTES_H_INCLUDED
|
#define CRYB_ATTRIBUTES_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__GNUC__) || defined(__clang__)
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
# define CRYB_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg)))
|
# define CRYB_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg)))
|
||||||
# define CRYB_NORETURN __attribute__((noreturn))
|
# define CRYB_NORETURN __attribute__((noreturn))
|
||||||
|
|
|
@ -31,6 +31,10 @@
|
||||||
#ifndef CRYB_BITWISE_H_INCLUDED
|
#ifndef CRYB_BITWISE_H_INCLUDED
|
||||||
#define CRYB_BITWISE_H_INCLUDED
|
#define CRYB_BITWISE_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CRYB_ROL_ROR(N) \
|
#define CRYB_ROL_ROR(N) \
|
||||||
static inline uint##N##_t rol##N(uint##N##_t i, int n) \
|
static inline uint##N##_t rol##N(uint##N##_t i, int n) \
|
||||||
{ \
|
{ \
|
||||||
|
|
|
@ -30,6 +30,12 @@
|
||||||
#ifndef CRYB_CIPHER_H_INCLUDED
|
#ifndef CRYB_CIPHER_H_INCLUDED
|
||||||
#define CRYB_CIPHER_H_INCLUDED
|
#define CRYB_CIPHER_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char *cryb_cipher_version(void);
|
||||||
|
|
||||||
#define cipher_ctx cryb_cipher_ctx
|
#define cipher_ctx cryb_cipher_ctx
|
||||||
#define cipher_init_func cryb_cipher_init_func
|
#define cipher_init_func cryb_cipher_init_func
|
||||||
#define cipher_update_func cryb_cipher_update_func
|
#define cipher_update_func cryb_cipher_update_func
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2014-2016 Dag-Erling Smørgrav
|
* Copyright (c) 2015 Dag-Erling Smørgrav
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -27,9 +27,13 @@
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CRYB_VERSION_H_INCLUDED
|
#ifndef CRYB_CORE_H_INCLUDED
|
||||||
#define CRYB_VERSION_H_INCLUDED
|
#define CRYB_CORE_H_INCLUDED
|
||||||
|
|
||||||
#define CRYB_VERSION 20160321
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char *cryb_core_version(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_COVERAGE_H_INCLUDED
|
#ifndef CRYB_COVERAGE_H_INCLUDED
|
||||||
#define CRYB_COVERAGE_H_INCLUDED
|
#define CRYB_COVERAGE_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if _BullseyeCoverage
|
#if _BullseyeCoverage
|
||||||
# define CRYB_COVERAGE 1
|
# define CRYB_COVERAGE 1
|
||||||
# define CRYB_DISABLE_COVERAGE _Pragma("BullseyeCoverage save off")
|
# define CRYB_DISABLE_COVERAGE _Pragma("BullseyeCoverage save off")
|
||||||
|
|
|
@ -30,6 +30,12 @@
|
||||||
#ifndef CRYB_CPE_H_INCLUDED
|
#ifndef CRYB_CPE_H_INCLUDED
|
||||||
#define CRYB_CPE_H_INCLUDED
|
#define CRYB_CPE_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char *cryb_cpe_version(void);
|
||||||
|
|
||||||
#define cpe_name cryb_cpe_name
|
#define cpe_name cryb_cpe_name
|
||||||
|
|
||||||
#define cpe22_ver 202
|
#define cpe22_ver 202
|
||||||
|
@ -71,6 +77,19 @@ typedef struct cpe_name {
|
||||||
wchar_t *attr[];
|
wchar_t *attr[];
|
||||||
} cpe_name;
|
} cpe_name;
|
||||||
|
|
||||||
|
#define cpe_clone cryb_cpe_clone
|
||||||
|
#define cpe_copy_attr cryb_cpe_copy_attr
|
||||||
|
#define cpe_destroy cryb_cpe_destroy
|
||||||
|
#define cpe_new cryb_cpe_new
|
||||||
|
#define cpe_bind_to_fs cryb_cpe_bind_to_fs
|
||||||
|
#define cpe_unbind_fs cryb_cpe_unbind_fs
|
||||||
|
#define cpe_upgrade22 cryb_cpe_upgrade22
|
||||||
|
#define cpe_upgrade cryb_cpe_upgrade
|
||||||
|
#define cpe_bind_to_uri cryb_cpe_bind_to_uri
|
||||||
|
#define cpe_unbind_uri cryb_cpe_unbind_uri
|
||||||
|
#define cpe_from_wfn cryb_cpe_from_wfn
|
||||||
|
#define cpe_to_wfn cryb_cpe_to_wfn
|
||||||
|
|
||||||
cpe_name *cpe_new(void);
|
cpe_name *cpe_new(void);
|
||||||
void cpe_destroy(cpe_name *);
|
void cpe_destroy(cpe_name *);
|
||||||
cpe_name *cpe_clone(const cpe_name *);
|
cpe_name *cpe_clone(const cpe_name *);
|
||||||
|
@ -86,4 +105,8 @@ wstring *cpe_bind_to_uri(const cpe_name *);
|
||||||
cpe_name *cpe_from_wfn(const wchar_t *);
|
cpe_name *cpe_from_wfn(const wchar_t *);
|
||||||
wchar_t *cpe_to_wfn(const cpe_name *);
|
wchar_t *cpe_to_wfn(const cpe_name *);
|
||||||
|
|
||||||
|
/* not part of public API */
|
||||||
|
int cpe_copy_attr(cpe_name *, const cpe_name *, int, int);
|
||||||
|
cpe_name *cpe_upgrade22(const cpe_name *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_CTYPE_H_INCLUDED
|
#ifndef CRYB_CTYPE_H_INCLUDED
|
||||||
#define CRYB_CTYPE_H_INCLUDED
|
#define CRYB_CTYPE_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Evaluates to non-zero if the argument is a digit.
|
* Evaluates to non-zero if the argument is a digit.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -31,6 +31,12 @@
|
||||||
#ifndef CRYB_DIGEST_H_INCLUDED
|
#ifndef CRYB_DIGEST_H_INCLUDED
|
||||||
#define CRYB_DIGEST_H_INCLUDED
|
#define CRYB_DIGEST_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char *cryb_digest_version(void);
|
||||||
|
|
||||||
#define digest_ctx cryb_digest_ctx
|
#define digest_ctx cryb_digest_ctx
|
||||||
#define digest_init_func cryb_digest_init_func
|
#define digest_init_func cryb_digest_init_func
|
||||||
#define digest_update_func cryb_digest_update_func
|
#define digest_update_func cryb_digest_update_func
|
||||||
|
|
|
@ -30,7 +30,13 @@
|
||||||
#ifndef CRYB_ENC_H_INCLUDED
|
#ifndef CRYB_ENC_H_INCLUDED
|
||||||
#define CRYB_ENC_H_INCLUDED
|
#define CRYB_ENC_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/rfc3986.h>
|
#include <cryb/rfc3986.h>
|
||||||
#include <cryb/rfc4648.h>
|
#include <cryb/rfc4648.h>
|
||||||
|
|
||||||
|
const char *cryb_enc_version(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_ENDIAN_H_INCLUDED
|
#ifndef CRYB_ENDIAN_H_INCLUDED
|
||||||
#define CRYB_ENDIAN_H_INCLUDED
|
#define CRYB_ENDIAN_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAVE_SYS_ENDIAN_H
|
#if HAVE_SYS_ENDIAN_H
|
||||||
#include <sys/endian.h>
|
#include <sys/endian.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,16 +30,26 @@
|
||||||
#ifndef CRYB_HASH_H_INCLUDED
|
#ifndef CRYB_HASH_H_INCLUDED
|
||||||
#define CRYB_HASH_H_INCLUDED
|
#define CRYB_HASH_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char *cryb_hash_version(void);
|
||||||
|
|
||||||
|
#define adler32_hash cryb_adler32_hash
|
||||||
|
#define fletcher16_hash cryb_fletcher16_hash
|
||||||
|
#define fletcher32_hash cryb_fletcher32_hash
|
||||||
|
#define fletcher64_hash cryb_fletcher64_hash
|
||||||
|
#define murmur3_32_hash cryb_murmur3_32_hash
|
||||||
#define pearson_hash cryb_pearson_hash
|
#define pearson_hash cryb_pearson_hash
|
||||||
#define pearson_hash_str cryb_pearson_hash_str
|
#define pearson_hash_str cryb_pearson_hash_str
|
||||||
#define murmur3_32_hash cryb_murmur3_32_hash
|
|
||||||
|
|
||||||
uint32_t adler32_hash(const void *, size_t);
|
uint32_t adler32_hash(const void *, size_t);
|
||||||
uint16_t fletcher16_hash(const void *, size_t);
|
uint16_t fletcher16_hash(const void *, size_t);
|
||||||
uint32_t fletcher32_hash(const void *, size_t);
|
uint32_t fletcher32_hash(const void *, size_t);
|
||||||
uint64_t fletcher64_hash(const void *, size_t);
|
uint64_t fletcher64_hash(const void *, size_t);
|
||||||
|
uint32_t murmur3_32_hash(const void *, size_t, uint32_t);
|
||||||
uint8_t pearson_hash(const void *, size_t);
|
uint8_t pearson_hash(const void *, size_t);
|
||||||
uint8_t pearson_hash_str(const char *);
|
uint8_t pearson_hash_str(const char *);
|
||||||
uint32_t murmur3_32_hash(const void *, size_t, uint32_t);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_HMAC_H_INCLUDED
|
#ifndef CRYB_HMAC_H_INCLUDED
|
||||||
#define CRYB_HMAC_H_INCLUDED
|
#define CRYB_HMAC_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/hmac_sha1.h>
|
#include <cryb/hmac_sha1.h>
|
||||||
#include <cryb/hmac_sha224.h>
|
#include <cryb/hmac_sha224.h>
|
||||||
#include <cryb/hmac_sha256.h>
|
#include <cryb/hmac_sha256.h>
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_HMAC_SHA1_H_INCLUDED
|
#ifndef CRYB_HMAC_SHA1_H_INCLUDED
|
||||||
#define CRYB_HMAC_SHA1_H_INCLUDED
|
#define CRYB_HMAC_SHA1_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/sha1.h>
|
#include <cryb/sha1.h>
|
||||||
|
|
||||||
#define HMAC_SHA1_MAC_LEN 20
|
#define HMAC_SHA1_MAC_LEN 20
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_HMAC_SHA224_H_INCLUDED
|
#ifndef CRYB_HMAC_SHA224_H_INCLUDED
|
||||||
#define CRYB_HMAC_SHA224_H_INCLUDED
|
#define CRYB_HMAC_SHA224_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/sha224.h>
|
#include <cryb/sha224.h>
|
||||||
|
|
||||||
#define HMAC_SHA224_MAC_LEN 28
|
#define HMAC_SHA224_MAC_LEN 28
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_HMAC_SHA256_H_INCLUDED
|
#ifndef CRYB_HMAC_SHA256_H_INCLUDED
|
||||||
#define CRYB_HMAC_SHA256_H_INCLUDED
|
#define CRYB_HMAC_SHA256_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/sha256.h>
|
#include <cryb/sha256.h>
|
||||||
|
|
||||||
#define HMAC_SHA256_MAC_LEN 32
|
#define HMAC_SHA256_MAC_LEN 32
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_HMAC_SHA384_H_INCLUDED
|
#ifndef CRYB_HMAC_SHA384_H_INCLUDED
|
||||||
#define CRYB_HMAC_SHA384_H_INCLUDED
|
#define CRYB_HMAC_SHA384_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/sha384.h>
|
#include <cryb/sha384.h>
|
||||||
|
|
||||||
#define HMAC_SHA384_MAC_LEN 48
|
#define HMAC_SHA384_MAC_LEN 48
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_HMAC_SHA512_H_INCLUDED
|
#ifndef CRYB_HMAC_SHA512_H_INCLUDED
|
||||||
#define CRYB_HMAC_SHA512_H_INCLUDED
|
#define CRYB_HMAC_SHA512_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/sha512.h>
|
#include <cryb/sha512.h>
|
||||||
|
|
||||||
#define HMAC_SHA512_MAC_LEN 64
|
#define HMAC_SHA512_MAC_LEN 64
|
||||||
|
|
|
@ -34,6 +34,10 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/attributes.h>
|
#include <cryb/attributes.h>
|
||||||
#include <cryb/coverage.h>
|
#include <cryb/coverage.h>
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,12 @@
|
||||||
#ifndef CRYB_MAC_H_INCLUDED
|
#ifndef CRYB_MAC_H_INCLUDED
|
||||||
#define CRYB_MAC_H_INCLUDED
|
#define CRYB_MAC_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/hmac.h>
|
#include <cryb/hmac.h>
|
||||||
|
|
||||||
|
const char *cryb_mac_version(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_MD2_H_INCLUDED
|
#ifndef CRYB_MD2_H_INCLUDED
|
||||||
#define CRYB_MD2_H_INCLUDED
|
#define CRYB_MD2_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/digest.h>
|
#include <cryb/digest.h>
|
||||||
|
|
||||||
#define MD2_BLOCK_LEN 16
|
#define MD2_BLOCK_LEN 16
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_MD4_H_INCLUDED
|
#ifndef CRYB_MD4_H_INCLUDED
|
||||||
#define CRYB_MD4_H_INCLUDED
|
#define CRYB_MD4_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/digest.h>
|
#include <cryb/digest.h>
|
||||||
|
|
||||||
#define MD4_BLOCK_LEN 64
|
#define MD4_BLOCK_LEN 64
|
||||||
|
|
|
@ -31,6 +31,10 @@
|
||||||
#ifndef CRYB_MD5_H_INCLUDED
|
#ifndef CRYB_MD5_H_INCLUDED
|
||||||
#define CRYB_MD5_H_INCLUDED
|
#define CRYB_MD5_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/digest.h>
|
#include <cryb/digest.h>
|
||||||
|
|
||||||
#define MD5_BLOCK_LEN 64
|
#define MD5_BLOCK_LEN 64
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_MEMSET_S_H_INCLUDED
|
#ifndef CRYB_MEMSET_S_H_INCLUDED
|
||||||
#define CRYB_MEMSET_S_H_INCLUDED
|
#define CRYB_MEMSET_S_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
int cryb_memset_s(void *, size_t, int, size_t);
|
int cryb_memset_s(void *, size_t, int, size_t);
|
||||||
|
|
||||||
#if !HAVE_MEMSET_S
|
#if !HAVE_MEMSET_S
|
||||||
|
|
|
@ -30,6 +30,32 @@
|
||||||
#ifndef CRYB_MPI_H_INCLUDED
|
#ifndef CRYB_MPI_H_INCLUDED
|
||||||
#define CRYB_MPI_H_INCLUDED
|
#define CRYB_MPI_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char *cryb_mpi_version(void);
|
||||||
|
|
||||||
|
#define mpi_add cryb_mpi_add
|
||||||
|
#define mpi_add_abs cryb_mpi_add_abs
|
||||||
|
#define mpi_cmp cryb_mpi_cmp
|
||||||
|
#define mpi_cmp_abs cryb_mpi_cmp_abs
|
||||||
|
#define mpi_copy cryb_mpi_copy
|
||||||
|
#define mpi_destroy cryb_mpi_destroy
|
||||||
|
#define mpi_eq cryb_mpi_eq
|
||||||
|
#define mpi_eq_abs cryb_mpi_eq_abs
|
||||||
|
#define mpi_grow cryb_mpi_grow
|
||||||
|
#define mpi_init cryb_mpi_init
|
||||||
|
#define mpi_load cryb_mpi_load
|
||||||
|
#define mpi_lshift cryb_mpi_lshift
|
||||||
|
#define mpi_negate cryb_mpi_negate
|
||||||
|
#define mpi_rshift cryb_mpi_rshift
|
||||||
|
#define mpi_set cryb_mpi_set
|
||||||
|
#define mpi_sub cryb_mpi_sub
|
||||||
|
#define mpi_sub_abs cryb_mpi_sub_abs
|
||||||
|
#define mpi_swap cryb_mpi_swap
|
||||||
|
#define mpi_zero cryb_mpi_zero
|
||||||
|
|
||||||
#define CRYB_MPI_SWORDS 16
|
#define CRYB_MPI_SWORDS 16
|
||||||
|
|
||||||
typedef struct cryb_mpi {
|
typedef struct cryb_mpi {
|
||||||
|
|
|
@ -31,8 +31,23 @@
|
||||||
#ifndef OATH_H_INCLUDED
|
#ifndef OATH_H_INCLUDED
|
||||||
#define OATH_H_INCLUDED
|
#define OATH_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/oath_constants.h>
|
#include <cryb/oath_constants.h>
|
||||||
#include <cryb/oath_types.h>
|
#include <cryb/oath_types.h>
|
||||||
|
#include <cryb/oath_hotp.h>
|
||||||
|
#include <cryb/oath_totp.h>
|
||||||
|
|
||||||
|
const char *cryb_oath_version(void);
|
||||||
|
|
||||||
|
#define oath_key_alloc cryb_oath_key_alloc
|
||||||
|
#define oath_key_create cryb_oath_key_create
|
||||||
|
#define oath_key_dummy cryb_oath_key_dummy
|
||||||
|
#define oath_key_from_uri cryb_oath_key_from_uri
|
||||||
|
#define oath_key_free cryb_oath_key_free
|
||||||
|
#define oath_key_to_uri cryb_oath_key_to_uri
|
||||||
|
|
||||||
struct oath_key *oath_key_alloc(void);
|
struct oath_key *oath_key_alloc(void);
|
||||||
struct oath_key *oath_key_create(const char *, enum oath_mode,
|
struct oath_key *oath_key_create(const char *, enum oath_mode,
|
||||||
|
@ -46,12 +61,4 @@ struct oath_key *oath_key_dummy(enum oath_mode, enum oath_hash, unsigned int);
|
||||||
|
|
||||||
enum oath_mode oath_mode(const char *);
|
enum oath_mode oath_mode(const char *);
|
||||||
|
|
||||||
unsigned int oath_hotp(const uint8_t *, size_t, uint64_t, unsigned int);
|
|
||||||
unsigned int oath_hotp_current(struct oath_key *);
|
|
||||||
int oath_hotp_match(struct oath_key *, unsigned int, int);
|
|
||||||
|
|
||||||
unsigned int oath_totp(const uint8_t *, size_t, unsigned int);
|
|
||||||
unsigned int oath_totp_current(const struct oath_key *);
|
|
||||||
int oath_totp_match(struct oath_key *, unsigned int, int);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef OATH_CONSTANTS_H_INCLUDED
|
#ifndef OATH_CONSTANTS_H_INCLUDED
|
||||||
#define OATH_CONSTANTS_H_INCLUDED
|
#define OATH_CONSTANTS_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* OATH modes
|
* OATH modes
|
||||||
*/
|
*/
|
||||||
|
|
49
include/cryb/oath_hotp.h
Normal file
49
include/cryb/oath_hotp.h
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2012-2014 The University of Oslo
|
||||||
|
* Copyright (c) 2013-2014 Dag-Erling Smørgrav
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef OATH_HOTP_H_INCLUDED
|
||||||
|
#define OATH_HOTP_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <cryb/oath_constants.h>
|
||||||
|
#include <cryb/oath_types.h>
|
||||||
|
|
||||||
|
#define oath_hotp cryb_oath_hotp
|
||||||
|
#define oath_hotp_current cryb_oath_hotp_current
|
||||||
|
#define oath_hotp_match cryb_oath_hotp_match
|
||||||
|
|
||||||
|
unsigned int oath_hotp(const uint8_t *, size_t, uint64_t, unsigned int);
|
||||||
|
unsigned int oath_hotp_current(struct oath_key *);
|
||||||
|
int oath_hotp_match(struct oath_key *, unsigned int, int);
|
||||||
|
|
||||||
|
#endif
|
49
include/cryb/oath_totp.h
Normal file
49
include/cryb/oath_totp.h
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2012-2014 The University of Oslo
|
||||||
|
* Copyright (c) 2013-2014 Dag-Erling Smørgrav
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef OATH_TOTP_H_INCLUDED
|
||||||
|
#define OATH_TOTP_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <cryb/oath_constants.h>
|
||||||
|
#include <cryb/oath_types.h>
|
||||||
|
|
||||||
|
#define oath_totp cryb_oath_totp
|
||||||
|
#define oath_totp_current cryb_oath_totp_current
|
||||||
|
#define oath_totp_match cryb_oath_totp_match
|
||||||
|
|
||||||
|
unsigned int oath_totp(const uint8_t *, size_t, unsigned int);
|
||||||
|
unsigned int oath_totp_current(const struct oath_key *);
|
||||||
|
int oath_totp_match(struct oath_key *, unsigned int, int);
|
||||||
|
|
||||||
|
#endif
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef OATH_TYPES_H_INCLUDED
|
#ifndef OATH_TYPES_H_INCLUDED
|
||||||
#define OATH_TYPES_H_INCLUDED
|
#define OATH_TYPES_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* OATH key and associated parameters
|
* OATH key and associated parameters
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -30,6 +30,12 @@
|
||||||
#ifndef CRYB_RAND_H_INCLUDED
|
#ifndef CRYB_RAND_H_INCLUDED
|
||||||
#define CRYB_RAND_H_INCLUDED
|
#define CRYB_RAND_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char *cryb_rand_version(void);
|
||||||
|
|
||||||
#define rand_bytes cryb_rand_bytes
|
#define rand_bytes cryb_rand_bytes
|
||||||
int rand_bytes(uint8_t *, size_t);
|
int rand_bytes(uint8_t *, size_t);
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_RC4_H_INCLUDED
|
#ifndef CRYB_RC4_H_INCLUDED
|
||||||
#define CRYB_RC4_H_INCLUDED
|
#define CRYB_RC4_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/cipher.h>
|
#include <cryb/cipher.h>
|
||||||
|
|
||||||
#define rc4_digest cryb_rc4_digest
|
#define rc4_digest cryb_rc4_digest
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_RFC3986_H_INCLUDED
|
#ifndef CRYB_RFC3986_H_INCLUDED
|
||||||
#define CRYB_RFC3986_H_INCLUDED
|
#define CRYB_RFC3986_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* estimate of output length for percent encoding / decoding */
|
/* estimate of output length for percent encoding / decoding */
|
||||||
#define percent_enclen(l) (size_t)((l) * 3)
|
#define percent_enclen(l) (size_t)((l) * 3)
|
||||||
#define percent_declen(l) (size_t)(l)
|
#define percent_declen(l) (size_t)(l)
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_RFC4648_H_INCLUDED
|
#ifndef CRYB_RFC4648_H_INCLUDED
|
||||||
#define CRYB_RFC4648_H_INCLUDED
|
#define CRYB_RFC4648_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* estimate of output length for base32 encoding / decoding */
|
/* estimate of output length for base32 encoding / decoding */
|
||||||
#define base32_enclen(l) (size_t)(((l + 4) / 5) * 8)
|
#define base32_enclen(l) (size_t)(((l + 4) / 5) * 8)
|
||||||
#define base32_declen(l) (size_t)(((l + 7) / 8) * 5)
|
#define base32_declen(l) (size_t)(((l + 7) / 8) * 5)
|
||||||
|
|
|
@ -31,6 +31,10 @@
|
||||||
#ifndef CRYB_SHA1_H_INCLUDED
|
#ifndef CRYB_SHA1_H_INCLUDED
|
||||||
#define CRYB_SHA1_H_INCLUDED
|
#define CRYB_SHA1_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/digest.h>
|
#include <cryb/digest.h>
|
||||||
|
|
||||||
#define SHA1_BLOCK_LEN 64
|
#define SHA1_BLOCK_LEN 64
|
||||||
|
|
|
@ -27,6 +27,10 @@
|
||||||
#ifndef CRYB_SHA224_H_INCLUDED
|
#ifndef CRYB_SHA224_H_INCLUDED
|
||||||
#define CRYB_SHA224_H_INCLUDED
|
#define CRYB_SHA224_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/digest.h>
|
#include <cryb/digest.h>
|
||||||
|
|
||||||
#define SHA224_BLOCK_LEN 64
|
#define SHA224_BLOCK_LEN 64
|
||||||
|
|
|
@ -27,6 +27,10 @@
|
||||||
#ifndef CRYB_SHA256_H_INCLUDED
|
#ifndef CRYB_SHA256_H_INCLUDED
|
||||||
#define CRYB_SHA256_H_INCLUDED
|
#define CRYB_SHA256_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/digest.h>
|
#include <cryb/digest.h>
|
||||||
|
|
||||||
#define SHA256_BLOCK_LEN 64
|
#define SHA256_BLOCK_LEN 64
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_SHA384_H_INCLUDED
|
#ifndef CRYB_SHA384_H_INCLUDED
|
||||||
#define CRYB_SHA384_H_INCLUDED
|
#define CRYB_SHA384_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/digest.h>
|
#include <cryb/digest.h>
|
||||||
|
|
||||||
#define SHA384_BLOCK_LEN 128
|
#define SHA384_BLOCK_LEN 128
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_SHA512_H_INCLUDED
|
#ifndef CRYB_SHA512_H_INCLUDED
|
||||||
#define CRYB_SHA512_H_INCLUDED
|
#define CRYB_SHA512_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/digest.h>
|
#include <cryb/digest.h>
|
||||||
|
|
||||||
#define SHA512_BLOCK_LEN 128
|
#define SHA512_BLOCK_LEN 128
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_STRING_H_INCLUDED
|
#ifndef CRYB_STRING_H_INCLUDED
|
||||||
#define CRYB_STRING_H_INCLUDED
|
#define CRYB_STRING_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define string_new cryb_string_new
|
#define string_new cryb_string_new
|
||||||
#define string_len cryb_string_len
|
#define string_len cryb_string_len
|
||||||
#define string_dup cryb_string_dup
|
#define string_dup cryb_string_dup
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_STRLCAT_H_INCLUDED
|
#ifndef CRYB_STRLCAT_H_INCLUDED
|
||||||
#define CRYB_STRLCAT_H_INCLUDED
|
#define CRYB_STRLCAT_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
size_t cryb_strlcat(char *, const char *, size_t);
|
size_t cryb_strlcat(char *, const char *, size_t);
|
||||||
|
|
||||||
#if !HAVE_STRLCAT
|
#if !HAVE_STRLCAT
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_STRLCMP_H_INCLUDED
|
#ifndef CRYB_STRLCMP_H_INCLUDED
|
||||||
#define CRYB_STRLCMP_H_INCLUDED
|
#define CRYB_STRLCMP_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
int cryb_strlcmp(const char *, const char *, size_t);
|
int cryb_strlcmp(const char *, const char *, size_t);
|
||||||
|
|
||||||
#if !HAVE_STRLCMP
|
#if !HAVE_STRLCMP
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_STRLCPY_H_INCLUDED
|
#ifndef CRYB_STRLCPY_H_INCLUDED
|
||||||
#define CRYB_STRLCPY_H_INCLUDED
|
#define CRYB_STRLCPY_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
size_t cryb_strlcpy(char *, const char *, size_t);
|
size_t cryb_strlcpy(char *, const char *, size_t);
|
||||||
|
|
||||||
#if !HAVE_STRLCPY
|
#if !HAVE_STRLCPY
|
||||||
|
|
|
@ -30,11 +30,17 @@
|
||||||
#ifndef CRYB_TEST_H_INCLUDED
|
#ifndef CRYB_TEST_H_INCLUDED
|
||||||
#define CRYB_TEST_H_INCLUDED
|
#define CRYB_TEST_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cryb/attributes.h>
|
#include <cryb/attributes.h>
|
||||||
#include <cryb/coverage.h>
|
#include <cryb/coverage.h>
|
||||||
|
|
||||||
CRYB_DISABLE_COVERAGE
|
CRYB_DISABLE_COVERAGE
|
||||||
|
|
||||||
|
const char *cryb_test_version(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Structure describing a test. Includes a pointer to the function that
|
* Structure describing a test. Includes a pointer to the function that
|
||||||
* performs the test, a pointer to the default description or comment
|
* performs the test, a pointer to the default description or comment
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2014 Dag-Erling Smørgrav
|
* Copyright (c) 2014-2016 Dag-Erling Smørgrav
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -30,6 +30,6 @@
|
||||||
#ifndef CRYB_TO_H_INCLUDED
|
#ifndef CRYB_TO_H_INCLUDED
|
||||||
#define CRYB_TO_H_INCLUDED
|
#define CRYB_TO_H_INCLUDED
|
||||||
|
|
||||||
#include <cryb/version.h>
|
#define CRYB_TO 20160321
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#ifndef CRYB_WSTRING_H_INCLUDED
|
#ifndef CRYB_WSTRING_H_INCLUDED
|
||||||
#define CRYB_WSTRING_H_INCLUDED
|
#define CRYB_WSTRING_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CRYB_TO
|
||||||
|
#include <cryb/to.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define wstring_new cryb_wstring_new
|
#define wstring_new cryb_wstring_new
|
||||||
#define wstring_len cryb_wstring_len
|
#define wstring_len cryb_wstring_len
|
||||||
#define wstring_dup cryb_wstring_dup
|
#define wstring_dup cryb_wstring_dup
|
||||||
|
|
|
@ -3,7 +3,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include
|
||||||
lib_LTLIBRARIES = libcryb-cipher.la
|
lib_LTLIBRARIES = libcryb-cipher.la
|
||||||
|
|
||||||
libcryb_cipher_la_SOURCES = \
|
libcryb_cipher_la_SOURCES = \
|
||||||
cryb_cipher.c \
|
cryb_aes.c \
|
||||||
|
cryb_rc4.c \
|
||||||
\
|
\
|
||||||
aes.c \
|
cryb_cipher.c
|
||||||
rc4.c
|
|
||||||
|
|
|
@ -37,6 +37,15 @@
|
||||||
#include <cryb/aes.h>
|
#include <cryb/aes.h>
|
||||||
#include <cryb/rc4.h>
|
#include <cryb/rc4.h>
|
||||||
|
|
||||||
|
static const char *cryb_cipher_version_string = PACKAGE_VERSION;
|
||||||
|
|
||||||
|
const char *
|
||||||
|
cryb_cipher_version(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
return (cryb_cipher_version_string);
|
||||||
|
}
|
||||||
|
|
||||||
static const cipher_algorithm **cryb_cipher_algorithms;
|
static const cipher_algorithm **cryb_cipher_algorithms;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -5,13 +5,13 @@ lib_LTLIBRARIES = libcryb-core.la
|
||||||
libcryb_core_la_SOURCES = \
|
libcryb_core_la_SOURCES = \
|
||||||
cryb_core.c \
|
cryb_core.c \
|
||||||
cryb_memset_s.c \
|
cryb_memset_s.c \
|
||||||
string.c \
|
cryb_string.c \
|
||||||
cryb_strlcat.c \
|
cryb_strlcat.c \
|
||||||
cryb_strlcpy.c \
|
cryb_strlcpy.c \
|
||||||
cryb_strlcmp.c \
|
cryb_strlcmp.c \
|
||||||
wstring.c
|
cryb_wstring.c
|
||||||
|
|
||||||
EXTRA_DIST = _string.c
|
EXTRA_DIST = cryb_string_impl.c
|
||||||
|
|
||||||
dist_man3_MANS = \
|
dist_man3_MANS = \
|
||||||
cryb_strlcat.3 \
|
cryb_strlcat.3 \
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2014 Dag-Erling Smørgrav
|
* Copyright (c) 2015 Dag-Erling Smørgrav
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -29,4 +29,13 @@
|
||||||
|
|
||||||
#include "cryb/impl.h"
|
#include "cryb/impl.h"
|
||||||
|
|
||||||
#include <cryb/to.h>
|
#include <cryb/core.h>
|
||||||
|
|
||||||
|
static const char *cryb_core_version_string = PACKAGE_VERSION;
|
||||||
|
|
||||||
|
const char *
|
||||||
|
cryb_core_version(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
return (cryb_core_version_string);
|
||||||
|
}
|
||||||
|
|
|
@ -38,4 +38,4 @@
|
||||||
|
|
||||||
#define char_t char
|
#define char_t char
|
||||||
|
|
||||||
#include "_string.c"
|
#include "cryb_string_impl.c"
|
|
@ -59,4 +59,4 @@
|
||||||
#define string_compare wstring_compare
|
#define string_compare wstring_compare
|
||||||
#define string_equal wstring_equal
|
#define string_equal wstring_equal
|
||||||
|
|
||||||
#include "_string.c"
|
#include "cryb_string_impl.c"
|
|
@ -3,10 +3,17 @@ AM_CPPFLAGS = -I$(top_srcdir)/include
|
||||||
lib_LTLIBRARIES = libcryb-cpe.la
|
lib_LTLIBRARIES = libcryb-cpe.la
|
||||||
|
|
||||||
libcryb_cpe_la_SOURCES = \
|
libcryb_cpe_la_SOURCES = \
|
||||||
cpe.c \
|
cryb_cpe_clone.c \
|
||||||
cpe_string.c \
|
cryb_cpe_copy_attr.c \
|
||||||
cpe_uri.c \
|
cryb_cpe_destroy.c \
|
||||||
cpe_wfn.c
|
cryb_cpe_new.c \
|
||||||
|
cryb_cpe_string.c \
|
||||||
|
cryb_cpe_upgrade22.c \
|
||||||
|
cryb_cpe_upgrade.c \
|
||||||
|
cryb_cpe_uri.c \
|
||||||
|
cryb_cpe_wfn.c \
|
||||||
|
\
|
||||||
|
cryb_cpe.c
|
||||||
|
|
||||||
libcryb_cpe_la_LIBADD = \
|
libcryb_cpe_la_LIBADD = \
|
||||||
$(top_builddir)/lib/core/libcryb-core.la
|
$(top_builddir)/lib/core/libcryb-core.la
|
||||||
|
|
158
lib/cpe/cpe.c
158
lib/cpe/cpe.c
|
@ -1,158 +0,0 @@
|
||||||
/*-
|
|
||||||
* Copyright (c) 2014 Dag-Erling Smørgrav
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior written
|
|
||||||
* permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "cryb/impl.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
#include <cryb/wstring.h>
|
|
||||||
#include <cryb/cpe.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Free all memory allocated to a cpe structure.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
cpe_destroy(cpe_name *cpe)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (cpe == NULL)
|
|
||||||
return;
|
|
||||||
for (int i = 0; i < cpe->nattr; ++i)
|
|
||||||
free(cpe->attr[i]);
|
|
||||||
free(cpe);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copy one or more attributes from a source cpe structure to a
|
|
||||||
* destination cpe structure. If an attribute in the source is NULL, the
|
|
||||||
* corresponding attribute in the destination will be an empty string.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
cpe_copy_attr(cpe_name *dst, const cpe_name *src, int base, int nattr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (base < 0 || nattr < 0 || base + nattr > src->nattr ||
|
|
||||||
base + nattr > dst->nattr)
|
|
||||||
return (-1);
|
|
||||||
if (nattr == 0)
|
|
||||||
nattr = src->nattr - base;
|
|
||||||
for (int i = base; i < base + nattr; ++i) {
|
|
||||||
if (src->attr[i] != NULL)
|
|
||||||
dst->attr[i] = wcsdup(src->attr[i]);
|
|
||||||
else
|
|
||||||
dst->attr[i] = wcsdup(L"");
|
|
||||||
if (dst->attr[i] == NULL)
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
return (nattr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Duplicate a cpe structure. Any attributes that are NULL in the source
|
|
||||||
* will be empty strings in the destination.
|
|
||||||
*/
|
|
||||||
cpe_name *
|
|
||||||
cpe_clone(const cpe_name *cpe)
|
|
||||||
{
|
|
||||||
cpe_name *ncpe;
|
|
||||||
|
|
||||||
ncpe = calloc(1, sizeof *ncpe +
|
|
||||||
cpe->nattr * sizeof *ncpe->attr);
|
|
||||||
if (ncpe == NULL)
|
|
||||||
return (NULL);
|
|
||||||
if (cpe_copy_attr(ncpe, cpe, 0, 0) < 0) {
|
|
||||||
cpe_destroy(ncpe);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
return (ncpe);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Allocate a new cpe structure.
|
|
||||||
*/
|
|
||||||
cpe_name *
|
|
||||||
cpe_new(void)
|
|
||||||
{
|
|
||||||
cpe_name *ncpe;
|
|
||||||
|
|
||||||
if ((ncpe = calloc(1, sizeof *ncpe)) == NULL)
|
|
||||||
return (NULL);
|
|
||||||
ncpe->ver = cpe23_ver;
|
|
||||||
ncpe->nattr = cpe23_nattr;
|
|
||||||
return (ncpe);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Upgrade a cpe 2.2 structure to the latest supported version.
|
|
||||||
*/
|
|
||||||
cpe_name *
|
|
||||||
cpe_upgrade22(const cpe_name *cpe)
|
|
||||||
{
|
|
||||||
cpe_name *ncpe;
|
|
||||||
|
|
||||||
if ((ncpe = cpe_new()) == NULL)
|
|
||||||
return (NULL);
|
|
||||||
/* copy existing attributes */
|
|
||||||
if (cpe_copy_attr(ncpe, cpe, 0, cpe22_nattr) < 0) {
|
|
||||||
cpe_destroy(ncpe);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
/* extended attributes? */
|
|
||||||
if (ncpe->attr[cpe22_edition][0] == L'~') {
|
|
||||||
/*
|
|
||||||
* XXX pseudo-code:
|
|
||||||
*
|
|
||||||
* - Split into fields (return an error if there are more
|
|
||||||
* than four)
|
|
||||||
* - Assign these to sw_edition, target_sw, target_hw and
|
|
||||||
* other, in that order.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
return (ncpe);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Upgrade a cpe structure to the latest supported version.
|
|
||||||
*/
|
|
||||||
cpe_name *
|
|
||||||
cpe_upgrade(const cpe_name *cpe)
|
|
||||||
{
|
|
||||||
|
|
||||||
switch (cpe->ver) {
|
|
||||||
case cpe23_ver:
|
|
||||||
/* already latest */
|
|
||||||
return (cpe_clone(cpe));
|
|
||||||
case cpe22_ver:
|
|
||||||
return (cpe_upgrade22(cpe));
|
|
||||||
default:
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
}
|
|
45
lib/cpe/cryb_cpe.c
Normal file
45
lib/cpe/cryb_cpe.c
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2015 Dag-Erling Smørgrav
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cryb/impl.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
#include <cryb/wstring.h>
|
||||||
|
#include <cryb/cpe.h>
|
||||||
|
|
||||||
|
static const char *cryb_cpe_version_string = PACKAGE_VERSION;
|
||||||
|
|
||||||
|
const char *
|
||||||
|
cryb_cpe_version(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
return (cryb_cpe_version_string);
|
||||||
|
}
|
56
lib/cpe/cryb_cpe_clone.c
Normal file
56
lib/cpe/cryb_cpe_clone.c
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2014 Dag-Erling Smørgrav
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cryb/impl.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
#include <cryb/wstring.h>
|
||||||
|
#include <cryb/cpe.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Duplicate a cpe structure. Any attributes that are NULL in the source
|
||||||
|
* will be empty strings in the destination.
|
||||||
|
*/
|
||||||
|
cpe_name *
|
||||||
|
cpe_clone(const cpe_name *cpe)
|
||||||
|
{
|
||||||
|
cpe_name *ncpe;
|
||||||
|
|
||||||
|
ncpe = calloc(1, sizeof *ncpe +
|
||||||
|
cpe->nattr * sizeof *ncpe->attr);
|
||||||
|
if (ncpe == NULL)
|
||||||
|
return (NULL);
|
||||||
|
if (cpe_copy_attr(ncpe, cpe, 0, 0) < 0) {
|
||||||
|
cpe_destroy(ncpe);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
return (ncpe);
|
||||||
|
}
|
61
lib/cpe/cryb_cpe_copy_attr.c
Normal file
61
lib/cpe/cryb_cpe_copy_attr.c
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2014 Dag-Erling Smørgrav
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cryb/impl.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
#include <cryb/wstring.h>
|
||||||
|
#include <cryb/cpe.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copy one or more attributes from a source cpe structure to a
|
||||||
|
* destination cpe structure. If an attribute in the source is NULL, the
|
||||||
|
* corresponding attribute in the destination will be an empty string.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
cpe_copy_attr(cpe_name *dst, const cpe_name *src, int base, int nattr)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (base < 0 || nattr < 0 || base + nattr > src->nattr ||
|
||||||
|
base + nattr > dst->nattr)
|
||||||
|
return (-1);
|
||||||
|
if (nattr == 0)
|
||||||
|
nattr = src->nattr - base;
|
||||||
|
for (int i = base; i < base + nattr; ++i) {
|
||||||
|
if (src->attr[i] != NULL)
|
||||||
|
dst->attr[i] = wcsdup(src->attr[i]);
|
||||||
|
else
|
||||||
|
dst->attr[i] = wcsdup(L"");
|
||||||
|
if (dst->attr[i] == NULL)
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
return (nattr);
|
||||||
|
}
|
50
lib/cpe/cryb_cpe_destroy.c
Normal file
50
lib/cpe/cryb_cpe_destroy.c
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2014 Dag-Erling Smørgrav
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cryb/impl.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
#include <cryb/wstring.h>
|
||||||
|
#include <cryb/cpe.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free all memory allocated to a cpe structure.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cpe_destroy(cpe_name *cpe)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (cpe == NULL)
|
||||||
|
return;
|
||||||
|
for (int i = 0; i < cpe->nattr; ++i)
|
||||||
|
free(cpe->attr[i]);
|
||||||
|
free(cpe);
|
||||||
|
}
|
51
lib/cpe/cryb_cpe_new.c
Normal file
51
lib/cpe/cryb_cpe_new.c
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2014 Dag-Erling Smørgrav
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cryb/impl.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
#include <cryb/wstring.h>
|
||||||
|
#include <cryb/cpe.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate a new cpe structure.
|
||||||
|
*/
|
||||||
|
cpe_name *
|
||||||
|
cpe_new(void)
|
||||||
|
{
|
||||||
|
cpe_name *ncpe;
|
||||||
|
|
||||||
|
if ((ncpe = calloc(1, sizeof *ncpe)) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
ncpe->ver = cpe23_ver;
|
||||||
|
ncpe->nattr = cpe23_nattr;
|
||||||
|
return (ncpe);
|
||||||
|
}
|
54
lib/cpe/cryb_cpe_upgrade.c
Normal file
54
lib/cpe/cryb_cpe_upgrade.c
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2014 Dag-Erling Smørgrav
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cryb/impl.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
#include <cryb/wstring.h>
|
||||||
|
#include <cryb/cpe.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Upgrade a cpe structure to the latest supported version.
|
||||||
|
*/
|
||||||
|
cpe_name *
|
||||||
|
cpe_upgrade(const cpe_name *cpe)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (cpe->ver) {
|
||||||
|
case cpe23_ver:
|
||||||
|
/* already latest */
|
||||||
|
return (cpe_clone(cpe));
|
||||||
|
case cpe22_ver:
|
||||||
|
return (cpe_upgrade22(cpe));
|
||||||
|
default:
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
}
|
65
lib/cpe/cryb_cpe_upgrade22.c
Normal file
65
lib/cpe/cryb_cpe_upgrade22.c
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2014 Dag-Erling Smørgrav
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cryb/impl.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
#include <cryb/wstring.h>
|
||||||
|
#include <cryb/cpe.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Upgrade a cpe 2.2 structure to the latest supported version.
|
||||||
|
*/
|
||||||
|
cpe_name *
|
||||||
|
cpe_upgrade22(const cpe_name *cpe)
|
||||||
|
{
|
||||||
|
cpe_name *ncpe;
|
||||||
|
|
||||||
|
if ((ncpe = cpe_new()) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
/* copy existing attributes */
|
||||||
|
if (cpe_copy_attr(ncpe, cpe, 0, cpe22_nattr) < 0) {
|
||||||
|
cpe_destroy(ncpe);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
/* extended attributes? */
|
||||||
|
if (ncpe->attr[cpe22_edition][0] == L'~') {
|
||||||
|
/*
|
||||||
|
* XXX pseudo-code:
|
||||||
|
*
|
||||||
|
* - Split into fields (return an error if there are more
|
||||||
|
* than four)
|
||||||
|
* - Assign these to sw_edition, target_sw, target_hw and
|
||||||
|
* other, in that order.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
return (ncpe);
|
||||||
|
}
|
|
@ -3,16 +3,16 @@ AM_CPPFLAGS = -I$(top_srcdir)/include
|
||||||
lib_LTLIBRARIES = libcryb-digest.la
|
lib_LTLIBRARIES = libcryb-digest.la
|
||||||
|
|
||||||
libcryb_digest_la_SOURCES = \
|
libcryb_digest_la_SOURCES = \
|
||||||
cryb_digest.c \
|
cryb_md2.c \
|
||||||
|
cryb_md4.c \
|
||||||
|
cryb_md5.c \
|
||||||
|
cryb_sha1.c \
|
||||||
|
cryb_sha224.c \
|
||||||
|
cryb_sha256.c \
|
||||||
|
cryb_sha384.c \
|
||||||
|
cryb_sha512.c \
|
||||||
\
|
\
|
||||||
md2.c \
|
cryb_digest.c
|
||||||
md4.c \
|
|
||||||
md5.c \
|
|
||||||
sha1.c \
|
|
||||||
sha224.c \
|
|
||||||
sha256.c \
|
|
||||||
sha384.c \
|
|
||||||
sha512.c
|
|
||||||
|
|
||||||
dist_man3_MANS = \
|
dist_man3_MANS = \
|
||||||
cryb_sha1.3
|
cryb_sha1.3
|
||||||
|
|
|
@ -42,6 +42,15 @@
|
||||||
#include <cryb/sha384.h>
|
#include <cryb/sha384.h>
|
||||||
#include <cryb/sha512.h>
|
#include <cryb/sha512.h>
|
||||||
|
|
||||||
|
static const char *cryb_digest_version_string = PACKAGE_VERSION;
|
||||||
|
|
||||||
|
const char *
|
||||||
|
cryb_digest_version(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
return (cryb_digest_version_string);
|
||||||
|
}
|
||||||
|
|
||||||
static const digest_algorithm **cryb_digest_algorithms;
|
static const digest_algorithm **cryb_digest_algorithms;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -3,9 +3,14 @@ AM_CPPFLAGS = -I$(top_srcdir)/include
|
||||||
lib_LTLIBRARIES = libcryb-enc.la
|
lib_LTLIBRARIES = libcryb-enc.la
|
||||||
|
|
||||||
libcryb_enc_la_SOURCES = \
|
libcryb_enc_la_SOURCES = \
|
||||||
cryb_base32.c \
|
cryb_base32_decode.c \
|
||||||
cryb_base64.c \
|
cryb_base32_encode.c \
|
||||||
cryb_percent.c
|
cryb_base64_decode.c \
|
||||||
|
cryb_base64_encode.c \
|
||||||
|
cryb_percent_decode.c \
|
||||||
|
cryb_percent_encode.c \
|
||||||
|
\
|
||||||
|
cryb_enc.c
|
||||||
|
|
||||||
dist_man3_MANS = \
|
dist_man3_MANS = \
|
||||||
cryb_percent.3
|
cryb_percent.3
|
||||||
|
|
|
@ -36,9 +36,6 @@
|
||||||
|
|
||||||
#include <cryb/rfc4648.h>
|
#include <cryb/rfc4648.h>
|
||||||
|
|
||||||
static const char b32enc[] =
|
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
||||||
|
|
||||||
static const char b32dec[256] = {
|
static const char b32dec[256] = {
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
|
@ -74,64 +71,6 @@ static const char b32dec[256] = {
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Encode data in RFC 4648 base 32 representation. The target buffer must
|
|
||||||
* have room for base32_enclen(len) characters and a terminating NUL.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
base32_encode(const uint8_t *in, size_t ilen, char *out, size_t *olen)
|
|
||||||
{
|
|
||||||
uint64_t bits;
|
|
||||||
|
|
||||||
if (*olen <= base32_enclen(ilen)) {
|
|
||||||
*olen = base32_enclen(ilen) + 1;
|
|
||||||
errno = ENOSPC;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
*olen = base32_enclen(ilen) + 1;
|
|
||||||
while (ilen >= 5) {
|
|
||||||
bits = 0;
|
|
||||||
bits |= (uint64_t)*in++ << 32;
|
|
||||||
bits |= (uint64_t)*in++ << 24;
|
|
||||||
bits |= (uint64_t)*in++ << 16;
|
|
||||||
bits |= (uint64_t)*in++ << 8;
|
|
||||||
bits |= (uint64_t)*in++;
|
|
||||||
*out++ = b32enc[bits >> 35 & 0x1f];
|
|
||||||
*out++ = b32enc[bits >> 30 & 0x1f];
|
|
||||||
*out++ = b32enc[bits >> 25 & 0x1f];
|
|
||||||
*out++ = b32enc[bits >> 20 & 0x1f];
|
|
||||||
*out++ = b32enc[bits >> 15 & 0x1f];
|
|
||||||
*out++ = b32enc[bits >> 10 & 0x1f];
|
|
||||||
*out++ = b32enc[bits >> 5 & 0x1f];
|
|
||||||
*out++ = b32enc[bits & 0x1f];
|
|
||||||
ilen -= 5;
|
|
||||||
}
|
|
||||||
if (ilen > 0) {
|
|
||||||
bits = 0;
|
|
||||||
switch (ilen) {
|
|
||||||
case 4:
|
|
||||||
bits |= (uint64_t)in[3] << 8;
|
|
||||||
case 3:
|
|
||||||
bits |= (uint64_t)in[2] << 16;
|
|
||||||
case 2:
|
|
||||||
bits |= (uint64_t)in[1] << 24;
|
|
||||||
case 1:
|
|
||||||
bits |= (uint64_t)in[0] << 32;
|
|
||||||
CRYB_NO_DEFAULT_CASE;
|
|
||||||
}
|
|
||||||
*out++ = b32enc[bits >> 35 & 0x1f];
|
|
||||||
*out++ = b32enc[bits >> 30 & 0x1f];
|
|
||||||
*out++ = ilen > 1 ? b32enc[bits >> 25 & 0x1f] : '=';
|
|
||||||
*out++ = ilen > 1 ? b32enc[bits >> 20 & 0x1f] : '=';
|
|
||||||
*out++ = ilen > 2 ? b32enc[bits >> 15 & 0x1f] : '=';
|
|
||||||
*out++ = ilen > 3 ? b32enc[bits >> 10 & 0x1f] : '=';
|
|
||||||
*out++ = ilen > 3 ? b32enc[bits >> 5 & 0x1f] : '=';
|
|
||||||
*out++ = '=';
|
|
||||||
}
|
|
||||||
*out++ = '\0';
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Decode data in RFC 4648 base 32 representation, stopping at the
|
* Decode data in RFC 4648 base 32 representation, stopping at the
|
||||||
* terminating NUL, the first invalid (non-base32, non-whitespace)
|
* terminating NUL, the first invalid (non-base32, non-whitespace)
|
98
lib/enc/cryb_base32_encode.c
Normal file
98
lib/enc/cryb_base32_encode.c
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2013-2014 The University of Oslo
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cryb/impl.h"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <cryb/rfc4648.h>
|
||||||
|
|
||||||
|
static const char b32enc[] =
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Encode data in RFC 4648 base 32 representation. The target buffer must
|
||||||
|
* have room for base32_enclen(len) characters and a terminating NUL.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
base32_encode(const uint8_t *in, size_t ilen, char *out, size_t *olen)
|
||||||
|
{
|
||||||
|
uint64_t bits;
|
||||||
|
|
||||||
|
if (*olen <= base32_enclen(ilen)) {
|
||||||
|
*olen = base32_enclen(ilen) + 1;
|
||||||
|
errno = ENOSPC;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
*olen = base32_enclen(ilen) + 1;
|
||||||
|
while (ilen >= 5) {
|
||||||
|
bits = 0;
|
||||||
|
bits |= (uint64_t)*in++ << 32;
|
||||||
|
bits |= (uint64_t)*in++ << 24;
|
||||||
|
bits |= (uint64_t)*in++ << 16;
|
||||||
|
bits |= (uint64_t)*in++ << 8;
|
||||||
|
bits |= (uint64_t)*in++;
|
||||||
|
*out++ = b32enc[bits >> 35 & 0x1f];
|
||||||
|
*out++ = b32enc[bits >> 30 & 0x1f];
|
||||||
|
*out++ = b32enc[bits >> 25 & 0x1f];
|
||||||
|
*out++ = b32enc[bits >> 20 & 0x1f];
|
||||||
|
*out++ = b32enc[bits >> 15 & 0x1f];
|
||||||
|
*out++ = b32enc[bits >> 10 & 0x1f];
|
||||||
|
*out++ = b32enc[bits >> 5 & 0x1f];
|
||||||
|
*out++ = b32enc[bits & 0x1f];
|
||||||
|
ilen -= 5;
|
||||||
|
}
|
||||||
|
if (ilen > 0) {
|
||||||
|
bits = 0;
|
||||||
|
switch (ilen) {
|
||||||
|
case 4:
|
||||||
|
bits |= (uint64_t)in[3] << 8;
|
||||||
|
case 3:
|
||||||
|
bits |= (uint64_t)in[2] << 16;
|
||||||
|
case 2:
|
||||||
|
bits |= (uint64_t)in[1] << 24;
|
||||||
|
case 1:
|
||||||
|
bits |= (uint64_t)in[0] << 32;
|
||||||
|
CRYB_NO_DEFAULT_CASE;
|
||||||
|
}
|
||||||
|
*out++ = b32enc[bits >> 35 & 0x1f];
|
||||||
|
*out++ = b32enc[bits >> 30 & 0x1f];
|
||||||
|
*out++ = ilen > 1 ? b32enc[bits >> 25 & 0x1f] : '=';
|
||||||
|
*out++ = ilen > 1 ? b32enc[bits >> 20 & 0x1f] : '=';
|
||||||
|
*out++ = ilen > 2 ? b32enc[bits >> 15 & 0x1f] : '=';
|
||||||
|
*out++ = ilen > 3 ? b32enc[bits >> 10 & 0x1f] : '=';
|
||||||
|
*out++ = ilen > 3 ? b32enc[bits >> 5 & 0x1f] : '=';
|
||||||
|
*out++ = '=';
|
||||||
|
}
|
||||||
|
*out++ = '\0';
|
||||||
|
return (0);
|
||||||
|
}
|
|
@ -36,11 +36,6 @@
|
||||||
|
|
||||||
#include <cryb/rfc4648.h>
|
#include <cryb/rfc4648.h>
|
||||||
|
|
||||||
static const char b64enc[] =
|
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
||||||
"abcdefghijklmnopqrstuvwxyz"
|
|
||||||
"0123456789+/";
|
|
||||||
|
|
||||||
static const char b64dec[256] = {
|
static const char b64dec[256] = {
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
|
@ -76,50 +71,6 @@ static const char b64dec[256] = {
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Encode data in RFC 4648 base 64 representation. The target buffer must
|
|
||||||
* have room for base64_enclen(len) characters and a terminating NUL.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
base64_encode(const uint8_t *in, size_t ilen, char *out, size_t *olen)
|
|
||||||
{
|
|
||||||
uint32_t bits;
|
|
||||||
|
|
||||||
if (*olen <= base64_enclen(ilen)) {
|
|
||||||
*olen = base64_enclen(ilen) + 1;
|
|
||||||
errno = ENOSPC;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
*olen = base64_enclen(ilen) + 1;
|
|
||||||
while (ilen >= 3) {
|
|
||||||
bits = 0;
|
|
||||||
bits |= (uint32_t)*in++ << 16;
|
|
||||||
bits |= (uint32_t)*in++ << 8;
|
|
||||||
bits |= (uint32_t)*in++;
|
|
||||||
ilen -= 3;
|
|
||||||
*out++ = b64enc[bits >> 18 & 0x3f];
|
|
||||||
*out++ = b64enc[bits >> 12 & 0x3f];
|
|
||||||
*out++ = b64enc[bits >> 6 & 0x3f];
|
|
||||||
*out++ = b64enc[bits & 0x3f];
|
|
||||||
}
|
|
||||||
if (ilen > 0) {
|
|
||||||
bits = 0;
|
|
||||||
switch (ilen) {
|
|
||||||
case 2:
|
|
||||||
bits |= (uint32_t)in[1] << 8;
|
|
||||||
case 1:
|
|
||||||
bits |= (uint32_t)in[0] << 16;
|
|
||||||
CRYB_NO_DEFAULT_CASE;
|
|
||||||
}
|
|
||||||
*out++ = b64enc[bits >> 18 & 0x3f];
|
|
||||||
*out++ = b64enc[bits >> 12 & 0x3f];
|
|
||||||
*out++ = ilen > 1 ? b64enc[bits >> 6 & 0x3f] : '=';
|
|
||||||
*out++ = '=';
|
|
||||||
}
|
|
||||||
*out++ = '\0';
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Decode data in RFC 4648 base 64 representation, stopping at the
|
* Decode data in RFC 4648 base 64 representation, stopping at the
|
||||||
* terminating NUL, the first invalid (non-base64, non-whitespace)
|
* terminating NUL, the first invalid (non-base64, non-whitespace)
|
86
lib/enc/cryb_base64_encode.c
Normal file
86
lib/enc/cryb_base64_encode.c
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2013-2014 The University of Oslo
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cryb/impl.h"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <cryb/rfc4648.h>
|
||||||
|
|
||||||
|
static const char b64enc[] =
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
"abcdefghijklmnopqrstuvwxyz"
|
||||||
|
"0123456789+/";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Encode data in RFC 4648 base 64 representation. The target buffer must
|
||||||
|
* have room for base64_enclen(len) characters and a terminating NUL.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
base64_encode(const uint8_t *in, size_t ilen, char *out, size_t *olen)
|
||||||
|
{
|
||||||
|
uint32_t bits;
|
||||||
|
|
||||||
|
if (*olen <= base64_enclen(ilen)) {
|
||||||
|
*olen = base64_enclen(ilen) + 1;
|
||||||
|
errno = ENOSPC;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
*olen = base64_enclen(ilen) + 1;
|
||||||
|
while (ilen >= 3) {
|
||||||
|
bits = 0;
|
||||||
|
bits |= (uint32_t)*in++ << 16;
|
||||||
|
bits |= (uint32_t)*in++ << 8;
|
||||||
|
bits |= (uint32_t)*in++;
|
||||||
|
ilen -= 3;
|
||||||
|
*out++ = b64enc[bits >> 18 & 0x3f];
|
||||||
|
*out++ = b64enc[bits >> 12 & 0x3f];
|
||||||
|
*out++ = b64enc[bits >> 6 & 0x3f];
|
||||||
|
*out++ = b64enc[bits & 0x3f];
|
||||||
|
}
|
||||||
|
if (ilen > 0) {
|
||||||
|
bits = 0;
|
||||||
|
switch (ilen) {
|
||||||
|
case 2:
|
||||||
|
bits |= (uint32_t)in[1] << 8;
|
||||||
|
case 1:
|
||||||
|
bits |= (uint32_t)in[0] << 16;
|
||||||
|
CRYB_NO_DEFAULT_CASE;
|
||||||
|
}
|
||||||
|
*out++ = b64enc[bits >> 18 & 0x3f];
|
||||||
|
*out++ = b64enc[bits >> 12 & 0x3f];
|
||||||
|
*out++ = ilen > 1 ? b64enc[bits >> 6 & 0x3f] : '=';
|
||||||
|
*out++ = '=';
|
||||||
|
}
|
||||||
|
*out++ = '\0';
|
||||||
|
return (0);
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2012 The University of Oslo
|
* Copyright (c) 2015 Dag-Erling Smørgrav
|
||||||
* Copyright (c) 2012 Dag-Erling Smørgrav
|
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -28,7 +27,18 @@
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CRYB_HOTP_H_INCLUDED
|
#include "cryb/impl.h"
|
||||||
#define CRYB_HOTP_H_INCLUDED
|
|
||||||
|
|
||||||
#endif
|
#include <stdint.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <cryb/enc.h>
|
||||||
|
|
||||||
|
static const char *cryb_enc_version_string = PACKAGE_VERSION;
|
||||||
|
|
||||||
|
const char *
|
||||||
|
cryb_enc_version(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
return (cryb_enc_version_string);
|
||||||
|
}
|
|
@ -36,46 +36,11 @@
|
||||||
#include <cryb/ctype.h>
|
#include <cryb/ctype.h>
|
||||||
#include <cryb/rfc3986.h>
|
#include <cryb/rfc3986.h>
|
||||||
|
|
||||||
static const char hex[] = "0123456789ABCDEF";
|
|
||||||
|
|
||||||
#define unhex(ch) \
|
#define unhex(ch) \
|
||||||
((ch >= '0' && ch <= '9') ? ch - '0' : \
|
((ch >= '0' && ch <= '9') ? ch - '0' : \
|
||||||
(ch >= 'A' && ch <= 'F') ? 0xa + ch - 'A' : \
|
(ch >= 'A' && ch <= 'F') ? 0xa + ch - 'A' : \
|
||||||
(ch >= 'a' && ch <= 'f') ? 0xa + ch - 'a' : 0)
|
(ch >= 'a' && ch <= 'f') ? 0xa + ch - 'a' : 0)
|
||||||
|
|
||||||
/*
|
|
||||||
* Encodes a string in RFC 3986 percent-encoded representation.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
percent_encode(const char *in, size_t ilen, char *out, size_t *olen)
|
|
||||||
{
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
for (len = 0; ilen > 0 && *in != '\0'; --ilen, ++in) {
|
|
||||||
if (is_uri(*in)) {
|
|
||||||
if (++len < *olen && out != NULL)
|
|
||||||
*out++ = *in;
|
|
||||||
} else {
|
|
||||||
if (++len < *olen && out != NULL)
|
|
||||||
*out++ = '%';
|
|
||||||
if (++len < *olen && out != NULL)
|
|
||||||
*out++ = hex[(uint8_t)*in >> 4];
|
|
||||||
if (++len < *olen && out != NULL)
|
|
||||||
*out++ = hex[(uint8_t)*in & 0xf];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (*olen > 0 && out != NULL)
|
|
||||||
*out = '\0';
|
|
||||||
if (++len > *olen && out != NULL) {
|
|
||||||
/* overflow */
|
|
||||||
*olen = len;
|
|
||||||
errno = ENOSPC;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
*olen = len;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Decodes a string in RFC 3986 percent-encoded representation.
|
* Decodes a string in RFC 3986 percent-encoded representation.
|
||||||
*/
|
*/
|
72
lib/enc/cryb_percent_encode.c
Normal file
72
lib/enc/cryb_percent_encode.c
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2014 Dag-Erling Smørgrav
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cryb/impl.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <cryb/ctype.h>
|
||||||
|
#include <cryb/rfc3986.h>
|
||||||
|
|
||||||
|
static const char hex[] = "0123456789ABCDEF";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Encodes a string in RFC 3986 percent-encoded representation.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
percent_encode(const char *in, size_t ilen, char *out, size_t *olen)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
for (len = 0; ilen > 0 && *in != '\0'; --ilen, ++in) {
|
||||||
|
if (is_uri(*in)) {
|
||||||
|
if (++len < *olen && out != NULL)
|
||||||
|
*out++ = *in;
|
||||||
|
} else {
|
||||||
|
if (++len < *olen && out != NULL)
|
||||||
|
*out++ = '%';
|
||||||
|
if (++len < *olen && out != NULL)
|
||||||
|
*out++ = hex[(uint8_t)*in >> 4];
|
||||||
|
if (++len < *olen && out != NULL)
|
||||||
|
*out++ = hex[(uint8_t)*in & 0xf];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (*olen > 0 && out != NULL)
|
||||||
|
*out = '\0';
|
||||||
|
if (++len > *olen && out != NULL) {
|
||||||
|
/* overflow */
|
||||||
|
*olen = len;
|
||||||
|
errno = ENOSPC;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
*olen = len;
|
||||||
|
return (0);
|
||||||
|
}
|
|
@ -3,12 +3,14 @@ AM_CPPFLAGS = -I$(top_srcdir)/include
|
||||||
lib_LTLIBRARIES = libcryb-hash.la
|
lib_LTLIBRARIES = libcryb-hash.la
|
||||||
|
|
||||||
libcryb_hash_la_SOURCES = \
|
libcryb_hash_la_SOURCES = \
|
||||||
adler32.c \
|
cryb_adler32.c \
|
||||||
fletcher16.c \
|
cryb_fletcher16.c \
|
||||||
fletcher32.c \
|
cryb_fletcher32.c \
|
||||||
fletcher64.c \
|
cryb_fletcher64.c \
|
||||||
murmur3_32.c \
|
cryb_murmur3_32.c \
|
||||||
pearson.c
|
cryb_pearson.c \
|
||||||
|
\
|
||||||
|
cryb_hash.c
|
||||||
|
|
||||||
dist_man3_MANS = \
|
dist_man3_MANS = \
|
||||||
cryb_fletcher.3 \
|
cryb_fletcher.3 \
|
||||||
|
|
44
lib/hash/cryb_hash.c
Normal file
44
lib/hash/cryb_hash.c
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2015 Dag-Erling Smørgrav
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cryb/impl.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <cryb/hash.h>
|
||||||
|
|
||||||
|
static const char *cryb_hash_version_string = PACKAGE_VERSION;
|
||||||
|
|
||||||
|
const char *
|
||||||
|
cryb_hash_version(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
return (cryb_hash_version_string);
|
||||||
|
}
|
|
@ -3,11 +3,13 @@ AM_CPPFLAGS = -I$(top_srcdir)/include
|
||||||
lib_LTLIBRARIES = libcryb-mac.la
|
lib_LTLIBRARIES = libcryb-mac.la
|
||||||
|
|
||||||
libcryb_mac_la_SOURCES = \
|
libcryb_mac_la_SOURCES = \
|
||||||
hmac_sha1.c \
|
cryb_hmac_sha1.c \
|
||||||
hmac_sha224.c \
|
cryb_hmac_sha224.c \
|
||||||
hmac_sha256.c \
|
cryb_hmac_sha256.c \
|
||||||
hmac_sha384.c \
|
cryb_hmac_sha384.c \
|
||||||
hmac_sha512.c
|
cryb_hmac_sha512.c \
|
||||||
|
\
|
||||||
|
cryb_mac.c
|
||||||
|
|
||||||
libcryb_mac_la_LIBADD = \
|
libcryb_mac_la_LIBADD = \
|
||||||
$(top_builddir)/lib/digest/libcryb-digest.la
|
$(top_builddir)/lib/digest/libcryb-digest.la
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue