003 File Manager
Current Path:
/usr/src/contrib/ntp/libntp
usr
/
src
/
contrib
/
ntp
/
libntp
/
📁
..
📄
Makefile.am
(3.27 KB)
📄
Makefile.in
(105.83 KB)
📄
README
(272 B)
📄
a_md5encrypt.c
(6.76 KB)
📄
adjtime.c
(10.29 KB)
📄
adjtimex.c
(334 B)
📄
atoint.c
(801 B)
📄
atolfp.c
(1.88 KB)
📄
atouint.c
(885 B)
📄
audio.c
(13.09 KB)
📄
authkeys.c
(19.92 KB)
📄
authreadkeys.c
(9.06 KB)
📄
authusekey.c
(748 B)
📄
bsd_strerror.c
(1.35 KB)
📄
buftvtots.c
(643 B)
📄
caljulian.c
(891 B)
📄
caltontp.c
(2.25 KB)
📄
calyearstart.c
(2.1 KB)
📄
clocktime.c
(4.49 KB)
📄
clocktypes.c
(3.69 KB)
📄
decodenetnum.c
(3.93 KB)
📄
dofptoa.c
(2.19 KB)
📄
dolfptoa.c
(3.14 KB)
📄
emalloc.c
(3.4 KB)
📄
findconfig.c
(1.46 KB)
📄
getopt.c
(2.21 KB)
📄
hextoint.c
(673 B)
📄
hextolfp.c
(1.35 KB)
📄
humandate.c
(1.1 KB)
📄
icom.c
(4.22 KB)
📄
iosignal.c
(12.27 KB)
📄
is_ip_address.c
(2.02 KB)
📄
lib_strbuf.c
(633 B)
📄
libssl_compat.c
(6.13 KB)
📄
machines.c
(13.05 KB)
📄
mktime.c
(8.29 KB)
📄
modetoa.c
(507 B)
📄
mstolfp.c
(2.01 KB)
📄
msyslog.c
(12.67 KB)
📄
netof.c
(1.17 KB)
📄
ntp_calendar.c
(58.49 KB)
📄
ntp_calgps.c
(15.73 KB)
📄
ntp_crypto_rnd.c
(2.11 KB)
📄
ntp_intres.c
(28.64 KB)
📄
ntp_libopts.c
(1.27 KB)
📄
ntp_lineedit.c
(3.88 KB)
📄
ntp_random.c
(17.63 KB)
📄
ntp_rfc2553.c
(14.85 KB)
📄
ntp_worker.c
(7.21 KB)
📄
numtoa.c
(963 B)
📄
numtohost.c
(908 B)
📄
octtoint.c
(578 B)
📄
prettydate.c
(5.53 KB)
📄
recvbuff.c
(7.3 KB)
📄
refidsmear.c
(1.05 KB)
📄
refnumtoa.c
(673 B)
📄
snprintf.c
(52.56 KB)
📄
socket.c
(4.88 KB)
📄
socktoa.c
(2.88 KB)
📄
socktohost.c
(2.54 KB)
📄
ssl_init.c
(5.09 KB)
📄
statestr.c
(11.4 KB)
📄
strdup.c
(854 B)
📄
strl_obsd.c
(3.65 KB)
📄
syssignal.c
(2.69 KB)
📄
systime.c
(17.51 KB)
📄
systime_s.c
(33 B)
📄
timespecops.c
(4.27 KB)
📄
timetoa.c
(2.75 KB)
📄
timevalops.c
(12.97 KB)
📄
timexsup.c
(1.17 KB)
📄
uglydate.c
(958 B)
📄
vint64ops.c
(5.1 KB)
📄
work_fork.c
(12.73 KB)
📄
work_thread.c
(22.88 KB)
📄
xsbprintf.c
(2.06 KB)
📄
ymd2yd.c
(582 B)
Editing: libssl_compat.c
/* * libssl_compat.c -- OpenSSL v1.1 compatibility functions * * --------------------------------------------------------------------- * Written by Juergen Perlinger <perlinger@ntp.org> for the NTP project * * Based on an idea by Kurt Roeckx <kurt@roeckx.be> * * --------------------------------------------------------------------- * This is a clean room implementation of shim functions that have * counterparts in the OpenSSL v1.1 API but not in earlier versions. So * while OpenSSL broke binary compatibility with v1.1, this shim module * should provide the necessary source code compatibility with older * versions of OpenSSL. * --------------------------------------------------------------------- */ #include "config.h" #include "ntp_types.h" /* ----------------------------------------------------------------- */ #ifdef OPENSSL # include <string.h> # include <openssl/bn.h> # include <openssl/evp.h> #endif /* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */ #if defined(OPENSSL) && OPENSSL_VERSION_NUMBER < 0x10100000L /* ----------------------------------------------------------------- */ #include "libssl_compat.h" #include "ntp_assert.h" /* -------------------------------------------------------------------- * replace a BIGNUM owned by the caller with another one if it's not * NULL, taking over the ownership of the new value. This clears & frees * the old value -- the clear might be overkill, but it's better to err * on the side of paranoia here. */ static void replace_bn_nn( BIGNUM ** ps, BIGNUM * n ) { if (n) { REQUIRE(*ps != n); BN_clear_free(*ps); *ps = n; } } /* -------------------------------------------------------------------- * allocation and deallocation of prime number callbacks */ BN_GENCB* sslshimBN_GENCB_new(void) { return calloc(1,sizeof(BN_GENCB)); } void sslshimBN_GENCB_free( BN_GENCB *cb ) { free(cb); } /* -------------------------------------------------------------------- * allocation and deallocation of message digests */ EVP_MD_CTX* sslshim_EVP_MD_CTX_new(void) { EVP_MD_CTX * ctx; if (NULL != (ctx = calloc(1, sizeof(EVP_MD_CTX)))) EVP_MD_CTX_init(ctx); return ctx; } void sslshim_EVP_MD_CTX_free( EVP_MD_CTX * pctx ) { free(pctx); } /* -------------------------------------------------------------------- * get EVP keys and key type */ int sslshim_EVP_PKEY_id( const EVP_PKEY *pkey ) { return (pkey) ? pkey->type : EVP_PKEY_NONE; } int sslshim_EVP_PKEY_base_id( const EVP_PKEY *pkey ) { return (pkey) ? EVP_PKEY_type(pkey->type) : EVP_PKEY_NONE; } RSA* sslshim_EVP_PKEY_get0_RSA( EVP_PKEY * pkey ) { return (pkey) ? pkey->pkey.rsa : NULL; } DSA* sslshim_EVP_PKEY_get0_DSA( EVP_PKEY * pkey ) { return (pkey) ? pkey->pkey.dsa : NULL; } /* -------------------------------------------------------------------- * set/get RSA params */ void sslshim_RSA_get0_key( const RSA * prsa, const BIGNUM ** pn, const BIGNUM ** pe, const BIGNUM ** pd ) { REQUIRE(prsa != NULL); if (pn) *pn = prsa->n; if (pe) *pe = prsa->e; if (pd) *pd = prsa->d; } int sslshim_RSA_set0_key( RSA * prsa, BIGNUM * n, BIGNUM * e, BIGNUM * d ) { REQUIRE(prsa != NULL); if (!((prsa->n || n) && (prsa->e || e))) return 0; replace_bn_nn(&prsa->n, n); replace_bn_nn(&prsa->e, e); replace_bn_nn(&prsa->d, d); return 1; } void sslshim_RSA_get0_factors( const RSA * prsa, const BIGNUM ** pp, const BIGNUM ** pq ) { REQUIRE(prsa != NULL); if (pp) *pp = prsa->p; if (pq) *pq = prsa->q; } int sslshim_RSA_set0_factors( RSA * prsa, BIGNUM * p, BIGNUM * q ) { REQUIRE(prsa != NULL); if (!((prsa->p || p) && (prsa->q || q))) return 0; replace_bn_nn(&prsa->p, p); replace_bn_nn(&prsa->q, q); return 1; } int sslshim_RSA_set0_crt_params( RSA * prsa, BIGNUM * dmp1, BIGNUM * dmq1, BIGNUM * iqmp ) { REQUIRE(prsa != NULL); if (!((prsa->dmp1 || dmp1) && (prsa->dmq1 || dmq1) && (prsa->iqmp || iqmp) )) return 0; replace_bn_nn(&prsa->dmp1, dmp1); replace_bn_nn(&prsa->dmq1, dmq1); replace_bn_nn(&prsa->iqmp, iqmp); return 1; } /* -------------------------------------------------------------------- * set/get DSA signature parameters */ void sslshim_DSA_SIG_get0( const DSA_SIG * psig, const BIGNUM ** pr, const BIGNUM ** ps ) { REQUIRE(psig != NULL); if (pr != NULL) *pr = psig->r; if (ps != NULL) *ps = psig->s; } int sslshim_DSA_SIG_set0( DSA_SIG * psig, BIGNUM * r, BIGNUM * s ) { REQUIRE(psig != NULL); if (!(r && s)) return 0; replace_bn_nn(&psig->r, r); replace_bn_nn(&psig->s, s); return 1; } /* -------------------------------------------------------------------- * get/set DSA parameters */ void sslshim_DSA_get0_pqg( const DSA * pdsa, const BIGNUM ** pp, const BIGNUM ** pq, const BIGNUM ** pg ) { REQUIRE(pdsa != NULL); if (pp != NULL) *pp = pdsa->p; if (pq != NULL) *pq = pdsa->q; if (pg != NULL) *pg = pdsa->g; } int sslshim_DSA_set0_pqg( DSA * pdsa, BIGNUM * p, BIGNUM * q, BIGNUM * g ) { if (!((pdsa->p || p) && (pdsa->q || q) && (pdsa->g || g))) return 0; replace_bn_nn(&pdsa->p, p); replace_bn_nn(&pdsa->q, q); replace_bn_nn(&pdsa->g, g); return 1; } void sslshim_DSA_get0_key( const DSA * pdsa, const BIGNUM ** ppub_key, const BIGNUM ** ppriv_key ) { REQUIRE(pdsa != NULL); if (ppub_key != NULL) *ppub_key = pdsa->pub_key; if (ppriv_key != NULL) *ppriv_key = pdsa->priv_key; } int sslshim_DSA_set0_key( DSA * pdsa, BIGNUM * pub_key, BIGNUM * priv_key ) { REQUIRE(pdsa != NULL); if (!(pdsa->pub_key || pub_key)) return 0; replace_bn_nn(&pdsa->pub_key, pub_key); replace_bn_nn(&pdsa->priv_key, priv_key); return 1; } int sslshim_X509_get_signature_nid( const X509 *x ) { return OBJ_obj2nid(x->sig_alg->algorithm); } /* ----------------------------------------------------------------- */ #else /* OPENSSL && OPENSSL_VERSION_NUMBER >= v1.1.0 */ /* ----------------------------------------------------------------- */ NONEMPTY_TRANSLATION_UNIT /* ----------------------------------------------------------------- */ #endif /* ----------------------------------------------------------------- */
Upload File
Create Folder