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: ssl_init.c
/* * ssl_init.c Common OpenSSL initialization code for the various * programs which use it. * * Moved from ntpd/ntp_crypto.c crypto_setup() */ #ifdef HAVE_CONFIG_H # include <config.h> #endif #include <ctype.h> #include <ntp.h> #include <ntp_debug.h> #include <lib_strbuf.h> #ifdef OPENSSL # include <openssl/crypto.h> # include <openssl/err.h> # include <openssl/evp.h> # include <openssl/opensslv.h> # include "libssl_compat.h" # ifdef HAVE_OPENSSL_CMAC_H # include <openssl/cmac.h> # define CMAC_LENGTH 16 # define CMAC "AES128CMAC" # endif /*HAVE_OPENSSL_CMAC_H*/ int ssl_init_done; #if OPENSSL_VERSION_NUMBER < 0x10100000L static void atexit_ssl_cleanup(void) { if (!ssl_init_done) { return; } ssl_init_done = FALSE; EVP_cleanup(); ERR_free_strings(); } void ssl_init(void) { init_lib(); if ( ! ssl_init_done) { ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); atexit(&atexit_ssl_cleanup); ssl_init_done = TRUE; } } #else /* OPENSSL_VERSION_NUMBER >= 0x10100000L */ void ssl_init(void) { init_lib(); ssl_init_done = TRUE; } #endif /* OPENSSL_VERSION_NUMBER */ void ssl_check_version(void) { u_long v; v = OpenSSL_version_num(); if ((v ^ OPENSSL_VERSION_NUMBER) & ~0xff0L) { msyslog(LOG_WARNING, "OpenSSL version mismatch. Built against %lx, you have %lx", (u_long)OPENSSL_VERSION_NUMBER, v); fprintf(stderr, "OpenSSL version mismatch. Built against %lx, you have %lx\n", (u_long)OPENSSL_VERSION_NUMBER, v); } INIT_SSL(); } #else /* !OPENSSL */ # define MD5_LENGTH 16 #endif /* OPENSSL */ /* * keytype_from_text returns OpenSSL NID for digest by name, and * optionally the associated digest length. * * Used by ntpd authreadkeys(), ntpq and ntpdc keytype() */ int keytype_from_text( const char * text, size_t * pdigest_len ) { int key_type; u_int digest_len; #ifdef OPENSSL /* --*-- OpenSSL code --*-- */ const u_long max_digest_len = MAX_MAC_LEN - sizeof(keyid_t); char * upcased; char * pch; EVP_MD const * md; /* * OpenSSL digest short names are capitalized, so uppercase the * digest name before passing to OBJ_sn2nid(). If it is not * recognized but matches our CMAC string use NID_cmac, or if * it begins with 'M' or 'm' use NID_md5 to be consistent with * past behavior. */ INIT_SSL(); /* get name in uppercase */ LIB_GETBUF(upcased); strlcpy(upcased, text, LIB_BUFLENGTH); for (pch = upcased; '\0' != *pch; pch++) { *pch = (char)toupper((unsigned char)*pch); } key_type = OBJ_sn2nid(upcased); # ifdef ENABLE_CMAC if (!key_type && !strncmp(CMAC, upcased, strlen(CMAC) + 1)) { key_type = NID_cmac; if (debug) { fprintf(stderr, "%s:%d:%s():%s:key\n", __FILE__, __LINE__, __func__, CMAC); } } # endif /*ENABLE_CMAC*/ #else key_type = 0; #endif if (!key_type && 'm' == tolower((unsigned char)text[0])) { key_type = NID_md5; } if (!key_type) { return 0; } if (NULL != pdigest_len) { #ifdef OPENSSL md = EVP_get_digestbynid(key_type); digest_len = (md) ? EVP_MD_size(md) : 0; if (!md || digest_len <= 0) { # ifdef ENABLE_CMAC if (key_type == NID_cmac) { digest_len = CMAC_LENGTH; if (debug) { fprintf(stderr, "%s:%d:%s():%s:len\n", __FILE__, __LINE__, __func__, CMAC); } } else # endif /*ENABLE_CMAC*/ { fprintf(stderr, "key type %s is not supported by OpenSSL\n", keytype_name(key_type)); msyslog(LOG_ERR, "key type %s is not supported by OpenSSL\n", keytype_name(key_type)); return 0; } } if (digest_len > max_digest_len) { fprintf(stderr, "key type %s %u octet digests are too big, max %lu\n", keytype_name(key_type), digest_len, max_digest_len); msyslog(LOG_ERR, "key type %s %u octet digests are too big, max %lu", keytype_name(key_type), digest_len, max_digest_len); return 0; } #else digest_len = MD5_LENGTH; #endif *pdigest_len = digest_len; } return key_type; } /* * keytype_name returns OpenSSL short name for digest by NID. * * Used by ntpq and ntpdc keytype() */ const char * keytype_name( int nid ) { static const char unknown_type[] = "(unknown key type)"; const char *name; #ifdef OPENSSL INIT_SSL(); name = OBJ_nid2sn(nid); # ifdef ENABLE_CMAC if (NID_cmac == nid) { name = CMAC; if (debug) { fprintf(stderr, "%s:%d:%s():%s:nid\n", __FILE__, __LINE__, __func__, CMAC); } } else # endif /*ENABLE_CMAC*/ if (NULL == name) { name = unknown_type; } #else /* !OPENSSL follows */ if (NID_md5 == nid) name = "MD5"; else name = unknown_type; #endif return name; } /* * Use getpassphrase() if configure.ac detected it, as Suns that * have it truncate the password in getpass() to 8 characters. */ #ifdef HAVE_GETPASSPHRASE # define getpass(str) getpassphrase(str) #endif /* * getpass_keytype() -- shared between ntpq and ntpdc, only vaguely * related to the rest of ssl_init.c. */ char * getpass_keytype( int keytype ) { char pass_prompt[64 + 11 + 1]; /* 11 for " Password: " */ snprintf(pass_prompt, sizeof(pass_prompt), "%.64s Password: ", keytype_name(keytype)); return getpass(pass_prompt); }
Upload File
Create Folder