import kpasman 0.1 sources
This commit is contained in:
parent
16a283b00c
commit
9a3f2b6afc
110 changed files with 27300 additions and 0 deletions
17
rc2-1.1.0/INSTALL
Normal file
17
rc2-1.1.0/INSTALL
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
Configuration:
|
||||
Edit the Makefile. Change anything that needs changing. It's all
|
||||
self-explanatory.
|
||||
|
||||
Compilation and installation is super-simple. Just type one of the following:
|
||||
|
||||
make all - if you want the library and example compiled and installed
|
||||
make librc2 - if you just want the library compiled
|
||||
make i_librc2 - if you just want the library compiled and the library and
|
||||
include file installed
|
||||
make rc2 - if you just want the example program compiled
|
||||
make i_rc2 - if you just want the example program made and installed
|
||||
|
||||
|
||||
---------------
|
||||
Matthew Palmer
|
||||
<mjp16@uow.edu.au>
|
||||
125
rc2-1.1.0/LICENSE
Normal file
125
rc2-1.1.0/LICENSE
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
The "Artistic License"
|
||||
|
||||
Preamble
|
||||
|
||||
The intent of this document is to state the conditions under which a
|
||||
Package may be copied, such that the Copyright Holder maintains some
|
||||
semblance of artistic control over the development of the Package,
|
||||
while giving the users of the package the right to use and distribute
|
||||
the Package in a more-or-less customary fashion, plus the right to make
|
||||
reasonable modifications.
|
||||
|
||||
It also grants you the rights to reuse parts of a Package in your own
|
||||
programs without transferring this License to those programs, provided
|
||||
that you meet some reasonable requirements.
|
||||
|
||||
Definitions:
|
||||
|
||||
"Package" refers to the collection of files distributed by the
|
||||
Copyright Holder, and derivatives of that collection of files
|
||||
created through textual modification.
|
||||
|
||||
"Standard Version" refers to such a Package if it has not been
|
||||
modified, or has been modified in accordance with the wishes
|
||||
of the Copyright Holder as specified below.
|
||||
|
||||
"Copyright Holder" is whoever is named in the copyright or
|
||||
copyrights for the package.
|
||||
|
||||
"You" is you, if you're thinking about copying or distributing
|
||||
this Package.
|
||||
|
||||
"Reasonable copying fee" is whatever you can justify on the
|
||||
basis of media cost, duplication charges, time of people involved,
|
||||
and so on. (You will not be required to justify it to the
|
||||
Copyright Holder, but only to the computing community at large
|
||||
as a market that must bear the fee.)
|
||||
|
||||
"Freely Available" means that no fee is charged for the item
|
||||
itself, though there may be fees involved in handling the item.
|
||||
It also means that recipients of the item may redistribute it
|
||||
under the same conditions they received it.
|
||||
|
||||
1. You may make and give away verbatim copies of the source form of the
|
||||
Standard Version of this Package without restriction, provided that you
|
||||
duplicate all of the original copyright notices and associated disclaimers.
|
||||
|
||||
2. You may apply bug fixes, portability fixes and other modifications
|
||||
derived from the Public Domain or from the Copyright Holder. A Package
|
||||
modified in such a way shall still be considered the Standard Version.
|
||||
|
||||
3. You may otherwise modify your copy of this Package in any way, provided
|
||||
that you insert a prominent notice in each changed file stating how and
|
||||
when you changed that file, and provided that you do at least ONE of the
|
||||
following:
|
||||
|
||||
a) place your modifications in the Public Domain or otherwise make them
|
||||
Freely Available, such as by posting said modifications to Usenet or
|
||||
an equivalent medium, or placing the modifications on a major archive
|
||||
site such as uunet.uu.net, or by allowing the Copyright Holder to include
|
||||
your modifications in the Standard Version of the Package.
|
||||
|
||||
b) use the modified Package only within your corporation or organization.
|
||||
|
||||
c) rename any non-standard executables so the names do not conflict
|
||||
with standard executables, which must also be provided, and provide
|
||||
a separate manual page for each non-standard executable that clearly
|
||||
documents how it differs from the Standard Version.
|
||||
|
||||
d) make other distribution arrangements with the Copyright Holder.
|
||||
|
||||
4. You may distribute the programs of this Package in object code or
|
||||
executable form, provided that you do at least ONE of the following:
|
||||
|
||||
a) distribute a Standard Version of the executables and library files,
|
||||
together with instructions (in the manual page or equivalent) on where
|
||||
to get the Standard Version.
|
||||
|
||||
b) accompany the distribution with the machine-readable source of
|
||||
the Package with your modifications.
|
||||
|
||||
c) give non-standard executables non-standard names, and clearly
|
||||
document the differences in manual pages (or equivalent), together
|
||||
with instructions on where to get the Standard Version.
|
||||
|
||||
d) make other distribution arrangements with the Copyright Holder.
|
||||
|
||||
5. You may charge a reasonable copying fee for any distribution of this
|
||||
Package. You may charge any fee you choose for support of this
|
||||
Package. You may not charge a fee for this Package itself. However,
|
||||
you may distribute this Package in aggregate with other (possibly
|
||||
commercial) programs as part of a larger (possibly commercial) software
|
||||
distribution provided that you do not advertise this Package as a
|
||||
product of your own.
|
||||
|
||||
6. The scripts and library files supplied as input to or produced as
|
||||
output from the programs of this Package do not automatically fall
|
||||
under the copyright of this Package, but belong to whomever generated
|
||||
them, and may be sold commercially, and may be aggregated with this
|
||||
Package. If such scripts or library files are aggregated with this
|
||||
Package via the so-called "undump" or "unexec" methods of producing a
|
||||
binary executable image, then distribution of such an image shall
|
||||
neither be construed as a distribution of this Package nor shall it
|
||||
fall under the restrictions of Paragraphs 3 and 4, provided that you do
|
||||
not represent such an executable image as a Standard Version of this
|
||||
Package.
|
||||
|
||||
7. You may reuse parts of this Package in your own programs, provided that
|
||||
you explicitly state where you got them from, in the source code (and, left
|
||||
to your courtesy, in the documentation), duplicating all the associated
|
||||
copyright notices and disclaimers. Besides your changes, if any, must be
|
||||
clearly marked as such. Parts reused that way will no longer fall under this
|
||||
license if, and only if, the name of your program(s) have no immediate
|
||||
connection with the name of the Package itself or its associated programs.
|
||||
You may then apply whatever restrictions you wish on the reused parts or
|
||||
choose to place them in the Public Domain--this will apply only within the
|
||||
context of your package.
|
||||
|
||||
8. The name of the Copyright Holder may not be used to endorse or promote
|
||||
products derived from this software without specific prior written permission.
|
||||
|
||||
9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
The End
|
||||
49
rc2-1.1.0/Makefile
Normal file
49
rc2-1.1.0/Makefile
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# Add any required compiler flags
|
||||
C_FLAGS = -O2 -Wall -fomit-frame-pointer
|
||||
|
||||
# Add any include directories, in the form -I<include-dir>. Some systems
|
||||
# apparently need -I/usr/local/include. Add it if rc2 barfs with a "not
|
||||
# found" error in rc2.c.
|
||||
INCLUDES =
|
||||
|
||||
# This shouldn't need to be changed
|
||||
CC = gcc
|
||||
|
||||
# Linker Flags - shouldn't be any problems. You might want to play with
|
||||
# libraries if you have real problems.
|
||||
LDFLAGS =
|
||||
|
||||
# Base directory for installation. rc2/derc2 will go in BASEDIR/bin, librc2
|
||||
# in BASEDIR/lib, and rc2.h into BASEDIR/include
|
||||
BASEDIR = /usr/local
|
||||
|
||||
###############################################################
|
||||
#
|
||||
# DON'T TOUCH BELOW THIS LINE
|
||||
#
|
||||
###############################################################
|
||||
|
||||
CFLAGS = $(C_FLAGS) $(INCLUDES)
|
||||
|
||||
all: i_librc2 i_rc2
|
||||
|
||||
rc2: rc2.o
|
||||
cc -Wall rc2.o -lrc2 -o rc2
|
||||
|
||||
librc2: librc2.o
|
||||
ar rc librc2.a librc2.o
|
||||
ranlib librc2.a
|
||||
|
||||
i_rc2: rc2
|
||||
install -g root -o root -m 644 rc2 $(BASEDIR)/bin
|
||||
ln -s $(BASEDIR)/bin/rc2 $(BASEDIR)/bin/derc2
|
||||
|
||||
i_librc2: librc2
|
||||
install -g root -o root -m 644 librc2.a $(BASEDIR)/lib
|
||||
install -g root -o root -m 644 rc2.h $(BASEDIR)/include
|
||||
|
||||
clean:
|
||||
rm *.o
|
||||
rm *.a
|
||||
rm derc2
|
||||
rm rc2
|
||||
8
rc2-1.1.0/README
Normal file
8
rc2-1.1.0/README
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
Please see rc2.doc for information on the library and example application,
|
||||
and INSTALL for the compilation/installation instructions. Licensing
|
||||
details are contained within the file LICENSE. If you want an alternate
|
||||
arrangement, please contact me.
|
||||
|
||||
--------------
|
||||
Matthew Palmer
|
||||
<mjp16@uow.edu.au>
|
||||
192
rc2-1.1.0/librc2.c
Normal file
192
rc2-1.1.0/librc2.c
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
/* C implementation of RC2 encryption algorithm, as described in RFC2268 */
|
||||
/* By Matthew Palmer <mjp16@uow.edu.au> */
|
||||
|
||||
#include "rc2.h"
|
||||
|
||||
unsigned char _rc2_pitable[] = { 0xd9, 0x78, 0xf9, 0xc4, 0x19, 0xdd, 0xb5, 0xed,
|
||||
0x28, 0xe9, 0xfd, 0x79, 0x4a, 0xa0, 0xd8, 0x9d,
|
||||
0xc6, 0x7e, 0x37, 0x83, 0x2b, 0x76, 0x53, 0x8e,
|
||||
0x62, 0x4c, 0x64, 0x88, 0x44, 0x8b, 0xfb, 0xa2,
|
||||
0x17, 0x9a, 0x59, 0xf5, 0x87, 0xb3, 0x4f, 0x13,
|
||||
0x61, 0x45, 0x6d, 0x8d, 0x09, 0x81, 0x7d, 0x32,
|
||||
0xbd, 0x8f, 0x40, 0xeb, 0x86, 0xb7, 0x7b, 0x0b,
|
||||
0xf0, 0x95, 0x21, 0x22, 0x5c, 0x6b, 0x4e, 0x82,
|
||||
0x54, 0xd6, 0x65, 0x93, 0xce, 0x60, 0xb2, 0x1c,
|
||||
0x73, 0x56, 0xc0, 0x14, 0xa7, 0x8c, 0xf1, 0xdc,
|
||||
0x12, 0x75, 0xca, 0x1f, 0x3b, 0xbe, 0xe4, 0xd1,
|
||||
0x42, 0x3d, 0xd4, 0x30, 0xa3, 0x3c, 0xb6, 0x26,
|
||||
0x6f, 0xbf, 0x0e, 0xda, 0x46, 0x69, 0x07, 0x57,
|
||||
0x27, 0xf2, 0x1d, 0x9b, 0xbc, 0x94, 0x43, 0x03,
|
||||
0xf8, 0x11, 0xc7, 0xf6, 0x90, 0xef, 0x3e, 0xe7,
|
||||
0x06, 0xc3, 0xd5, 0x2f, 0xc8, 0x66, 0x1e, 0xd7,
|
||||
0x08, 0xe8, 0xea, 0xde, 0x80, 0x52, 0xee, 0xf7,
|
||||
0x84, 0xaa, 0x72, 0xac, 0x35, 0x4d, 0x6a, 0x2a,
|
||||
0x96, 0x1a, 0xd2, 0x71, 0x5a, 0x15, 0x49, 0x74,
|
||||
0x4b, 0x9f, 0xd0, 0x5e, 0x04, 0x18, 0xa4, 0xec,
|
||||
0xc2, 0xe0, 0x41, 0x6e, 0x0f, 0x51, 0xcb, 0xcc,
|
||||
0x24, 0x91, 0xaf, 0x50, 0xa1, 0xf4, 0x70, 0x39,
|
||||
0x99, 0x7c, 0x3a, 0x85, 0x23, 0xb8, 0xb4, 0x7a,
|
||||
0xfc, 0x02, 0x36, 0x5b, 0x25, 0x55, 0x97, 0x31,
|
||||
0x2d, 0x5d, 0xfa, 0x98, 0xe3, 0x8a, 0x92, 0xae,
|
||||
0x05, 0xdf, 0x29, 0x10, 0x67, 0x6c, 0xba, 0xc9,
|
||||
0xd3, 0x00, 0xe6, 0xcf, 0xe1, 0x9e, 0xa8, 0x2c,
|
||||
0x63, 0x16, 0x01, 0x3f, 0x58, 0xe2, 0x89, 0xa9,
|
||||
0x0d, 0x38, 0x34, 0x1b, 0xab, 0x33, 0xff, 0xb0,
|
||||
0xbb, 0x48, 0x0c, 0x5f, 0xb9, 0xb1, 0xcd, 0x2e,
|
||||
0xc5, 0xf3, 0xdb, 0x47, 0xe5, 0xa5, 0x9c, 0x77,
|
||||
0x0a, 0xa6, 0x20, 0x68, 0xfe, 0x7f, 0xc1, 0xad };
|
||||
unsigned char _rc2_expkey[128]; /* Expanded Key */
|
||||
int _rc2_counter; /* global integer variable used in mixing */
|
||||
int _rc2_s[] = {1, 2, 3, 5};
|
||||
|
||||
|
||||
void rc2_expandkey(char key[], int length, int ekl)
|
||||
{
|
||||
int ekl8, keymask, i;
|
||||
|
||||
/* Put supplied key into first length - 1 bytes of the key buffer */
|
||||
for (i = 0; i < length; i++) {
|
||||
_rc2_expkey[i] = key[i];
|
||||
}
|
||||
|
||||
ekl8 = (ekl + 7) / 8;
|
||||
i = _rc2_pow(2, (8 + ekl - 8 * ekl8));
|
||||
keymask = 255 % i;
|
||||
|
||||
/* First expansion step */
|
||||
for (i = length; i < 128; i++) {
|
||||
_rc2_expkey[i] = _rc2_pitable[(_rc2_expkey[i - 1] + _rc2_expkey[i - length]) % 256];
|
||||
}
|
||||
|
||||
/* Expansion intermediate step */
|
||||
_rc2_expkey[128 - ekl8] = _rc2_pitable[_rc2_expkey[128 - ekl8] & keymask];
|
||||
|
||||
/* Third Expansion step */
|
||||
for (i = 127 - ekl8; i >= 0; i--) {
|
||||
_rc2_expkey[i] = _rc2_pitable[_rc2_expkey[i + 1] ^ _rc2_expkey[i + ekl8]];
|
||||
}
|
||||
}
|
||||
|
||||
void rc2_encrypt(unsigned short input[4])
|
||||
{
|
||||
int i;
|
||||
|
||||
_rc2_counter = 0;
|
||||
for (i = 0; i < 5; i++) {
|
||||
_rc2_mix(input);
|
||||
}
|
||||
_rc2_mash(input);
|
||||
for (i = 0; i < 6; i++) {
|
||||
_rc2_mix(input);
|
||||
}
|
||||
_rc2_mash(input);
|
||||
for (i = 0; i < 5; i++) {
|
||||
_rc2_mix(input);
|
||||
}
|
||||
}
|
||||
|
||||
void _rc2_mix(unsigned short input[])
|
||||
{
|
||||
unsigned short K, i;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
K = _rc2_expkey[_rc2_counter * 2] + 256 * _rc2_expkey[_rc2_counter * 2 + 1];
|
||||
input[i] = input[i] + K + (input[(i + 3) % 4] & input[(i + 2) % 4]) + ((~input[(i + 3) % 4]) & input[(i + 1) % 4]);
|
||||
_rc2_counter++;
|
||||
input[i] = _rc2_rol(input[i], _rc2_s[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void _rc2_mash(unsigned short input[])
|
||||
{
|
||||
unsigned short K, i, x;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
x = input[(i + 3) % 4] & 63;
|
||||
K = _rc2_expkey[2 * x] + 256 * _rc2_expkey[2 * x + 1];
|
||||
input[i] = input[i] + K;
|
||||
}
|
||||
}
|
||||
|
||||
void rc2_decrypt(unsigned short input[4])
|
||||
{
|
||||
int i;
|
||||
|
||||
_rc2_counter = 63;
|
||||
for (i = 0; i < 5; i++) {
|
||||
_rc2_rmix(input);
|
||||
}
|
||||
_rc2_rmash(input);
|
||||
for (i = 0; i < 6; i++) {
|
||||
_rc2_rmix(input);
|
||||
}
|
||||
_rc2_rmash(input);
|
||||
for (i = 0; i < 5; i++) {
|
||||
_rc2_rmix(input);
|
||||
}
|
||||
}
|
||||
|
||||
void _rc2_rmix(unsigned short input[])
|
||||
{
|
||||
unsigned short K;
|
||||
int i;
|
||||
|
||||
for (i = 3; i >= 0; i--) {
|
||||
input[i] = _rc2_ror(input[i], _rc2_s[i]);
|
||||
K = _rc2_expkey[_rc2_counter * 2] + 256 * _rc2_expkey[_rc2_counter * 2 + 1];
|
||||
input[i] = input[i] - K - (input[(i + 3) % 4] & input[(i + 2) % 4]) - ((~input[(i + 3) % 4]) & input[(i + 1) % 4]);
|
||||
_rc2_counter--;
|
||||
}
|
||||
}
|
||||
|
||||
void _rc2_rmash(unsigned short input[])
|
||||
{
|
||||
unsigned short K, x;
|
||||
int i;
|
||||
|
||||
for (i = 3; i >= 0; i--) {
|
||||
x = input[(i + 3) % 4] & 63;
|
||||
K = _rc2_expkey[2 * x] + 256 * _rc2_expkey[2 * x + 1];
|
||||
input[i] = input[i] - K;
|
||||
}
|
||||
}
|
||||
int _rc2_pow(base, exponent)
|
||||
{
|
||||
int i, result;
|
||||
|
||||
if (exponent == 0) {
|
||||
return 1;
|
||||
}
|
||||
result = 1;
|
||||
for (i = 0; i < exponent; i++) {
|
||||
result = result * base;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned short _rc2_rol(unsigned short input, int places)
|
||||
{
|
||||
unsigned short temp, i;
|
||||
|
||||
for (i = 0; i < places; i++) {
|
||||
temp = input & 0x8000;
|
||||
input = input << 1;
|
||||
if (temp) {
|
||||
input++;
|
||||
}
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
unsigned short _rc2_ror(unsigned short input, int places)
|
||||
{
|
||||
unsigned short temp, i;
|
||||
for (i = 0; i < places; i++) {
|
||||
temp = input & 0x1;
|
||||
input = input >> 1;
|
||||
if (temp) {
|
||||
input = input + 0x8000;
|
||||
}
|
||||
}
|
||||
return input;
|
||||
}
|
||||
103
rc2-1.1.0/rc2.c
Normal file
103
rc2-1.1.0/rc2.c
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <rc2.h>
|
||||
|
||||
void rc2(void);
|
||||
void derc2(void);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
unsigned int i, j = 0, keypiece, keylength;
|
||||
unsigned char temp[3], key[128];
|
||||
|
||||
if (argc < 3) {
|
||||
exit(0);
|
||||
}
|
||||
if (!strncmp("0x",argv[1],2)) {
|
||||
for (i = 2; argv[1][i] != '\0'; j++) {
|
||||
temp[0] = argv[1][i++];
|
||||
temp[1] = argv[1][i++];
|
||||
temp[2] = '\0';
|
||||
keypiece = (int) strtol(temp, NULL, 16);
|
||||
key[j] = (char) keypiece;
|
||||
}
|
||||
} else {
|
||||
for (j = 0; argv[1][j] != '\0'; j++) {
|
||||
key[j] = argv[1][j];
|
||||
}
|
||||
}
|
||||
keylength = j;
|
||||
rc2_expandkey(key, keylength, atoi(argv[2]));
|
||||
if (!strcmp(argv[0],"rc2")) {
|
||||
rc2();
|
||||
} else if (!strcmp(argv[0],"derc2")) {
|
||||
derc2();
|
||||
} else {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rc2()
|
||||
{
|
||||
unsigned char charbuf[8];
|
||||
unsigned short text[4];
|
||||
unsigned int count, i;
|
||||
|
||||
do {
|
||||
count = read(fileno(stdin),charbuf,8);
|
||||
if (count == 0) {
|
||||
exit(0);
|
||||
}
|
||||
if (count < 8) {
|
||||
for (i = count; i < 8; i++) {
|
||||
charbuf[i] = '\0';
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
text[i] = charbuf[i * 2] + 256 * charbuf[i * 2 + 1];
|
||||
}
|
||||
rc2_encrypt(text);
|
||||
for (i = 0; i < 4; i++) {
|
||||
charbuf[i * 2] = text[i] & 0xff;
|
||||
charbuf[i * 2 + 1] = text[i] >> 8;
|
||||
}
|
||||
for (i = 0; i < 8; i++) {
|
||||
putchar((int) charbuf[i]);
|
||||
}
|
||||
} while (count == 8);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void derc2()
|
||||
{
|
||||
unsigned char charbuf[8];
|
||||
unsigned short text[4];
|
||||
unsigned int count, i;
|
||||
|
||||
do {
|
||||
count = read(fileno(stdin),charbuf,8);
|
||||
if (count == 0) {
|
||||
exit(0);
|
||||
}
|
||||
if (count < 8) {
|
||||
for (i = count; i < 8; i++) {
|
||||
charbuf[i] = '\0';
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
text[i] = charbuf[i * 2] + 256 * charbuf[i * 2 + 1];
|
||||
}
|
||||
rc2_decrypt(text);
|
||||
for (i = 0; i < 4; i++) {
|
||||
charbuf[i * 2] = text[i] & 0xff;
|
||||
charbuf[i * 2 + 1] = text[i] >> 8;
|
||||
}
|
||||
for (i = 0; i < 8; i++) {
|
||||
putchar((int) charbuf[i]);
|
||||
}
|
||||
} while (count == 8);
|
||||
exit(0);
|
||||
}
|
||||
44
rc2-1.1.0/rc2.doc
Normal file
44
rc2-1.1.0/rc2.doc
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
This is a library of routines that implements the RC2 algorithm, as
|
||||
described in RFC2268. It consists of the following routines:
|
||||
|
||||
rc2_expand_key(char[] key, int length, int effective_key_length);
|
||||
|
||||
This places the given key (consisting of an array of chars of length length)
|
||||
into the 128 byte key buffer (internal). The maths is interesting, but the
|
||||
outcome is that each byte of the expanded key depends on every byte of the
|
||||
given key.
|
||||
|
||||
The effective_key_length specifies how much of the given key to actually
|
||||
use. This is a throwback to the underlying algorithm used. Usually it
|
||||
should be the same as length.
|
||||
|
||||
rc2_encrypt(unsigned short input[4]);
|
||||
|
||||
Encrypts the given 8 bytes and places the result in the same place, using
|
||||
the previously expanded key.
|
||||
|
||||
rc2_decrypt(unsigned short input[4]);
|
||||
|
||||
The reverse operation from above, again using the previously expanded key.
|
||||
|
||||
In short, therefore, the following actions take place to encrypt a piece of
|
||||
data:
|
||||
|
||||
rc2_expand_key();
|
||||
while (data left to encrypt) {
|
||||
rc2_encrypt();
|
||||
}
|
||||
|
||||
And a similar operation for decryption.
|
||||
|
||||
An example application, written by myself, is provided. This program
|
||||
endeavours to either encrypt or decrypt stdin (depending on how it is
|
||||
invoked) and print the results to stdout, using the supplied key and other
|
||||
data.
|
||||
|
||||
Any questions, comments, bug reports, can go to moi at the address below,
|
||||
all flames (for whatever reason) can be happily poured to /dev/null.
|
||||
|
||||
------------------
|
||||
Matthew Palmer
|
||||
<mjp16@uow.edu.au>
|
||||
17
rc2-1.1.0/rc2.h
Normal file
17
rc2-1.1.0/rc2.h
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/* Header file for rc2 implementation by Matthew Palmer <mjp16@uow.edu.au> */
|
||||
|
||||
/* Externally worked functions */
|
||||
void rc2_expandkey(char [], int, int);
|
||||
void rc2_encrypt(unsigned short *);
|
||||
void rc2_decrypt(unsigned short *);
|
||||
|
||||
/* The internals */
|
||||
void _rc2_mix(unsigned short *);
|
||||
void _rc2_mash(unsigned short *);
|
||||
void _rc2_rmix(unsigned short *);
|
||||
void _rc2_rmash(unsigned short *);
|
||||
int _rc2_pow(int, int);
|
||||
unsigned short _rc2_ror(unsigned short, int);
|
||||
unsigned short _rc2_rol(unsigned short, int);
|
||||
|
||||
/* End rc2.h */
|
||||
Reference in a new issue