mirror of
https://github.com/clearml/dropbear
synced 2025-06-26 18:17:32 +00:00
Compare commits
1 Commits
DROPBEAR_0
...
libtommath
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea8cd283eb |
546
CHANGES
546
CHANGES
@@ -1,546 +0,0 @@
|
||||
0.48.1 - Sat 11 March 2006
|
||||
|
||||
- Compile fix for scp
|
||||
|
||||
0.48 - Thurs 9 March 2006
|
||||
|
||||
- Check that the circular buffer is properly empty before
|
||||
closing a channel, which could cause truncated transfers
|
||||
(thanks to Tomas Vanek for helping track it down)
|
||||
|
||||
- Implement per-IP pre-authentication connection limits
|
||||
(after some poking from Pablo Fernandez)
|
||||
|
||||
- Exit gracefully if trying to connect to as SSH v1 server
|
||||
(reported by Rushi Lala)
|
||||
|
||||
- Only read /dev/random once at startup when in non-inetd mode
|
||||
|
||||
- Allow ctrl-c to close a dbclient password prompt (may
|
||||
still have to press enter on some platforms)
|
||||
|
||||
- Merged in uClinux patch for inetd mode
|
||||
|
||||
- Updated to scp from OpenSSH 4.3p2 - fixes a security issue
|
||||
where use of system() could cause users to execute arbitrary
|
||||
code through malformed filenames, ref CVE-2006-0225
|
||||
|
||||
0.47 - Thurs Dec 8 2005
|
||||
|
||||
- SECURITY: fix for buffer allocation error in server code, could potentially
|
||||
allow authenticated users to gain elevated privileges. All multi-user systems
|
||||
running the server should upgrade (or apply the patch available on the
|
||||
Dropbear webpage).
|
||||
|
||||
- Fix channel handling code so that redirecting to /dev/null doesn't use
|
||||
100% CPU.
|
||||
|
||||
- Turn on zlib compression for dbclient.
|
||||
|
||||
- Set "low delay" TOS bit, can significantly improve interactivity
|
||||
over some links.
|
||||
|
||||
- Added client keyboard-interactive mode support, allows operation with
|
||||
newer OpenSSH servers in default config.
|
||||
|
||||
- Log when pubkey auth fails because of bad ~/.ssh/authorized_keys permissions
|
||||
|
||||
- Improve logging of assertions
|
||||
|
||||
- Added aes-256 cipher and sha1-96 hmac.
|
||||
|
||||
- Fix twofish so that it actually works.
|
||||
|
||||
- Improve PAM prompt comparison.
|
||||
|
||||
- Added -g (dbclient) and -a (dropbear server) options to allow
|
||||
connections to listening forwarded ports from remote machines.
|
||||
|
||||
- Various other minor fixes
|
||||
|
||||
- Compile fixes for glibc 2.1 (ss_family vs __ss_family) and NetBSD
|
||||
(netinet/in_systm.h needs to be included).
|
||||
|
||||
0.46 - Sat July 9 2005
|
||||
|
||||
- Fix long-standing bug which caused connections to be closed if an ssh-agent
|
||||
socket was no longer available
|
||||
|
||||
- Print a warning if we seem to be blocking on /dev/random
|
||||
(suggested by Paul Fox)
|
||||
|
||||
- Fixed a memory leak in DSS code (thanks to Boris Berezovsky for the patch)
|
||||
|
||||
- dbclient -L no longer segfaults, allocate correct buffer size (thanks
|
||||
to David Cook for reporting it, and Christopher Faylor for independently
|
||||
sending in a patch)
|
||||
|
||||
- Added RSA blinding to signing code (suggested by Dan Kaminsky)
|
||||
|
||||
- Rearranged bignum reading/random generation code
|
||||
|
||||
- Reset the non-blocking status on stderr and stdout as well as stdin,
|
||||
fixes a problem where the shell running dbclient will exit (thanks to
|
||||
Brent Roman for reporting it)
|
||||
|
||||
- Fix so that all file descriptors are closed so the child shell doesn't
|
||||
inherit descriptors (thanks to Linden May for the patch)
|
||||
|
||||
- Change signkey.c to avoid gcc 4 generating incorrect code
|
||||
|
||||
- After both sides of a file descriptor have been shutdown(), close()
|
||||
it to avoid leaking descriptors (thanks to Ari Hyttinen for a patch)
|
||||
|
||||
- Update to LibTomCrypt 1.05 and LibTomMath 0.35
|
||||
|
||||
0.45 - Mon March 7 2005
|
||||
|
||||
- Makefile no longer appends 'static' to statically linked binaries
|
||||
|
||||
- Add optional SSH_ASKPASS support to the client
|
||||
|
||||
- Respect HOST_LOOKUP option
|
||||
|
||||
- Fix accidentally removed "return;" statement which was removed in 0.44
|
||||
(causing clients which sent an empty terminal-modes string to fail to
|
||||
connect - including pssh, ssh.com, danger hiptop). (patches
|
||||
independently from Paul Fox, David Horwitt and Sven-Ola Tuecke)
|
||||
|
||||
- Read "y/n" response for fingerprints from /dev/tty directly so that dbclient
|
||||
will work with scp.
|
||||
|
||||
0.44 - Mon Jan 3 2005
|
||||
|
||||
- SECURITY: Fix for PAM auth so that usernames are logged and conversation
|
||||
function responses are allocated correctly - all 0.44test4 users with PAM
|
||||
compiled in (not default) are advised to upgrade.
|
||||
|
||||
- Fix calls to getnameinfo() for compatibility with Solaris
|
||||
|
||||
- Pristine compilation works (run 'configure' from a fresh dir and make it
|
||||
there)
|
||||
|
||||
- Fixes for compiling with most options disabled.
|
||||
|
||||
- Upgraded to LibTomCrypt 0.99 and LibTomMath 0.32
|
||||
|
||||
- Make sure that zeroing out of values in LTM and LTC won't get optimised away
|
||||
|
||||
- Removed unused functions from loginrec.c
|
||||
|
||||
- /dev/random is now the default entropy source rather than /dev/urandom
|
||||
|
||||
- Logging of IPs in auth success/failure messages for improved greppability
|
||||
|
||||
- Fix dbclient so that "scp -i keyfile" works. (It can handle "-ikeyfile
|
||||
properly)
|
||||
|
||||
- Avoid a race in server shell-handling code which prevents the exit-code
|
||||
from being returned to the client in some circumstances.
|
||||
|
||||
- Makefile modified so that install target works correctly (doesn't try
|
||||
to install "all" binary) - patch from Juergen Daubert
|
||||
|
||||
- Various minor fixes and compile warnings.
|
||||
|
||||
0.44test4 - Tue Sept 14 2004 21:15:54 +0800
|
||||
|
||||
- Fix inetd mode so it actually loads the hostkeys (oops)
|
||||
|
||||
- Changed DROPBEAR_DEFPORT properly everywhere
|
||||
|
||||
- Fix a small memory leak in the auth code
|
||||
|
||||
- WCOREDUMP is only used on systems which support it (ie not cygwin or AIX)
|
||||
|
||||
- Check (and fail for) cases when we can't negotiate algorithms with the
|
||||
remote side successfully (rather than bombing out ungracefully)
|
||||
|
||||
- Handle authorized_keys files without a terminating newline
|
||||
|
||||
- Fiddle the channel receive window size for possibly better performance
|
||||
|
||||
- Added in the PAM authentication code (finally! thanks to Martin Carlsson)
|
||||
|
||||
0.44test3 - Fri Aug 27 22:20:54 +0800
|
||||
|
||||
- Fixed a bunch of warnings.
|
||||
|
||||
- scp works correctly when passed a username (fix for the dbclient program
|
||||
itself as well, "-lmatt" works as well as "-l matt").
|
||||
|
||||
- Remove unrequired debian files
|
||||
|
||||
- Exit with the remote process's return code for dbclient
|
||||
|
||||
- Display stderr messages from the server in the client
|
||||
|
||||
- Add circular buffering to the channel code. This should dramatically reduce
|
||||
the amount of backtraffic sent in response to traffic incoming to the
|
||||
Dropbear end - improves high-latency performance (ie dialup).
|
||||
|
||||
- Various other related channel-handling fixups.
|
||||
|
||||
- Allow leading lines in the banner when connecting to servers
|
||||
|
||||
- Fixed printing out errors onto the network socket with stderr (for inetd
|
||||
mode when using xinetd)
|
||||
|
||||
- Remove obselete documentation
|
||||
|
||||
- Fix a null-pointer exception when trying to free non-existant listeners
|
||||
at cleanup.
|
||||
|
||||
- DEBUG_TRACE now only works if you add "-v" to the program commandline
|
||||
|
||||
- Don't leave stdin non-blocking on exit - this caused the parent shell
|
||||
of dbclient to close when dbclient exited, for some shells in BusyBox
|
||||
|
||||
- Server connections no longer timeout after 5 minutes
|
||||
|
||||
- Fixed stupid DSS hostkey typo (server couldn't load host keys)
|
||||
|
||||
0.44test2 - Tues Aug 17 2004 17:43:54 +0800
|
||||
|
||||
- Fix up dropbearmulti targets in the Makefile - symlinks are now created
|
||||
|
||||
- Compile fake-rfc2553 even with dropbearconvert/dropbearkey - this
|
||||
allows them to work on platforms without a native getaddrinfo()
|
||||
|
||||
- Create ~/.ssh/known_hosts properly if it doesn't exist
|
||||
|
||||
- Fix basename() function prototype
|
||||
|
||||
- Backport some local changes (more #ifdefs for termcodes.c, a fix for missing
|
||||
defines on AIX).
|
||||
|
||||
- Let dbclient be run as "ssh"
|
||||
|
||||
- Initialise mp_ints by default
|
||||
|
||||
0.44test1 - Sun Aug 16 2005 17:43:54 +0800
|
||||
|
||||
- TESTING RELEASE - this is the first public release of the client codebase,
|
||||
so there are sure to be bugs to be found. In addition, if you're just using
|
||||
the server portion, the final binary size probably will increase - I'll
|
||||
be trying to get it back down in future releases.
|
||||
|
||||
- Dropbear client added - lots of changes to the server code as well to
|
||||
generalise things
|
||||
|
||||
- IPv6 support added for client, server, and forwarding
|
||||
|
||||
- New makefile with more generic support for multiple-program binaries
|
||||
|
||||
0.43 - Fri Jul 16 2004 17:44:54 +0800
|
||||
|
||||
- SECURITY: Don't try to free() uninitialised variables in DSS verification
|
||||
code. Thanks to Arne Bernin for pointing out this bug. This is possibly
|
||||
exploitable, all users with DSS and pubkey-auth compiled in are advised to
|
||||
upgrade.
|
||||
|
||||
- Clean up agent forwarding socket files correctly, patch from Gerrit Pape.
|
||||
|
||||
- Don't go into an infinite loop when portforwarding to servers which don't
|
||||
send any initial data/banner. Patch from Nikola Vladov
|
||||
|
||||
- Fix for network vs. host byte order in logging remote TCP ports, also
|
||||
from Gerrit Pape.
|
||||
|
||||
- Initialise many pointers to NULL, for general safety. Also checked cleanup
|
||||
code for mp_ints (related to security issues above).
|
||||
|
||||
0.42 - Wed Jun 16 2004 12:44:54 +0800
|
||||
|
||||
- Updated to Gerrit Pape's official Debian subdirectory
|
||||
|
||||
- Fixed bad check when opening /dev/urandom - thanks to Danny Sung.
|
||||
|
||||
- Added -i inetd mode flag, and associated options in options.h . Dropbear
|
||||
can be compiled with either normal mode, inetd, or both modes. Thanks
|
||||
to Gerrit Pape for basic patch and motivation.
|
||||
|
||||
- Use <dirent.h> rather than <sys/dir.h> for POSIX compliance. Thanks to Bill
|
||||
Sommerfield.
|
||||
|
||||
- Fixed a TCP forwarding (client-local, -L style) bug which caused the whole
|
||||
session to close if the TCP connection failed. Thanks to Andrew Braund for
|
||||
reporting it and helping track it down.
|
||||
|
||||
- Re-enable sigpipe for child processes. Thanks to Gerrit Pape for some
|
||||
suggestions, and BSD manpages for a clearer explanation of the behaviour.
|
||||
|
||||
- Added manpages, thanks to Gerrit Pape.
|
||||
|
||||
- Changed license text for LibTomCrypt and LibTomMath.
|
||||
|
||||
- Added strip-static target
|
||||
|
||||
- Fixed a bug in agent-forwarding cleanup handler - would segfault
|
||||
(dereferencing a null pointer) if agent forwarding had failed.
|
||||
|
||||
- Fix behaviour of authorized_keys parsing, so larger (>1024 bit) DSA keys will
|
||||
work. Thanks to Dr. Markus Waldeck for the report.
|
||||
|
||||
- Fixed local port forwarding code so that the "-j" option will make forwarding
|
||||
attempts fail more gracefully.
|
||||
|
||||
- Allow repeated requests in a single session if previous ones fail - this fixes PuTTY and some other SCP clients, which try SFTP, then fall-back to SCP if it
|
||||
isn't available. Thanks to Stirling Westrup for the report.
|
||||
|
||||
- Updated to LibTomCrypt 0.96 and LibTomMath 0.30. The AES code now uses
|
||||
smaller non-precomputed tables if DROPBEAR_SMALL_CODE is defined in
|
||||
options.h, leading to a significant reduction in the binary size.
|
||||
|
||||
0.41 - Mon Jan 19 2004 22:40:19 +0800
|
||||
|
||||
- Fix in configure so that cross-compiling works, thanks to numerous people for
|
||||
reporting and testing
|
||||
|
||||
- Terminal mode parsing now handles empty terminal mode strings (sent by
|
||||
Windows ssh.com clients), thanks to Ricardo Derbes for the report
|
||||
|
||||
- Handling is improved for users with no shell specified in /etc/passwd,
|
||||
thanks again to Ricardo Derbes
|
||||
|
||||
- Fix for compiling with --disable-syslog, thanks to gordonfh
|
||||
|
||||
- Various minor fixes allow scp to work with irix, thanks to Paul Marinceu for
|
||||
fixing it up
|
||||
|
||||
- Use <stropts.h> not <sys/stropts.h>, since the former seems more common
|
||||
|
||||
0.40 - Tue Jan 13 2004 21:05:19 +0800
|
||||
|
||||
- Remote TCP forwarding (-R) style implemented
|
||||
|
||||
- Local and remote TCP forwarding can each be disabled at runtime (-k and -j
|
||||
switches)
|
||||
|
||||
- Fix for problems detecting openpty() with uClibc - many thanks to various
|
||||
people for reporting and testing fixes, including (in random order) Cristian
|
||||
Ionescu-Idbohrn, James Ewing, Steve Dover, Thomas Lundquist and Frederic
|
||||
Lavernhe
|
||||
|
||||
- Improved portability for IRIX, thanks to Paul Marinceu
|
||||
|
||||
- AIX and HPUX portability fixes, thanks to Darren Tucker for patches
|
||||
|
||||
- prngd should now work correctly, thanks to Darren Tucker for the patch
|
||||
|
||||
- scp compilation on systems without strlcpy() is fixed, thanks to Peter
|
||||
Jannesen and David Muse for reporting it (independently and simultaneously :)
|
||||
|
||||
- Merged in new LibTomCrypt 0.92 and LibTomMath 0.28
|
||||
|
||||
0.39 - Tue Dec 16 2003 15:19:19 +0800
|
||||
|
||||
- Better checking of key lengths and parameters for DSS and RSA auth
|
||||
|
||||
- Print fingerprint of keys used for pubkey auth
|
||||
|
||||
- More consistent logging of usernames and IPs
|
||||
|
||||
- Added option to disable password auth (or just for root) at runtime
|
||||
|
||||
- Avoid including bignum functions which don't give much speed benefit but
|
||||
take up binary size
|
||||
|
||||
- Added a stripped down version of OpenSSH's scp binary
|
||||
|
||||
- Added additional supporting functions for Irix, thanks to Paul Marinceu
|
||||
|
||||
- Don't check for unused libraries in configure script
|
||||
|
||||
- Removed trailing comma in algorithm lists (thanks to Mihnea Stoenescu)
|
||||
|
||||
- Fixed up channel close handling, always send close packet in response
|
||||
(also thanks to Mihnea Stoenescu)
|
||||
|
||||
- Various makefile improvements for cross-compiling, thanks to Friedrich
|
||||
Lobenstock and Mihnea Stoenescu
|
||||
|
||||
- Use daemon() function if available (or our own copy) rather than separate
|
||||
code (thanks to Frédéric Lavernhe for the report and debugging, and Bernard
|
||||
Blackham for his suggestion on what to look at)
|
||||
|
||||
- Fixed up support for first_kex_packet_follows, required to talk to ssh.com
|
||||
clients. Thanks to Marian Stagarescu for the bug report.
|
||||
|
||||
- Avoid using MAXPATHLEN, pointer from Ian Morris
|
||||
|
||||
- Improved input sanity checking
|
||||
|
||||
0.38 - Sat Oct 11 2003 16:28:13 +0800
|
||||
|
||||
- Default hostkey path changed to /etc/dropbear/dropbear_{rsa,dss}_host_key
|
||||
rather than /etc/dropbear_{rsa,dss}_host_key
|
||||
|
||||
- Added SMALL and MULTI text files which have info on compiling for multiple
|
||||
binaries or small binaries
|
||||
|
||||
- Allow for commandline definition of some options.h settings
|
||||
(without warnings)
|
||||
|
||||
- Be more careful handling EINTR
|
||||
|
||||
- More fixes for channel closing
|
||||
|
||||
- Added multi-binary support
|
||||
|
||||
- Improved logging of IPs, now get logged in all cases
|
||||
|
||||
- Don't chew cpu when waiting for version identification string, also
|
||||
make sure that we kick off people if they don't auth within 5 minutes.
|
||||
|
||||
- Various small fixes, warnings etc
|
||||
|
||||
- Display MOTD if requested - suggested by
|
||||
Trent Lloyd <lathiat at sixlabs.org> and
|
||||
Zach White <zwhite at darkstar.frop.org>
|
||||
|
||||
- sftp support works (relies on OpenSSH sftp binary or similar)
|
||||
|
||||
- Added --disable-shadow option (requested by the floppyfw guys)
|
||||
|
||||
0.37 - Wed Sept 24 2003 19:42:12 +0800
|
||||
|
||||
- Various portability fixes, fixes for Solaris 9, Tru64 5.1, Mac OS X 10.2,
|
||||
AIX, BSDs
|
||||
|
||||
- Updated LibTomMath to 0.27 and LibTomCrypt to 0.90
|
||||
|
||||
- Renamed util.{c,h} to dbutil.{c,h} to avoid conflicts with system util.h
|
||||
|
||||
- Added some small changes so it'll work with AIX (plus Linux Affinity).
|
||||
Thanks to Shig for them.
|
||||
|
||||
- Improved the closing messages, so a clean exit is "Exited normally"
|
||||
|
||||
- Added some more robust integer/size checking in buffer.c as a backstop for
|
||||
integer overflows
|
||||
|
||||
- X11 forwarding fixed for OSX, path for xauth changed to /usr/X11R6/bin/xauth
|
||||
|
||||
- Channel code handles closing more nicely, doesn't sit waiting for an extra
|
||||
keystroke on BSD/OSX platforms, and data is flushed fully before closing
|
||||
child processes (thanks to
|
||||
Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com> for
|
||||
pointing that out).
|
||||
|
||||
- Changed "DISABLE_TCPFWD" to "ENABLE_TCPFWD" (and for x11/auth) so
|
||||
"disable DISABLE_TCPWD" isn't so confusing.
|
||||
|
||||
- Fix authorized_keys handling (don't crash on too-long keys, and
|
||||
use fgetc not getc to avoid strange macro-related issues), thanks to
|
||||
Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>
|
||||
and Steve Rodgers <hwstar at cox.net> for reporting and testing.
|
||||
|
||||
- Fixes to the README with regard to uClibc systems, thanks to
|
||||
Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>,
|
||||
as well as general improvements to documentation (split README/INSTALL)
|
||||
|
||||
- Fixed up some compilation problems with dropbearconvert/dropbearkey if
|
||||
DSS or RSA were disabled, reported by Patrik Karlsson <patrik at cqure.net>
|
||||
|
||||
- Fix double-free bug for hostkeys, reported by
|
||||
Vincent Sanders <vince at kyllikki.org>
|
||||
|
||||
- Fix up missing \ns from dropbearconvert help message,
|
||||
thanks to Mordy Ovits <movits at bloomberg.com> for the patch
|
||||
|
||||
0.36 - Tue August 19 2003 12:16:23 +0800
|
||||
|
||||
- Fix uninitialised temporary variable in DSS signing code
|
||||
(thanks to Matthew Franz <mdfranz at io.com> for reporting, and the authors
|
||||
of Valgrind for making it easy to track down)
|
||||
- Fix remote version-string parsing error
|
||||
(thanks to Bernard Blackham <bernard at blackham.com.au> for noticing)
|
||||
- Improved host-algorithm-matching algorithm in algo.c
|
||||
- Decreased MAX_STRING_LEN to a more realistic value
|
||||
- Fix incorrect version (0.34) in this CHANGES file for the previous release.
|
||||
|
||||
0.35 - Sun August 17 2003 05:37:47 +0800
|
||||
|
||||
- Fix for remotely exploitable format string buffer overflow.
|
||||
(thanks to Joel Eriksson <je at bitnux.com>)
|
||||
|
||||
0.34 - Fri August 15 2003 15:10:00 +0800
|
||||
|
||||
- Made syslog optional, both at compile time and as a compile option
|
||||
(suggested by Laurent Bercot <ska at skarnet.org>)
|
||||
- Fixup for bad base64 parsing in authorized_keys
|
||||
(noticed by Davyd Madeley <davyd at zdlcomputing.com>)
|
||||
- Added initial tcp forwarding code, only -L (local) at this stage
|
||||
- Improved "make install" with DESTDIR and changing ownership seperately,
|
||||
don't check for setpgrp on Linux for crosscompiling.
|
||||
(from Erik Andersen <andersen at codepoet.org>)
|
||||
- More commenting, fix minor compile warnings, make return values more
|
||||
consistent etc
|
||||
- Various signedness fixes
|
||||
- Can listen on multiple ports
|
||||
- added option to disable openpty with configure script,
|
||||
(from K.-P. Kirchdörfer <kapeka at epost.de>)
|
||||
- Various cleanups to bignum code
|
||||
(thanks to Tom St Denis <tomstdenis at iahu.ca>)
|
||||
- Fix compile error when disabling RSA
|
||||
(from Marc Kleine-Budde <kleine-budde at gmx.de>)
|
||||
- Other cleanups, splitting large functions for packet and kex handling etc
|
||||
|
||||
0.33 - Sun June 22 2003 22:24:12 +0800
|
||||
|
||||
- Fixed some invalid assertions in the channel code, fixing the server dying
|
||||
when forwarding X11 connections.
|
||||
- Add dropbearconvert to convert to/from OpenSSH host keys and Dropbear keys
|
||||
- RSA keys now keep p and q parameters for compatibility -- old Dropbear keys
|
||||
still work, but can't be converted to OpenSSH etc.
|
||||
- Debian packaging directory added, thanks to
|
||||
Grahame (grahame at angrygoats.net)
|
||||
- 'install' target added to the makefile
|
||||
- general tidying, improve consistency of functions etc
|
||||
- If RSA or DSS hostkeys don't exist, that algorithm won't be used.
|
||||
- Improved RSA and DSS key generation, more efficient and fixed some minor bugs
|
||||
(thanks to Tom St Denis for the advice)
|
||||
- Merged new versions of LibTomCrypt (0.86) and LibTomMath (0.21)
|
||||
|
||||
0.32 - Sat May 24 2003 12:44:11 +0800
|
||||
|
||||
- Don't compile unused code from libtomcrypt (test vectors etc)
|
||||
- Updated to libtommath 0.17 and libtomcrypt 0.83. New libtommath results
|
||||
in smaller binary size, due to not linking unrequired code
|
||||
- X11 forwarding added
|
||||
- Agent forwarding added (for OpenSSH.com ssh client/agent)
|
||||
- Fix incorrect buffer freeing when banners are used
|
||||
- Hostname resolution works
|
||||
- Various minor bugfixes/code size improvements etc
|
||||
|
||||
0.31 - Fri May 9 2003 17:57:16 +0800
|
||||
|
||||
- Improved syslog messages - IP logging etc
|
||||
- Strip control characters from log messages (specified username currently)
|
||||
- Login recording (utmp/wtmp) support, so last/w/who work - taken from OpenSSH
|
||||
- Shell is started as a proper login shell, so /etc/profile etc is sourced
|
||||
- Ptys work on Solaris (2.8 x86 tested) now
|
||||
- Fixed bug in specifying the rsa hostkey
|
||||
- Fixed bug in compression code, could trigger if compression resulted in
|
||||
larger output than input (uncommon but possible).
|
||||
|
||||
0.30 - Thu Apr 17 2003 18:46:15 +0800
|
||||
|
||||
- SECURITY: buffer.c had bad checking for buffer increment length - fixed
|
||||
- channel code now closes properly on EOF - scp processes don't hang around
|
||||
- syslog support added - improved auth/login/failure messages
|
||||
- general code tidying, made return codes more consistent
|
||||
- Makefile fixed for dependencies and makes libtomcrypt as well
|
||||
- Implemented sending SSH_MSG_UNIMPLEMENTED :)
|
||||
|
||||
0.29 - Wed Apr 9 2003
|
||||
|
||||
- Fixed a stupid bug in 0.28 release, 'newstr = strdup(oldstr)',
|
||||
not 'newstr=oldstr'
|
||||
|
||||
0.28 - Sun Apr 6 2003
|
||||
|
||||
- Initial public release
|
||||
|
||||
Development was started in October 2002
|
||||
79
INSTALL
79
INSTALL
@@ -1,79 +0,0 @@
|
||||
Basic Dropbear build instructions:
|
||||
|
||||
- Edit options.h to set which features you want.
|
||||
- Edit debug.h if you want any debug options (not usually required).
|
||||
|
||||
(If using a non-tarball copy, "autoconf; autoheader")
|
||||
|
||||
./configure (optionally with --disable-zlib or --disable-syslog,
|
||||
or --help for other options)
|
||||
|
||||
Now compile:
|
||||
|
||||
make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp"
|
||||
|
||||
And install (/usr/local/bin is usual default):
|
||||
|
||||
make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" install
|
||||
|
||||
(you can leave items out of the PROGRAMS list to avoid compiling them. If you
|
||||
recompile after changing the PROGRAMS list, you *MUST* "make clean" before
|
||||
recompiling - bad things will happen otherwise)
|
||||
|
||||
See MULTI for instructions on making all-in-one binaries.
|
||||
|
||||
If you want to compile statically, add "STATIC=1" to the make command-line.
|
||||
|
||||
Binaries can be strippd with "make strip"
|
||||
|
||||
============================================================================
|
||||
|
||||
If you're compiling for a 386-class CPU, you will probably need to add
|
||||
CFLAGS=-DLTC_NO_BSWAP so that libtomcrypt doesn't use 486+ instructions.
|
||||
|
||||
============================================================================
|
||||
|
||||
Compiling with uClibc:
|
||||
|
||||
Firstly, make sure you have at least uclibc 0.9.17, as getusershell() in prior
|
||||
versions is broken. Also note that you may get strange issues if your uClibc
|
||||
headers don't match the library you are running with, ie the headers might
|
||||
say that shadow password support exists, but the libraries don't have it.
|
||||
|
||||
Compiling for uClibc should be the same as normal, just set CC to the magic
|
||||
uClibc toolchain compiler (ie export CC=i386-uclibc-gcc or whatever).
|
||||
You can use "make STATIC=1" to make statically linked binaries, and it is
|
||||
advisable to strip the binaries too. If you're looking to make a small binary,
|
||||
you should remove unneeded ciphers and MD5, by editing options.h
|
||||
|
||||
It is possible to compile zlib in, by copying zlib.h and zconf.h into a
|
||||
subdirectory (ie zlibincludes), and
|
||||
|
||||
export CFLAGS="-Izlibincludes -I../zlibincludes"
|
||||
export LDFLAGS=/usr/lib/libz.a
|
||||
|
||||
before ./configure and make.
|
||||
|
||||
If you disable zlib, you must explicitly disable compression for the client -
|
||||
OpenSSH is possibly buggy in this regard, it seems you need to disable it
|
||||
globally in ~/.ssh/config, not just in the host entry in that file.
|
||||
|
||||
You may want to manually disable lastlog recording when using uClibc, configure
|
||||
with --disable-lastlog.
|
||||
|
||||
One common problem is pty allocation. There are a number of types of pty
|
||||
allocation which can be used -- if they work properly, the end result is the
|
||||
same for each type. Running configure should detect the best type to use
|
||||
automatically, however for some systems, this may be incorrect. Some
|
||||
things to note:
|
||||
|
||||
If your system expects /dev/pts to be mounted (this is a uClibc option),
|
||||
make sure that it is.
|
||||
|
||||
Make sure that your libc headers match the library version you are using.
|
||||
|
||||
If openpty() is being used (HAVE_OPENPTY defined in config.h) and it fails,
|
||||
you can try compiling with --disable-openpty. You will probably then need
|
||||
to create all the /dev/pty?? and /dev/tty?? devices, which can be
|
||||
problematic for devfs. In general, openpty() is the best way to allocate
|
||||
PTYs, so it's best to try and get it working.
|
||||
89
LICENSE
89
LICENSE
@@ -1,89 +1,4 @@
|
||||
Dropbear contains a number of components from different sources, hence there
|
||||
are a few licenses and authors involved. All licenses are fairly
|
||||
non-restrictive.
|
||||
LibTomMath is hereby released into the Public Domain.
|
||||
|
||||
-- Tom St Denis
|
||||
|
||||
The majority of code is written by Matt Johnston, under the license below.
|
||||
|
||||
Portions of the client-mode work are (c) 2004 Mihnea Stoenescu, under the
|
||||
same license:
|
||||
|
||||
Copyright (c) 2002-2004 Matt Johnston
|
||||
Portions copyright (c) 2004 Mihnea Stoenescu
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
=====
|
||||
|
||||
LibTomCrypt and LibTomMath are written by Tom St Denis, and are Public Domain.
|
||||
|
||||
=====
|
||||
|
||||
sshpty.c is taken from OpenSSH 3.5p1,
|
||||
Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
All rights reserved
|
||||
"As far as I am concerned, the code I have written for this software
|
||||
can be used freely for any purpose. Any derived versions of this
|
||||
software must be clearly marked as such, and if the derived work is
|
||||
incompatible with the protocol description in the RFC file, it must be
|
||||
called by a name other than "ssh" or "Secure Shell". "
|
||||
|
||||
=====
|
||||
|
||||
loginrec.c
|
||||
loginrec.h
|
||||
atomicio.h
|
||||
atomicio.c
|
||||
and strlcat() (included in util.c) are from OpenSSH 3.6.1p2, and are licensed
|
||||
under the 2 point BSD license.
|
||||
|
||||
loginrec is written primarily by Andre Lucas, atomicio.c by Theo de Raadt.
|
||||
|
||||
strlcat() is (c) Todd C. Miller
|
||||
|
||||
=====
|
||||
|
||||
Import code in keyimport.c is modified from PuTTY's import.c, licensed as
|
||||
follows:
|
||||
|
||||
PuTTY is copyright 1997-2003 Simon Tatham.
|
||||
|
||||
Portions copyright Robert de Bath, Joris van Rantwijk, Delian
|
||||
Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas Barry,
|
||||
Justin Bradford, and CORE SDI S.A.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation files
|
||||
(the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
|
||||
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
26
MULTI
26
MULTI
@@ -1,26 +0,0 @@
|
||||
Multi-binary compilation
|
||||
========================
|
||||
|
||||
To compile for systems without much space (floppy distributions etc), you
|
||||
can create a single binary. This will save disk space by avoiding repeated
|
||||
code between the various parts.
|
||||
If you are familiar with "busybox", it's the same principle.
|
||||
|
||||
To compile the multi-binary, first "make clean" (if you've compiled
|
||||
previously), then
|
||||
|
||||
make PROGRAMS="programs you want here" MULTI=1
|
||||
|
||||
To use the binary, symlink it from the desired executable:
|
||||
|
||||
ln -s dropbearmulti dropbear
|
||||
ln -s dropbearmulti dbclient
|
||||
etc
|
||||
|
||||
then execute as normal:
|
||||
|
||||
./dropbear <options here>
|
||||
|
||||
"make install" doesn't currently work for multi-binary configuration, though
|
||||
in most situations where it is being used, the target and build systems will
|
||||
differ.
|
||||
209
Makefile.in
209
Makefile.in
@@ -1,209 +0,0 @@
|
||||
# This Makefile is for Dropbear SSH Server and Client
|
||||
# @configure_input@
|
||||
|
||||
# invocation:
|
||||
# make PROGRAMS="dropbear dbclient scp" MULTI=1 STATIC=1 SCPPROGRESS=1
|
||||
#
|
||||
# to make a multiple-program statically linked binary "staticdropbearmulti".
|
||||
# This example will include dropbear, scp, dropbearkey, dropbearconvert, and
|
||||
# dbclient functionality, and includes the progress-bar functionality in scp.
|
||||
# Hopefully that seems intuitive.
|
||||
|
||||
ifndef PROGRAMS
|
||||
PROGRAMS=dropbear dbclient dropbearkey dropbearconvert
|
||||
endif
|
||||
|
||||
LTC=libtomcrypt/libtomcrypt.a
|
||||
LTM=libtommath/libtommath.a
|
||||
|
||||
COMMONOBJS=dbutil.o buffer.o \
|
||||
dss.o bignum.o \
|
||||
signkey.o rsa.o random.o \
|
||||
queue.o \
|
||||
atomicio.o compat.o fake-rfc2553.o
|
||||
|
||||
SVROBJS=svr-kex.o svr-algo.o svr-auth.o sshpty.o \
|
||||
svr-authpasswd.o svr-authpubkey.o svr-session.o svr-service.o \
|
||||
svr-chansession.o svr-runopts.o svr-agentfwd.o svr-main.o svr-x11fwd.o\
|
||||
svr-tcpfwd.o svr-authpam.o
|
||||
|
||||
CLIOBJS=cli-algo.o cli-main.o cli-auth.o cli-authpasswd.o cli-kex.o \
|
||||
cli-session.o cli-service.o cli-runopts.o cli-chansession.o \
|
||||
cli-authpubkey.o cli-tcpfwd.o cli-channel.o cli-authinteract.o
|
||||
|
||||
CLISVROBJS=common-session.o packet.o common-algo.o common-kex.o \
|
||||
common-channel.o common-chansession.o termcodes.o loginrec.o \
|
||||
tcp-accept.o listener.o process-packet.o \
|
||||
common-runopts.o circbuffer.o
|
||||
|
||||
KEYOBJS=dropbearkey.o gendss.o genrsa.o
|
||||
|
||||
CONVERTOBJS=dropbearconvert.o keyimport.o
|
||||
|
||||
SCPOBJS=scp.o progressmeter.o atomicio.o scpmisc.o
|
||||
|
||||
HEADERS=options.h dbutil.h session.h packet.h algo.h ssh.h buffer.h kex.h \
|
||||
dss.h bignum.h signkey.h rsa.h random.h service.h auth.h \
|
||||
debug.h channel.h chansession.h config.h queue.h sshpty.h \
|
||||
termcodes.h gendss.h genrsa.h runopts.h includes.h \
|
||||
loginrec.h atomicio.h x11fwd.h agentfwd.h tcpfwd.h compat.h \
|
||||
listener.h fake-rfc2553.h
|
||||
|
||||
dropbearobjs=$(COMMONOBJS) $(CLISVROBJS) $(SVROBJS)
|
||||
dbclientobjs=$(COMMONOBJS) $(CLISVROBJS) $(CLIOBJS)
|
||||
dropbearkeyobjs=$(COMMONOBJS) $(KEYOBJS)
|
||||
dropbearconvertobjs=$(COMMONOBJS) $(CONVERTOBJS)
|
||||
scpobjs=$(SCPOBJS)
|
||||
|
||||
VPATH=@srcdir@
|
||||
srcdir=@srcdir@
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=${prefix}
|
||||
bindir=${exec_prefix}/bin
|
||||
sbindir=${exec_prefix}/sbin
|
||||
|
||||
CC=@CC@
|
||||
LD=@LD@
|
||||
AR=@AR@
|
||||
RANLIB=@RANLIB@
|
||||
STRIP=@STRIP@
|
||||
INSTALL=@INSTALL@
|
||||
CFLAGS=-I. -I$(srcdir)/libtomcrypt/src/headers/ @CFLAGS@
|
||||
LIBS=$(LTC) $(LTM) @LIBS@
|
||||
LDFLAGS=@LDFLAGS@
|
||||
|
||||
EXEEXT=@EXEEXT@
|
||||
|
||||
# whether we're building client, server, or both for the common objects.
|
||||
# evilness so we detect 'dropbear' by itself as a word
|
||||
space:= $(empty) $(empty)
|
||||
ifneq (,$(strip $(foreach prog, $(PROGRAMS), $(findstring ZdropbearZ, Z$(prog)Z))))
|
||||
CFLAGS+= -DDROPBEAR_SERVER
|
||||
endif
|
||||
ifneq (,$(strip $(foreach prog, $(PROGRAMS), $(findstring ZdbclientZ, Z$(prog)Z))))
|
||||
CFLAGS+= -DDROPBEAR_CLIENT
|
||||
endif
|
||||
|
||||
|
||||
# these are exported so that libtomcrypt's makefile will use them
|
||||
export CC
|
||||
export CFLAGS
|
||||
export RANLIB AR STRIP
|
||||
|
||||
ifeq ($(STATIC), 1)
|
||||
LDFLAGS+=-static
|
||||
endif
|
||||
|
||||
ifeq ($(MULTI), 1)
|
||||
TARGETS=dropbearmulti
|
||||
else
|
||||
TARGETS=$(PROGRAMS)
|
||||
endif
|
||||
|
||||
# for the scp progress meter. The -D doesn't affect anything else.
|
||||
ifeq ($(SCPPROGRESS), 1)
|
||||
CFLAGS+=-DPROGRESS_METER
|
||||
endif
|
||||
|
||||
#%: $(HEADERS)
|
||||
#%: $(HEADERS) Makefile
|
||||
# TODO
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
strip: $(TARGETS)
|
||||
$(STRIP) $(addsuffix $(EXEEXT), $(TARGETS))
|
||||
|
||||
install: $(addprefix inst_, $(TARGETS))
|
||||
|
||||
installdropbearmulti: insdbmulti $(addprefix insmulti, $(PROGRAMS))
|
||||
|
||||
insdbmulti: dropbearmulti
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)$(bindir)
|
||||
$(INSTALL) -m 755 dropbearmulti$(EXEEXT) $(DESTDIR)$(bindir)
|
||||
-chown root $(DESTDIR)$(bindir)/dropbearmulti$(EXEEXT)
|
||||
-chgrp 0 $(DESTDIR)$(bindir)/dropbearmulti$(EXEEXT)
|
||||
|
||||
insmultidropbear: dropbearmulti
|
||||
-rm -f $(DESTDIR)$(sbindir)/dropbear$(EXEEXT)
|
||||
-ln -s $(DESTDIR)$(bindir)/dropbearmulti$(EXEEXT) $(DESTDIR)$(sbindir)/dropbear$(EXEEXT)
|
||||
|
||||
insmulti%: dropbearmulti
|
||||
-rm -f $(DESTDIR)$(bindir)/$*$(EXEEXT)
|
||||
-ln -s $(DESTDIR)$(bindir)/dropbearmulti$(EXEEXT) $(DESTDIR)$(bindir)/$*$(EXEEXT)
|
||||
|
||||
# dropbear should go in sbin, so it needs a seperate rule
|
||||
inst_dropbear: dropbear
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)$(sbindir)
|
||||
$(INSTALL) -m 755 dropbear$(EXEEXT) $(DESTDIR)$(sbindir)
|
||||
-chown root $(DESTDIR)$(sbindir)/dropbear$(EXEEXT)
|
||||
-chgrp 0 $(DESTDIR)$(sbindir)/dropbear$(EXEEXT)
|
||||
|
||||
inst_%: $*
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)$(bindir)
|
||||
$(INSTALL) -m 755 $*$(EXEEXT) $(DESTDIR)$(bindir)
|
||||
-chown root $(DESTDIR)$(bindir)/$*$(EXEEXT)
|
||||
-chgrp 0 $(DESTDIR)$(bindir)/$*$(EXEEXT)
|
||||
|
||||
|
||||
# for some reason the rule further down doesn't like $($@objs) as a prereq.
|
||||
dropbear: $(dropbearobjs)
|
||||
dbclient: $(dbclientobjs)
|
||||
dropbearkey: $(dropbearkeyobjs)
|
||||
dropbearconvert: $(dropbearconvertobjs)
|
||||
|
||||
dropbear dbclient dropbearkey dropbearconvert: $(HEADERS) $(LTC) $(LTM) \
|
||||
Makefile
|
||||
$(LD) $(LDFLAGS) -o $@$(EXEEXT) $($@objs) $(LIBS)
|
||||
|
||||
# scp doesn't use the libs so is special.
|
||||
scp: $(SCPOBJS) $(HEADERS) Makefile
|
||||
$(LD) $(LDFLAGS) -o $@$(EXEEXT) $(SCPOBJS)
|
||||
|
||||
|
||||
# multi-binary compilation.
|
||||
MULTIOBJS=
|
||||
ifeq ($(MULTI),1)
|
||||
MULTIOBJS=dbmulti.o $(sort $(foreach prog, $(PROGRAMS), $($(prog)objs)))
|
||||
CFLAGS+=$(addprefix -DDBMULTI_, $(PROGRAMS)) -DDROPBEAR_MULTI
|
||||
endif
|
||||
|
||||
dropbearmulti: multilink
|
||||
|
||||
multibinary: $(HEADERS) $(MULTIOBJS) $(LTC) $(LTM) Makefile
|
||||
$(LD) $(LDFLAGS) -o dropbearmulti$(EXEEXT) $(MULTIOBJS) $(LIBS)
|
||||
|
||||
multilink: multibinary $(addprefix link, $(PROGRAMS))
|
||||
|
||||
link%:
|
||||
-rm -f $*$(EXEEXT)
|
||||
-ln -s dropbearmulti$(EXEEXT) $*$(EXEEXT)
|
||||
|
||||
$(LTC): options.h
|
||||
cd libtomcrypt && $(MAKE) clean && $(MAKE)
|
||||
|
||||
$(LTM): options.h
|
||||
cd libtommath && $(MAKE)
|
||||
|
||||
ltc-clean:
|
||||
cd libtomcrypt && $(MAKE) clean
|
||||
|
||||
ltm-clean:
|
||||
cd libtommath && $(MAKE) clean
|
||||
|
||||
sizes: dropbear
|
||||
objdump -t dropbear|grep ".text"|cut -d "." -f 2|sort -rn
|
||||
|
||||
clean: ltc-clean ltm-clean thisclean
|
||||
|
||||
thisclean:
|
||||
-rm -f dropbear dbclient dropbearkey dropbearconvert scp scp-progress \
|
||||
dropbearmulti *.o *.da *.bb *.bbg *.prof
|
||||
|
||||
distclean: clean tidy
|
||||
-rm -f config.h
|
||||
-rm -f Makefile
|
||||
|
||||
tidy:
|
||||
-rm -f *~ *.gcov */*~
|
||||
74
README
74
README
@@ -1,74 +0,0 @@
|
||||
This is Dropbear, a smallish SSH 2 server and client.
|
||||
|
||||
INSTALL has compilation instructions.
|
||||
|
||||
MULTI has instructions on making a multi-purpose binary (ie a single binary
|
||||
which performs multiple tasks, to save disk space)
|
||||
|
||||
SMALL has some tips on creating small binaries.
|
||||
|
||||
See TODO for a few of the things I know need looking at, and please contact
|
||||
me if you have any questions/bugs found/features/ideas/comments etc :)
|
||||
|
||||
Matt Johnston
|
||||
matt@ucc.asn.au
|
||||
|
||||
|
||||
In the absence of detailed documentation, some notes follow:
|
||||
============================================================================
|
||||
|
||||
Server public key auth:
|
||||
|
||||
You can use ~/.ssh/authorized_keys in the same way as with OpenSSH, just put
|
||||
the key entries in that file. They should be of the form:
|
||||
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAwVa6M6cGVmUcLl2cFzkxEoJd06Ub4bVDsYrWvXhvUV+ZAM9uGuewZBDoAqNKJxoIn0Hyd0Nk/yU99UVv6NWV/5YSHtnf35LKds56j7cuzoQpFIdjNwdxAN0PCET/MG8qyskG/2IE2DPNIaJ3Wy+Ws4IZEgdJgPlTYUBWWtCWOGc= someone@hostname
|
||||
|
||||
You must make sure that ~/.ssh, and the key file, are only writable by the
|
||||
user. Beware of editors that split the key into multiple lines.
|
||||
|
||||
NOTE: Dropbear ignores authorized_keys options such as those described in the
|
||||
OpenSSH sshd manpage, and will not allow a login for these keys.
|
||||
|
||||
============================================================================
|
||||
|
||||
Client public key auth:
|
||||
|
||||
Dropbear can do public key auth as a client, but you will have to convert
|
||||
OpenSSH style keys to Dropbear format, or use dropbearkey to create them.
|
||||
|
||||
If you have an OpenSSH-style private key ~/.ssh/id_rsa, you need to do:
|
||||
|
||||
dropbearconvert openssh dropbear ~/.ssh/id_rsa ~/.ssh/id_rsa.db
|
||||
dbclient -i ~/.ssh/id_rsa.db <hostname>
|
||||
|
||||
Currently encrypted keys aren't supported, neither is agent forwarding. At some
|
||||
stage both hopefully will be.
|
||||
|
||||
============================================================================
|
||||
|
||||
If you want to get the public-key portion of a Dropbear private key, look at
|
||||
dropbearkey's '-y' option.
|
||||
|
||||
============================================================================
|
||||
|
||||
To run the server, you need to generate server keys, this is one-off:
|
||||
./dropbearkey -t rsa -f dropbear_rsa_host_key
|
||||
./dropbearkey -t dss -f dropbear_dss_host_key
|
||||
|
||||
or alternatively convert OpenSSH keys to Dropbear:
|
||||
./dropbearconvert openssh dropbear /etc/ssh/ssh_host_dsa_key dropbear_dss_host_key
|
||||
|
||||
============================================================================
|
||||
|
||||
If the server is run as non-root, you most likely won't be able to allocate a
|
||||
pty, and you cannot login as any user other than that running the daemon
|
||||
(obviously). Shadow passwords will also be unusable as non-root.
|
||||
|
||||
============================================================================
|
||||
|
||||
The Dropbear distribution includes a standalone version of OpenSSH's scp
|
||||
program. You can compile it with "make scp", you may want to change the path
|
||||
of the ssh binary, specified by _PATH_SSH_PROGRAM in options.h . By default
|
||||
the progress meter isn't compiled in to save space, you can enable it by
|
||||
adding 'SCPPROGRESS=1' to the make commandline.
|
||||
53
SMALL
53
SMALL
@@ -1,53 +0,0 @@
|
||||
Tips for a small system:
|
||||
|
||||
If you only want server functionality (for example), compile with
|
||||
make PROGRAMS=dropbear
|
||||
rather than just
|
||||
make dropbear
|
||||
so that client functionality in shared portions of Dropbear won't be included.
|
||||
The same applies if you are compiling just a client.
|
||||
|
||||
---
|
||||
|
||||
The following are set in options.h:
|
||||
|
||||
- You can safely disable blowfish and twofish ciphers, and MD5 hmac, without
|
||||
affecting interoperability
|
||||
|
||||
- If you're compiling statically, you can turn off host lookups
|
||||
|
||||
- You can disable either password or public-key authentication, though note
|
||||
that the IETF draft states that pubkey authentication is required.
|
||||
|
||||
- Similarly with DSS and RSA, you can disable one of these if you know that
|
||||
all clients will be able to support a particular one. The IETF draft
|
||||
states that DSS is required, however you may prefer to use RSA.
|
||||
DON'T disable either of these on systems where you aren't 100% sure about
|
||||
who will be connecting and what clients they will be using.
|
||||
|
||||
- Disabling the MOTD code and SFTP-SERVER may save a small amount of codesize
|
||||
|
||||
- You can disable x11, tcp and agent forwarding as desired. None of these are
|
||||
essential, although agent-forwarding is often useful even on firewall boxes.
|
||||
|
||||
---
|
||||
|
||||
If you are compiling statically, you may want to disable zlib, as it will use
|
||||
a few tens of kB of binary-size (./configure --disable-zlib).
|
||||
|
||||
You can create a combined binary, see the file MULTI, which will put all
|
||||
the functions into one binary, avoiding repeated code.
|
||||
|
||||
If you're compiling with gcc, you might want to look at gcc's options for
|
||||
stripping unused code. The relevant vars to set before configure are:
|
||||
|
||||
LDFLAGS=-Wl,--gc-sections
|
||||
CFLAGS="-ffunction-sections -fdata-sections"
|
||||
|
||||
You can also experiment with optimisation flags such as -Os, note that in some
|
||||
cases these flags actually seem to increase size, so experiment before
|
||||
deciding.
|
||||
|
||||
Of course using small C libraries such as uClibc and dietlibc can also help.
|
||||
|
||||
If you have any queries, mail me and I'll see if I can help.
|
||||
27
TODO
27
TODO
@@ -1,27 +0,0 @@
|
||||
Current:
|
||||
|
||||
Things which might need doing:
|
||||
|
||||
- default private dbclient keys
|
||||
|
||||
- Make options.h generated from configure perhaps?
|
||||
|
||||
- handle /etc/environment in AIX
|
||||
|
||||
- check that there aren't timing issues with valid/invalid user authentication
|
||||
feedback.
|
||||
|
||||
- Binding to different interfaces
|
||||
|
||||
- CTR mode
|
||||
- SSH_MSG_IGNORE sending to improve CBC security
|
||||
- DH Group Exchange possibly, or just add group14 (whatever it's called today)
|
||||
|
||||
- fix scp.c for IRIX
|
||||
|
||||
- Be able to use OpenSSH keys for the client? or at least have some form of
|
||||
encrypted keys.
|
||||
|
||||
- Client agent forwarding
|
||||
|
||||
- Handle restrictions in ~/.ssh/authorized_keys ?
|
||||
43
agentfwd.h
43
agentfwd.h
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Dropbear - a SSH2 server
|
||||
*
|
||||
* Copyright (c) 2002,2003 Matt Johnston
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE. */
|
||||
#ifndef _AGENTFWD_H_
|
||||
#define _AGENTFWD_H_
|
||||
#ifndef DISABLE_AGENTFWD
|
||||
|
||||
#include "includes.h"
|
||||
#include "chansession.h"
|
||||
#include "channel.h"
|
||||
|
||||
int agentreq(struct ChanSess * chansess);
|
||||
void agentsetauth(struct ChanSess *chansess);
|
||||
void agentcleanup(struct ChanSess * chansess);
|
||||
void agentset(struct ChanSess *chansess);
|
||||
|
||||
#ifdef __hpux
|
||||
#define seteuid(a) setresuid(-1, (a), -1)
|
||||
#define setegid(a) setresgid(-1, (a), -1)
|
||||
#endif
|
||||
|
||||
#endif /* DROPBEAR_AGENTFWD */
|
||||
#endif /* _AGENTFWD_H_ */
|
||||
74
algo.h
74
algo.h
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Dropbear - a SSH2 server
|
||||
*
|
||||
* Copyright (c) 2002,2003 Matt Johnston
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE. */
|
||||
|
||||
#ifndef _ALGO_H_
|
||||
|
||||
#define _ALGO_H_
|
||||
|
||||
#include "includes.h"
|
||||
#include "buffer.h"
|
||||
|
||||
struct Algo_Type {
|
||||
|
||||
unsigned char *name; /* identifying name */
|
||||
char val; /* a value for this cipher, or -1 for invalid */
|
||||
void *data; /* algorithm specific data */
|
||||
unsigned usable : 1; /* whether we can use this algorithm */
|
||||
|
||||
};
|
||||
|
||||
typedef struct Algo_Type algo_type;
|
||||
|
||||
/* lists mapping ssh types of algorithms to internal values */
|
||||
extern algo_type sshkex[];
|
||||
extern algo_type sshhostkey[];
|
||||
extern algo_type sshciphers[];
|
||||
extern algo_type sshhashes[];
|
||||
extern algo_type sshcompress[];
|
||||
|
||||
extern const struct dropbear_cipher dropbear_nocipher;
|
||||
extern const struct dropbear_hash dropbear_nohash;
|
||||
|
||||
struct dropbear_cipher {
|
||||
const struct ltc_cipher_descriptor *cipherdesc;
|
||||
unsigned long keysize;
|
||||
unsigned char blocksize;
|
||||
};
|
||||
|
||||
struct dropbear_hash {
|
||||
const struct ltc_hash_descriptor *hashdesc;
|
||||
unsigned long keysize;
|
||||
unsigned char hashsize;
|
||||
};
|
||||
|
||||
void crypto_init();
|
||||
int have_algo(char* algo, size_t algolen, algo_type algos[]);
|
||||
void buf_put_algolist(buffer * buf, algo_type localalgos[]);
|
||||
|
||||
algo_type * svr_buf_match_algo(buffer* buf, algo_type localalgos[],
|
||||
int *goodguess);
|
||||
algo_type * cli_buf_match_algo(buffer* buf, algo_type localalgos[],
|
||||
int *goodguess);
|
||||
|
||||
#endif /* _ALGO_H_ */
|
||||
63
atomicio.c
63
atomicio.c
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copied from OpenSSH 3.6.1p2.
|
||||
*
|
||||
* Copyright (c) 1995,1999 Theo de Raadt. All rights reserved.
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*/
|
||||
|
||||
/* RCSID("OpenBSD: atomicio.c,v 1.10 2001/05/08 22:48:07 markus Exp "); */
|
||||
|
||||
#include "atomicio.h"
|
||||
|
||||
/*
|
||||
* ensure all of data on socket comes through. f==read || f==write
|
||||
*/
|
||||
ssize_t
|
||||
atomicio(f, fd, _s, n)
|
||||
ssize_t (*f) ();
|
||||
int fd;
|
||||
void *_s;
|
||||
size_t n;
|
||||
{
|
||||
char *s = _s;
|
||||
ssize_t res;
|
||||
size_t pos = 0;
|
||||
|
||||
while (n > pos) {
|
||||
res = (f) (fd, s + pos, n - pos);
|
||||
switch (res) {
|
||||
case -1:
|
||||
#ifdef EWOULDBLOCK
|
||||
if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)
|
||||
#else
|
||||
if (errno == EINTR || errno == EAGAIN)
|
||||
#endif
|
||||
continue;
|
||||
case 0:
|
||||
return (res);
|
||||
default:
|
||||
pos += res;
|
||||
}
|
||||
}
|
||||
return (pos);
|
||||
}
|
||||
36
atomicio.h
36
atomicio.h
@@ -1,36 +0,0 @@
|
||||
|
||||
/*
|
||||
* Copied from OpenSSH 3.6.1p2, required for loginrec.c
|
||||
*
|
||||
* $OpenBSD: atomicio.h,v 1.4 2001/06/26 06:32:46 itojun Exp $
|
||||
*
|
||||
* Copyright (c) 1995,1999 Theo de Raadt. All rights reserved.
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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 "includes.h"
|
||||
|
||||
/*
|
||||
* Ensure all of data on socket comes through. f==read || f==write
|
||||
*/
|
||||
ssize_t atomicio(ssize_t (*)(), int, void *, size_t);
|
||||
111
auth.h
111
auth.h
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* Dropbear - a SSH2 server
|
||||
*
|
||||
* Copyright (c) 2002,2003 Matt Johnston
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE. */
|
||||
|
||||
#ifndef _AUTH_H_
|
||||
#define _AUTH_H_
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
void svr_authinitialise();
|
||||
void cli_authinitialise();
|
||||
|
||||
/* Server functions */
|
||||
void recv_msg_userauth_request();
|
||||
void send_msg_userauth_failure(int partial, int incrfail);
|
||||
void send_msg_userauth_success();
|
||||
void svr_auth_password();
|
||||
void svr_auth_pubkey();
|
||||
void svr_auth_pam();
|
||||
|
||||
/* Client functions */
|
||||
void recv_msg_userauth_failure();
|
||||
void recv_msg_userauth_success();
|
||||
void recv_msg_userauth_specific_60();
|
||||
void recv_msg_userauth_pk_ok();
|
||||
void recv_msg_userauth_info_request();
|
||||
void cli_get_user();
|
||||
void cli_auth_getmethods();
|
||||
void cli_auth_try();
|
||||
void recv_msg_userauth_banner();
|
||||
void cli_pubkeyfail();
|
||||
void cli_auth_password();
|
||||
int cli_auth_pubkey();
|
||||
void cli_auth_interactive();
|
||||
char* getpass_or_cancel();
|
||||
|
||||
|
||||
#define MAX_USERNAME_LEN 25 /* arbitrary for the moment */
|
||||
|
||||
#define AUTH_TYPE_NONE 1
|
||||
#define AUTH_TYPE_PUBKEY 1 << 1
|
||||
#define AUTH_TYPE_PASSWORD 1 << 2
|
||||
#define AUTH_TYPE_INTERACT 1 << 3
|
||||
|
||||
#define AUTH_METHOD_NONE "none"
|
||||
#define AUTH_METHOD_NONE_LEN 4
|
||||
#define AUTH_METHOD_PUBKEY "publickey"
|
||||
#define AUTH_METHOD_PUBKEY_LEN 9
|
||||
#define AUTH_METHOD_PASSWORD "password"
|
||||
#define AUTH_METHOD_PASSWORD_LEN 8
|
||||
#define AUTH_METHOD_INTERACT "keyboard-interactive"
|
||||
#define AUTH_METHOD_INTERACT_LEN 20
|
||||
|
||||
|
||||
|
||||
/* This structure is shared between server and client - it contains
|
||||
* relatively little extraneous bits when used for the client rather than the
|
||||
* server */
|
||||
struct AuthState {
|
||||
|
||||
char *username; /* This is the username the client presents to check. It
|
||||
is updated each run through, used for auth checking */
|
||||
unsigned char authtypes; /* Flags indicating which auth types are still
|
||||
valid */
|
||||
unsigned int failcount; /* Number of (failed) authentication attempts.*/
|
||||
unsigned authdone : 1; /* 0 if we haven't authed, 1 if we have. Applies for
|
||||
client and server (though has differing [obvious]
|
||||
meanings). */
|
||||
unsigned perm_warn : 1; /* Server only, set if bad permissions on
|
||||
~/.ssh/authorized_keys have already been
|
||||
logged. */
|
||||
|
||||
/* These are only used for the server */
|
||||
char *printableuser; /* stripped of control chars, used for logs etc */
|
||||
struct passwd * pw;
|
||||
|
||||
};
|
||||
|
||||
struct SignKeyList;
|
||||
/* A singly linked list of signing keys */
|
||||
struct SignKeyList {
|
||||
|
||||
sign_key *key;
|
||||
int type; /* The type of key */
|
||||
struct SignKeyList *next;
|
||||
/* filename? or the buffer? for encrypted keys, so we can later get
|
||||
* the private key portion */
|
||||
|
||||
};
|
||||
|
||||
#endif /* _AUTH_H_ */
|
||||
75
bignum.c
75
bignum.c
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Dropbear - a SSH2 server
|
||||
*
|
||||
* Copyright (c) 2002,2003 Matt Johnston
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE. */
|
||||
|
||||
/* Contains helper functions for mp_int handling */
|
||||
|
||||
#include "includes.h"
|
||||
#include "dbutil.h"
|
||||
|
||||
/* wrapper for mp_init, failing fatally on errors (memory allocation) */
|
||||
void m_mp_init(mp_int *mp) {
|
||||
|
||||
if (mp_init(mp) != MP_OKAY) {
|
||||
dropbear_exit("mem alloc error");
|
||||
}
|
||||
}
|
||||
|
||||
/* simplified duplication of bn_mp_multi's mp_init_multi, but die fatally
|
||||
* on error */
|
||||
void m_mp_init_multi(mp_int *mp, ...)
|
||||
{
|
||||
mp_int* cur_arg = mp;
|
||||
va_list args;
|
||||
|
||||
va_start(args, mp); /* init args to next argument from caller */
|
||||
while (cur_arg != NULL) {
|
||||
if (mp_init(cur_arg) != MP_OKAY) {
|
||||
dropbear_exit("mem alloc error");
|
||||
}
|
||||
cur_arg = va_arg(args, mp_int*);
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void bytes_to_mp(mp_int *mp, const unsigned char* bytes, unsigned int len) {
|
||||
|
||||
if (mp_read_unsigned_bin(mp, (unsigned char*)bytes, len) != MP_OKAY) {
|
||||
dropbear_exit("mem alloc error");
|
||||
}
|
||||
}
|
||||
|
||||
/* hash the ssh representation of the mp_int mp */
|
||||
void sha1_process_mp(hash_state *hs, mp_int *mp) {
|
||||
|
||||
int i;
|
||||
buffer * buf;
|
||||
|
||||
buf = buf_new(512 + 20); /* max buffer is a 4096 bit key,
|
||||
plus header + some leeway*/
|
||||
buf_putmpint(buf, mp);
|
||||
i = buf->pos;
|
||||
buf_setpos(buf, 0);
|
||||
sha1_process(hs, buf_getptr(buf, i), i);
|
||||
buf_free(buf);
|
||||
}
|
||||
35
bignum.h
35
bignum.h
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Dropbear - a SSH2 server
|
||||
*
|
||||
* Copyright (c) 2002,2003 Matt Johnston
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE. */
|
||||
|
||||
#ifndef _BIGNUM_H_
|
||||
#define _BIGNUM_H_
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
void m_mp_init(mp_int *mp);
|
||||
void m_mp_init_multi(mp_int *mp, ...);
|
||||
void bytes_to_mp(mp_int *mp, const unsigned char* bytes, unsigned int len);
|
||||
void sha1_process_mp(hash_state *hs, mp_int *mp);
|
||||
|
||||
#endif /* _BIGNUM_H_ */
|
||||
6
bn.ilg
Normal file
6
bn.ilg
Normal file
@@ -0,0 +1,6 @@
|
||||
This is makeindex, version 2.14 [02-Oct-2002] (kpathsea + Thai support).
|
||||
Scanning input file bn.idx....done (79 entries accepted, 0 rejected).
|
||||
Sorting entries....done (511 comparisons).
|
||||
Generating output file bn.ind....done (82 lines written, 0 warnings).
|
||||
Output written in bn.ind.
|
||||
Transcript written in bn.ilg.
|
||||
82
bn.ind
Normal file
82
bn.ind
Normal file
@@ -0,0 +1,82 @@
|
||||
\begin{theindex}
|
||||
|
||||
\item mp\_add, \hyperpage{31}
|
||||
\item mp\_add\_d, \hyperpage{56}
|
||||
\item mp\_and, \hyperpage{31}
|
||||
\item mp\_clear, \hyperpage{12}
|
||||
\item mp\_clear\_multi, \hyperpage{13}
|
||||
\item mp\_cmp, \hyperpage{25}
|
||||
\item mp\_cmp\_d, \hyperpage{26}
|
||||
\item mp\_cmp\_mag, \hyperpage{23}
|
||||
\item mp\_div, \hyperpage{32}
|
||||
\item mp\_div\_2, \hyperpage{28}
|
||||
\item mp\_div\_2d, \hyperpage{30}
|
||||
\item mp\_div\_d, \hyperpage{56}
|
||||
\item mp\_dr\_reduce, \hyperpage{45}
|
||||
\item mp\_dr\_setup, \hyperpage{45}
|
||||
\item MP\_EQ, \hyperpage{23}
|
||||
\item mp\_error\_to\_string, \hyperpage{9}
|
||||
\item mp\_expt\_d, \hyperpage{47}
|
||||
\item mp\_exptmod, \hyperpage{47}
|
||||
\item mp\_exteuclid, \hyperpage{55}
|
||||
\item mp\_gcd, \hyperpage{55}
|
||||
\item mp\_get\_int, \hyperpage{20}
|
||||
\item mp\_grow, \hyperpage{17}
|
||||
\item MP\_GT, \hyperpage{23}
|
||||
\item mp\_init, \hyperpage{11}
|
||||
\item mp\_init\_copy, \hyperpage{14}
|
||||
\item mp\_init\_multi, \hyperpage{13}
|
||||
\item mp\_init\_set, \hyperpage{21}
|
||||
\item mp\_init\_set\_int, \hyperpage{21}
|
||||
\item mp\_init\_size, \hyperpage{15}
|
||||
\item mp\_int, \hyperpage{10}
|
||||
\item mp\_invmod, \hyperpage{56}
|
||||
\item mp\_jacobi, \hyperpage{56}
|
||||
\item mp\_lcm, \hyperpage{56}
|
||||
\item mp\_lshd, \hyperpage{30}
|
||||
\item MP\_LT, \hyperpage{23}
|
||||
\item MP\_MEM, \hyperpage{9}
|
||||
\item mp\_mod, \hyperpage{39}
|
||||
\item mp\_mod\_d, \hyperpage{56}
|
||||
\item mp\_montgomery\_calc\_normalization, \hyperpage{42}
|
||||
\item mp\_montgomery\_reduce, \hyperpage{42}
|
||||
\item mp\_montgomery\_setup, \hyperpage{42}
|
||||
\item mp\_mul, \hyperpage{33}
|
||||
\item mp\_mul\_2, \hyperpage{28}
|
||||
\item mp\_mul\_2d, \hyperpage{29}
|
||||
\item mp\_mul\_d, \hyperpage{56}
|
||||
\item mp\_n\_root, \hyperpage{48}
|
||||
\item mp\_neg, \hyperpage{31, 32}
|
||||
\item MP\_NO, \hyperpage{9}
|
||||
\item MP\_OKAY, \hyperpage{9}
|
||||
\item mp\_or, \hyperpage{31}
|
||||
\item mp\_prime\_fermat, \hyperpage{49}
|
||||
\item mp\_prime\_is\_divisible, \hyperpage{49}
|
||||
\item mp\_prime\_is\_prime, \hyperpage{51}
|
||||
\item mp\_prime\_miller\_rabin, \hyperpage{50}
|
||||
\item mp\_prime\_next\_prime, \hyperpage{51}
|
||||
\item mp\_prime\_rabin\_miller\_trials, \hyperpage{50}
|
||||
\item mp\_prime\_random, \hyperpage{51}
|
||||
\item mp\_prime\_random\_ex, \hyperpage{52}
|
||||
\item mp\_radix\_size, \hyperpage{53}
|
||||
\item mp\_read\_radix, \hyperpage{53}
|
||||
\item mp\_read\_unsigned\_bin, \hyperpage{54}
|
||||
\item mp\_reduce, \hyperpage{40}
|
||||
\item mp\_reduce\_2k, \hyperpage{46}
|
||||
\item mp\_reduce\_2k\_setup, \hyperpage{46}
|
||||
\item mp\_reduce\_setup, \hyperpage{40}
|
||||
\item mp\_rshd, \hyperpage{30}
|
||||
\item mp\_set, \hyperpage{19}
|
||||
\item mp\_set\_int, \hyperpage{20}
|
||||
\item mp\_shrink, \hyperpage{16}
|
||||
\item mp\_sqr, \hyperpage{35}
|
||||
\item mp\_sub, \hyperpage{31}
|
||||
\item mp\_sub\_d, \hyperpage{56}
|
||||
\item mp\_to\_unsigned\_bin, \hyperpage{54}
|
||||
\item mp\_toradix, \hyperpage{53}
|
||||
\item mp\_unsigned\_bin\_size, \hyperpage{54}
|
||||
\item MP\_VAL, \hyperpage{9}
|
||||
\item mp\_xor, \hyperpage{31}
|
||||
\item MP\_YES, \hyperpage{9}
|
||||
|
||||
\end{theindex}
|
||||
@@ -1,4 +1,4 @@
|
||||
\documentclass[b5paper]{book}
|
||||
\documentclass[synpaper]{book}
|
||||
\usepackage{hyperref}
|
||||
\usepackage{makeidx}
|
||||
\usepackage{amssymb}
|
||||
@@ -49,8 +49,8 @@
|
||||
\begin{document}
|
||||
\frontmatter
|
||||
\pagestyle{empty}
|
||||
\title{LibTomMath User Manual \\ v0.35}
|
||||
\author{Tom St Denis \\ tomstdenis@iahu.ca}
|
||||
\title{LibTomMath User Manual \\ v0.40}
|
||||
\author{Tom St Denis \\ tomstdenis@gmail.com}
|
||||
\maketitle
|
||||
This text, the library and the accompanying textbook are all hereby placed in the public domain. This book has been
|
||||
formatted for B5 [176x250] paper using the \LaTeX{} {\em book} macro package.
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
static const struct {
|
||||
@@ -41,3 +41,7 @@ char *mp_error_to_string(int code)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_error.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* computes the modular inverse via binary extended euclidean algorithm,
|
||||
@@ -142,3 +142,7 @@ LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &B, &D, NULL);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_fast_mp_invmod.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* computes xR**-1 == x (mod N) via Montgomery Reduction
|
||||
@@ -166,3 +166,7 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_fast_mp_montgomery_reduce.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* Fast (comba) multiplier
|
||||
@@ -70,6 +70,7 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
||||
/* execute loop */
|
||||
for (iz = 0; iz < iy; ++iz) {
|
||||
_W += ((mp_word)*tmpx++)*((mp_word)*tmpy--);
|
||||
|
||||
}
|
||||
|
||||
/* store term */
|
||||
@@ -77,10 +78,7 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
||||
|
||||
/* make next carry */
|
||||
_W = _W >> ((mp_word)DIGIT_BIT);
|
||||
}
|
||||
|
||||
/* store final carry */
|
||||
W[ix] = (mp_digit)(_W & MP_MASK);
|
||||
}
|
||||
|
||||
/* setup dest */
|
||||
olduse = c->used;
|
||||
@@ -103,3 +101,7 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_mul_digs.c,v $ */
|
||||
/* $Revision: 1.7 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* this is a modified version of fast_s_mul_digs that only produces
|
||||
@@ -70,9 +70,6 @@ int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
||||
_W = _W >> ((mp_word)DIGIT_BIT);
|
||||
}
|
||||
|
||||
/* store final carry */
|
||||
W[ix] = (mp_digit)(_W & MP_MASK);
|
||||
|
||||
/* setup dest */
|
||||
olduse = c->used;
|
||||
c->used = pa;
|
||||
@@ -81,7 +78,7 @@ int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
||||
register mp_digit *tmpc;
|
||||
|
||||
tmpc = c->dp + digs;
|
||||
for (ix = digs; ix <= pa; ix++) {
|
||||
for (ix = digs; ix < pa; ix++) {
|
||||
/* now extract the previous digit [below the carry] */
|
||||
*tmpc++ = W[ix];
|
||||
}
|
||||
@@ -95,3 +92,7 @@ int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_mul_high_digs.c,v $ */
|
||||
/* $Revision: 1.5 $ */
|
||||
/* $Date: 2006/11/14 03:46:25 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* the jist of squaring...
|
||||
@@ -108,3 +108,7 @@ int fast_s_mp_sqr (mp_int * a, mp_int * b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_sqr.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* computes a = 2**b
|
||||
@@ -42,3 +42,7 @@ mp_2expt (mp_int * a, int b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_2expt.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* b = |a|
|
||||
@@ -37,3 +37,7 @@ mp_abs (mp_int * a, mp_int * b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_abs.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* high level addition (handles signs) */
|
||||
@@ -47,3 +47,7 @@ int mp_add (mp_int * a, mp_int * b, mp_int * c)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_add.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* single digit addition */
|
||||
@@ -40,6 +40,9 @@ mp_add_d (mp_int * a, mp_digit b, mp_int * c)
|
||||
/* fix sign */
|
||||
a->sign = c->sign = MP_NEG;
|
||||
|
||||
/* clamp */
|
||||
mp_clamp(c);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -103,3 +106,7 @@ mp_add_d (mp_int * a, mp_digit b, mp_int * c)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_add_d.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* d = a + b (mod c) */
|
||||
@@ -35,3 +35,7 @@ mp_addmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_addmod.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* AND two ints together */
|
||||
@@ -51,3 +51,7 @@ mp_and (mp_int * a, mp_int * b, mp_int * c)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_and.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* trim unused digits
|
||||
@@ -38,3 +38,7 @@ mp_clamp (mp_int * a)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_clamp.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,24 +12,21 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* clear one (frees) */
|
||||
void
|
||||
mp_clear (mp_int * a)
|
||||
{
|
||||
volatile mp_digit *p;
|
||||
int len;
|
||||
int i;
|
||||
|
||||
/* only do anything if a hasn't been freed previously */
|
||||
if (a->dp != NULL) {
|
||||
/* first zero the digits */
|
||||
len = a->alloc;
|
||||
p = a->dp;
|
||||
while (len--) {
|
||||
*p++ = 0;
|
||||
}
|
||||
for (i = 0; i < a->used; i++) {
|
||||
a->dp[i] = 0;
|
||||
}
|
||||
|
||||
/* free ram */
|
||||
XFREE(a->dp);
|
||||
@@ -41,3 +38,7 @@ mp_clear (mp_int * a)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_clear.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
|
||||
@@ -28,3 +28,7 @@ void mp_clear_multi(mp_int *mp, ...)
|
||||
va_end(args);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_clear_multi.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* compare two ints (signed)*/
|
||||
@@ -37,3 +37,7 @@ mp_cmp (mp_int * a, mp_int * b)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_cmp.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* compare a digit */
|
||||
@@ -38,3 +38,7 @@ int mp_cmp_d(mp_int * a, mp_digit b)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_cmp_d.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* compare maginitude of two ints (unsigned) */
|
||||
@@ -49,3 +49,7 @@ int mp_cmp_mag (mp_int * a, mp_int * b)
|
||||
return MP_EQ;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_cmp_mag.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
static const int lnz[16] = {
|
||||
@@ -47,3 +47,7 @@ int mp_cnt_lsb(mp_int *a)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_cnt_lsb.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* copy, b = a */
|
||||
@@ -62,3 +62,7 @@ mp_copy (mp_int * a, mp_int * b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_copy.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* returns the number of bits in an int */
|
||||
@@ -39,3 +39,7 @@ mp_count_bits (mp_int * a)
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_count_bits.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
#ifdef BN_MP_DIV_SMALL
|
||||
@@ -286,3 +286,7 @@ LBL_Q:mp_clear (&q);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_div.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* b = a/2 */
|
||||
@@ -62,3 +62,7 @@ int mp_div_2(mp_int * a, mp_int * b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_div_2.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* shift right by a certain bit count (store quotient in c, optional remainder in d) */
|
||||
@@ -91,3 +91,7 @@ int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_div_2d.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* divide by three (based on routine from MPI and the GMP manual) */
|
||||
@@ -73,3 +73,7 @@ mp_div_3 (mp_int * a, mp_int *c, mp_digit * d)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_div_3.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
static int s_is_power_of_two(mp_digit b, int *p)
|
||||
@@ -104,3 +104,7 @@ int mp_div_d (mp_int * a, mp_digit b, mp_int * c, mp_digit * d)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_div_d.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* determines if a number is a valid DR modulus */
|
||||
@@ -37,3 +37,7 @@ int mp_dr_is_modulus(mp_int *a)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_dr_is_modulus.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* reduce "x" in place modulo "n" using the Diminished Radix algorithm.
|
||||
@@ -88,3 +88,7 @@ top:
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_dr_reduce.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* determines the setup value */
|
||||
@@ -26,3 +26,7 @@ void mp_dr_setup(mp_int *a, mp_digit *d)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_dr_setup.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* swap the elements of two integers, for cases where you can't simply swap the
|
||||
@@ -28,3 +28,7 @@ mp_exch (mp_int * a, mp_int * b)
|
||||
*b = t;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_exch.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* calculate c = a**b using a square-multiply algorithm */
|
||||
@@ -51,3 +51,7 @@ int mp_expt_d (mp_int * a, mp_digit b, mp_int * c)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_expt_d.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y)
|
||||
}
|
||||
|
||||
/* modified diminished radix reduction */
|
||||
#if defined(BN_MP_REDUCE_IS_2K_L_C) && defined(BN_MP_REDUCE_2K_L_C)
|
||||
#if defined(BN_MP_REDUCE_IS_2K_L_C) && defined(BN_MP_REDUCE_2K_L_C) && defined(BN_S_MP_EXPTMOD_C)
|
||||
if (mp_reduce_is_2k_l(P) == MP_YES) {
|
||||
return s_mp_exptmod(G, X, P, Y, 1);
|
||||
}
|
||||
@@ -106,3 +106,7 @@ int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_exptmod.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* computes Y == G**X mod P, HAC pp.616, Algorithm 14.85
|
||||
@@ -315,3 +315,7 @@ LBL_M:
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_exptmod_fast.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* Extended euclidean algorithm of (a, b) produces
|
||||
@@ -76,3 +76,7 @@ _ERR: mp_clear_multi(&u1, &u2, &u3, &v1, &v2, &v3, &t1, &t2, &t3, &q, &tmp, NULL
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_exteuclid.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* read a bigint from a file stream in ASCII */
|
||||
@@ -61,3 +61,7 @@ int mp_fread(mp_int *a, int radix, FILE *stream)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_fread.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
int mp_fwrite(mp_int *a, int radix, FILE *stream)
|
||||
@@ -46,3 +46,7 @@ int mp_fwrite(mp_int *a, int radix, FILE *stream)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_fwrite.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* Greatest Common Divisor using the binary method */
|
||||
@@ -22,21 +22,13 @@ int mp_gcd (mp_int * a, mp_int * b, mp_int * c)
|
||||
int k, u_lsb, v_lsb, res;
|
||||
|
||||
/* either zero than gcd is the largest */
|
||||
if (mp_iszero (a) == 1 && mp_iszero (b) == 0) {
|
||||
if (mp_iszero (a) == MP_YES) {
|
||||
return mp_abs (b, c);
|
||||
}
|
||||
if (mp_iszero (a) == 0 && mp_iszero (b) == 1) {
|
||||
if (mp_iszero (b) == MP_YES) {
|
||||
return mp_abs (a, c);
|
||||
}
|
||||
|
||||
/* optimized. At this point if a == 0 then
|
||||
* b must equal zero too
|
||||
*/
|
||||
if (mp_iszero (a) == 1) {
|
||||
mp_zero(c);
|
||||
return MP_OKAY;
|
||||
}
|
||||
|
||||
/* get copies of a and b we can modify */
|
||||
if ((res = mp_init_copy (&u, a)) != MP_OKAY) {
|
||||
return res;
|
||||
@@ -107,3 +99,7 @@ LBL_U:mp_clear (&v);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_gcd.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* get the lower 32-bits of an mp_int */
|
||||
@@ -39,3 +39,7 @@ unsigned long mp_get_int(mp_int * a)
|
||||
return res & 0xFFFFFFFFUL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_get_int.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* grow as required */
|
||||
@@ -51,3 +51,7 @@ int mp_grow (mp_int * a, int size)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_grow.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* init a new mp_int */
|
||||
@@ -40,3 +40,7 @@ int mp_init (mp_int * a)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_init.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* creates "a" then copies b into it */
|
||||
@@ -26,3 +26,7 @@ int mp_init_copy (mp_int * a, mp_int * b)
|
||||
return mp_copy (b, a);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_init_copy.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
|
||||
@@ -53,3 +53,7 @@ int mp_init_multi(mp_int *mp, ...)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_init_multi.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* initialize and set a digit */
|
||||
@@ -26,3 +26,7 @@ int mp_init_set (mp_int * a, mp_digit b)
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_init_set.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* initialize and set a digit */
|
||||
@@ -25,3 +25,7 @@ int mp_init_set_int (mp_int * a, unsigned long b)
|
||||
return mp_set_int(a, b);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_init_set_int.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* init an mp_init for a given size */
|
||||
@@ -42,3 +42,7 @@ int mp_init_size (mp_int * a, int size)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_init_size.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* hac 14.61, pp608 */
|
||||
@@ -37,3 +37,7 @@ int mp_invmod (mp_int * a, mp_int * b, mp_int * c)
|
||||
return MP_VAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_invmod.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* hac 14.61, pp608 */
|
||||
@@ -169,3 +169,7 @@ LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &A, &B, &C, &D, NULL);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_invmod_slow.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* Check if remainders are possible squares - fast exclude non-squares */
|
||||
@@ -103,3 +103,7 @@ ERR:mp_clear(&t);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_is_square.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* computes the jacobi c = (a | n) (or Legendre if n is prime)
|
||||
@@ -99,3 +99,7 @@ LBL_A1:mp_clear (&a1);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_jacobi.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* c = |a| * |b| using Karatsuba Multiplication using
|
||||
@@ -26,12 +26,12 @@
|
||||
* b = b1 * B**n + b0
|
||||
*
|
||||
* Then, a * b =>
|
||||
a1b1 * B**2n + ((a1 - a0)(b1 - b0) + a0b0 + a1b1) * B + a0b0
|
||||
a1b1 * B**2n + ((a1 + a0)(b1 + b0) - (a0b0 + a1b1)) * B + a0b0
|
||||
*
|
||||
* Note that a1b1 and a0b0 are used twice and only need to be
|
||||
* computed once. So in total three half size (half # of
|
||||
* digit) multiplications are performed, a0b0, a1b1 and
|
||||
* (a1-b1)(a0-b0)
|
||||
* (a1+b1)(a0+b0)
|
||||
*
|
||||
* Note that a multiplication of half the digits requires
|
||||
* 1/4th the number of single precision multiplications so in
|
||||
@@ -122,19 +122,19 @@ int mp_karatsuba_mul (mp_int * a, mp_int * b, mp_int * c)
|
||||
if (mp_mul (&x1, &y1, &x1y1) != MP_OKAY)
|
||||
goto X1Y1; /* x1y1 = x1*y1 */
|
||||
|
||||
/* now calc x1-x0 and y1-y0 */
|
||||
if (mp_sub (&x1, &x0, &t1) != MP_OKAY)
|
||||
/* now calc x1+x0 and y1+y0 */
|
||||
if (s_mp_add (&x1, &x0, &t1) != MP_OKAY)
|
||||
goto X1Y1; /* t1 = x1 - x0 */
|
||||
if (mp_sub (&y1, &y0, &x0) != MP_OKAY)
|
||||
if (s_mp_add (&y1, &y0, &x0) != MP_OKAY)
|
||||
goto X1Y1; /* t2 = y1 - y0 */
|
||||
if (mp_mul (&t1, &x0, &t1) != MP_OKAY)
|
||||
goto X1Y1; /* t1 = (x1 - x0) * (y1 - y0) */
|
||||
goto X1Y1; /* t1 = (x1 + x0) * (y1 + y0) */
|
||||
|
||||
/* add x0y0 */
|
||||
if (mp_add (&x0y0, &x1y1, &x0) != MP_OKAY)
|
||||
goto X1Y1; /* t2 = x0y0 + x1y1 */
|
||||
if (mp_sub (&x0, &t1, &t1) != MP_OKAY)
|
||||
goto X1Y1; /* t1 = x0y0 + x1y1 - (x1-x0)*(y1-y0) */
|
||||
if (s_mp_sub (&t1, &x0, &t1) != MP_OKAY)
|
||||
goto X1Y1; /* t1 = (x1+x0)*(y1+y0) - (x1y1 + x0y0) */
|
||||
|
||||
/* shift by B */
|
||||
if (mp_lshd (&t1, B) != MP_OKAY)
|
||||
@@ -161,3 +161,7 @@ ERR:
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_karatsuba_mul.c,v $ */
|
||||
/* $Revision: 1.5 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* Karatsuba squaring, computes b = a*a using three
|
||||
@@ -80,8 +80,8 @@ int mp_karatsuba_sqr (mp_int * a, mp_int * b)
|
||||
if (mp_sqr (&x1, &x1x1) != MP_OKAY)
|
||||
goto X1X1; /* x1x1 = x1*x1 */
|
||||
|
||||
/* now calc (x1-x0)**2 */
|
||||
if (mp_sub (&x1, &x0, &t1) != MP_OKAY)
|
||||
/* now calc (x1+x0)**2 */
|
||||
if (s_mp_add (&x1, &x0, &t1) != MP_OKAY)
|
||||
goto X1X1; /* t1 = x1 - x0 */
|
||||
if (mp_sqr (&t1, &t1) != MP_OKAY)
|
||||
goto X1X1; /* t1 = (x1 - x0) * (x1 - x0) */
|
||||
@@ -89,8 +89,8 @@ int mp_karatsuba_sqr (mp_int * a, mp_int * b)
|
||||
/* add x0y0 */
|
||||
if (s_mp_add (&x0x0, &x1x1, &t2) != MP_OKAY)
|
||||
goto X1X1; /* t2 = x0x0 + x1x1 */
|
||||
if (mp_sub (&t2, &t1, &t1) != MP_OKAY)
|
||||
goto X1X1; /* t1 = x0x0 + x1x1 - (x1-x0)*(x1-x0) */
|
||||
if (s_mp_sub (&t1, &t2, &t1) != MP_OKAY)
|
||||
goto X1X1; /* t1 = (x1+x0)**2 - (x0x0 + x1x1) */
|
||||
|
||||
/* shift by B */
|
||||
if (mp_lshd (&t1, B) != MP_OKAY)
|
||||
@@ -115,3 +115,7 @@ ERR:
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_karatsuba_sqr.c,v $ */
|
||||
/* $Revision: 1.5 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* computes least common multiple as |a*b|/(a, b) */
|
||||
@@ -54,3 +54,7 @@ LBL_T:
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_lcm.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* shift left a certain amount of digits */
|
||||
@@ -61,3 +61,7 @@ int mp_lshd (mp_int * a, int b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_lshd.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* c = a mod b, 0 <= c < b */
|
||||
@@ -42,3 +42,7 @@ mp_mod (mp_int * a, mp_int * b, mp_int * c)
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_mod.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* calc a value mod 2**b */
|
||||
@@ -49,3 +49,7 @@ mp_mod_2d (mp_int * a, int b, mp_int * c)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_mod_2d.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
int
|
||||
@@ -21,3 +21,7 @@ mp_mod_d (mp_int * a, mp_digit b, mp_digit * c)
|
||||
return mp_div_d(a, b, NULL, c);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_mod_d.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -53,3 +53,7 @@ int mp_montgomery_calc_normalization (mp_int * a, mp_int * b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_montgomery_calc_normalization.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* computes xR**-1 == x (mod N) via Montgomery Reduction */
|
||||
@@ -112,3 +112,7 @@ mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_montgomery_reduce.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* setups the montgomery reduction stuff */
|
||||
@@ -48,8 +48,12 @@ mp_montgomery_setup (mp_int * n, mp_digit * rho)
|
||||
#endif
|
||||
|
||||
/* rho = -1/m mod b */
|
||||
*rho = (((mp_word)1 << ((mp_word) DIGIT_BIT)) - x) & MP_MASK;
|
||||
*rho = (unsigned long)(((mp_word)1 << ((mp_word) DIGIT_BIT)) - x) & MP_MASK;
|
||||
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_montgomery_setup.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/12/04 21:34:03 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* high level multiplication (handles sign) */
|
||||
@@ -60,3 +60,7 @@ int mp_mul (mp_int * a, mp_int * b, mp_int * c)
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_mul.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* b = a*2 */
|
||||
@@ -76,3 +76,7 @@ int mp_mul_2(mp_int * a, mp_int * b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_mul_2.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* shift left by a certain bit count */
|
||||
@@ -79,3 +79,7 @@ int mp_mul_2d (mp_int * a, int b, mp_int * c)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_mul_2d.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* multiply by a digit */
|
||||
@@ -73,3 +73,7 @@ mp_mul_d (mp_int * a, mp_digit b, mp_int * c)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_mul_d.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,12 +12,11 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* d = a * b (mod c) */
|
||||
int
|
||||
mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
|
||||
int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
|
||||
{
|
||||
int res;
|
||||
mp_int t;
|
||||
@@ -35,3 +34,7 @@ mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_mulmod.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* find the n'th root of an integer
|
||||
@@ -126,3 +126,7 @@ LBL_T1:mp_clear (&t1);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_n_root.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* b = -a */
|
||||
@@ -34,3 +34,7 @@ int mp_neg (mp_int * a, mp_int * b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_neg.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* OR two ints together */
|
||||
@@ -44,3 +44,7 @@ int mp_or (mp_int * a, mp_int * b, mp_int * c)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_or.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* performs one Fermat test.
|
||||
@@ -56,3 +56,7 @@ LBL_T:mp_clear (&t);
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_prime_fermat.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* determines if an integers is divisible by one
|
||||
@@ -44,3 +44,7 @@ int mp_prime_is_divisible (mp_int * a, int *result)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_prime_is_divisible.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* performs a variable number of rounds of Miller-Rabin
|
||||
@@ -77,3 +77,7 @@ LBL_B:mp_clear (&b);
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_prime_is_prime.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* Miller-Rabin test of "a" to the base of "b" as described in
|
||||
@@ -97,3 +97,7 @@ LBL_N1:mp_clear (&n1);
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_prime_miller_rabin.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* finds the next prime after the number "a" using "t" trials
|
||||
@@ -164,3 +164,7 @@ LBL_ERR:
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_prime_next_prime.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
|
||||
@@ -46,3 +46,7 @@ int mp_prime_rabin_miller_trials(int size)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_prime_rabin_miller_trials.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* makes a truly random prime of a given size (bits),
|
||||
@@ -62,10 +62,8 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
|
||||
maskOR_msb = 0;
|
||||
maskOR_msb_offset = ((size & 7) == 1) ? 1 : 0;
|
||||
if (flags & LTM_PRIME_2MSB_ON) {
|
||||
maskOR_msb |= 1 << ((size - 2) & 7);
|
||||
} else if (flags & LTM_PRIME_2MSB_OFF) {
|
||||
maskAND &= ~(1 << ((size - 2) & 7));
|
||||
}
|
||||
maskOR_msb |= 0x80 >> ((9 - size) & 7);
|
||||
}
|
||||
|
||||
/* get the maskOR_lsb */
|
||||
maskOR_lsb = 1;
|
||||
@@ -121,3 +119,7 @@ error:
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_prime_random_ex.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* returns size of ASCII reprensentation */
|
||||
@@ -36,7 +36,7 @@ int mp_radix_size (mp_int * a, int radix, int *size)
|
||||
}
|
||||
|
||||
if (mp_iszero(a) == MP_YES) {
|
||||
*size = 2;
|
||||
*size = 2;
|
||||
return MP_OKAY;
|
||||
}
|
||||
|
||||
@@ -72,3 +72,7 @@ int mp_radix_size (mp_int * a, int radix, int *size)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_radix_size.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,9 +12,13 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* chars used in radix conversions */
|
||||
const char *mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_radix_smap.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* makes a pseudo-random int of a given size */
|
||||
@@ -49,3 +49,7 @@ mp_rand (mp_int * a, int digits)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_rand.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* read a string [ASCII] in a given radix */
|
||||
@@ -21,6 +21,9 @@ int mp_read_radix (mp_int * a, const char *str, int radix)
|
||||
int y, res, neg;
|
||||
char ch;
|
||||
|
||||
/* zero the digit bignum */
|
||||
mp_zero(a);
|
||||
|
||||
/* make sure the radix is ok */
|
||||
if (radix < 2 || radix > 64) {
|
||||
return MP_VAL;
|
||||
@@ -76,3 +79,7 @@ int mp_read_radix (mp_int * a, const char *str, int radix)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_read_radix.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,12 +12,11 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* read signed bin, big endian, first byte is 0==positive or 1==negative */
|
||||
int
|
||||
mp_read_signed_bin (mp_int * a, unsigned char *b, int c)
|
||||
int mp_read_signed_bin (mp_int * a, const unsigned char *b, int c)
|
||||
{
|
||||
int res;
|
||||
|
||||
@@ -36,3 +35,7 @@ mp_read_signed_bin (mp_int * a, unsigned char *b, int c)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_read_signed_bin.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,12 +12,11 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* reads a unsigned char array, assumes the msb is stored first [big endian] */
|
||||
int
|
||||
mp_read_unsigned_bin (mp_int * a, unsigned char *b, int c)
|
||||
int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c)
|
||||
{
|
||||
int res;
|
||||
|
||||
@@ -50,3 +49,7 @@ mp_read_unsigned_bin (mp_int * a, unsigned char *b, int c)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_read_unsigned_bin.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
@@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* reduces x mod m, assumes 0 < x < m**2, mu is
|
||||
@@ -94,3 +94,7 @@ CLEANUP:
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_reduce.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user