Deal with generated files.
This commit is contained in:
parent
29c7896f13
commit
8d7ed6ff90
7
CHANGES
7
CHANGES
@ -16,6 +16,13 @@
|
||||
sco5-cc.
|
||||
[Ben Laurie]
|
||||
|
||||
*) Eliminate generated files from CVS. Reorder tests to regenerate files
|
||||
before they are needed.
|
||||
[Ben Laurie]
|
||||
|
||||
*) Generate Makefile.ssl from Makefile.org (to keep CVS happy).
|
||||
[Ben Laurie]
|
||||
|
||||
Changes between 0.9.1b and 0.9.1c
|
||||
|
||||
*) Added OPENSSL_VERSION_NUMBER to crypto/crypto.h and
|
||||
|
@ -327,7 +327,7 @@ if ($rmd160_obj =~ /\.o$/)
|
||||
}
|
||||
|
||||
my $n=&file_new($Makefile);
|
||||
open(IN,"<".$Makefile) || die "unable to read $Makefile:$!\n";
|
||||
open(IN,'<Makefile.org') || die "unable to read $Makefile:$!\n";
|
||||
open(OUT,">".$n) || die "unable to read $n:$!\n";
|
||||
while (<IN>)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Makefile for all the SSL related library routines and utilities
|
||||
VERSION = 0.9.1c
|
||||
PLATFORM=dist
|
||||
PLATFORM=FreeBSD
|
||||
#
|
||||
# make install will install:
|
||||
# libraries into $INSTALLTOP/lib
|
||||
@ -62,9 +62,9 @@ PLATFORM=dist
|
||||
# equal 4.
|
||||
# PKCS1_CHECK - pkcs1 tests.
|
||||
|
||||
CC= cc
|
||||
CC= gcc
|
||||
#CFLAG= -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall -Wuninitialized -DSHA1_ASM -DMD5_ASM -DRMD160_ASM
|
||||
CFLAG= -O -DNOPROTO
|
||||
CFLAG= -DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall -DSHA1_ASM -DMD5_ASM -DRMD160_ASM
|
||||
PEX_LIBS= -L. -L.. -L../.. -L../../..
|
||||
EX_LIBS=
|
||||
AR=ar r
|
||||
@ -86,7 +86,7 @@ BN_ASM= bn_asm.o
|
||||
|
||||
# Set DES_ENC to des_enc.o if you want to use the C version
|
||||
#There are 4 x86 assember options.
|
||||
DES_ENC= des_enc.o fcrypt_b.o
|
||||
DES_ENC= asm/dx86-out.o asm/yx86-out.o
|
||||
#DES_ENC= des_enc.o fcrypt_b.o # C
|
||||
#DES_ENC= asm/dx86-elf.o asm/yx86-elf.o # elf
|
||||
#DES_ENC= asm/dx86-sol.o asm/yx86-sol.o # solaris
|
||||
@ -95,7 +95,7 @@ DES_ENC= des_enc.o fcrypt_b.o
|
||||
|
||||
# Set BF_ENC to bf_enc.o if you want to use the C version
|
||||
#There are 4 x86 assember options.
|
||||
BF_ENC= bf_enc.o
|
||||
BF_ENC= asm/bx86-out.o
|
||||
#BF_ENC= bf_enc.o
|
||||
#BF_ENC= asm/bx86-elf.o # elf
|
||||
#BF_ENC= asm/bx86-sol.o # solaris
|
||||
@ -104,7 +104,7 @@ BF_ENC= bf_enc.o
|
||||
|
||||
# Set CAST_ENC to c_enc.o if you want to use the C version
|
||||
#There are 4 x86 assember options.
|
||||
CAST_ENC= c_enc.o
|
||||
CAST_ENC= asm/cx86-out.o
|
||||
#CAST_ENC= c_enc.o
|
||||
#CAST_ENC= asm/cx86-elf.o # elf
|
||||
#CAST_ENC= asm/cx86-sol.o # solaris
|
||||
@ -113,7 +113,7 @@ CAST_ENC= c_enc.o
|
||||
|
||||
# Set RC4_ENC to rc4_enc.o if you want to use the C version
|
||||
#There are 4 x86 assember options.
|
||||
RC4_ENC= rc4_enc.o
|
||||
RC4_ENC= asm/rx86-out.o
|
||||
#RC4_ENC= rc4_enc.o
|
||||
#RC4_ENC= asm/rx86-elf.o # elf
|
||||
#RC4_ENC= asm/rx86-sol.o # solaris
|
||||
@ -122,7 +122,7 @@ RC4_ENC= rc4_enc.o
|
||||
|
||||
# Set RC5_ENC to rc5_enc.o if you want to use the C version
|
||||
#There are 4 x86 assember options.
|
||||
RC5_ENC= rc5_enc.o
|
||||
RC5_ENC= asm/r586-out.o
|
||||
#RC5_ENC= rc5_enc.o
|
||||
#RC5_ENC= asm/r586-elf.o # elf
|
||||
#RC5_ENC= asm/r586-sol.o # solaris
|
||||
@ -130,21 +130,21 @@ RC5_ENC= rc5_enc.o
|
||||
#RC5_ENC= asm/r586bsdi.o # bsdi
|
||||
|
||||
# Also need MD5_ASM defined
|
||||
MD5_ASM_OBJ=
|
||||
MD5_ASM_OBJ= asm/mx86-out.o
|
||||
#MD5_ASM_OBJ= asm/mx86-elf.o # elf
|
||||
#MD5_ASM_OBJ= asm/mx86-sol.o # solaris
|
||||
#MD5_ASM_OBJ= asm/mx86-out.o # a.out, FreeBSD
|
||||
#MD5_ASM_OBJ= asm/mx86bsdi.o # bsdi
|
||||
|
||||
# Also need SHA1_ASM defined
|
||||
SHA1_ASM_OBJ=
|
||||
SHA1_ASM_OBJ= asm/sx86-out.o
|
||||
#SHA1_ASM_OBJ= asm/sx86-elf.o # elf
|
||||
#SHA1_ASM_OBJ= asm/sx86-sol.o # solaris
|
||||
#SHA1_ASM_OBJ= asm/sx86-out.o # a.out, FreeBSD
|
||||
#SHA1_ASM_OBJ= asm/sx86bsdi.o # bsdi
|
||||
|
||||
# Also need RMD160_ASM defined
|
||||
RMD160_ASM_OBJ=
|
||||
RMD160_ASM_OBJ= asm/rm86-out.o
|
||||
#RMD160_ASM_OBJ= asm/rm86-elf.o # elf
|
||||
#RMD160_ASM_OBJ= asm/rm86-sol.o # solaris
|
||||
#RMD160_ASM_OBJ= asm/rm86-out.o # a.out, FreeBSD
|
@ -1,242 +0,0 @@
|
||||
/* crypto/bf/bf_locl.org */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* 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 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*
|
||||
* Always modify bf_locl.org since bf_locl.h is automatically generated from
|
||||
* it during SSLeay configuration.
|
||||
*
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*/
|
||||
|
||||
/* Special defines which change the way the code is built depending on the
|
||||
CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
|
||||
even newer MIPS CPU's, but at the moment one size fits all for
|
||||
optimization options. Older Sparc's work better with only UNROLL, but
|
||||
there's no way to tell at compile time what it is you're running on */
|
||||
|
||||
#if defined( sun ) /* Newer Sparc's */
|
||||
# define BF_PTR
|
||||
#elif defined( __ultrix ) /* Older MIPS */
|
||||
# define BF_PTR
|
||||
#elif defined( __osf1__ ) /* Alpha */
|
||||
/* None */
|
||||
#elif defined ( _AIX ) /* RS6000 */
|
||||
/* Unknown */
|
||||
#elif defined( __hpux ) /* HP-PA */
|
||||
/* None */
|
||||
#elif defined( __aux ) /* 68K */
|
||||
/* Unknown */
|
||||
#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
|
||||
/* Unknown */
|
||||
#elif defined( __sgi ) /* Newer MIPS */
|
||||
# define BF_PTR
|
||||
#elif defined( i386 ) /* x86 boxes, should be gcc */
|
||||
#elif defined( _MSC_VER ) /* x86 boxes, Visual C */
|
||||
#endif /* Systems-specific speed defines */
|
||||
|
||||
#undef c2l
|
||||
#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
|
||||
l|=((unsigned long)(*((c)++)))<< 8L, \
|
||||
l|=((unsigned long)(*((c)++)))<<16L, \
|
||||
l|=((unsigned long)(*((c)++)))<<24L)
|
||||
|
||||
/* NOTE - c is not incremented as per c2l */
|
||||
#undef c2ln
|
||||
#define c2ln(c,l1,l2,n) { \
|
||||
c+=n; \
|
||||
l1=l2=0; \
|
||||
switch (n) { \
|
||||
case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
|
||||
case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
|
||||
case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
|
||||
case 5: l2|=((unsigned long)(*(--(c)))); \
|
||||
case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
|
||||
case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
|
||||
case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
|
||||
case 1: l1|=((unsigned long)(*(--(c)))); \
|
||||
} \
|
||||
}
|
||||
|
||||
#undef l2c
|
||||
#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>16L)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>24L)&0xff))
|
||||
|
||||
/* NOTE - c is not incremented as per l2c */
|
||||
#undef l2cn
|
||||
#define l2cn(l1,l2,c,n) { \
|
||||
c+=n; \
|
||||
switch (n) { \
|
||||
case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
|
||||
case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
|
||||
case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
|
||||
case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
|
||||
case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
|
||||
case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
|
||||
case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
|
||||
case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
|
||||
} \
|
||||
}
|
||||
|
||||
/* NOTE - c is not incremented as per n2l */
|
||||
#define n2ln(c,l1,l2,n) { \
|
||||
c+=n; \
|
||||
l1=l2=0; \
|
||||
switch (n) { \
|
||||
case 8: l2 =((unsigned long)(*(--(c)))) ; \
|
||||
case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
|
||||
case 6: l2|=((unsigned long)(*(--(c))))<<16; \
|
||||
case 5: l2|=((unsigned long)(*(--(c))))<<24; \
|
||||
case 4: l1 =((unsigned long)(*(--(c)))) ; \
|
||||
case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
|
||||
case 2: l1|=((unsigned long)(*(--(c))))<<16; \
|
||||
case 1: l1|=((unsigned long)(*(--(c))))<<24; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* NOTE - c is not incremented as per l2n */
|
||||
#define l2nn(l1,l2,c,n) { \
|
||||
c+=n; \
|
||||
switch (n) { \
|
||||
case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
|
||||
case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
|
||||
case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
|
||||
case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
|
||||
case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
|
||||
case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
|
||||
case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
|
||||
case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
|
||||
} \
|
||||
}
|
||||
|
||||
#undef n2l
|
||||
#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
|
||||
l|=((unsigned long)(*((c)++)))<<16L, \
|
||||
l|=((unsigned long)(*((c)++)))<< 8L, \
|
||||
l|=((unsigned long)(*((c)++))))
|
||||
|
||||
#undef l2n
|
||||
#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>16L)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l) )&0xff))
|
||||
|
||||
/* This is actually a big endian algorithm, the most significate byte
|
||||
* is used to lookup array 0 */
|
||||
|
||||
/* use BF_PTR2 for intel boxes,
|
||||
* BF_PTR for sparc and MIPS/SGI
|
||||
* use nothing for Alpha and HP.
|
||||
*/
|
||||
#if !defined(BF_PTR) && !defined(BF_PTR2)
|
||||
#undef BF_PTR
|
||||
#endif
|
||||
|
||||
#define BF_M 0x3fc
|
||||
#define BF_0 22L
|
||||
#define BF_1 14L
|
||||
#define BF_2 6L
|
||||
#define BF_3 2L /* left shift */
|
||||
|
||||
#if defined(BF_PTR2)
|
||||
|
||||
/* This is basically a special pentium verson */
|
||||
#define BF_ENC(LL,R,S,P) \
|
||||
{ \
|
||||
BF_LONG t,u,v; \
|
||||
u=R>>BF_0; \
|
||||
v=R>>BF_1; \
|
||||
u&=BF_M; \
|
||||
v&=BF_M; \
|
||||
t= *(BF_LONG *)((unsigned char *)&(S[ 0])+u); \
|
||||
u=R>>BF_2; \
|
||||
t+= *(BF_LONG *)((unsigned char *)&(S[256])+v); \
|
||||
v=R<<BF_3; \
|
||||
u&=BF_M; \
|
||||
v&=BF_M; \
|
||||
t^= *(BF_LONG *)((unsigned char *)&(S[512])+u); \
|
||||
LL^=P; \
|
||||
t+= *(BF_LONG *)((unsigned char *)&(S[768])+v); \
|
||||
LL^=t; \
|
||||
}
|
||||
|
||||
#elif defined(BF_PTR)
|
||||
|
||||
/* This is normally very good */
|
||||
|
||||
#define BF_ENC(LL,R,S,P) \
|
||||
LL^=P; \
|
||||
LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((R>>BF_0)&BF_M))+ \
|
||||
*(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \
|
||||
*(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \
|
||||
*(BF_LONG *)((unsigned char *)&(S[768])+((R<<BF_3)&BF_M)));
|
||||
#else
|
||||
|
||||
/* This will always work, even on 64 bit machines and strangly enough,
|
||||
* on the Alpha it is faster than the pointer versions (both 32 and 64
|
||||
* versions of BF_LONG) */
|
||||
|
||||
#define BF_ENC(LL,R,S,P) \
|
||||
LL^=P; \
|
||||
LL^=((( S[ (int)(R>>24L) ] + \
|
||||
S[0x0100+((int)(R>>16L)&0xff)])^ \
|
||||
S[0x0200+((int)(R>> 8L)&0xff)])+ \
|
||||
S[0x0300+((int)(R )&0xff)])&0xffffffffL;
|
||||
#endif
|
599
crypto/bn/bn.h
599
crypto/bn/bn.h
@ -1,599 +0,0 @@
|
||||
/* crypto/bn/bn.org */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* 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 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*
|
||||
* Always modify bn.org since bn.h is automatically generated from
|
||||
* it during SSLeay configuration.
|
||||
*
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BN_H
|
||||
#define HEADER_BN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#undef BN_LLONG
|
||||
|
||||
#ifdef WIN32
|
||||
#define BN_LLONG /* This comment stops Configure mutilating things */
|
||||
#endif
|
||||
|
||||
#define BN_MUL_COMBA
|
||||
#define BN_SQR_COMBA
|
||||
#define BN_RECURSION
|
||||
#define RECP_MUL_MOD
|
||||
#define MONT_MUL_MOD
|
||||
|
||||
/* This next option uses the C libraries (2 word)/(1 word) function.
|
||||
* If it is not defined, I use my C version (which is slower).
|
||||
* The reason for this flag is that when the particular C compiler
|
||||
* library routine is used, and the library is linked with a different
|
||||
* compiler, the library is missing. This mostly happens when the
|
||||
* library is built with gcc and then linked using nornal cc. This would
|
||||
* be a common occurance because gcc normally produces code that is
|
||||
* 2 times faster than system compilers for the big number stuff.
|
||||
* For machines with only one compiler (or shared libraries), this should
|
||||
* be on. Again this in only really a problem on machines
|
||||
* using "long long's", are 32bit, and are not using my assember code. */
|
||||
#if defined(MSDOS) || defined(WINDOWS) || defined(linux)
|
||||
#define BN_DIV2W
|
||||
#endif
|
||||
|
||||
/* Only one for the following should be defined */
|
||||
/* The prime number generation stuff may not work when
|
||||
* EIGHT_BIT but I don't care since I've only used this mode
|
||||
* for debuging the bignum libraries */
|
||||
#undef SIXTY_FOUR_BIT_LONG
|
||||
#undef SIXTY_FOUR_BIT
|
||||
#define THIRTY_TWO_BIT
|
||||
#undef SIXTEEN_BIT
|
||||
#undef EIGHT_BIT
|
||||
|
||||
|
||||
/* assuming long is 64bit - this is the DEC Alpha
|
||||
* unsigned long long is only 64 bits :-(, don't define
|
||||
* BN_LLONG for the DEC Alpha */
|
||||
#ifdef SIXTY_FOUR_BIT_LONG
|
||||
#define BN_ULLONG unsigned long long
|
||||
#define BN_ULONG unsigned long
|
||||
#define BN_LONG long
|
||||
#define BN_BITS 128
|
||||
#define BN_BYTES 8
|
||||
#define BN_BITS2 64
|
||||
#define BN_BITS4 32
|
||||
#define BN_MASK (0xffffffffffffffffffffffffffffffffLL)
|
||||
#define BN_MASK2 (0xffffffffffffffffL)
|
||||
#define BN_MASK2l (0xffffffffL)
|
||||
#define BN_MASK2h (0xffffffff00000000L)
|
||||
#define BN_MASK2h1 (0xffffffff80000000L)
|
||||
#define BN_TBIT (0x8000000000000000L)
|
||||
#define BN_DEC_CONV (10000000000000000000UL)
|
||||
#define BN_DEC_FMT1 "%lu"
|
||||
#define BN_DEC_FMT2 "%019lu"
|
||||
#define BN_DEC_NUM 19
|
||||
#endif
|
||||
|
||||
/* This is where the long long data type is 64 bits, but long is 32.
|
||||
* For machines where there are 64bit registers, this is the mode to use.
|
||||
* IRIX, on R4000 and above should use this mode, along with the relevent
|
||||
* assember code :-). Do NOT define BN_ULLONG.
|
||||
*/
|
||||
#ifdef SIXTY_FOUR_BIT
|
||||
#undef BN_LLONG
|
||||
/* #define BN_ULLONG unsigned long long */
|
||||
#define BN_ULONG unsigned long long
|
||||
#define BN_LONG long long
|
||||
#define BN_BITS 128
|
||||
#define BN_BYTES 8
|
||||
#define BN_BITS2 64
|
||||
#define BN_BITS4 32
|
||||
#define BN_MASK2 (0xffffffffffffffffLL)
|
||||
#define BN_MASK2l (0xffffffffL)
|
||||
#define BN_MASK2h (0xffffffff00000000LL)
|
||||
#define BN_MASK2h1 (0xffffffff80000000LL)
|
||||
#define BN_TBIT (0x8000000000000000LL)
|
||||
#define BN_DEC_CONV (10000000000000000000LL)
|
||||
#define BN_DEC_FMT1 "%llu"
|
||||
#define BN_DEC_FMT2 "%019llu"
|
||||
#define BN_DEC_NUM 19
|
||||
#endif
|
||||
|
||||
#ifdef THIRTY_TWO_BIT
|
||||
#ifdef WIN32
|
||||
#define BN_ULLONG unsigned _int64
|
||||
#else
|
||||
#define BN_ULLONG unsigned long long
|
||||
#endif
|
||||
#define BN_ULONG unsigned long
|
||||
#define BN_LONG long
|
||||
#define BN_BITS 64
|
||||
#define BN_BYTES 4
|
||||
#define BN_BITS2 32
|
||||
#define BN_BITS4 16
|
||||
#define BN_MASK (0xffffffffffffffffLL)
|
||||
#define BN_MASK2 (0xffffffffL)
|
||||
#define BN_MASK2l (0xffff)
|
||||
#define BN_MASK2h1 (0xffff8000L)
|
||||
#define BN_MASK2h (0xffff0000L)
|
||||
#define BN_TBIT (0x80000000L)
|
||||
#define BN_DEC_CONV (1000000000L)
|
||||
#define BN_DEC_FMT1 "%lu"
|
||||
#define BN_DEC_FMT2 "%09lu"
|
||||
#define BN_DEC_NUM 9
|
||||
#endif
|
||||
|
||||
#ifdef SIXTEEN_BIT
|
||||
#ifndef BN_DIV2W
|
||||
#define BN_DIV2W
|
||||
#endif
|
||||
#define BN_ULLONG unsigned long
|
||||
#define BN_ULONG unsigned short
|
||||
#define BN_LONG short
|
||||
#define BN_BITS 32
|
||||
#define BN_BYTES 2
|
||||
#define BN_BITS2 16
|
||||
#define BN_BITS4 8
|
||||
#define BN_MASK (0xffffffff)
|
||||
#define BN_MASK2 (0xffff)
|
||||
#define BN_MASK2l (0xff)
|
||||
#define BN_MASK2h1 (0xff80)
|
||||
#define BN_MASK2h (0xff00)
|
||||
#define BN_TBIT (0x8000)
|
||||
#define BN_DEC_CONV (100000)
|
||||
#define BN_DEC_FMT1 "%u"
|
||||
#define BN_DEC_FMT2 "%05u"
|
||||
#define BN_DEC_NUM 5
|
||||
#endif
|
||||
|
||||
#ifdef EIGHT_BIT
|
||||
#ifndef BN_DIV2W
|
||||
#define BN_DIV2W
|
||||
#endif
|
||||
#define BN_ULLONG unsigned short
|
||||
#define BN_ULONG unsigned char
|
||||
#define BN_LONG char
|
||||
#define BN_BITS 16
|
||||
#define BN_BYTES 1
|
||||
#define BN_BITS2 8
|
||||
#define BN_BITS4 4
|
||||
#define BN_MASK (0xffff)
|
||||
#define BN_MASK2 (0xff)
|
||||
#define BN_MASK2l (0xf)
|
||||
#define BN_MASK2h1 (0xf8)
|
||||
#define BN_MASK2h (0xf0)
|
||||
#define BN_TBIT (0x80)
|
||||
#define BN_DEC_CONV (100)
|
||||
#define BN_DEC_FMT1 "%u"
|
||||
#define BN_DEC_FMT2 "%02u"
|
||||
#define BN_DEC_NUM 2
|
||||
#endif
|
||||
|
||||
#define BN_DEFAULT_BITS 1280
|
||||
|
||||
#ifdef BIGNUM
|
||||
#undef BIGNUM
|
||||
#endif
|
||||
|
||||
#define BN_FLG_MALLOCED 0x01
|
||||
#define BN_FLG_STATIC_DATA 0x02
|
||||
#define BN_FLG_FREE 0x8000 /* used for debuging */
|
||||
#define BN_set_flags(b,n) ((b)->flags|=(n))
|
||||
#define BN_get_flags(b,n) ((b)->flags&(n))
|
||||
|
||||
typedef struct bignum_st
|
||||
{
|
||||
BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */
|
||||
int top; /* Index of last used d +1. */
|
||||
/* The next are internal book keeping for bn_expand. */
|
||||
int max; /* Size of the d array. */
|
||||
int neg; /* one if the number is negative */
|
||||
int flags;
|
||||
} BIGNUM;
|
||||
|
||||
/* Used for temp variables */
|
||||
#define BN_CTX_NUM 12
|
||||
typedef struct bignum_ctx
|
||||
{
|
||||
int tos;
|
||||
BIGNUM bn[BN_CTX_NUM+1];
|
||||
int flags;
|
||||
} BN_CTX;
|
||||
|
||||
typedef struct bn_blinding_st
|
||||
{
|
||||
int init;
|
||||
BIGNUM *A;
|
||||
BIGNUM *Ai;
|
||||
BIGNUM *mod; /* just a reference */
|
||||
} BN_BLINDING;
|
||||
|
||||
/* Used for montgomery multiplication */
|
||||
typedef struct bn_mont_ctx_st
|
||||
{
|
||||
int use_word; /* 0 for word form, 1 for long form */
|
||||
int ri; /* number of bits in R */
|
||||
BIGNUM RR; /* used to convert to montgomery form */
|
||||
BIGNUM N; /* The modulus */
|
||||
BIGNUM Ni; /* The inverse of N */
|
||||
BN_ULONG n0; /* word form of inverse, normally only one of
|
||||
* Ni or n0 is defined */
|
||||
int flags;
|
||||
} BN_MONT_CTX;
|
||||
|
||||
/* Used for reciprocal division/mod functions
|
||||
* It cannot be shared between threads
|
||||
*/
|
||||
typedef struct bn_recp_ctx_st
|
||||
{
|
||||
BIGNUM N; /* the divisor */
|
||||
BIGNUM Nr; /* the reciprocal */
|
||||
int num_bits;
|
||||
int shift;
|
||||
int flags;
|
||||
} BN_RECP_CTX;
|
||||
|
||||
#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\
|
||||
r,a,&((mont)->RR),(mont),ctx)
|
||||
|
||||
#define BN_prime_checks (5)
|
||||
|
||||
#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
|
||||
#define BN_is_word(a,w) (((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w)))
|
||||
#define BN_is_zero(a) (((a)->top == 0) || BN_is_word(a,0))
|
||||
#define BN_is_one(a) (BN_is_word((a),1))
|
||||
#define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1))
|
||||
#define BN_one(a) (BN_set_word((a),1))
|
||||
#define BN_zero(a) (BN_set_word((a),0))
|
||||
|
||||
/*#define BN_ascii2bn(a) BN_hex2bn(a) */
|
||||
/*#define BN_bn2ascii(a) BN_bn2hex(a) */
|
||||
|
||||
#define bn_expand(n,b) ((((((b+BN_BITS2-1))/BN_BITS2)) <= (n)->max)?\
|
||||
(n):bn_expand2((n),(b)/BN_BITS2+1))
|
||||
#define bn_wexpand(n,b) (((b) <= (n)->max)?(n):bn_expand2((n),(b)))
|
||||
|
||||
#define bn_fix_top(a) \
|
||||
{ \
|
||||
BN_ULONG *ftl; \
|
||||
if ((a)->top > 0) \
|
||||
{ \
|
||||
for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \
|
||||
if (*(ftl--)) break; \
|
||||
} \
|
||||
}
|
||||
|
||||
#ifndef NOPROTO
|
||||
BIGNUM *BN_value_one(void);
|
||||
char * BN_options(void);
|
||||
BN_CTX *BN_CTX_new(void);
|
||||
void BN_CTX_init(BN_CTX *c);
|
||||
void BN_CTX_free(BN_CTX *c);
|
||||
int BN_rand(BIGNUM *rnd, int bits, int top,int bottom);
|
||||
int BN_num_bits(BIGNUM *a);
|
||||
int BN_num_bits_word(BN_ULONG);
|
||||
BIGNUM *BN_new(void);
|
||||
void BN_init(BIGNUM *);
|
||||
void BN_clear_free(BIGNUM *a);
|
||||
BIGNUM *BN_copy(BIGNUM *a, BIGNUM *b);
|
||||
BIGNUM *BN_bin2bn(unsigned char *s,int len,BIGNUM *ret);
|
||||
int BN_bn2bin(BIGNUM *a, unsigned char *to);
|
||||
BIGNUM *BN_mpi2bn(unsigned char *s,int len,BIGNUM *ret);
|
||||
int BN_bn2mpi(BIGNUM *a, unsigned char *to);
|
||||
int BN_sub(BIGNUM *r, BIGNUM *a, BIGNUM *b);
|
||||
int BN_usub(BIGNUM *r, BIGNUM *a, BIGNUM *b);
|
||||
int BN_uadd(BIGNUM *r, BIGNUM *a, BIGNUM *b);
|
||||
int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b);
|
||||
int BN_mod(BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx);
|
||||
int BN_div(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx);
|
||||
int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b,BN_CTX *ctx);
|
||||
int BN_sqr(BIGNUM *r, BIGNUM *a,BN_CTX *ctx);
|
||||
BN_ULONG BN_mod_word(BIGNUM *a, BN_ULONG w);
|
||||
BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_mul_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_add_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_sub_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_set_word(BIGNUM *a, BN_ULONG w);
|
||||
BN_ULONG BN_get_word(BIGNUM *a);
|
||||
int BN_cmp(BIGNUM *a, BIGNUM *b);
|
||||
void BN_free(BIGNUM *a);
|
||||
int BN_is_bit_set(BIGNUM *a, int n);
|
||||
int BN_lshift(BIGNUM *r, BIGNUM *a, int n);
|
||||
int BN_lshift1(BIGNUM *r, BIGNUM *a);
|
||||
int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p,BN_CTX *ctx);
|
||||
int BN_mod_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx);
|
||||
int BN_mod_exp_mont(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx,
|
||||
BN_MONT_CTX *m_ctx);
|
||||
int BN_mod_exp2_mont(BIGNUM *r, BIGNUM *a1, BIGNUM *p1,BIGNUM *a2,
|
||||
BIGNUM *p2,BIGNUM *m,BN_CTX *ctx,BN_MONT_CTX *m_ctx);
|
||||
int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p,
|
||||
BIGNUM *m,BN_CTX *ctx);
|
||||
int BN_mask_bits(BIGNUM *a,int n);
|
||||
int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, BIGNUM *m,
|
||||
BN_CTX *ctx);
|
||||
#ifndef WIN16
|
||||
int BN_print_fp(FILE *fp, BIGNUM *a);
|
||||
#endif
|
||||
#ifdef HEADER_BIO_H
|
||||
int BN_print(BIO *fp, BIGNUM *a);
|
||||
#else
|
||||
int BN_print(char *fp, BIGNUM *a);
|
||||
#endif
|
||||
int BN_reciprocal(BIGNUM *r, BIGNUM *m, int len, BN_CTX *ctx);
|
||||
int BN_rshift(BIGNUM *r, BIGNUM *a, int n);
|
||||
int BN_rshift1(BIGNUM *r, BIGNUM *a);
|
||||
void BN_clear(BIGNUM *a);
|
||||
BIGNUM *bn_expand2(BIGNUM *b, int bits);
|
||||
BIGNUM *BN_dup(BIGNUM *a);
|
||||
int BN_ucmp(BIGNUM *a, BIGNUM *b);
|
||||
int BN_set_bit(BIGNUM *a, int n);
|
||||
int BN_clear_bit(BIGNUM *a, int n);
|
||||
char * BN_bn2hex(BIGNUM *a);
|
||||
char * BN_bn2dec(BIGNUM *a);
|
||||
int BN_hex2bn(BIGNUM **a,char *str);
|
||||
int BN_dec2bn(BIGNUM **a,char *str);
|
||||
int BN_gcd(BIGNUM *r,BIGNUM *in_a,BIGNUM *in_b,BN_CTX *ctx);
|
||||
BIGNUM *BN_mod_inverse(BIGNUM *ret,BIGNUM *a, BIGNUM *n,BN_CTX *ctx);
|
||||
BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int strong,BIGNUM *add,
|
||||
BIGNUM *rem,void (*callback)(int,int,char *),char *cb_arg);
|
||||
int BN_is_prime(BIGNUM *p,int nchecks,void (*callback)(int,int,char *),
|
||||
BN_CTX *ctx,char *cb_arg);
|
||||
void ERR_load_BN_strings(void );
|
||||
|
||||
BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
|
||||
BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
|
||||
void bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num);
|
||||
BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
|
||||
BN_ULONG bn_add_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num);
|
||||
BN_ULONG bn_sub_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num);
|
||||
|
||||
BN_MONT_CTX *BN_MONT_CTX_new(void );
|
||||
void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
|
||||
int BN_mod_mul_montgomery(BIGNUM *r,BIGNUM *a,BIGNUM *b,BN_MONT_CTX *mont,
|
||||
BN_CTX *ctx);
|
||||
int BN_from_montgomery(BIGNUM *r,BIGNUM *a,BN_MONT_CTX *mont,BN_CTX *ctx);
|
||||
void BN_MONT_CTX_free(BN_MONT_CTX *mont);
|
||||
int BN_MONT_CTX_set(BN_MONT_CTX *mont,BIGNUM *modulus,BN_CTX *ctx);
|
||||
BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from);
|
||||
|
||||
BN_BLINDING *BN_BLINDING_new(BIGNUM *A,BIGNUM *Ai,BIGNUM *mod);
|
||||
void BN_BLINDING_free(BN_BLINDING *b);
|
||||
int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx);
|
||||
int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *r, BN_CTX *ctx);
|
||||
int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
|
||||
|
||||
void BN_set_params(int mul,int high,int low,int mont);
|
||||
int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */
|
||||
|
||||
void bn_mul_normal(BN_ULONG *r,BN_ULONG *a,int na,BN_ULONG *b,int nb);
|
||||
void bn_mul_comba8(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b);
|
||||
void bn_mul_comba4(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b);
|
||||
void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp);
|
||||
void bn_sqr_comba8(BN_ULONG *r,BN_ULONG *a);
|
||||
void bn_sqr_comba4(BN_ULONG *r,BN_ULONG *a);
|
||||
int bn_cmp_words(BN_ULONG *a,BN_ULONG *b,int n);
|
||||
void bn_mul_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,BN_ULONG *t);
|
||||
void bn_mul_part_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,
|
||||
int tn, int n,BN_ULONG *t);
|
||||
void bn_sqr_recursive(BN_ULONG *r,BN_ULONG *a, int n2, BN_ULONG *t);
|
||||
void bn_mul_low_normal(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b, int n);
|
||||
|
||||
void BN_RECP_CTX_init(BN_RECP_CTX *recp);
|
||||
BN_RECP_CTX *BN_RECP_CTX_new(void);
|
||||
void BN_RECP_CTX_free(BN_RECP_CTX *recp);
|
||||
int BN_RECP_CTX_set(BN_RECP_CTX *recp,BIGNUM *rdiv,BN_CTX *ctx);
|
||||
int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y,
|
||||
BN_RECP_CTX *recp,BN_CTX *ctx);
|
||||
int BN_mod_exp_recp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx);
|
||||
int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m,
|
||||
BN_RECP_CTX *recp, BN_CTX *ctx);
|
||||
|
||||
|
||||
#else
|
||||
|
||||
BIGNUM *BN_value_one();
|
||||
char * BN_options();
|
||||
BN_CTX *BN_CTX_new();
|
||||
void BN_CTX_init();
|
||||
void BN_CTX_free();
|
||||
int BN_rand();
|
||||
int BN_num_bits();
|
||||
int BN_num_bits_word();
|
||||
BIGNUM *BN_new();
|
||||
void BN_init();
|
||||
void BN_clear_free();
|
||||
BIGNUM *BN_copy();
|
||||
BIGNUM *BN_bin2bn();
|
||||
int BN_bn2bin();
|
||||
BIGNUM *BN_mpi2bn();
|
||||
int BN_bn2mpi();
|
||||
int BN_sub();
|
||||
int BN_usub();
|
||||
int BN_uadd();
|
||||
int BN_add();
|
||||
int BN_mod();
|
||||
int BN_div();
|
||||
int BN_mul();
|
||||
int BN_sqr();
|
||||
BN_ULONG BN_mod_word();
|
||||
BN_ULONG BN_div_word();
|
||||
int BN_add_word();
|
||||
int BN_sub_word();
|
||||
int BN_mul_word();
|
||||
int BN_set_word();
|
||||
unsigned long BN_get_word();
|
||||
int BN_cmp();
|
||||
void BN_free();
|
||||
int BN_is_bit_set();
|
||||
int BN_lshift();
|
||||
int BN_lshift1();
|
||||
int BN_exp();
|
||||
int BN_mod_exp();
|
||||
int BN_mod_exp_mont();
|
||||
int BN_mod_exp_recp();
|
||||
int BN_mod_exp_simple();
|
||||
int BN_mask_bits();
|
||||
int BN_mod_mul_reciprocal();
|
||||
int BN_mod_mul();
|
||||
#ifndef WIN16
|
||||
int BN_print_fp();
|
||||
#endif
|
||||
int BN_print();
|
||||
int BN_reciprocal();
|
||||
int BN_rshift();
|
||||
int BN_rshift1();
|
||||
void BN_clear();
|
||||
BIGNUM *bn_expand2();
|
||||
BIGNUM *BN_dup();
|
||||
int BN_ucmp();
|
||||
int BN_set_bit();
|
||||
int BN_clear_bit();
|
||||
char * BN_bn2hex();
|
||||
char * BN_bn2dec();
|
||||
int BN_hex2bn();
|
||||
int BN_dec2bn();
|
||||
int BN_gcd();
|
||||
BIGNUM *BN_mod_inverse();
|
||||
BIGNUM *BN_generate_prime();
|
||||
int BN_is_prime();
|
||||
void ERR_load_BN_strings();
|
||||
|
||||
BN_ULONG bn_mul_add_words();
|
||||
BN_ULONG bn_mul_words();
|
||||
void bn_sqr_words();
|
||||
BN_ULONG bn_div_words();
|
||||
BN_ULONG bn_add_words();
|
||||
BN_ULONG bn_sub_words();
|
||||
|
||||
int BN_mod_mul_montgomery();
|
||||
int BN_from_montgomery();
|
||||
BN_MONT_CTX *BN_MONT_CTX_new();
|
||||
void BN_MONT_CTX_init();
|
||||
void BN_MONT_CTX_free();
|
||||
int BN_MONT_CTX_set();
|
||||
|
||||
BN_BLINDING *BN_BLINDING_new();
|
||||
void BN_BLINDING_free();
|
||||
int BN_BLINDING_update();
|
||||
int BN_BLINDING_convert();
|
||||
int BN_BLINDING_invert();
|
||||
|
||||
void bn_mul_normal();
|
||||
void bn_mul_comba8();
|
||||
void bn_mul_comba4();
|
||||
void bn_sqr_normal();
|
||||
void bn_sqr_comba8();
|
||||
void bn_sqr_comba4();
|
||||
int bn_cmp_words();
|
||||
void bn_mul_recursive();
|
||||
void bn_mul_part_recursive();
|
||||
void bn_sqr_recursive();
|
||||
void bn_mul_low_normal();
|
||||
|
||||
void BN_RECP_CTX_init();
|
||||
BN_RECP_CTX *BN_RECP_CTX_new();
|
||||
void BN_RECP_CTX_free();
|
||||
int BN_RECP_CTX_set();
|
||||
int BN_mod_mul_reciprocal();
|
||||
int BN_mod_exp_recp();
|
||||
int BN_div_recp();
|
||||
|
||||
#endif
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/* Error codes for the BN functions. */
|
||||
|
||||
/* Function codes. */
|
||||
#define BN_F_BN_BLINDING_CONVERT 100
|
||||
#define BN_F_BN_BLINDING_INVERT 101
|
||||
#define BN_F_BN_BLINDING_NEW 102
|
||||
#define BN_F_BN_BLINDING_UPDATE 103
|
||||
#define BN_F_BN_BL_CTX_INIT 104
|
||||
#define BN_F_BN_BL_CTX_NEW 105
|
||||
#define BN_F_BN_BN2DEC 106
|
||||
#define BN_F_BN_BN2HEX 107
|
||||
#define BN_F_BN_CTX_NEW 108
|
||||
#define BN_F_BN_DIV 109
|
||||
#define BN_F_BN_EXPAND2 110
|
||||
#define BN_F_BN_MOD_EXP_MONT 111
|
||||
#define BN_F_BN_MOD_INVERSE 112
|
||||
#define BN_F_BN_MOD_MUL_RECIPROCAL 113
|
||||
#define BN_F_BN_MPI2BN 114
|
||||
#define BN_F_BN_NEW 115
|
||||
#define BN_F_BN_RAND 116
|
||||
#define BN_F_BN_USUB 117
|
||||
|
||||
/* Reason codes. */
|
||||
#define BN_R_ARG2_LT_ARG3 100
|
||||
#define BN_R_BAD_RECIPROCAL 101
|
||||
#define BN_R_CALLED_WITH_EVEN_MODULUS 102
|
||||
#define BN_R_DIV_BY_ZERO 103
|
||||
#define BN_R_ENCODING_ERROR 104
|
||||
#define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105
|
||||
#define BN_R_INVALID_LENGTH 106
|
||||
#define BN_R_NOT_INITALISED 107
|
||||
#define BN_R_NO_INVERSE 108
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -1 +0,0 @@
|
||||
#define DATE "Tue Dec 8 17:40:20 CET 1998"
|
303
crypto/des/des.h
303
crypto/des/des.h
@ -1,303 +0,0 @@
|
||||
/* crypto/des/des.org */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* 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 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*
|
||||
* Always modify des.org since des.h is automatically generated from
|
||||
* it during SSLeay configuration.
|
||||
*
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*/
|
||||
|
||||
#ifndef HEADER_DES_H
|
||||
#define HEADER_DES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
|
||||
* %20 speed up (longs are 8 bytes, int's are 4). */
|
||||
#ifndef DES_LONG
|
||||
#define DES_LONG unsigned long
|
||||
#endif
|
||||
|
||||
typedef unsigned char des_cblock[8];
|
||||
typedef struct des_ks_struct
|
||||
{
|
||||
union {
|
||||
des_cblock _;
|
||||
/* make sure things are correct size on machines with
|
||||
* 8 byte longs */
|
||||
DES_LONG pad[2];
|
||||
} ks;
|
||||
#undef _
|
||||
#define _ ks._
|
||||
int weak_key;
|
||||
} des_key_schedule[16];
|
||||
|
||||
#define DES_KEY_SZ (sizeof(des_cblock))
|
||||
#define DES_SCHEDULE_SZ (sizeof(des_key_schedule))
|
||||
|
||||
#define DES_ENCRYPT 1
|
||||
#define DES_DECRYPT 0
|
||||
|
||||
#define DES_CBC_MODE 0
|
||||
#define DES_PCBC_MODE 1
|
||||
|
||||
#define des_ecb2_encrypt(i,o,k1,k2,e) \
|
||||
des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
|
||||
|
||||
#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
|
||||
des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
|
||||
|
||||
#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
|
||||
des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
|
||||
|
||||
#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
|
||||
des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
|
||||
|
||||
#define C_Block des_cblock
|
||||
#define Key_schedule des_key_schedule
|
||||
#ifdef KERBEROS
|
||||
#define ENCRYPT DES_ENCRYPT
|
||||
#define DECRYPT DES_DECRYPT
|
||||
#endif
|
||||
#define KEY_SZ DES_KEY_SZ
|
||||
#define string_to_key des_string_to_key
|
||||
#define read_pw_string des_read_pw_string
|
||||
#define random_key des_random_key
|
||||
#define pcbc_encrypt des_pcbc_encrypt
|
||||
#define set_key des_set_key
|
||||
#define key_sched des_key_sched
|
||||
#define ecb_encrypt des_ecb_encrypt
|
||||
#define cbc_encrypt des_cbc_encrypt
|
||||
#define ncbc_encrypt des_ncbc_encrypt
|
||||
#define xcbc_encrypt des_xcbc_encrypt
|
||||
#define cbc_cksum des_cbc_cksum
|
||||
#define quad_cksum des_quad_cksum
|
||||
|
||||
/* For compatibility with the MIT lib - eay 20/05/92 */
|
||||
typedef des_key_schedule bit_64;
|
||||
#define des_fixup_key_parity des_set_odd_parity
|
||||
#define des_check_key_parity check_parity
|
||||
|
||||
extern int des_check_key; /* defaults to false */
|
||||
extern int des_rw_mode; /* defaults to DES_PCBC_MODE */
|
||||
extern int des_set_weak_key_flag; /* set the weak key flag */
|
||||
|
||||
/* The next line is used to disable full ANSI prototypes, if your
|
||||
* compiler has problems with the prototypes, make sure this line always
|
||||
* evaluates to true :-) */
|
||||
#if defined(MSDOS) || defined(__STDC__)
|
||||
#undef NOPROTO
|
||||
#endif
|
||||
#ifndef NOPROTO
|
||||
char *des_options(void);
|
||||
void des_ecb3_encrypt(des_cblock *input,des_cblock *output,
|
||||
des_key_schedule ks1,des_key_schedule ks2,
|
||||
des_key_schedule ks3, int enc);
|
||||
DES_LONG des_cbc_cksum(des_cblock *input,des_cblock *output,
|
||||
long length,des_key_schedule schedule,des_cblock *ivec);
|
||||
void des_cbc_encrypt(des_cblock *input,des_cblock *output,long length,
|
||||
des_key_schedule schedule,des_cblock *ivec,int enc);
|
||||
void des_ncbc_encrypt(des_cblock *input,des_cblock *output,long length,
|
||||
des_key_schedule schedule,des_cblock *ivec,int enc);
|
||||
void des_xcbc_encrypt(des_cblock *input,des_cblock *output,long length,
|
||||
des_key_schedule schedule,des_cblock *ivec,
|
||||
des_cblock *inw,des_cblock *outw,int enc);
|
||||
void des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
|
||||
long length,des_key_schedule schedule,des_cblock *ivec,int enc);
|
||||
void des_ecb_encrypt(des_cblock *input,des_cblock *output,
|
||||
des_key_schedule ks,int enc);
|
||||
void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
|
||||
void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
|
||||
void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
|
||||
des_key_schedule ks2, des_key_schedule ks3);
|
||||
void des_decrypt3(DES_LONG *data, des_key_schedule ks1,
|
||||
des_key_schedule ks2, des_key_schedule ks3);
|
||||
void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output,
|
||||
long length, des_key_schedule ks1, des_key_schedule ks2,
|
||||
des_key_schedule ks3, des_cblock *ivec, int enc);
|
||||
void des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
|
||||
long length, des_key_schedule ks1, des_key_schedule ks2,
|
||||
des_key_schedule ks3, des_cblock *ivec, int *num, int enc);
|
||||
void des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
|
||||
long length, des_key_schedule ks1, des_key_schedule ks2,
|
||||
des_key_schedule ks3, des_cblock *ivec, int *num);
|
||||
|
||||
void des_xwhite_in2out(des_cblock (*des_key), des_cblock (*in_white),
|
||||
des_cblock (*out_white));
|
||||
|
||||
int des_enc_read(int fd,char *buf,int len,des_key_schedule sched,
|
||||
des_cblock *iv);
|
||||
int des_enc_write(int fd,char *buf,int len,des_key_schedule sched,
|
||||
des_cblock *iv);
|
||||
char *des_fcrypt(const char *buf,const char *salt, char *ret);
|
||||
#ifdef PERL5
|
||||
char *des_crypt(const char *buf,const char *salt);
|
||||
#else
|
||||
/* some stupid compilers complain because I have declared char instead
|
||||
* of const char */
|
||||
#ifdef HEADER_DES_LOCL_H
|
||||
char *crypt(const char *buf,const char *salt);
|
||||
#else
|
||||
char *crypt();
|
||||
#endif
|
||||
#endif
|
||||
void des_ofb_encrypt(unsigned char *in,unsigned char *out,
|
||||
int numbits,long length,des_key_schedule schedule,des_cblock *ivec);
|
||||
void des_pcbc_encrypt(des_cblock *input,des_cblock *output,long length,
|
||||
des_key_schedule schedule,des_cblock *ivec,int enc);
|
||||
DES_LONG des_quad_cksum(des_cblock *input,des_cblock *output,
|
||||
long length,int out_count,des_cblock *seed);
|
||||
void des_random_seed(des_cblock key);
|
||||
void des_random_key(des_cblock ret);
|
||||
int des_read_password(des_cblock *key,char *prompt,int verify);
|
||||
int des_read_2passwords(des_cblock *key1,des_cblock *key2,
|
||||
char *prompt,int verify);
|
||||
int des_read_pw_string(char *buf,int length,char *prompt,int verify);
|
||||
void des_set_odd_parity(des_cblock *key);
|
||||
int des_is_weak_key(des_cblock *key);
|
||||
int des_set_key(des_cblock *key,des_key_schedule schedule);
|
||||
int des_key_sched(des_cblock *key,des_key_schedule schedule);
|
||||
void des_string_to_key(char *str,des_cblock *key);
|
||||
void des_string_to_2keys(char *str,des_cblock *key1,des_cblock *key2);
|
||||
void des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
|
||||
des_key_schedule schedule, des_cblock *ivec, int *num, int enc);
|
||||
void des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
|
||||
des_key_schedule schedule, des_cblock *ivec, int *num);
|
||||
int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify);
|
||||
|
||||
/* Extra functions from Mark Murray <mark@grondar.za> */
|
||||
void des_cblock_print_file(des_cblock *cb, FILE *fp);
|
||||
/* The following functions are not in the normal unix build or the
|
||||
* SSLeay build. When using the SSLeay build, use RAND_seed()
|
||||
* and RAND_bytes() instead. */
|
||||
int des_new_random_key(des_cblock *key);
|
||||
void des_init_random_number_generator(des_cblock *key);
|
||||
void des_set_random_generator_seed(des_cblock *key);
|
||||
void des_set_sequence_number(des_cblock new_sequence_number);
|
||||
void des_generate_random_block(des_cblock *block);
|
||||
|
||||
#else
|
||||
|
||||
char *des_options();
|
||||
void des_ecb3_encrypt();
|
||||
DES_LONG des_cbc_cksum();
|
||||
void des_cbc_encrypt();
|
||||
void des_ncbc_encrypt();
|
||||
void des_xcbc_encrypt();
|
||||
void des_cfb_encrypt();
|
||||
void des_ede3_cfb64_encrypt();
|
||||
void des_ede3_ofb64_encrypt();
|
||||
void des_ecb_encrypt();
|
||||
void des_encrypt();
|
||||
void des_encrypt2();
|
||||
void des_encrypt3();
|
||||
void des_decrypt3();
|
||||
void des_ede3_cbc_encrypt();
|
||||
int des_enc_read();
|
||||
int des_enc_write();
|
||||
char *des_fcrypt();
|
||||
#ifdef PERL5
|
||||
char *des_crypt();
|
||||
#else
|
||||
char *crypt();
|
||||
#endif
|
||||
void des_ofb_encrypt();
|
||||
void des_pcbc_encrypt();
|
||||
DES_LONG des_quad_cksum();
|
||||
void des_random_seed();
|
||||
void des_random_key();
|
||||
int des_read_password();
|
||||
int des_read_2passwords();
|
||||
int des_read_pw_string();
|
||||
void des_set_odd_parity();
|
||||
int des_is_weak_key();
|
||||
int des_set_key();
|
||||
int des_key_sched();
|
||||
void des_string_to_key();
|
||||
void des_string_to_2keys();
|
||||
void des_cfb64_encrypt();
|
||||
void des_ofb64_encrypt();
|
||||
int des_read_pw();
|
||||
void des_xwhite_in2out();
|
||||
|
||||
/* Extra functions from Mark Murray <mark@grondar.za> */
|
||||
void des_cblock_print_file();
|
||||
/* The following functions are not in the normal unix build or the
|
||||
* SSLeay build. When using the SSLeay build, use RAND_seed()
|
||||
* and RAND_bytes() instead. */
|
||||
#ifdef FreeBSD
|
||||
int des_new_random_key();
|
||||
void des_init_random_number_generator();
|
||||
void des_set_random_generator_seed();
|
||||
void des_set_sequence_number();
|
||||
void des_generate_random_block();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,516 +0,0 @@
|
||||
/* crypto/des/des_locl.org */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* 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 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*
|
||||
* Always modify des_locl.org since des_locl.h is automatically generated from
|
||||
* it during SSLeay configuration.
|
||||
*
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*/
|
||||
|
||||
#ifndef HEADER_DES_LOCL_H
|
||||
#define HEADER_DES_LOCL_H
|
||||
|
||||
#if defined(WIN32) || defined(WIN16)
|
||||
#ifndef MSDOS
|
||||
#define MSDOS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifndef MSDOS
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include "des.h"
|
||||
|
||||
#ifndef DES_DEFAULT_OPTIONS
|
||||
/* the following is tweaked from a config script, that is why it is a
|
||||
* protected undef/define */
|
||||
#ifndef DES_PTR
|
||||
#undef DES_PTR
|
||||
#endif
|
||||
|
||||
/* This helps C compiler generate the correct code for multiple functional
|
||||
* units. It reduces register dependancies at the expense of 2 more
|
||||
* registers */
|
||||
#ifndef DES_RISC1
|
||||
#undef DES_RISC1
|
||||
#endif
|
||||
|
||||
#ifndef DES_RISC2
|
||||
#undef DES_RISC2
|
||||
#endif
|
||||
|
||||
#if defined(DES_RISC1) && defined(DES_RISC2)
|
||||
YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
|
||||
#endif
|
||||
|
||||
/* Unroll the inner loop, this sometimes helps, sometimes hinders.
|
||||
* Very mucy CPU dependant */
|
||||
#ifndef DES_UNROLL
|
||||
#undef DES_UNROLL
|
||||
#endif
|
||||
|
||||
/* These default values were supplied by
|
||||
* Peter Gutman <pgut001@cs.auckland.ac.nz>
|
||||
* They are only used if nothing else has been defined */
|
||||
#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
|
||||
/* Special defines which change the way the code is built depending on the
|
||||
CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
|
||||
even newer MIPS CPU's, but at the moment one size fits all for
|
||||
optimization options. Older Sparc's work better with only UNROLL, but
|
||||
there's no way to tell at compile time what it is you're running on */
|
||||
|
||||
#if defined( sun ) /* Newer Sparc's */
|
||||
# define DES_PTR
|
||||
# define DES_RISC1
|
||||
# define DES_UNROLL
|
||||
#elif defined( __ultrix ) /* Older MIPS */
|
||||
# define DES_PTR
|
||||
# define DES_RISC2
|
||||
# define DES_UNROLL
|
||||
#elif defined( __osf1__ ) /* Alpha */
|
||||
# define DES_PTR
|
||||
# define DES_RISC2
|
||||
#elif defined ( _AIX ) /* RS6000 */
|
||||
/* Unknown */
|
||||
#elif defined( __hpux ) /* HP-PA */
|
||||
/* Unknown */
|
||||
#elif defined( __aux ) /* 68K */
|
||||
/* Unknown */
|
||||
#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
|
||||
# define DES_UNROLL
|
||||
#elif defined( __sgi ) /* Newer MIPS */
|
||||
# define DES_PTR
|
||||
# define DES_RISC2
|
||||
# define DES_UNROLL
|
||||
#elif defined( i386 ) /* x86 boxes, should be gcc */
|
||||
# define DES_PTR
|
||||
# define DES_RISC1
|
||||
# define DES_UNROLL
|
||||
#endif /* Systems-specific speed defines */
|
||||
#endif
|
||||
|
||||
#endif /* DES_DEFAULT_OPTIONS */
|
||||
|
||||
#ifdef MSDOS /* Visual C++ 2.1 (Windows NT/95) */
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <io.h>
|
||||
#ifndef RAND
|
||||
#define RAND
|
||||
#endif
|
||||
#undef NOPROTO
|
||||
#endif
|
||||
|
||||
#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS)
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifndef RAND
|
||||
#define RAND
|
||||
#endif
|
||||
|
||||
#ifdef linux
|
||||
#undef RAND
|
||||
#endif
|
||||
|
||||
#ifdef MSDOS
|
||||
#define getpid() 2
|
||||
#define RAND
|
||||
#undef NOPROTO
|
||||
#endif
|
||||
|
||||
#if defined(NOCONST)
|
||||
#define const
|
||||
#endif
|
||||
|
||||
#ifdef __STDC__
|
||||
#undef NOPROTO
|
||||
#endif
|
||||
|
||||
#ifdef RAND
|
||||
#define srandom(s) srand(s)
|
||||
#define random rand
|
||||
#endif
|
||||
|
||||
#define ITERATIONS 16
|
||||
#define HALF_ITERATIONS 8
|
||||
|
||||
/* used in des_read and des_write */
|
||||
#define MAXWRITE (1024*16)
|
||||
#define BSIZE (MAXWRITE+4)
|
||||
|
||||
#define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \
|
||||
l|=((DES_LONG)(*((c)++)))<< 8L, \
|
||||
l|=((DES_LONG)(*((c)++)))<<16L, \
|
||||
l|=((DES_LONG)(*((c)++)))<<24L)
|
||||
|
||||
/* NOTE - c is not incremented as per c2l */
|
||||
#define c2ln(c,l1,l2,n) { \
|
||||
c+=n; \
|
||||
l1=l2=0; \
|
||||
switch (n) { \
|
||||
case 8: l2 =((DES_LONG)(*(--(c))))<<24L; \
|
||||
case 7: l2|=((DES_LONG)(*(--(c))))<<16L; \
|
||||
case 6: l2|=((DES_LONG)(*(--(c))))<< 8L; \
|
||||
case 5: l2|=((DES_LONG)(*(--(c)))); \
|
||||
case 4: l1 =((DES_LONG)(*(--(c))))<<24L; \
|
||||
case 3: l1|=((DES_LONG)(*(--(c))))<<16L; \
|
||||
case 2: l1|=((DES_LONG)(*(--(c))))<< 8L; \
|
||||
case 1: l1|=((DES_LONG)(*(--(c)))); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>16L)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>24L)&0xff))
|
||||
|
||||
/* replacements for htonl and ntohl since I have no idea what to do
|
||||
* when faced with machines with 8 byte longs. */
|
||||
#define HDRSIZE 4
|
||||
|
||||
#define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \
|
||||
l|=((DES_LONG)(*((c)++)))<<16L, \
|
||||
l|=((DES_LONG)(*((c)++)))<< 8L, \
|
||||
l|=((DES_LONG)(*((c)++))))
|
||||
|
||||
#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>16L)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l) )&0xff))
|
||||
|
||||
/* NOTE - c is not incremented as per l2c */
|
||||
#define l2cn(l1,l2,c,n) { \
|
||||
c+=n; \
|
||||
switch (n) { \
|
||||
case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
|
||||
case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
|
||||
case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
|
||||
case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
|
||||
case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
|
||||
case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
|
||||
case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
|
||||
case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
|
||||
} \
|
||||
}
|
||||
|
||||
#if defined(WIN32)
|
||||
#define ROTATE(a,n) (_lrotr(a,n))
|
||||
#else
|
||||
#define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n))))
|
||||
#endif
|
||||
|
||||
/* Don't worry about the LOAD_DATA() stuff, that is used by
|
||||
* fcrypt() to add it's little bit to the front */
|
||||
|
||||
#ifdef DES_FCRYPT
|
||||
|
||||
#define LOAD_DATA_tmp(R,S,u,t,E0,E1) \
|
||||
{ DES_LONG tmp; LOAD_DATA(R,S,u,t,E0,E1,tmp); }
|
||||
|
||||
#define LOAD_DATA(R,S,u,t,E0,E1,tmp) \
|
||||
t=R^(R>>16L); \
|
||||
u=t&E0; t&=E1; \
|
||||
tmp=(u<<16); u^=R^s[S ]; u^=tmp; \
|
||||
tmp=(t<<16); t^=R^s[S+1]; t^=tmp
|
||||
#else
|
||||
#define LOAD_DATA_tmp(a,b,c,d,e,f) LOAD_DATA(a,b,c,d,e,f,g)
|
||||
#define LOAD_DATA(R,S,u,t,E0,E1,tmp) \
|
||||
u=R^s[S ]; \
|
||||
t=R^s[S+1]
|
||||
#endif
|
||||
|
||||
/* The changes to this macro may help or hinder, depending on the
|
||||
* compiler and the achitecture. gcc2 always seems to do well :-).
|
||||
* Inspired by Dana How <how@isl.stanford.edu>
|
||||
* DO NOT use the alternative version on machines with 8 byte longs.
|
||||
* It does not seem to work on the Alpha, even when DES_LONG is 4
|
||||
* bytes, probably an issue of accessing non-word aligned objects :-( */
|
||||
#ifdef DES_PTR
|
||||
|
||||
/* It recently occured to me that 0^0^0^0^0^0^0 == 0, so there
|
||||
* is no reason to not xor all the sub items together. This potentially
|
||||
* saves a register since things can be xored directly into L */
|
||||
|
||||
#if defined(DES_RISC1) || defined(DES_RISC2)
|
||||
#ifdef DES_RISC1
|
||||
#define D_ENCRYPT(LL,R,S) { \
|
||||
unsigned int u1,u2,u3; \
|
||||
LOAD_DATA(R,S,u,t,E0,E1,u1); \
|
||||
u2=(int)u>>8L; \
|
||||
u1=(int)u&0xfc; \
|
||||
u2&=0xfc; \
|
||||
t=ROTATE(t,4); \
|
||||
u>>=16L; \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP +u1); \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x200+u2); \
|
||||
u3=(int)(u>>8L); \
|
||||
u1=(int)u&0xfc; \
|
||||
u3&=0xfc; \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x400+u1); \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x600+u3); \
|
||||
u2=(int)t>>8L; \
|
||||
u1=(int)t&0xfc; \
|
||||
u2&=0xfc; \
|
||||
t>>=16L; \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x100+u1); \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x300+u2); \
|
||||
u3=(int)t>>8L; \
|
||||
u1=(int)t&0xfc; \
|
||||
u3&=0xfc; \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x500+u1); \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x700+u3); }
|
||||
#endif
|
||||
#ifdef DES_RISC2
|
||||
#define D_ENCRYPT(LL,R,S) { \
|
||||
unsigned int u1,u2,s1,s2; \
|
||||
LOAD_DATA(R,S,u,t,E0,E1,u1); \
|
||||
u2=(int)u>>8L; \
|
||||
u1=(int)u&0xfc; \
|
||||
u2&=0xfc; \
|
||||
t=ROTATE(t,4); \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP +u1); \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x200+u2); \
|
||||
s1=(int)(u>>16L); \
|
||||
s2=(int)(u>>24L); \
|
||||
s1&=0xfc; \
|
||||
s2&=0xfc; \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x400+s1); \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x600+s2); \
|
||||
u2=(int)t>>8L; \
|
||||
u1=(int)t&0xfc; \
|
||||
u2&=0xfc; \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x100+u1); \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x300+u2); \
|
||||
s1=(int)(t>>16L); \
|
||||
s2=(int)(t>>24L); \
|
||||
s1&=0xfc; \
|
||||
s2&=0xfc; \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x500+s1); \
|
||||
LL^= *(DES_LONG *)((unsigned char *)des_SP+0x700+s2); }
|
||||
#endif
|
||||
#else
|
||||
#define D_ENCRYPT(LL,R,S) { \
|
||||
LOAD_DATA_tmp(R,S,u,t,E0,E1); \
|
||||
t=ROTATE(t,4); \
|
||||
LL^= \
|
||||
*(DES_LONG *)((unsigned char *)des_SP +((u )&0xfc))^ \
|
||||
*(DES_LONG *)((unsigned char *)des_SP+0x200+((u>> 8L)&0xfc))^ \
|
||||
*(DES_LONG *)((unsigned char *)des_SP+0x400+((u>>16L)&0xfc))^ \
|
||||
*(DES_LONG *)((unsigned char *)des_SP+0x600+((u>>24L)&0xfc))^ \
|
||||
*(DES_LONG *)((unsigned char *)des_SP+0x100+((t )&0xfc))^ \
|
||||
*(DES_LONG *)((unsigned char *)des_SP+0x300+((t>> 8L)&0xfc))^ \
|
||||
*(DES_LONG *)((unsigned char *)des_SP+0x500+((t>>16L)&0xfc))^ \
|
||||
*(DES_LONG *)((unsigned char *)des_SP+0x700+((t>>24L)&0xfc)); }
|
||||
#endif
|
||||
|
||||
#else /* original version */
|
||||
|
||||
#if defined(DES_RISC1) || defined(DES_RISC2)
|
||||
#ifdef DES_RISC1
|
||||
#define D_ENCRYPT(LL,R,S) {\
|
||||
unsigned int u1,u2,u3; \
|
||||
LOAD_DATA(R,S,u,t,E0,E1,u1); \
|
||||
u>>=2L; \
|
||||
t=ROTATE(t,6); \
|
||||
u2=(int)u>>8L; \
|
||||
u1=(int)u&0x3f; \
|
||||
u2&=0x3f; \
|
||||
u>>=16L; \
|
||||
LL^=des_SPtrans[0][u1]; \
|
||||
LL^=des_SPtrans[2][u2]; \
|
||||
u3=(int)u>>8L; \
|
||||
u1=(int)u&0x3f; \
|
||||
u3&=0x3f; \
|
||||
LL^=des_SPtrans[4][u1]; \
|
||||
LL^=des_SPtrans[6][u3]; \
|
||||
u2=(int)t>>8L; \
|
||||
u1=(int)t&0x3f; \
|
||||
u2&=0x3f; \
|
||||
t>>=16L; \
|
||||
LL^=des_SPtrans[1][u1]; \
|
||||
LL^=des_SPtrans[3][u2]; \
|
||||
u3=(int)t>>8L; \
|
||||
u1=(int)t&0x3f; \
|
||||
u3&=0x3f; \
|
||||
LL^=des_SPtrans[5][u1]; \
|
||||
LL^=des_SPtrans[7][u3]; }
|
||||
#endif
|
||||
#ifdef DES_RISC2
|
||||
#define D_ENCRYPT(LL,R,S) {\
|
||||
unsigned int u1,u2,s1,s2; \
|
||||
LOAD_DATA(R,S,u,t,E0,E1,u1); \
|
||||
u>>=2L; \
|
||||
t=ROTATE(t,6); \
|
||||
u2=(int)u>>8L; \
|
||||
u1=(int)u&0x3f; \
|
||||
u2&=0x3f; \
|
||||
LL^=des_SPtrans[0][u1]; \
|
||||
LL^=des_SPtrans[2][u2]; \
|
||||
s1=(int)u>>16L; \
|
||||
s2=(int)u>>24L; \
|
||||
s1&=0x3f; \
|
||||
s2&=0x3f; \
|
||||
LL^=des_SPtrans[4][s1]; \
|
||||
LL^=des_SPtrans[6][s2]; \
|
||||
u2=(int)t>>8L; \
|
||||
u1=(int)t&0x3f; \
|
||||
u2&=0x3f; \
|
||||
LL^=des_SPtrans[1][u1]; \
|
||||
LL^=des_SPtrans[3][u2]; \
|
||||
s1=(int)t>>16; \
|
||||
s2=(int)t>>24L; \
|
||||
s1&=0x3f; \
|
||||
s2&=0x3f; \
|
||||
LL^=des_SPtrans[5][s1]; \
|
||||
LL^=des_SPtrans[7][s2]; }
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define D_ENCRYPT(LL,R,S) {\
|
||||
LOAD_DATA_tmp(R,S,u,t,E0,E1); \
|
||||
t=ROTATE(t,4); \
|
||||
LL^=\
|
||||
des_SPtrans[0][(u>> 2L)&0x3f]^ \
|
||||
des_SPtrans[2][(u>>10L)&0x3f]^ \
|
||||
des_SPtrans[4][(u>>18L)&0x3f]^ \
|
||||
des_SPtrans[6][(u>>26L)&0x3f]^ \
|
||||
des_SPtrans[1][(t>> 2L)&0x3f]^ \
|
||||
des_SPtrans[3][(t>>10L)&0x3f]^ \
|
||||
des_SPtrans[5][(t>>18L)&0x3f]^ \
|
||||
des_SPtrans[7][(t>>26L)&0x3f]; }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* IP and FP
|
||||
* The problem is more of a geometric problem that random bit fiddling.
|
||||
0 1 2 3 4 5 6 7 62 54 46 38 30 22 14 6
|
||||
8 9 10 11 12 13 14 15 60 52 44 36 28 20 12 4
|
||||
16 17 18 19 20 21 22 23 58 50 42 34 26 18 10 2
|
||||
24 25 26 27 28 29 30 31 to 56 48 40 32 24 16 8 0
|
||||
|
||||
32 33 34 35 36 37 38 39 63 55 47 39 31 23 15 7
|
||||
40 41 42 43 44 45 46 47 61 53 45 37 29 21 13 5
|
||||
48 49 50 51 52 53 54 55 59 51 43 35 27 19 11 3
|
||||
56 57 58 59 60 61 62 63 57 49 41 33 25 17 9 1
|
||||
|
||||
The output has been subject to swaps of the form
|
||||
0 1 -> 3 1 but the odd and even bits have been put into
|
||||
2 3 2 0
|
||||
different words. The main trick is to remember that
|
||||
t=((l>>size)^r)&(mask);
|
||||
r^=t;
|
||||
l^=(t<<size);
|
||||
can be used to swap and move bits between words.
|
||||
|
||||
So l = 0 1 2 3 r = 16 17 18 19
|
||||
4 5 6 7 20 21 22 23
|
||||
8 9 10 11 24 25 26 27
|
||||
12 13 14 15 28 29 30 31
|
||||
becomes (for size == 2 and mask == 0x3333)
|
||||
t = 2^16 3^17 -- -- l = 0 1 16 17 r = 2 3 18 19
|
||||
6^20 7^21 -- -- 4 5 20 21 6 7 22 23
|
||||
10^24 11^25 -- -- 8 9 24 25 10 11 24 25
|
||||
14^28 15^29 -- -- 12 13 28 29 14 15 28 29
|
||||
|
||||
Thanks for hints from Richard Outerbridge - he told me IP&FP
|
||||
could be done in 15 xor, 10 shifts and 5 ands.
|
||||
When I finally started to think of the problem in 2D
|
||||
I first got ~42 operations without xors. When I remembered
|
||||
how to use xors :-) I got it to its final state.
|
||||
*/
|
||||
#define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
|
||||
(b)^=(t),\
|
||||
(a)^=((t)<<(n)))
|
||||
|
||||
#define IP(l,r) \
|
||||
{ \
|
||||
register DES_LONG tt; \
|
||||
PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \
|
||||
PERM_OP(l,r,tt,16,0x0000ffffL); \
|
||||
PERM_OP(r,l,tt, 2,0x33333333L); \
|
||||
PERM_OP(l,r,tt, 8,0x00ff00ffL); \
|
||||
PERM_OP(r,l,tt, 1,0x55555555L); \
|
||||
}
|
||||
|
||||
#define FP(l,r) \
|
||||
{ \
|
||||
register DES_LONG tt; \
|
||||
PERM_OP(l,r,tt, 1,0x55555555L); \
|
||||
PERM_OP(r,l,tt, 8,0x00ff00ffL); \
|
||||
PERM_OP(l,r,tt, 2,0x33333333L); \
|
||||
PERM_OP(r,l,tt,16,0x0000ffffL); \
|
||||
PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \
|
||||
}
|
||||
|
||||
extern const DES_LONG des_SPtrans[8][64];
|
||||
|
||||
#ifndef NOPROTO
|
||||
void fcrypt_body(DES_LONG *out,des_key_schedule ks,
|
||||
DES_LONG Eswap0, DES_LONG Eswap1);
|
||||
#else
|
||||
void fcrypt_body();
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,116 +0,0 @@
|
||||
/* crypto/idea/idea.org */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* 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 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*
|
||||
* Always modify idea.org since idea.h is automatically generated from
|
||||
* it during SSLeay configuration.
|
||||
*
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HEADER_IDEA_H
|
||||
#define HEADER_IDEA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define IDEA_ENCRYPT 1
|
||||
#define IDEA_DECRYPT 0
|
||||
|
||||
#define IDEA_INT unsigned int
|
||||
#define IDEA_BLOCK 8
|
||||
#define IDEA_KEY_LENGTH 16
|
||||
|
||||
typedef struct idea_key_st
|
||||
{
|
||||
IDEA_INT data[9][6];
|
||||
} IDEA_KEY_SCHEDULE;
|
||||
|
||||
#ifndef NOPROTO
|
||||
char *idea_options(void);
|
||||
void idea_ecb_encrypt(unsigned char *in, unsigned char *out,
|
||||
IDEA_KEY_SCHEDULE *ks);
|
||||
void idea_set_encrypt_key(unsigned char *key, IDEA_KEY_SCHEDULE *ks);
|
||||
void idea_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk);
|
||||
void idea_cbc_encrypt(unsigned char *in, unsigned char *out,
|
||||
long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,int enc);
|
||||
void idea_cfb64_encrypt(unsigned char *in, unsigned char *out,
|
||||
long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,
|
||||
int *num,int enc);
|
||||
void idea_ofb64_encrypt(unsigned char *in, unsigned char *out,
|
||||
long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, int *num);
|
||||
void idea_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks);
|
||||
#else
|
||||
char *idea_options();
|
||||
void idea_ecb_encrypt();
|
||||
void idea_set_encrypt_key();
|
||||
void idea_set_decrypt_key();
|
||||
void idea_cbc_encrypt();
|
||||
void idea_cfb64_encrypt();
|
||||
void idea_ofb64_encrypt();
|
||||
void idea_encrypt();
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
106
crypto/md2/md2.h
106
crypto/md2/md2.h
@ -1,106 +0,0 @@
|
||||
/* crypto/md/md2.org */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* 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 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*
|
||||
* Always modify md2.org since md2.h is automatically generated from
|
||||
* it during SSLeay configuration.
|
||||
*
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HEADER_MD2_H
|
||||
#define HEADER_MD2_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MD2_DIGEST_LENGTH 16
|
||||
#define MD2_BLOCK 16
|
||||
|
||||
#define MD2_INT unsigned int
|
||||
|
||||
typedef struct MD2state_st
|
||||
{
|
||||
int num;
|
||||
unsigned char data[MD2_BLOCK];
|
||||
MD2_INT cksm[MD2_BLOCK];
|
||||
MD2_INT state[MD2_BLOCK];
|
||||
} MD2_CTX;
|
||||
|
||||
#ifndef NOPROTO
|
||||
char *MD2_options(void);
|
||||
void MD2_Init(MD2_CTX *c);
|
||||
void MD2_Update(MD2_CTX *c, register unsigned char *data, unsigned long len);
|
||||
void MD2_Final(unsigned char *md, MD2_CTX *c);
|
||||
unsigned char *MD2(unsigned char *d, unsigned long n,unsigned char *md);
|
||||
#else
|
||||
char *MD2_options();
|
||||
void MD2_Init();
|
||||
void MD2_Update();
|
||||
void MD2_Final();
|
||||
unsigned char *MD2();
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
562
crypto/pem/pem.h
562
crypto/pem/pem.h
@ -1,562 +0,0 @@
|
||||
/* crypto/pem/pem.org */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* 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 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*
|
||||
* Always modify pem.org since pem.h is automatically generated from
|
||||
* it during SSLeay configuration.
|
||||
*
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*/
|
||||
|
||||
#ifndef HEADER_PEM_H
|
||||
#define HEADER_PEM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "evp.h"
|
||||
#include "x509.h"
|
||||
|
||||
#define PEM_OBJ_UNDEF 0
|
||||
#define PEM_OBJ_X509 1
|
||||
#define PEM_OBJ_X509_REQ 2
|
||||
#define PEM_OBJ_CRL 3
|
||||
#define PEM_OBJ_SSL_SESSION 4
|
||||
#define PEM_OBJ_PRIV_KEY 10
|
||||
#define PEM_OBJ_PRIV_RSA 11
|
||||
#define PEM_OBJ_PRIV_DSA 12
|
||||
#define PEM_OBJ_PRIV_DH 13
|
||||
#define PEM_OBJ_PUB_RSA 14
|
||||
#define PEM_OBJ_PUB_DSA 15
|
||||
#define PEM_OBJ_PUB_DH 16
|
||||
#define PEM_OBJ_DHPARAMS 17
|
||||
#define PEM_OBJ_DSAPARAMS 18
|
||||
#define PEM_OBJ_PRIV_RSA_PUBLIC 19
|
||||
|
||||
#define PEM_ERROR 30
|
||||
#define PEM_DEK_DES_CBC 40
|
||||
#define PEM_DEK_IDEA_CBC 45
|
||||
#define PEM_DEK_DES_EDE 50
|
||||
#define PEM_DEK_DES_ECB 60
|
||||
#define PEM_DEK_RSA 70
|
||||
#define PEM_DEK_RSA_MD2 80
|
||||
#define PEM_DEK_RSA_MD5 90
|
||||
|
||||
#define PEM_MD_MD2 NID_md2
|
||||
#define PEM_MD_MD5 NID_md5
|
||||
#define PEM_MD_SHA NID_sha
|
||||
#define PEM_MD_MD2_RSA NID_md2WithRSAEncryption
|
||||
#define PEM_MD_MD5_RSA NID_md5WithRSAEncryption
|
||||
#define PEM_MD_SHA_RSA NID_sha1WithRSAEncryption
|
||||
|
||||
#define PEM_STRING_X509_OLD "X509 CERTIFICATE"
|
||||
#define PEM_STRING_X509 "CERTIFICATE"
|
||||
#define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
|
||||
#define PEM_STRING_X509_REQ "CERTIFICATE REQUEST"
|
||||
#define PEM_STRING_X509_CRL "X509 CRL"
|
||||
#define PEM_STRING_EVP_PKEY "PRIVATE KEY"
|
||||
#define PEM_STRING_RSA "RSA PRIVATE KEY"
|
||||
#define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY"
|
||||
#define PEM_STRING_DSA "DSA PRIVATE KEY"
|
||||
#define PEM_STRING_PKCS7 "PKCS7"
|
||||
#define PEM_STRING_DHPARAMS "DH PARAMETERS"
|
||||
#define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS"
|
||||
#define PEM_STRING_DSAPARAMS "DSA PARAMETERS"
|
||||
|
||||
#ifndef HEADER_ENVELOPE_H
|
||||
|
||||
#define EVP_ENCODE_CTX_SIZE 96
|
||||
#define EVP_MD_SIZE 60
|
||||
#define EVP_MD_CTX_SIZE 152
|
||||
#define EVP_CIPHER_SIZE 40
|
||||
#define EVP_CIPHER_CTX_SIZE 4212
|
||||
#define EVP_MAX_MD_SIZE 20
|
||||
|
||||
typedef struct evp_encode_ctx_st
|
||||
{
|
||||
char data[EVP_ENCODE_CTX_SIZE];
|
||||
} EVP_ENCODE_CTX;
|
||||
|
||||
typedef struct env_md_ctx_st
|
||||
{
|
||||
char data[EVP_MD_CTX_SIZE];
|
||||
} EVP_MD_CTX;
|
||||
|
||||
typedef struct evp_cipher_st
|
||||
{
|
||||
char data[EVP_CIPHER_SIZE];
|
||||
} EVP_CIPHER;
|
||||
|
||||
typedef struct evp_cipher_ctx_st
|
||||
{
|
||||
char data[EVP_CIPHER_CTX_SIZE];
|
||||
} EVP_CIPHER_CTX;
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct PEM_Encode_Seal_st
|
||||
{
|
||||
EVP_ENCODE_CTX encode;
|
||||
EVP_MD_CTX md;
|
||||
EVP_CIPHER_CTX cipher;
|
||||
} PEM_ENCODE_SEAL_CTX;
|
||||
|
||||
/* enc_type is one off */
|
||||
#define PEM_TYPE_ENCRYPTED 10
|
||||
#define PEM_TYPE_MIC_ONLY 20
|
||||
#define PEM_TYPE_MIC_CLEAR 30
|
||||
#define PEM_TYPE_CLEAR 40
|
||||
|
||||
typedef struct pem_recip_st
|
||||
{
|
||||
char *name;
|
||||
X509_NAME *dn;
|
||||
|
||||
int cipher;
|
||||
int key_enc;
|
||||
char iv[8];
|
||||
} PEM_USER;
|
||||
|
||||
typedef struct pem_ctx_st
|
||||
{
|
||||
int type; /* what type of object */
|
||||
|
||||
struct {
|
||||
int version;
|
||||
int mode;
|
||||
} proc_type;
|
||||
|
||||
char *domain;
|
||||
|
||||
struct {
|
||||
int cipher;
|
||||
unsigned char iv[8];
|
||||
} DEK_info;
|
||||
|
||||
PEM_USER *originator;
|
||||
|
||||
int num_recipient;
|
||||
PEM_USER **recipient;
|
||||
|
||||
#ifdef HEADER_STACK_H
|
||||
STACK *x509_chain; /* certificate chain */
|
||||
#else
|
||||
char *x509_chain; /* certificate chain */
|
||||
#endif
|
||||
EVP_MD *md; /* signature type */
|
||||
|
||||
int md_enc; /* is the md encrypted or not? */
|
||||
int md_len; /* length of md_data */
|
||||
char *md_data; /* message digest, could be pkey encrypted */
|
||||
|
||||
EVP_CIPHER *dec; /* date encryption cipher */
|
||||
int key_len; /* key length */
|
||||
unsigned char *key; /* key */
|
||||
unsigned char iv[8]; /* the iv */
|
||||
|
||||
|
||||
int data_enc; /* is the data encrypted */
|
||||
int data_len;
|
||||
unsigned char *data;
|
||||
} PEM_CTX;
|
||||
|
||||
#ifdef SSLEAY_MACROS
|
||||
|
||||
#define PEM_write_SSL_SESSION(fp,x) \
|
||||
PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \
|
||||
PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL)
|
||||
#define PEM_write_X509(fp,x) \
|
||||
PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \
|
||||
(char *)x, NULL,NULL,0,NULL)
|
||||
#define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \
|
||||
(int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \
|
||||
NULL,NULL,0,NULL)
|
||||
#define PEM_write_X509_CRL(fp,x) \
|
||||
PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \
|
||||
fp,(char *)x, NULL,NULL,0,NULL)
|
||||
#define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb) \
|
||||
PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\
|
||||
(char *)x,enc,kstr,klen,cb)
|
||||
#define PEM_write_RSAPublicKey(fp,x) \
|
||||
PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\
|
||||
PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL)
|
||||
#define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb) \
|
||||
PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\
|
||||
(char *)x,enc,kstr,klen,cb)
|
||||
#define PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb) \
|
||||
PEM_ASN1_write((int (*)())i2d_PrivateKey,\
|
||||
(((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
|
||||
bp,(char *)x,enc,kstr,klen,cb)
|
||||
#define PEM_write_PKCS7(fp,x) \
|
||||
PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \
|
||||
(char *)x, NULL,NULL,0,NULL)
|
||||
#define PEM_write_DHparams(fp,x) \
|
||||
PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\
|
||||
(char *)x,NULL,NULL,0,NULL)
|
||||
|
||||
#define PEM_read_SSL_SESSION(fp,x,cb) (SSL_SESSION *)PEM_ASN1_read( \
|
||||
(char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb)
|
||||
#define PEM_read_X509(fp,x,cb) (X509 *)PEM_ASN1_read( \
|
||||
(char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb)
|
||||
#define PEM_read_X509_REQ(fp,x,cb) (X509_REQ *)PEM_ASN1_read( \
|
||||
(char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb)
|
||||
#define PEM_read_X509_CRL(fp,x,cb) (X509_CRL *)PEM_ASN1_read( \
|
||||
(char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb)
|
||||
#define PEM_read_RSAPrivateKey(fp,x,cb) (RSA *)PEM_ASN1_read( \
|
||||
(char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb)
|
||||
#define PEM_read_RSAPublicKey(fp,x,cb) (RSA *)PEM_ASN1_read( \
|
||||
(char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb)
|
||||
#define PEM_read_DSAPrivateKey(fp,x,cb) (DSA *)PEM_ASN1_read( \
|
||||
(char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb)
|
||||
#define PEM_read_PrivateKey(fp,x,cb) (EVP_PKEY *)PEM_ASN1_read( \
|
||||
(char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb)
|
||||
#define PEM_read_PKCS7(fp,x,cb) (PKCS7 *)PEM_ASN1_read( \
|
||||
(char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb)
|
||||
#define PEM_read_DHparams(fp,x,cb) (DH *)PEM_ASN1_read( \
|
||||
(char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb)
|
||||
|
||||
#define PEM_write_bio_SSL_SESSION(bp,x) \
|
||||
PEM_ASN1_write_bio((int (*)())i2d_SSL_SESSION, \
|
||||
PEM_STRING_SSL_SESSION,bp, (char *)x, NULL,NULL,0,NULL)
|
||||
#define PEM_write_bio_X509(bp,x) \
|
||||
PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \
|
||||
(char *)x, NULL,NULL,0,NULL)
|
||||
#define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \
|
||||
(int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \
|
||||
NULL,NULL,0,NULL)
|
||||
#define PEM_write_bio_X509_CRL(bp,x) \
|
||||
PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\
|
||||
bp,(char *)x, NULL,NULL,0,NULL)
|
||||
#define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb) \
|
||||
PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\
|
||||
bp,(char *)x,enc,kstr,klen,cb)
|
||||
#define PEM_write_bio_RSAPublicKey(bp,x) \
|
||||
PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \
|
||||
PEM_STRING_RSA_PUBLIC,\
|
||||
bp,(char *)x,NULL,NULL,0,NULL)
|
||||
#define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb) \
|
||||
PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\
|
||||
bp,(char *)x,enc,kstr,klen,cb)
|
||||
#define PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb) \
|
||||
PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\
|
||||
(((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
|
||||
bp,(char *)x,enc,kstr,klen,cb)
|
||||
#define PEM_write_bio_PKCS7(bp,x) \
|
||||
PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \
|
||||
(char *)x, NULL,NULL,0,NULL)
|
||||
#define PEM_write_bio_DHparams(bp,x) \
|
||||
PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\
|
||||
bp,(char *)x,NULL,NULL,0,NULL)
|
||||
#define PEM_write_bio_DSAparams(bp,x) \
|
||||
PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \
|
||||
PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL)
|
||||
|
||||
#define PEM_read_bio_SSL_SESSION(bp,x,cb) (SSL_SESSION *)PEM_ASN1_read_bio( \
|
||||
(char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,(char **)x,cb)
|
||||
#define PEM_read_bio_X509(bp,x,cb) (X509 *)PEM_ASN1_read_bio( \
|
||||
(char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb)
|
||||
#define PEM_read_bio_X509_REQ(bp,x,cb) (X509_REQ *)PEM_ASN1_read_bio( \
|
||||
(char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb)
|
||||
#define PEM_read_bio_X509_CRL(bp,x,cb) (X509_CRL *)PEM_ASN1_read_bio( \
|
||||
(char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb)
|
||||
#define PEM_read_bio_RSAPrivateKey(bp,x,cb) (RSA *)PEM_ASN1_read_bio( \
|
||||
(char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb)
|
||||
#define PEM_read_bio_RSAPublicKey(bp,x,cb) (RSA *)PEM_ASN1_read_bio( \
|
||||
(char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb)
|
||||
#define PEM_read_bio_DSAPrivateKey(bp,x,cb) (DSA *)PEM_ASN1_read_bio( \
|
||||
(char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb)
|
||||
#define PEM_read_bio_PrivateKey(bp,x,cb) (EVP_PKEY *)PEM_ASN1_read_bio( \
|
||||
(char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb)
|
||||
|
||||
#define PEM_read_bio_PKCS7(bp,x,cb) (PKCS7 *)PEM_ASN1_read_bio( \
|
||||
(char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb)
|
||||
#define PEM_read_bio_DHparams(bp,x,cb) (DH *)PEM_ASN1_read_bio( \
|
||||
(char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb)
|
||||
#define PEM_read_bio_DSAparams(bp,x,cb) (DSA *)PEM_ASN1_read_bio( \
|
||||
(char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb)
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NOPROTO
|
||||
int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
|
||||
int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len,
|
||||
int (*callback)());
|
||||
|
||||
#ifdef HEADER_BIO_H
|
||||
int PEM_read_bio(BIO *bp, char **name, char **header,
|
||||
unsigned char **data,long *len);
|
||||
int PEM_write_bio(BIO *bp,char *name,char *hdr,unsigned char *data,
|
||||
long len);
|
||||
char * PEM_ASN1_read_bio(char *(*d2i)(),char *name,BIO *bp,char **x,
|
||||
int (*cb)());
|
||||
int PEM_ASN1_write_bio(int (*i2d)(),char *name,BIO *bp,char *x,
|
||||
EVP_CIPHER *enc,unsigned char *kstr,int klen,int (*callback)());
|
||||
STACK * PEM_X509_INFO_read_bio(BIO *bp, STACK *sk, int (*cb)());
|
||||
int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc,
|
||||
unsigned char *kstr, int klen, int (*cb)());
|
||||
#endif
|
||||
|
||||
#ifndef WIN16
|
||||
int PEM_read(FILE *fp, char **name, char **header,
|
||||
unsigned char **data,long *len);
|
||||
int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len);
|
||||
char * PEM_ASN1_read(char *(*d2i)(),char *name,FILE *fp,char **x,
|
||||
int (*cb)());
|
||||
int PEM_ASN1_write(int (*i2d)(),char *name,FILE *fp,char *x,
|
||||
EVP_CIPHER *enc,unsigned char *kstr,int klen,int (*callback)());
|
||||
STACK * PEM_X509_INFO_read(FILE *fp, STACK *sk, int (*cb)());
|
||||
#endif
|
||||
|
||||
int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,
|
||||
EVP_MD *md_type, unsigned char **ek, int *ekl,
|
||||
unsigned char *iv, EVP_PKEY **pubk, int npubk);
|
||||
void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,
|
||||
unsigned char *in, int inl);
|
||||
int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl,
|
||||
unsigned char *out, int *outl, EVP_PKEY *priv);
|
||||
|
||||
void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
|
||||
void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt);
|
||||
int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
|
||||
unsigned int *siglen, EVP_PKEY *pkey);
|
||||
|
||||
void ERR_load_PEM_strings(void);
|
||||
|
||||
void PEM_proc_type(char *buf, int type);
|
||||
void PEM_dek_info(char *buf, char *type, int len, char *str);
|
||||
|
||||
#ifndef SSLEAY_MACROS
|
||||
|
||||
#ifndef WIN16
|
||||
X509 *PEM_read_X509(FILE *fp,X509 **x,int (*cb)());
|
||||
X509_REQ *PEM_read_X509_REQ(FILE *fp,X509_REQ **x,int (*cb)());
|
||||
X509_CRL *PEM_read_X509_CRL(FILE *fp,X509_CRL **x,int (*cb)());
|
||||
RSA *PEM_read_RSAPrivateKey(FILE *fp,RSA **x,int (*cb)());
|
||||
RSA *PEM_read_RSAPublicKey(FILE *fp,RSA **x,int (*cb)());
|
||||
DSA *PEM_read_DSAPrivateKey(FILE *fp,DSA **x,int (*cb)());
|
||||
EVP_PKEY *PEM_read_PrivateKey(FILE *fp,EVP_PKEY **x,int (*cb)());
|
||||
PKCS7 *PEM_read_PKCS7(FILE *fp,PKCS7 **x,int (*cb)());
|
||||
DH *PEM_read_DHparams(FILE *fp,DH **x,int (*cb)());
|
||||
DSA *PEM_read_DSAparams(FILE *fp,DSA **x,int (*cb)());
|
||||
int PEM_write_X509(FILE *fp,X509 *x);
|
||||
int PEM_write_X509_REQ(FILE *fp,X509_REQ *x);
|
||||
int PEM_write_X509_CRL(FILE *fp,X509_CRL *x);
|
||||
int PEM_write_RSAPrivateKey(FILE *fp,RSA *x,EVP_CIPHER *enc,unsigned char *kstr,
|
||||
int klen,int (*cb)());
|
||||
int PEM_write_RSAPublicKey(FILE *fp,RSA *x);
|
||||
int PEM_write_DSAPrivateKey(FILE *fp,DSA *x,EVP_CIPHER *enc,unsigned char *kstr,
|
||||
int klen,int (*cb)());
|
||||
int PEM_write_PrivateKey(FILE *fp,EVP_PKEY *x,EVP_CIPHER *enc,
|
||||
unsigned char *kstr,int klen,int (*cb)());
|
||||
int PEM_write_PKCS7(FILE *fp,PKCS7 *x);
|
||||
int PEM_write_DHparams(FILE *fp,DH *x);
|
||||
int PEM_write_DSAparams(FILE *fp,DSA *x);
|
||||
#endif
|
||||
|
||||
#ifdef HEADER_BIO_H
|
||||
X509 *PEM_read_bio_X509(BIO *bp,X509 **x,int (*cb)());
|
||||
X509_REQ *PEM_read_bio_X509_REQ(BIO *bp,X509_REQ **x,int (*cb)());
|
||||
X509_CRL *PEM_read_bio_X509_CRL(BIO *bp,X509_CRL **x,int (*cb)());
|
||||
RSA *PEM_read_bio_RSAPrivateKey(BIO *bp,RSA **x,int (*cb)());
|
||||
RSA *PEM_read_bio_RSAPublicKey(BIO *bp,RSA **x,int (*cb)());
|
||||
DSA *PEM_read_bio_DSAPrivateKey(BIO *bp,DSA **x,int (*cb)());
|
||||
EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp,EVP_PKEY **x,int (*cb)());
|
||||
PKCS7 *PEM_read_bio_PKCS7(BIO *bp,PKCS7 **x,int (*cb)());
|
||||
DH *PEM_read_bio_DHparams(BIO *bp,DH **x,int (*cb)());
|
||||
DSA *PEM_read_bio_DSAparams(BIO *bp,DSA **x,int (*cb)());
|
||||
int PEM_write_bio_X509(BIO *bp,X509 *x);
|
||||
int PEM_write_bio_X509_REQ(BIO *bp,X509_REQ *x);
|
||||
int PEM_write_bio_X509_CRL(BIO *bp,X509_CRL *x);
|
||||
int PEM_write_bio_RSAPrivateKey(BIO *fp,RSA *x,EVP_CIPHER *enc,
|
||||
unsigned char *kstr,int klen,int (*cb)());
|
||||
int PEM_write_bio_RSAPublicKey(BIO *fp,RSA *x);
|
||||
int PEM_write_bio_DSAPrivateKey(BIO *fp,DSA *x,EVP_CIPHER *enc,
|
||||
unsigned char *kstr,int klen,int (*cb)());
|
||||
int PEM_write_bio_PrivateKey(BIO *fp,EVP_PKEY *x,EVP_CIPHER *enc,
|
||||
unsigned char *kstr,int klen,int (*cb)());
|
||||
int PEM_write_bio_PKCS7(BIO *bp,PKCS7 *x);
|
||||
int PEM_write_bio_DHparams(BIO *bp,DH *x);
|
||||
int PEM_write_bio_DSAparams(BIO *bp,DSA *x);
|
||||
#endif
|
||||
|
||||
#endif /* SSLEAY_MACROS */
|
||||
|
||||
|
||||
#else
|
||||
|
||||
int PEM_get_EVP_CIPHER_INFO();
|
||||
int PEM_do_header();
|
||||
int PEM_read_bio();
|
||||
int PEM_write_bio();
|
||||
#ifndef WIN16
|
||||
int PEM_read();
|
||||
int PEM_write();
|
||||
STACK * PEM_X509_INFO_read();
|
||||
char * PEM_ASN1_read();
|
||||
int PEM_ASN1_write();
|
||||
#endif
|
||||
STACK * PEM_X509_INFO_read_bio();
|
||||
int PEM_X509_INFO_write_bio();
|
||||
char * PEM_ASN1_read_bio();
|
||||
int PEM_ASN1_write_bio();
|
||||
int PEM_SealInit();
|
||||
void PEM_SealUpdate();
|
||||
int PEM_SealFinal();
|
||||
int PEM_SignFinal();
|
||||
|
||||
void ERR_load_PEM_strings();
|
||||
|
||||
void PEM_proc_type();
|
||||
void PEM_dek_info();
|
||||
|
||||
#ifndef SSLEAY_MACROS
|
||||
#ifndef WIN16
|
||||
X509 *PEM_read_X509();
|
||||
X509_REQ *PEM_read_X509_REQ();
|
||||
X509_CRL *PEM_read_X509_CRL();
|
||||
RSA *PEM_read_RSAPrivateKey();
|
||||
RSA *PEM_read_RSAPublicKey();
|
||||
DSA *PEM_read_DSAPrivateKey();
|
||||
EVP_PKEY *PEM_read_PrivateKey();
|
||||
PKCS7 *PEM_read_PKCS7();
|
||||
DH *PEM_read_DHparams();
|
||||
DSA *PEM_read_DSAparams();
|
||||
int PEM_write_X509();
|
||||
int PEM_write_X509_REQ();
|
||||
int PEM_write_X509_CRL();
|
||||
int PEM_write_RSAPrivateKey();
|
||||
int PEM_write_RSAPublicKey();
|
||||
int PEM_write_DSAPrivateKey();
|
||||
int PEM_write_PrivateKey();
|
||||
int PEM_write_PKCS7();
|
||||
int PEM_write_DHparams();
|
||||
int PEM_write_DSAparams();
|
||||
#endif
|
||||
|
||||
X509 *PEM_read_bio_X509();
|
||||
X509_REQ *PEM_read_bio_X509_REQ();
|
||||
X509_CRL *PEM_read_bio_X509_CRL();
|
||||
RSA *PEM_read_bio_RSAPrivateKey();
|
||||
RSA *PEM_read_bio_RSAPublicKey();
|
||||
DSA *PEM_read_bio_DSAPrivateKey();
|
||||
EVP_PKEY *PEM_read_bio_PrivateKey();
|
||||
PKCS7 *PEM_read_bio_PKCS7();
|
||||
DH *PEM_read_bio_DHparams();
|
||||
DSA *PEM_read_bio_DSAparams();
|
||||
int PEM_write_bio_X509();
|
||||
int PEM_write_bio_X509_REQ();
|
||||
int PEM_write_bio_X509_CRL();
|
||||
int PEM_write_bio_RSAPrivateKey();
|
||||
int PEM_write_bio_RSAPublicKey();
|
||||
int PEM_write_bio_DSAPrivateKey();
|
||||
int PEM_write_bio_PrivateKey();
|
||||
int PEM_write_bio_PKCS7();
|
||||
int PEM_write_bio_DHparams();
|
||||
int PEM_write_bio_DSAparams();
|
||||
|
||||
#endif /* SSLEAY_MACROS */
|
||||
|
||||
#endif
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/* Error codes for the PEM functions. */
|
||||
|
||||
/* Function codes. */
|
||||
#define PEM_F_DEF_CALLBACK 100
|
||||
#define PEM_F_LOAD_IV 101
|
||||
#define PEM_F_PEM_ASN1_READ 102
|
||||
#define PEM_F_PEM_ASN1_READ_BIO 103
|
||||
#define PEM_F_PEM_ASN1_WRITE 104
|
||||
#define PEM_F_PEM_ASN1_WRITE_BIO 105
|
||||
#define PEM_F_PEM_DO_HEADER 106
|
||||
#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107
|
||||
#define PEM_F_PEM_READ 108
|
||||
#define PEM_F_PEM_READ_BIO 109
|
||||
#define PEM_F_PEM_SEALFINAL 110
|
||||
#define PEM_F_PEM_SEALINIT 111
|
||||
#define PEM_F_PEM_SIGNFINAL 112
|
||||
#define PEM_F_PEM_WRITE 113
|
||||
#define PEM_F_PEM_WRITE_BIO 114
|
||||
#define PEM_F_PEM_X509_INFO_READ 115
|
||||
#define PEM_F_PEM_X509_INFO_READ_BIO 116
|
||||
#define PEM_F_PEM_X509_INFO_WRITE_BIO 117
|
||||
|
||||
/* Reason codes. */
|
||||
#define PEM_R_BAD_BASE64_DECODE 100
|
||||
#define PEM_R_BAD_DECRYPT 101
|
||||
#define PEM_R_BAD_END_LINE 102
|
||||
#define PEM_R_BAD_IV_CHARS 103
|
||||
#define PEM_R_BAD_PASSWORD_READ 104
|
||||
#define PEM_R_NOT_DEK_INFO 105
|
||||
#define PEM_R_NOT_ENCRYPTED 106
|
||||
#define PEM_R_NOT_PROC_TYPE 107
|
||||
#define PEM_R_NO_START_LINE 108
|
||||
#define PEM_R_PROBLEMS_GETTING_PASSWORD 109
|
||||
#define PEM_R_PUBLIC_KEY_NO_RSA 110
|
||||
#define PEM_R_READ_KEY 111
|
||||
#define PEM_R_SHORT_HEADER 112
|
||||
#define PEM_R_UNSUPPORTED_CIPHER 113
|
||||
#define PEM_R_UNSUPPORTED_ENCRYPTION 114
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
118
crypto/rc2/rc2.h
118
crypto/rc2/rc2.h
@ -1,118 +0,0 @@
|
||||
/* crypto/rc2/rc2.org */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* 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 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*
|
||||
* Always modify rc2.org since rc2.h is automatically generated from
|
||||
* it during SSLeay configuration.
|
||||
*
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*/
|
||||
|
||||
#ifndef HEADER_RC2_H
|
||||
#define HEADER_RC2_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define RC2_ENCRYPT 1
|
||||
#define RC2_DECRYPT 0
|
||||
|
||||
/* I need to put in a mod for the alpha - eay */
|
||||
#define RC2_INT unsigned int
|
||||
|
||||
#define RC2_BLOCK 8
|
||||
#define RC2_KEY_LENGTH 16
|
||||
|
||||
typedef struct rc2_key_st
|
||||
{
|
||||
RC2_INT data[64];
|
||||
} RC2_KEY;
|
||||
|
||||
#ifndef NOPROTO
|
||||
|
||||
void RC2_set_key(RC2_KEY *key, int len, unsigned char *data,int bits);
|
||||
void RC2_ecb_encrypt(unsigned char *in,unsigned char *out,RC2_KEY *key,
|
||||
int enc);
|
||||
void RC2_encrypt(unsigned long *data,RC2_KEY *key);
|
||||
void RC2_decrypt(unsigned long *data,RC2_KEY *key);
|
||||
void RC2_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
|
||||
RC2_KEY *ks, unsigned char *iv, int enc);
|
||||
void RC2_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
|
||||
RC2_KEY *schedule, unsigned char *ivec, int *num, int enc);
|
||||
void RC2_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
|
||||
RC2_KEY *schedule, unsigned char *ivec, int *num);
|
||||
|
||||
#else
|
||||
|
||||
void RC2_set_key();
|
||||
void RC2_ecb_encrypt();
|
||||
void RC2_encrypt();
|
||||
void RC2_decrypt();
|
||||
void RC2_cbc_encrypt();
|
||||
void RC2_cfb64_encrypt();
|
||||
void RC2_ofb64_encrypt();
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
103
crypto/rc4/rc4.h
103
crypto/rc4/rc4.h
@ -1,103 +0,0 @@
|
||||
/* crypto/rc4/rc4.org */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* 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 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*
|
||||
* Always modify rc4.org since rc4.h is automatically generated from
|
||||
* it during SSLeay configuration.
|
||||
*
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*/
|
||||
|
||||
#ifndef HEADER_RC4_H
|
||||
#define HEADER_RC4_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* using int types make the structure larger but make the code faster
|
||||
* on most boxes I have tested - up to %20 faster. */
|
||||
#define RC4_INT unsigned int
|
||||
|
||||
typedef struct rc4_key_st
|
||||
{
|
||||
RC4_INT x,y;
|
||||
RC4_INT data[256];
|
||||
} RC4_KEY;
|
||||
|
||||
#ifndef NOPROTO
|
||||
|
||||
char *RC4_options(void);
|
||||
void RC4_set_key(RC4_KEY *key, int len, unsigned char *data);
|
||||
void RC4(RC4_KEY *key, unsigned long len, unsigned char *indata,
|
||||
unsigned char *outdata);
|
||||
|
||||
#else
|
||||
|
||||
char *RC4_options();
|
||||
void RC4_set_key();
|
||||
void RC4();
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,70 +0,0 @@
|
||||
/* crypto/rc4/rc4_locl.org */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* 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 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*
|
||||
* Always modify bf_locl.org since bf_locl.h is automatically generated from
|
||||
* it during SSLeay configuration.
|
||||
*
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
*/
|
||||
|
||||
/* if this is defined data[i] is used instead of *data, this is a %20
|
||||
* speedup on x86 */
|
||||
#undef RC4_INDEX
|
||||
|
@ -94,8 +94,8 @@ tags:
|
||||
tests: exe apps \
|
||||
test_des test_idea test_sha test_md5 test_hmac test_md2 test_mdc2 \
|
||||
test_rc2 test_rc4 test_rc5 test_bf test_cast \
|
||||
test_rand test_enc test_x509 test_rsa test_crl test_sid test_req \
|
||||
test_pkcs7 test_bn test_verify test_dh test_dsa test_reqgen \
|
||||
test_rand test_enc test_x509 test_rsa test_crl test_sid test_reqgen \
|
||||
test_req test_pkcs7 test_bn test_verify test_dh test_dsa \
|
||||
test_ss test_ssl test_ca
|
||||
|
||||
apps:
|
||||
|
@ -1 +0,0 @@
|
||||
99
|
@ -1,9 +0,0 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIBOwIBAAJBANRkqBhIy4l2LDZohAgbgsO+b0dtSfInKPpaA+SnD3x1UpOPSOjc
|
||||
Xqf97dqdjO9Kk6I+RO6/DbT3KyXMmzjRJ/sCAwEAAQJBAMfjC0f/in6OFsIFzuyK
|
||||
Z6Cs4rGIK2WYcTpb6PoSN8LaN0khhkn8PAua72FnTiRwLEyoBqwl+g/jNy8Dio8K
|
||||
47ECIQD8401+qBwqoIpSPX7lHwa0kO9wqFG6MVMF0jdhIWOgHQIhANcBx4yghPDl
|
||||
7WgtodDlqgwn+iKUUpZW2d3YF3MCoJz3AiAUZqXuzNMQ4UinX8yn4TviPzsBxKJr
|
||||
OeVvt8i97jqiRQIhANZRaMdN7pZuq0KwUd94PxQU+WpkrRo9Arj3QRCcqtsrAiAf
|
||||
ppDnmxlAEwjl8GOerlaKXUICnF7v3SjELP9tH9cQtA==
|
||||
-----END RSA PRIVATE KEY-----
|
@ -1,9 +0,0 @@
|
||||
-----BEGIN CERTIFICATE REQUEST-----
|
||||
MIIBQjCB7QIBADCBhzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQx
|
||||
ETAPBgNVBAcTCEJyaXNiYW5lMRowGAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0ZDET
|
||||
MBEGA1UEAxMKRXJpYyBZb3VuZzEfMB0GCSqGSIb3DQEJARYQZWF5QG1pbmNvbS5v
|
||||
ei5hdTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDUZKgYSMuJdiw2aIQIG4LDvm9H
|
||||
bUnyJyj6WgPkpw98dVKTj0jo3F6n/e3anYzvSpOiPkTuvw209yslzJs40Sf7AgMB
|
||||
AAGgADANBgkqhkiG9w0BAQQFAANBAES6okHo15lRtghclOyzSQ7pTUva8h5nxiKu
|
||||
62HR6t9kAIU1apoOdM/Rn1e6dF3+aZjpxY0uIdNg+q2VSyeBdsM=
|
||||
-----END CERTIFICATE REQUEST-----
|
Loading…
x
Reference in New Issue
Block a user