From b3aaa0cc21c63d388230c7ef2a80abd631ff20d5 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Thu, 26 Feb 2009 21:43:15 +0000 Subject: [PATCH] Rename all symbols in libmp(3) to mp_*, just like Solaris. The function pow() in libmp(3) clashes with pow(3) in libm. We could rename this single function, but we can just take the same approach as the Solaris folks did, which is to prefix all function names with mp_. libmp(3) isn't really popular nowadays. I suspect not a single application in ports depends on it. There's still a chance, so I've increased the SHLIB_MAJOR and __FreeBSD_version. Reviewed by: deischen, rdivacky --- ObsoleteFiles.inc | 2 + contrib/telnet/libtelnet/pk.c | 86 ++++++++--------- lib/libmp/Makefile | 7 +- lib/libmp/Symbol.map | 23 +++++ lib/libmp/libmp.3 | 90 ++++++++---------- lib/libmp/mp.h | 34 +++---- lib/libmp/mpasbn.c | 34 +++---- lib/libtelnet/Makefile | 2 +- sys/sys/param.h | 2 +- tools/regression/lib/libmp/test-libmp.c | 118 ++++++++++++------------ usr.bin/chkey/Makefile | 2 + usr.bin/newkey/Makefile | 2 + usr.bin/newkey/generic.c | 40 ++++---- usr.sbin/keyserv/Makefile | 2 + usr.sbin/keyserv/setkey.c | 40 ++++---- 15 files changed, 255 insertions(+), 229 deletions(-) create mode 100644 lib/libmp/Symbol.map diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index f184254b7847..fcc117a69a8d 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -14,6 +14,8 @@ # The file is partitioned: OLD_FILES first, then OLD_LIBS and OLD_DIRS last. # +# 20090226: libmp(3) functions renamed +OLD_LIBS+=usr/lib/libmp.so.6 # 20090223: changeover of USB stacks OLD_FILES+=usr/include/dev/usb2/include/ufm2_ioctl.h OLD_FILES+=usr/include/dev/usb2/include/urio2_ioctl.h diff --git a/contrib/telnet/libtelnet/pk.c b/contrib/telnet/libtelnet/pk.c index 044e9b9e8ffa..05b74f43d414 100644 --- a/contrib/telnet/libtelnet/pk.c +++ b/contrib/telnet/libtelnet/pk.c @@ -68,19 +68,19 @@ extractideakey(MINT *ck, IdeaData *ideakey) short base = (1 << 8); char *k; - z = itom(0); - a = itom(0); - madd(ck, z, a); + z = mp_itom(0); + a = mp_itom(0); + mp_madd(ck, z, a); for (i = 0; i < ((KEYSIZE - 128) / 8); i++) { - sdiv(a, base, a, &r); + mp_sdiv(a, base, a, &r); } k = (char *)ideakey; for (i = 0; i < 16; i++) { - sdiv(a, base, a, &r); + mp_sdiv(a, base, a, &r); *k++ = r; } - mfree(z); - mfree(a); + mp_mfree(z); + mp_mfree(a); } /* @@ -97,19 +97,19 @@ extractdeskey(MINT *ck, DesData *deskey) short base = (1 << 8); char *k; - z = itom(0); - a = itom(0); - madd(ck, z, a); + z = mp_itom(0); + a = mp_itom(0); + mp_madd(ck, z, a); for (i = 0; i < ((KEYSIZE - 64) / 2) / 8; i++) { - sdiv(a, base, a, &r); + mp_sdiv(a, base, a, &r); } k = (char *)deskey; for (i = 0; i < 8; i++) { - sdiv(a, base, a, &r); + mp_sdiv(a, base, a, &r); *k++ = r; } - mfree(z); - mfree(a); + mp_mfree(z); + mp_mfree(a); } /* @@ -121,19 +121,19 @@ common_key(char *xsecret, char *xpublic, IdeaData *ideakey, DesData *deskey) MINT *public; MINT *secret; MINT *common; - MINT *modulus = xtom(HEXMODULUS); + MINT *modulus = mp_xtom(HEXMODULUS); - public = xtom(xpublic); - secret = xtom(xsecret); - common = itom(0); - pow(public, secret, modulus, common); + public = mp_xtom(xpublic); + secret = mp_xtom(xsecret); + common = mp_itom(0); + mp_pow(public, secret, modulus, common); extractdeskey(common, deskey); extractideakey(common, ideakey); des_set_odd_parity(deskey); - mfree(common); - mfree(secret); - mfree(public); - mfree(modulus); + mp_mfree(common); + mp_mfree(secret); + mp_mfree(public); + mp_mfree(modulus); } /* @@ -161,12 +161,12 @@ genkeys(char *public, char *secret) # define BASEBITS (8*sizeof(short) - 1) # define BASE (1 << BASEBITS) - MINT *pk = itom(0); - MINT *sk = itom(0); + MINT *pk = mp_itom(0); + MINT *sk = mp_itom(0); MINT *tmp; - MINT *base = itom(BASE); - MINT *root = itom(PROOT); - MINT *modulus = xtom(HEXMODULUS); + MINT *base = mp_itom(BASE); + MINT *root = mp_itom(PROOT); + MINT *modulus = mp_xtom(HEXMODULUS); short r; unsigned short seed[KEYSIZE/BASEBITS + 1]; char *xkey; @@ -174,24 +174,24 @@ genkeys(char *public, char *secret) getseed((char *)seed, sizeof(seed)); for (i = 0; i < KEYSIZE/BASEBITS + 1; i++) { r = seed[i] % BASE; - tmp = itom(r); - mult(sk, base, sk); - madd(sk, tmp, sk); - mfree(tmp); + tmp = mp_itom(r); + mp_mult(sk, base, sk); + mp_madd(sk, tmp, sk); + mp_mfree(tmp); } - tmp = itom(0); - mdiv(sk, modulus, tmp, sk); - mfree(tmp); - pow(root, sk, modulus, pk); - xkey = mtox(sk); + tmp = mp_itom(0); + mp_mdiv(sk, modulus, tmp, sk); + mp_mfree(tmp); + mp_pow(root, sk, modulus, pk); + xkey = mp_mtox(sk); adjust(secret, xkey); - xkey = mtox(pk); + xkey = mp_mtox(pk); adjust(public, xkey); - mfree(sk); - mfree(base); - mfree(pk); - mfree(root); - mfree(modulus); + mp_mfree(sk); + mp_mfree(base); + mp_mfree(pk); + mp_mfree(root); + mp_mfree(modulus); } /* diff --git a/lib/libmp/Makefile b/lib/libmp/Makefile index 2aed4e94a1f3..6c51c5787f09 100644 --- a/lib/libmp/Makefile +++ b/lib/libmp/Makefile @@ -1,14 +1,17 @@ # $FreeBSD$ LIB= mp -SHLIB_MAJOR= 6 +SHLIB_MAJOR= 7 DPADD= ${LIBCRYPTO} LDADD= -lcrypto MAN= libmp.3 INCS= mp.h SRCS= mpasbn.c -WARNS?= 0 +WARNS?= 6 CFLAGS+= -I${.CURDIR}/../../crypto +VERSION_DEF= ${.CURDIR}/../libc/Versions.def +SYMBOL_MAPS= ${.CURDIR}/Symbol.map + .include diff --git a/lib/libmp/Symbol.map b/lib/libmp/Symbol.map new file mode 100644 index 000000000000..0bd8684bfa9e --- /dev/null +++ b/lib/libmp/Symbol.map @@ -0,0 +1,23 @@ +/* + * $FreeBSD$ + */ + +FBSD_1.1 { + mp_gcd; + mp_itom; + mp_madd; + mp_mcmp; + mp_mdiv; + mp_mfree; + mp_min; + mp_mout; + mp_move; + mp_msqrt; + mp_msub; + mp_mtox; + mp_mult; + mp_pow; + mp_rpow; + mp_sdiv; + mp_xtom; +}; diff --git a/lib/libmp/libmp.3 b/lib/libmp/libmp.3 index 9be21d7b0de4..b826aa833fed 100644 --- a/lib/libmp/libmp.3 +++ b/lib/libmp/libmp.3 @@ -70,47 +70,47 @@ stored using the defined type Pointers to .Vt MINT are initialized using -.Fn itom +.Fn mp_itom or -.Fn xtom , +.Fn mp_xtom , and must be recycled with -.Fn mfree +.Fn mp_mfree when they are no longer needed. Routines which store a result in one of their arguments expect that the latter has also been initialized prior to being passed to it. The following routines are defined and implemented: .Pp .Ft "MINT *" Ns -.Fn itom "short n" ; +.Fn mp_itom "short n" ; .Pp .Ft "MINT *" Ns -.Fn xtom "const char *s" ; +.Fn mp_xtom "const char *s" ; .Pp .Ft "char *" Ns -.Fn mtox "const MINT *mp" ; +.Fn mp_mtox "const MINT *mp" ; .Pp .Ft void -.Fn mfree "MINT *mp" ; +.Fn mp_mfree "MINT *mp" ; .Bd -ragged -offset indent -.Fn itom +.Fn mp_itom returns an .Vt MINT with the value of .Fa n . -.Fn xtom +.Fn mp_xtom returns an .Vt MINT with the value of .Fa s , which is treated to be in hexadecimal. The return values from -.Fn itom +.Fn mp_itom and -.Fn xtom +.Fn mp_xtom must be released with -.Fn mfree +.Fn mp_mfree when they are no longer needed. -.Fn mtox +.Fn mp_mtox returns a null-terminated hexadecimal string having the value of .Fa mp ; its return value must be released with @@ -120,18 +120,18 @@ when it is no longer needed. .Ed .Pp .Ft void -.Fn madd "const MINT *mp1" "const MINT *mp2" "MINT *rmp" ; +.Fn mp_madd "const MINT *mp1" "const MINT *mp2" "MINT *rmp" ; .Pp .Ft void -.Fn msub "const MINT *mp1" "const MINT *mp2" "MINT *rmp" ; +.Fn mp_msub "const MINT *mp1" "const MINT *mp2" "MINT *rmp" ; .Pp .Ft void -.Fn mult "const MINT *mp1" "const MINT *mp2" "MINT *rmp" ; +.Fn mp_mult "const MINT *mp1" "const MINT *mp2" "MINT *rmp" ; .Bd -ragged -offset indent -.Fn madd , -.Fn msub , +.Fn mp_madd , +.Fn mp_msub , and -.Fn mult +.Fn mp_mult store the sum, difference, or product, respectively, of .Fa mp1 and @@ -141,12 +141,12 @@ in .Ed .Pp .Ft void -.Fn mdiv "const MINT *nmp" "const MINT *dmp" "MINT *qmp" "MINT *rmp" ; +.Fn mp_mdiv "const MINT *nmp" "const MINT *dmp" "MINT *qmp" "MINT *rmp" ; .Pp .Ft void -.Fn sdiv "const MINT *nmp" "short d" "MINT *qmp" "short *ro" ; +.Fn mp_sdiv "const MINT *nmp" "short d" "MINT *qmp" "short *ro" ; .Bd -ragged -offset indent -.Fn mdiv +.Fn mp_mdiv computes the quotient and remainder of .Fa nmp and @@ -156,9 +156,9 @@ and stores the result in and .Fa rmp , respectively. -.Fn sdiv +.Fn mp_sdiv is similar to -.Fn mdiv +.Fn mp_mdiv except the divisor .Fa ( dmp or @@ -171,12 +171,12 @@ are ordinary integers. .Ed .Pp .Ft void -.Fn pow "const MINT *bmp" "const MINT *emp" "const MINT *mmp" "MINT *rmp" ; +.Fn mp_pow "const MINT *bmp" "const MINT *emp" "const MINT *mmp" "MINT *rmp" ; .Pp .Ft void -.Fn rpow "const MINT *bmp" "short e" "MINT *rmp" ; +.Fn mp_rpow "const MINT *bmp" "short e" "MINT *rmp" ; .Bd -ragged -offset indent -.Fn rpow +.Fn mp_rpow computes the result of .Fa bmp raised to the @@ -185,7 +185,7 @@ power and reduced modulo .Fa mmp ; the result is stored in .Fa rmp . -.Fn pow +.Fn mp_pow computes the result of .Fa bmp raised to the @@ -195,25 +195,25 @@ power and stores the result in .Ed .Pp .Ft void -.Fn min "MINT *mp" ; +.Fn mp_min "MINT *mp" ; .Pp .Ft void -.Fn mout "const MINT *mp" ; +.Fn mp_mout "const MINT *mp" ; .Bd -ragged -offset indent -.Fn min +.Fn mp_min reads a line from standard input, tries to interpret it as a decimal number, and if successful, stores the result in .Fa mp . -.Fn mout +.Fn mp_mout prints the value, in decimal, of .Fa mp to standard output (without a trailing newline). .Ed .Pp .Ft void -.Fn gcd "const MINT *mp1" "const MINT *mp2" "MINT *rmp" ; +.Fn mp_gcd "const MINT *mp1" "const MINT *mp2" "MINT *rmp" ; .Bd -ragged -offset indent -.Fn gcd +.Fn mp_gcd computes the greatest common divisor of .Fa mp1 and @@ -223,7 +223,7 @@ and stores the result in .Ed .Pp .Ft int -.Fn mcmp "const MINT *mp1" "const MINT *mp2" ; +.Fn mp_mcmp "const MINT *mp1" "const MINT *mp2" ; .Bd -ragged -offset indent .Fa mcmp compares the values of @@ -243,9 +243,9 @@ is greater than .Ed .Pp .Ft void -.Fn move "const MINT *smp" "MINT *tmp" ; +.Fn mp_move "const MINT *smp" "MINT *tmp" ; .Bd -ragged -offset indent -.Fn move +.Fn mp_move copies the value of .Fa smp to @@ -254,9 +254,9 @@ to .Ed .Pp .Ft void -.Fn msqrt "const MINT *nmp" "MINT *xmp" "MINT *rmp" ; +.Fn mp_msqrt "const MINT *nmp" "MINT *xmp" "MINT *rmp" ; .Bd -ragged -offset indent -.Fn msqrt +.Fn mp_msqrt computes the square root and remainder of .Fa nmp and stores them in @@ -296,24 +296,16 @@ implemented in terms of This implementation appeared in .Fx 5.0 . .Sh BUGS -The -.Fn pow -routine exists in both -.Nm libmp -and -.Nm libm -with incompatible semantics. -.Pp Errors are reported via output to standard error and abnormal program termination instead of via return values. The application cannot control this behavior. .Pp It is not clear whether the string returned by -.Fn mtox +.Fn mp_mtox may be written to by the caller. This implementation allows it, but others may not. Ideally, -.Fn mtox +.Fn mp_mtox would take a pointer to a buffer to fill in. .Pp It is not clear whether using the same variable as both source and diff --git a/lib/libmp/mp.h b/lib/libmp/mp.h index 4c2c94d05fc8..78f09fd4a129 100644 --- a/lib/libmp/mp.h +++ b/lib/libmp/mp.h @@ -11,22 +11,22 @@ typedef struct _mint { BIGNUM *bn; } MINT; -void gcd(const MINT *, const MINT *, MINT *); -MINT *itom(short); -void madd(const MINT *, const MINT *, MINT *); -int mcmp(const MINT *, const MINT *); -void mdiv(const MINT *, const MINT *, MINT *, MINT *); -void mfree(MINT *); -void min(MINT *); -void mout(const MINT *); -void move(const MINT *, MINT *); -void msqrt(const MINT *, MINT *, MINT *); -void msub(const MINT *, const MINT *, MINT *); -char *mtox(const MINT *); -void mult(const MINT *, const MINT *, MINT *); -void pow(const MINT *, const MINT *, const MINT *, MINT *); -void rpow(const MINT *, short, MINT *); -void sdiv(const MINT *, short, MINT *, short *); -MINT *xtom(const char *); +void mp_gcd(const MINT *, const MINT *, MINT *); +MINT *mp_itom(short); +void mp_madd(const MINT *, const MINT *, MINT *); +int mp_mcmp(const MINT *, const MINT *); +void mp_mdiv(const MINT *, const MINT *, MINT *, MINT *); +void mp_mfree(MINT *); +void mp_min(MINT *); +void mp_mout(const MINT *); +void mp_move(const MINT *, MINT *); +void mp_msqrt(const MINT *, MINT *, MINT *); +void mp_msub(const MINT *, const MINT *, MINT *); +char *mp_mtox(const MINT *); +void mp_mult(const MINT *, const MINT *, MINT *); +void mp_pow(const MINT *, const MINT *, const MINT *, MINT *); +void mp_rpow(const MINT *, short, MINT *); +void mp_sdiv(const MINT *, short, MINT *, short *); +MINT *mp_xtom(const char *); #endif /* !_MP_H_ */ diff --git a/lib/libmp/mpasbn.c b/lib/libmp/mpasbn.c index 797960def73d..bc5556dfb080 100644 --- a/lib/libmp/mpasbn.c +++ b/lib/libmp/mpasbn.c @@ -140,7 +140,7 @@ _dtom(const char *msg, const char *s) * Compute the greatest common divisor of mp1 and mp2; result goes in rmp. */ void -gcd(const MINT *mp1, const MINT *mp2, MINT *rmp) +mp_gcd(const MINT *mp1, const MINT *mp2, MINT *rmp) { BIGNUM b; BN_CTX *c; @@ -173,7 +173,7 @@ _itom(const char *msg, short n) } MINT * -itom(short n) +mp_itom(short n) { return (_itom("itom", n)); @@ -194,7 +194,7 @@ _madd(const char *msg, const MINT *mp1, const MINT *mp2, MINT *rmp) } void -madd(const MINT *mp1, const MINT *mp2, MINT *rmp) +mp_madd(const MINT *mp1, const MINT *mp2, MINT *rmp) { _madd("madd", mp1, mp2, rmp); @@ -204,7 +204,7 @@ madd(const MINT *mp1, const MINT *mp2, MINT *rmp) * Return -1, 0, or 1 if mp1mp2, respectivley. */ int -mcmp(const MINT *mp1, const MINT *mp2) +mp_mcmp(const MINT *mp1, const MINT *mp2) { return (BN_cmp(mp1->bn, mp2->bn)); @@ -239,7 +239,7 @@ _mdiv(const char *msg, const MINT *nmp, const MINT *dmp, MINT *qmp, MINT *rmp, } void -mdiv(const MINT *nmp, const MINT *dmp, MINT *qmp, MINT *rmp) +mp_mdiv(const MINT *nmp, const MINT *dmp, MINT *qmp, MINT *rmp) { BN_CTX *c; @@ -263,7 +263,7 @@ _mfree(const char *msg __unused, MINT *mp) } void -mfree(MINT *mp) +mp_mfree(MINT *mp) { _mfree("mfree", mp); @@ -277,7 +277,7 @@ mfree(MINT *mp) * exported.) */ void -min(MINT *mp) +mp_min(MINT *mp) { MINT *rmp; char *line, *nline; @@ -302,7 +302,7 @@ min(MINT *mp) * above min() for why this is so useless. */ void -mout(const MINT *mp) +mp_mout(const MINT *mp) { char *s; @@ -315,7 +315,7 @@ mout(const MINT *mp) * Set the value of tmp to the value of smp (i.e., tmp=smp). */ void -move(const MINT *smp, MINT *tmp) +mp_move(const MINT *smp, MINT *tmp) { _movem("move", smp, tmp); @@ -357,7 +357,7 @@ _movem(const char *msg, const MINT *smp, MINT *tmp) * although suboptimal, works, too; this is that is used below. */ void -msqrt(const MINT *nmp, MINT *xmp, MINT *rmp) +mp_msqrt(const MINT *nmp, MINT *xmp, MINT *rmp) { BN_CTX *c; MINT *tolerance; @@ -409,7 +409,7 @@ _msub(const char *msg, const MINT *mp1, const MINT *mp2, MINT *rmp) } void -msub(const MINT *mp1, const MINT *mp2, MINT *rmp) +mp_msub(const MINT *mp1, const MINT *mp2, MINT *rmp) { _msub("msub", mp1, mp2, rmp); @@ -467,7 +467,7 @@ _mtox(const char *msg, const MINT *mp) } char * -mtox(const MINT *mp) +mp_mtox(const MINT *mp) { return (_mtox("mtox", mp)); @@ -488,7 +488,7 @@ _mult(const char *msg, const MINT *mp1, const MINT *mp2, MINT *rmp, BN_CTX *c) } void -mult(const MINT *mp1, const MINT *mp2, MINT *rmp) +mp_mult(const MINT *mp1, const MINT *mp2, MINT *rmp) { BN_CTX *c; @@ -504,7 +504,7 @@ mult(const MINT *mp1, const MINT *mp2, MINT *rmp) * means 'raise to power', not 'bitwise XOR'.) */ void -pow(const MINT *bmp, const MINT *emp, const MINT *mmp, MINT *rmp) +mp_pow(const MINT *bmp, const MINT *emp, const MINT *mmp, MINT *rmp) { BIGNUM b; BN_CTX *c; @@ -523,7 +523,7 @@ pow(const MINT *bmp, const MINT *emp, const MINT *mmp, MINT *rmp) * Compute rmp=bmp^e. (See note above pow().) */ void -rpow(const MINT *bmp, short e, MINT *rmp) +mp_rpow(const MINT *bmp, short e, MINT *rmp) { MINT *emp; BIGNUM b; @@ -572,7 +572,7 @@ _sdiv(const char *msg, const MINT *nmp, short d, MINT *qmp, short *ro, } void -sdiv(const MINT *nmp, short d, MINT *qmp, short *ro) +mp_sdiv(const MINT *nmp, short d, MINT *qmp, short *ro) { BN_CTX *c; @@ -602,7 +602,7 @@ _xtom(const char *msg, const char *s) } MINT * -xtom(const char *s) +mp_xtom(const char *s) { return (_xtom("xtom", s)); diff --git a/lib/libtelnet/Makefile b/lib/libtelnet/Makefile index 37eb8f6da801..1cf52a01e882 100644 --- a/lib/libtelnet/Makefile +++ b/lib/libtelnet/Makefile @@ -13,7 +13,7 @@ INTERNALLIB= SRCS= genget.c getent.c misc.c CFLAGS+= -I${TELNETDIR} -WARNS?= 0 +WARNS?= 2 .if !defined(RELEASE_CRUNCH) .if ${MK_OPENSSL} != "no" diff --git a/sys/sys/param.h b/sys/sys/param.h index b390cde41362..3676c1e4c354 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -57,7 +57,7 @@ * is created, otherwise 1. */ #undef __FreeBSD_version -#define __FreeBSD_version 800064 /* Master, propagated to newvers */ +#define __FreeBSD_version 800065 /* Master, propagated to newvers */ #ifndef LOCORE #include diff --git a/tools/regression/lib/libmp/test-libmp.c b/tools/regression/lib/libmp/test-libmp.c index 519656ade3b3..d9d2c9f6b3e0 100644 --- a/tools/regression/lib/libmp/test-libmp.c +++ b/tools/regression/lib/libmp/test-libmp.c @@ -40,7 +40,7 @@ static void testmcmp(const MINT *mp1, const MINT *mp2, const char *tname) { - if (mcmp(mp1, mp2) == 0) + if (mp_mcmp(mp1, mp2) == 0) printf("ok %d - %s\n", ++tnr, tname); else printf("not ok - %d %s\n", ++tnr, tname); @@ -53,32 +53,32 @@ testsimpel(void) MINT *t2; char *s; - madd(c42, c1, t0); + mp_madd(c42, c1, t0); testmcmp(c43, t0, "madd0"); - madd(t0, c1, t0); + mp_madd(t0, c1, t0); testmcmp(c44, t0, "madd1"); - msub(t0, c1, t0); + mp_msub(t0, c1, t0); testmcmp(c43, t0, "msub0"); - msub(t0, c1, t0); + mp_msub(t0, c1, t0); testmcmp(c42, t0, "msub1"); - move(c42, t0); + mp_move(c42, t0); testmcmp(c42, t0, "move0"); - t2 = xtom(str42); + t2 = mp_xtom(str42); testmcmp(c42, t2, "xtom"); - s = mtox(t2); + s = mp_mtox(t2); if (strcmp(str42, s) == 0) printf("ok %d - %s\n", ++tnr, "mtox0"); else printf("not ok %d - %s\n", ++tnr, "mtox0"); - mfree(t2); + mp_mfree(t2); } static int testgcd(void) { - gcd(c10, c15, t0); + mp_gcd(c10, c15, t0); testmcmp(t0, c5, "gcd0"); } @@ -86,10 +86,10 @@ static int testmsqrt(void) { - msqrt(c25, t0, t1); + mp_msqrt(c25, t0, t1); testmcmp(t0, c5, "msqrt0"); testmcmp(t1, c0, "msqrt1"); - msqrt(c42, t0, t1); + mp_msqrt(c42, t0, t1); testmcmp(t0, c6, "msqrt2"); testmcmp(t1, c6, "msqrt3"); } @@ -100,34 +100,34 @@ testdiv(void) short ro; MINT *t2; - mdiv(c42, c5, t0, t1); + mp_mdiv(c42, c5, t0, t1); testmcmp(t0, c8, "mdiv0"); testmcmp(t1, c2, "mdiv1"); - mdiv(c10, c8, t0, t1); + mp_mdiv(c10, c8, t0, t1); testmcmp(t0, c1, "mdiv2"); testmcmp(t1, c2, "mdiv3"); - sdiv(c42, 5, t0, &ro); + mp_sdiv(c42, 5, t0, &ro); testmcmp(t0, c8, "sdiv0"); - t2 = itom(ro); // Simpler to use common testmcmp() + t2 = mp_itom(ro); // Simpler to use common testmcmp() testmcmp(t2, c2, "sdiv1"); - mfree(t2); + mp_mfree(t2); - sdiv(c10, 8, t0, &ro); + mp_sdiv(c10, 8, t0, &ro); testmcmp(t0, c1, "sdiv2"); - t2 = itom(ro); // Simpler to use common testmcmp() + t2 = mp_itom(ro); // Simpler to use common testmcmp() testmcmp(t2, c2, "sdiv3"); - mfree(t2); + mp_mfree(t2); } static int testmult(void) { - mult(c5, c2, t0); + mp_mult(c5, c2, t0); testmcmp(t0, c10, "mmult0"); - mult(c3, c14, t0); + mp_mult(c3, c14, t0); testmcmp(t0, c42, "mmult1"); } @@ -135,11 +135,11 @@ static int testpow(void) { - pow(c2, c3, c10, t0); + mp_pow(c2, c3, c10, t0); testmcmp(t0, c8, "pow0"); - pow(c2, c3, c3, t0); + mp_pow(c2, c3, c3, t0); testmcmp(t0, c2, "pow1"); - rpow(c2, 3, t0); + mp_rpow(c2, 3, t0); testmcmp(t0, c8, "rpow0"); } @@ -160,25 +160,25 @@ main(int argc, char *argv[]) * cumbersome way to in theory be able to check for memory * leaks. */ - c0 = itom(0); - c1 = itom(1); - c2 = itom(2); - c3 = itom(3); - c5 = itom(5); - c6 = itom(6); - c8 = itom(8); - c10 = itom(10); - c14 = itom(14); - c15 = itom(15); - c25 = itom(25); - c42 = itom(42); - c43 = itom(43); - c44 = itom(44); - c45 = itom(45); + c0 = mp_itom(0); + c1 = mp_itom(1); + c2 = mp_itom(2); + c3 = mp_itom(3); + c5 = mp_itom(5); + c6 = mp_itom(6); + c8 = mp_itom(8); + c10 = mp_itom(10); + c14 = mp_itom(14); + c15 = mp_itom(15); + c25 = mp_itom(25); + c42 = mp_itom(42); + c43 = mp_itom(43); + c44 = mp_itom(44); + c45 = mp_itom(45); // Init temp variables - t0 = itom(0); - t1 = itom(0); + t0 = mp_itom(0); + t1 = mp_itom(0); // Run tests testsimpel(); @@ -189,23 +189,23 @@ main(int argc, char *argv[]) testmsqrt(); // Cleanup - mfree(c0); - mfree(c1); - mfree(c2); - mfree(c3); - mfree(c5); - mfree(c6); - mfree(c8); - mfree(c10); - mfree(c14); - mfree(c15); - mfree(c25); - mfree(c42); - mfree(c43); - mfree(c44); - mfree(c45); - mfree(t0); - mfree(t1); + mp_mfree(c0); + mp_mfree(c1); + mp_mfree(c2); + mp_mfree(c3); + mp_mfree(c5); + mp_mfree(c6); + mp_mfree(c8); + mp_mfree(c10); + mp_mfree(c14); + mp_mfree(c15); + mp_mfree(c25); + mp_mfree(c42); + mp_mfree(c43); + mp_mfree(c44); + mp_mfree(c45); + mp_mfree(t0); + mp_mfree(t1); return (EX_OK); } diff --git a/usr.bin/chkey/Makefile b/usr.bin/chkey/Makefile index 847e5c960106..2813ca1a45f0 100644 --- a/usr.bin/chkey/Makefile +++ b/usr.bin/chkey/Makefile @@ -13,4 +13,6 @@ CFLAGS+= -DYP DPADD= ${LIBRPCSVC} ${LIBMP} ${LIBCRYPTO} LDADD= -lrpcsvc -lmp -lcrypto +WARNS?= 6 + .include diff --git a/usr.bin/newkey/Makefile b/usr.bin/newkey/Makefile index b3b5b51d8c9f..1460f8719419 100644 --- a/usr.bin/newkey/Makefile +++ b/usr.bin/newkey/Makefile @@ -11,4 +11,6 @@ MAN= newkey.8 DPADD= ${LIBRPCSVC} ${LIBMP} ${LIBCRYPTO} LDADD= -lrpcsvc -lmp -lcrypto +WARNS?= 6 + .include diff --git a/usr.bin/newkey/generic.c b/usr.bin/newkey/generic.c index 3572df92f727..3626960f9540 100644 --- a/usr.bin/newkey/generic.c +++ b/usr.bin/newkey/generic.c @@ -79,12 +79,12 @@ genkeys(char *public, char *secret, char *pass) # define BASEBITS (8*sizeof (short) - 1) # define BASE (1 << BASEBITS) - MINT *pk = itom(0); - MINT *sk = itom(0); + MINT *pk = mp_itom(0); + MINT *sk = mp_itom(0); MINT *tmp; - MINT *base = itom(BASE); - MINT *root = itom(PROOT); - MINT *modulus = xtom(HEXMODULUS); + MINT *base = mp_itom(BASE); + MINT *root = mp_itom(PROOT); + MINT *modulus = mp_xtom(HEXMODULUS); short r; unsigned short seed[KEYSIZE/BASEBITS + 1]; char *xkey; @@ -92,24 +92,24 @@ genkeys(char *public, char *secret, char *pass) getseed((char *)seed, sizeof (seed), (u_char *)pass); for (i = 0; i < KEYSIZE/BASEBITS + 1; i++) { r = seed[i] % BASE; - tmp = itom(r); - mult(sk, base, sk); - madd(sk, tmp, sk); - mfree(tmp); + tmp = mp_itom(r); + mp_mult(sk, base, sk); + mp_madd(sk, tmp, sk); + mp_mfree(tmp); } - tmp = itom(0); - mdiv(sk, modulus, tmp, sk); - mfree(tmp); - pow(root, sk, modulus, pk); - xkey = mtox(sk); + tmp = mp_itom(0); + mp_mdiv(sk, modulus, tmp, sk); + mp_mfree(tmp); + mp_pow(root, sk, modulus, pk); + xkey = mp_mtox(sk); adjust(secret, xkey); - xkey = mtox(pk); + xkey = mp_mtox(pk); adjust(public, xkey); - mfree(sk); - mfree(base); - mfree(pk); - mfree(root); - mfree(modulus); + mp_mfree(sk); + mp_mfree(base); + mp_mfree(pk); + mp_mfree(root); + mp_mfree(modulus); } /* diff --git a/usr.sbin/keyserv/Makefile b/usr.sbin/keyserv/Makefile index 54075da67638..37a416f8dfc5 100644 --- a/usr.sbin/keyserv/Makefile +++ b/usr.sbin/keyserv/Makefile @@ -9,6 +9,8 @@ CFLAGS+= -DKEYSERV_RANDOM -DBROKEN_DES -I. DPADD= ${LIBMP} ${LIBCRYPTO} ${LIBRPCSVC} LDADD= -lmp -lcrypto -lrpcsvc +WARNS?= 1 + RPCDIR= ${DESTDIR}/usr/include/rpcsvc CLEANFILES= crypt_svc.c crypt.h diff --git a/usr.sbin/keyserv/setkey.c b/usr.sbin/keyserv/setkey.c index 046a358c56f2..a11d04d4babe 100644 --- a/usr.sbin/keyserv/setkey.c +++ b/usr.sbin/keyserv/setkey.c @@ -84,7 +84,7 @@ void setmodulus(modx) char *modx; { - MODULUS = xtom(modx); + MODULUS = mp_xtom(modx); } /* @@ -198,19 +198,19 @@ pk_crypt(uid, remote_name, remote_key, key, mode) } if (!readcache(xpublic, xsecret, &deskey)) { - public = xtom(xpublic); - secret = xtom(xsecret); + public = mp_xtom(xpublic); + secret = mp_xtom(xsecret); /* Sanity Check on public and private keys */ if ((public == NULL) || (secret == NULL)) return (KEY_SYSTEMERR); - common = itom(0); - pow(public, secret, MODULUS, common); + common = mp_itom(0); + mp_pow(public, secret, MODULUS, common); extractdeskey(common, &deskey); writecache(xpublic, xsecret, &deskey); - mfree(secret); - mfree(public); - mfree(common); + mp_mfree(secret); + mp_mfree(public); + mp_mfree(common); } err = ecb_crypt((char *)&deskey, (char *)key, sizeof (des_block), DES_HW | mode); @@ -248,19 +248,19 @@ pk_get_conv_key(uid, xpublic, result) } if (!readcache(xpublic, xsecret, &result->cryptkeyres_u.deskey)) { - public = xtom(xpublic); - secret = xtom(xsecret); + public = mp_xtom(xpublic); + secret = mp_xtom(xsecret); /* Sanity Check on public and private keys */ if ((public == NULL) || (secret == NULL)) return (KEY_SYSTEMERR); - common = itom(0); - pow(public, secret, MODULUS, common); + common = mp_itom(0); + mp_pow(public, secret, MODULUS, common); extractdeskey(common, &result->cryptkeyres_u.deskey); writecache(xpublic, xsecret, &result->cryptkeyres_u.deskey); - mfree(secret); - mfree(public); - mfree(common); + mp_mfree(secret); + mp_mfree(public); + mp_mfree(common); } return (KEY_SUCCESS); @@ -281,21 +281,21 @@ extractdeskey(ck, deskey) short base = (1 << 8); char *k; - a = itom(0); + a = mp_itom(0); #ifdef SOLARIS_MP _mp_move(ck, a); #else - move(ck, a); + mp_move(ck, a); #endif for (i = 0; i < ((KEYSIZE - 64) / 2) / 8; i++) { - sdiv(a, base, a, &r); + mp_sdiv(a, base, a, &r); } k = deskey->c; for (i = 0; i < 8; i++) { - sdiv(a, base, a, &r); + mp_sdiv(a, base, a, &r); *k++ = r; } - mfree(a); + mp_mfree(a); des_setparity((char *)deskey); }